xref: /netbsd-src/external/gpl2/texinfo/dist/intl/relocatable.h (revision 29619d2afe564e54d657b83e5a3ae89584f83720)
1 /*	$NetBSD: relocatable.h,v 1.1.1.1 2016/01/14 00:11:28 christos Exp $	*/
2 
3 /* Provide relocatable packages.
4    Copyright (C) 2003 Free Software Foundation, Inc.
5    Written by Bruno Haible <bruno@clisp.org>, 2003.
6 
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)
10    any later version.
11 
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.
16 
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,
20    USA.  */
21 
22 #ifndef _RELOCATABLE_H
23 #define _RELOCATABLE_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /* This can be enabled through the configure --enable-relocatable option.  */
31 #if ENABLE_RELOCATABLE
32 
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)
35    in any case.  */
36 #if 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 extern const char * relocate (const char *pathname);
54 
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.  */
58 
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);
66 
67 #else
68 
69 /* By default, we use the hardwired pathnames.  */
70 #define relocate(pathname) (pathname)
71 
72 #endif
73 
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* _RELOCATABLE_H */
80