GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gishelp.c
Go to the documentation of this file.
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  *
18  * G_gishelp(helpfile, request)
19  * char *helpfile help directory where "request" is found
20  * char *request help file desired
21  *
22  * Prints a helpfile to the screen. Helpfiles are stored in directories
23  * associated with different GRID programs. A given file will be
24  * found in $GISBASE/txt/"helpfile"/"request".
25  *
26  **********************************************************************/
27 
28 #include <grass/gis.h>
29 #include <grass/glocale.h>
30 #include <unistd.h>
31 #include <stdlib.h>
32 #include <grass/spawn.h>
33 #define GEN_HELP "gen_help"
34 
35 int G_gishelp(const char *helpfile, const char *request)
36 {
37  char file[1024];
38 
39  if (request == NULL)
40  request = GEN_HELP;
41 
42  sprintf(file, "%s/txt/%s/%s", G_getenv("GISBASE"), helpfile, request);
43 
44  if (!access(file, 04)) {
45  fprintf(stderr, _("one moment...\n"));
46  G_spawn(getenv("GRASS_PAGER"), getenv("GRASS_PAGER"), file, NULL);
47  }
48  else {
49  fprintf(stderr, _("No help available for command [%s]\n"), request);
50  }
51 
52  return 0;
53 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
char * G_getenv(const char *name)
Get environment variable.
Definition: env.c:267
char * getenv()
#define GEN_HELP
Definition: gishelp.c:33
return NULL
Definition: dbfopen.c:1394
int G_gishelp(const char *helpfile, const char *request)
Definition: gishelp.c:35
#define file
int G_spawn(const char *command,...)
Spawn new process based on command.
Definition: spawn.c:924