Bash  5.0-beta2
Bash - Bourne Again shell
relocatable.h
Go to the documentation of this file.
1 /* relocatable.h - Provide relocatable packages. */
2 
3 /* Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
4  Written by Bruno Haible <bruno@clisp.org>, 2003.
5 
6  This file is part of GNU Bash.
7 
8  Bash is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Bash is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Bash. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef _RELOCATABLE_H
23 #define _RELOCATABLE_H
24 
25 /* This can be enabled through the configure --enable-relocatable option. */
26 #if ENABLE_RELOCATABLE
27 
28 /* When building a DLL, we must export some functions. Note that because
29  this is a private .h file, we don't need to use __declspec(dllimport)
30  in any case. */
31 #if defined _MSC_VER && BUILDING_DLL
32 # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
33 #else
34 # define RELOCATABLE_DLL_EXPORTED
35 #endif
36 
37 /* Sets the original and the current installation prefix of the package.
38  Relocation simply replaces a pathname starting with the original prefix
39  by the corresponding pathname with the current prefix instead. Both
40  prefixes should be directory names without trailing slash (i.e. use ""
41  instead of "/"). */
42 extern RELOCATABLE_DLL_EXPORTED void
43  set_relocation_prefix (const char *orig_prefix,
44  const char *curr_prefix);
45 
46 /* Returns the pathname, relocated according to the current installation
47  directory. */
48 extern const char * relocate (const char *pathname);
49 
50 /* Memory management: relocate() leaks memory, because it has to construct
51  a fresh pathname. If this is a problem because your program calls
52  relocate() frequently, think about caching the result. */
53 
54 /* Convenience function:
55  Computes the current installation prefix, based on the original
56  installation prefix, the original installation directory of a particular
57  file, and the current pathname of this file. Returns NULL upon failure. */
58 extern const char * compute_curr_prefix (const char *orig_installprefix,
59  const char *orig_installdir,
60  const char *curr_pathname);
61 
62 #else
63 
64 /* By default, we use the hardwired pathnames. */
65 #define relocate(pathname) (pathname)
66 
67 #endif
68 
69 #endif /* _RELOCATABLE_H */
#define relocate(pathname)
Definition: relocatable.h:65