relocatable.h 2.6 KB

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