progrm_nme.c 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**********************************************************************
  2. *
  3. * char *
  4. * G_program_name()
  5. *
  6. * returns the current program name
  7. *
  8. **********************************************************************
  9. *
  10. * G_set_program_name(name)
  11. * char *name
  12. *
  13. * program name set to name (name will be returned by G_program_name
  14. *
  15. **********************************************************************/
  16. #include <string.h>
  17. #include <grass/gis.h>
  18. static const char *name = "?";
  19. /*!
  20. * \brief return module name
  21. *
  22. * Routine returns the name
  23. * of the module as set by the call to <i>G_gisinit.</i>
  24. *
  25. * \param ~
  26. * \return char *
  27. */
  28. const char *G_program_name(void)
  29. {
  30. return name;
  31. }
  32. int G_set_program_name(const char *s)
  33. {
  34. int i;
  35. char *temp;
  36. i = strlen(s);
  37. while (--i >= 0) {
  38. if (G_is_dirsep(s[i])) {
  39. s += i + 1;
  40. break;
  41. }
  42. }
  43. temp = G_store(s);
  44. G_basename(temp, "exe");
  45. name = G_store(temp);
  46. G_free(temp);
  47. return 0;
  48. }