progrm_nme.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. * \file lib/gis/progrm_nme.c
  3. *
  4. * \brief GIS Library - Program name
  5. *
  6. * (C) 2001-2014 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. Extension like .exe or .py is stripped from program name.
  33. \param s program name
  34. */
  35. void G_set_program_name(const char *s)
  36. {
  37. int i;
  38. char *temp;
  39. i = strlen(s);
  40. while (--i >= 0) {
  41. if (G_is_dirsep(s[i])) {
  42. s += i + 1;
  43. break;
  44. }
  45. }
  46. /* strip extension from program name */
  47. temp = G_store(s);
  48. G_basename(temp, "exe");
  49. G_basename(temp, "py");
  50. name = G_store(temp);
  51. G_debug(1, "G_set_program_name(): %s", name);
  52. G_free(temp);
  53. }