gishelp.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. ****************************************************************************
  3. *
  4. * MODULE: GRASS 5 gis library, gishelp.c
  5. * AUTHOR(S): unknown
  6. * PURPOSE: Print help information
  7. * COPYRIGHT: (C) 2000 by the GRASS Development Team
  8. *
  9. * This program is free software under the GNU General Public
  10. * License (>=v2). Read the file COPYING that comes with GRASS
  11. * for details.
  12. *
  13. *****************************************************************************/
  14. /*
  15. **********************************************************************
  16. *
  17. * G_gishelp(helpfile, request)
  18. * char *helpfile help directory where "request" is found
  19. * char *request help file desired
  20. *
  21. * Prints a helpfile to the screen. Helpfiles are stored in directories
  22. * associated with different GRID programs. A given file will be
  23. * found in $GISBASE/txt/"helpfile"/"request".
  24. *
  25. **********************************************************************/
  26. #include <grass/gis.h>
  27. #include <grass/glocale.h>
  28. #include <unistd.h>
  29. #include <stdlib.h>
  30. #include <grass/spawn.h>
  31. #define GEN_HELP "gen_help"
  32. int G_gishelp(const char *helpfile, const char *request)
  33. {
  34. char file[1024];
  35. if (request == NULL)
  36. request = GEN_HELP;
  37. sprintf(file, "%s/txt/%s/%s", G_getenv("GISBASE"), helpfile, request);
  38. if (!access(file, 04)) {
  39. fprintf(stderr, _("one moment...\n"));
  40. G_spawn(getenv("GRASS_PAGER"), getenv("GRASS_PAGER"), file, NULL);
  41. }
  42. else {
  43. fprintf(stderr, _("No help available for command [%s]\n"), request);
  44. }
  45. return 0;
  46. }