GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dig_title.c
Go to the documentation of this file.
1 
2 /**************************************************************
3  * char *G_get_cell_title (name, mapset)
4  * char *name name of map file
5  * char *mapset mapset containing name
6  *
7  * returns pointer to string containing cell title. (from cats file)
8  *************************************************************/
9 
10 #include <stdio.h>
11 #include <grass/gis.h>
12 
13 char *G_get_dig_title(const char *name, const char *mapset)
14 {
15  FILE *fd;
16  int stat = -1;
17  char title[100];
18 
19  fd = G_fopen_old("dig_cats", name, mapset);
20  if (fd) {
21  stat = 1;
22  if (!fgets(title, sizeof title, fd)) /* skip number of cats */
23  stat = -1;
24  else if (!G_getl(title, sizeof title, fd)) /* read title */
25  stat = -1;
26 
27  fclose(fd);
28  }
29 
30  if (stat < 0)
31  *title = 0;
32  else
33  G_strip(title);
34 
35  return G_store(title);
36 }
char * G_store(const char *s)
Copy string to allocated memory.
Definition: store.c:32
FILE * fd
Definition: g3dcolor.c:368
string name
Definition: render.py:1314
int stat
Definition: g3dcolor.c:369
int G_strip(char *buf)
Removes all leading and trailing white space from string.
Definition: strings.c:389
int G_getl(char *buf, int n, FILE *fd)
gets a line of text from a file
Definition: getl.c:17
fclose(fd)
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
Definition: gis/open.c:226
char * G_get_dig_title(const char *name, const char *mapset)
Definition: dig_title.c:13