Back to index

tetex-bin  3.0
relocatable.h
Go to the documentation of this file.
00001 /* Provide relocatable packages.
00002    Copyright (C) 2003 Free Software Foundation, Inc.
00003    Written by Bruno Haible <bruno@clisp.org>, 2003.
00004 
00005    This program is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00018    USA.  */
00019 
00020 #ifndef _RELOCATABLE_H
00021 #define _RELOCATABLE_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 
00028 /* This can be enabled through the configure --enable-relocatable option.  */
00029 #if ENABLE_RELOCATABLE
00030 
00031 /* When building a DLL, we must export some functions.  Note that because
00032    this is a private .h file, we don't need to use __declspec(dllimport)
00033    in any case.  */
00034 #if defined _MSC_VER && BUILDING_DLL
00035 # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
00036 #else
00037 # define RELOCATABLE_DLL_EXPORTED
00038 #endif
00039 
00040 /* Sets the original and the current installation prefix of the package.
00041    Relocation simply replaces a pathname starting with the original prefix
00042    by the corresponding pathname with the current prefix instead.  Both
00043    prefixes should be directory names without trailing slash (i.e. use ""
00044    instead of "/").  */
00045 extern RELOCATABLE_DLL_EXPORTED void
00046        set_relocation_prefix (const char *orig_prefix,
00047                            const char *curr_prefix);
00048 
00049 /* Returns the pathname, relocated according to the current installation
00050    directory.  */
00051 extern const char * relocate (const char *pathname);
00052 
00053 /* Memory management: relocate() leaks memory, because it has to construct
00054    a fresh pathname.  If this is a problem because your program calls
00055    relocate() frequently, think about caching the result.  */
00056 
00057 /* Convenience function:
00058    Computes the current installation prefix, based on the original
00059    installation prefix, the original installation directory of a particular
00060    file, and the current pathname of this file.  Returns NULL upon failure.  */
00061 extern const char * compute_curr_prefix (const char *orig_installprefix,
00062                                     const char *orig_installdir,
00063                                     const char *curr_pathname);
00064 
00065 #else
00066 
00067 /* By default, we use the hardwired pathnames.  */
00068 #define relocate(pathname) (pathname)
00069 
00070 #endif
00071 
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif /* _RELOCATABLE_H */