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