gisbase.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**********************************************************************
  2. *
  3. * char *
  4. * G_gisbase()
  5. *
  6. * returns: pointer to string containing the base directory of
  7. * GRASS-GRID
  8. **********************************************************************/
  9. #include <grass/gis.h>
  10. /*!
  11. * \brief Get full path name of the top level module directory
  12. *
  13. * Returns the full path name of the top level directory for GRASS
  14. * programs. This directory will have subdirectories which will
  15. * contain modules and files required for the running of the
  16. * system. Some of these directories are:
  17. \verbatim
  18. bin commands run by the user
  19. etc modules and data files used by GRASS commands
  20. \endverbatim
  21. * The use of G_gisbase() to find these subdirectories enables GRASS
  22. * modules to be written independently of where the GRASS system is
  23. * actually installed on the machine. For example, to run the module
  24. * <i>sroff</i> in the GRASS <i>etc</i> directory:
  25. \code
  26. char command[200];
  27. sprintf(command, "%s/etc/sroff", G_gisbase());
  28. G_spawn(command, "sroff", NULL);
  29. \endcode
  30. *
  31. * \return pointer to a string
  32. */
  33. const char *G_gisbase(void)
  34. {
  35. return G_getenv("GISBASE");
  36. }