progname.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Program name management.
  2. Copyright (C) 2001-2004, 2006, 2009-2013 Free Software Foundation, Inc.
  3. Written by Bruno Haible <bruno@clisp.org>, 2001.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) 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
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _PROGNAME_H
  15. #define _PROGNAME_H
  16. /* Programs using this file should do the following in main():
  17. set_program_name (argv[0]);
  18. */
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* String containing name the program is called with. */
  23. extern const char *program_name;
  24. /* Set program_name, based on argv[0].
  25. argv0 must be a string allocated with indefinite extent, and must not be
  26. modified after this call. */
  27. extern void set_program_name (const char *argv0);
  28. #if ENABLE_RELOCATABLE
  29. /* Set program_name, based on argv[0], and original installation prefix and
  30. directory, for relocatability. */
  31. extern void set_program_name_and_installdir (const char *argv0,
  32. const char *orig_installprefix,
  33. const char *orig_installdir);
  34. #undef set_program_name
  35. #define set_program_name(ARG0) \
  36. set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
  37. /* Return the full pathname of the current executable, based on the earlier
  38. call to set_program_name_and_installdir. Return NULL if unknown. */
  39. extern char *get_full_program_name (void);
  40. #endif
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* _PROGNAME_H */