3 /* Provide relocatable packages.
4 Copyright (C) 2003 Free Software Foundation, Inc.
5 Written by Bruno Haible <bruno@clisp.org>, 2003.
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published
9 by the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 #ifndef _RELOCATABLE_H
23 #define _RELOCATABLE_H
30 /* This can be enabled through the configure --enable-relocatable option. */
31 #if ENABLE_RELOCATABLE
33 /* When building a DLL, we must export some functions. Note that because
34 this is a private .h file, we don't need to use __declspec(dllimport)
36 #if defined _MSC_VER && BUILDING_DLL
37 # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
39 # define RELOCATABLE_DLL_EXPORTED
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 ""
47 extern RELOCATABLE_DLL_EXPORTED
void
48 set_relocation_prefix (const char *orig_prefix
,
49 const char *curr_prefix
);
51 /* Returns the pathname, relocated according to the current installation
53 extern const char * relocate (const char *pathname
);
55 /* Memory management: relocate() leaks memory, because it has to construct
56 a fresh pathname. If this is a problem because your program calls
57 relocate() frequently, think about caching the result. */
59 /* Convenience function:
60 Computes the current installation prefix, based on the original
61 installation prefix, the original installation directory of a particular
62 file, and the current pathname of this file. Returns NULL upon failure. */
63 extern const char * compute_curr_prefix (const char *orig_installprefix
,
64 const char *orig_installdir
,
65 const char *curr_pathname
);
69 /* By default, we use the hardwired pathnames. */
70 #define relocate(pathname) (pathname)
79 #endif /* _RELOCATABLE_H */