progrm_nme.c 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*!
  2. * \file gis/progrm_nme.c
  3. *
  4. * \brief GIS Library - Program name
  5. *
  6. * (C) 2001-2009 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author Original author CERL
  12. */
  13. #include <string.h>
  14. #include <grass/gis.h>
  15. static const char *name = "?";
  16. /*!
  17. * \brief Return module name
  18. *
  19. * Routine returns the name of the module as set by the call to
  20. * G_gisinit().
  21. *
  22. * \return pointer to string with program name
  23. */
  24. const char *G_program_name(void)
  25. {
  26. return name;
  27. }
  28. /*!
  29. \brief Set program name
  30. Program name set to name (name will be returned by
  31. G_program_name*())
  32. \param s program name
  33. */
  34. void G_set_program_name(const char *s)
  35. {
  36. int i;
  37. char *temp;
  38. i = strlen(s);
  39. while (--i >= 0) {
  40. if (G_is_dirsep(s[i])) {
  41. s += i + 1;
  42. break;
  43. }
  44. }
  45. temp = G_store(s);
  46. G_basename(temp, "exe");
  47. name = G_store(temp);
  48. G_free(temp);
  49. }