blob: de57f446db5e3513a387434825c5c987c40e7141 [file] [log] [blame]
Jari Aalto31859422009-01-12 13:36:28 +00001/* relocatable.h - Provide relocatable packages. */
2
3/* Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
Jari Aaltob80f6442004-07-27 13:29:18 +00004 Written by Bruno Haible <bruno@clisp.org>, 2003.
5
Jari Aalto31859422009-01-12 13:36:28 +00006 This file is part of GNU Bash.
Jari Aaltob80f6442004-07-27 13:29:18 +00007
Jari Aalto31859422009-01-12 13:36:28 +00008 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,
Jari Aaltob80f6442004-07-27 13:29:18 +000014 but WITHOUT ANY WARRANTY; without even the implied warranty of
Jari Aalto31859422009-01-12 13:36:28 +000015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
Jari Aaltob80f6442004-07-27 13:29:18 +000017
Jari Aalto31859422009-01-12 13:36:28 +000018 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*/
Jari Aaltob80f6442004-07-27 13:29:18 +000021
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 "/"). */
42extern 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. */
48extern 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. */
58extern 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 */