Annotation of embedaddon/libiconv/srclib/relocatable.h, revision 1.1
1.1 ! misho 1: /* Provide relocatable packages.
! 2: Copyright (C) 2003, 2005, 2008 Free Software Foundation, Inc.
! 3: Written by Bruno Haible <bruno@clisp.org>, 2003.
! 4:
! 5: This program is free software; you can redistribute it and/or modify it
! 6: under the terms of the GNU General Public License as published
! 7: by the Free Software Foundation; either version 3, or (at your option)
! 8: any later version.
! 9:
! 10: This program is distributed in the hope that it will be useful,
! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! 13: Library General Public License for more details.
! 14:
! 15: You should have received a copy of the GNU General Public
! 16: License along with this program; if not, write to the Free Software
! 17: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
! 18: USA. */
! 19:
! 20: #ifndef _RELOCATABLE_H
! 21: #define _RELOCATABLE_H
! 22:
! 23: #ifdef __cplusplus
! 24: extern "C" {
! 25: #endif
! 26:
! 27:
! 28: /* This can be enabled through the configure --enable-relocatable option. */
! 29: #if ENABLE_RELOCATABLE
! 30:
! 31: /* When building a DLL, we must export some functions. Note that because
! 32: this is a private .h file, we don't need to use __declspec(dllimport)
! 33: in any case. */
! 34: #if HAVE_VISIBILITY && BUILDING_DLL
! 35: # define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
! 36: #elif defined _MSC_VER && BUILDING_DLL
! 37: # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
! 38: #else
! 39: # define RELOCATABLE_DLL_EXPORTED
! 40: #endif
! 41:
! 42: /* Sets the original and the current installation prefix of the package.
! 43: Relocation simply replaces a pathname starting with the original prefix
! 44: by the corresponding pathname with the current prefix instead. Both
! 45: prefixes should be directory names without trailing slash (i.e. use ""
! 46: instead of "/"). */
! 47: extern RELOCATABLE_DLL_EXPORTED void
! 48: set_relocation_prefix (const char *orig_prefix,
! 49: const char *curr_prefix);
! 50:
! 51: /* Returns the pathname, relocated according to the current installation
! 52: directory.
! 53: The returned string is either PATHNAME unmodified or a freshly allocated
! 54: string that you can free with free() after casting it to 'char *'. */
! 55: extern const char * relocate (const char *pathname);
! 56:
! 57: /* Memory management: relocate() potentially allocates memory, because it has
! 58: to construct a fresh pathname. If this is a problem because your program
! 59: calls relocate() frequently, think about caching the result. Or free the
! 60: return value if it was different from the argument pathname. */
! 61:
! 62: /* Convenience function:
! 63: Computes the current installation prefix, based on the original
! 64: installation prefix, the original installation directory of a particular
! 65: file, and the current pathname of this file.
! 66: Returns it, freshly allocated. Returns NULL upon failure. */
! 67: extern char * compute_curr_prefix (const char *orig_installprefix,
! 68: const char *orig_installdir,
! 69: const char *curr_pathname);
! 70:
! 71: #else
! 72:
! 73: /* By default, we use the hardwired pathnames. */
! 74: #define relocate(pathname) (pathname)
! 75:
! 76: #endif
! 77:
! 78:
! 79: #ifdef __cplusplus
! 80: }
! 81: #endif
! 82:
! 83: #endif /* _RELOCATABLE_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>