GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
myname.c
Go to the documentation of this file.
1 /*!
2  * \file lib/gis/myname.c
3  *
4  * \brief GIS Library - Database name functions.
5  *
6  * (C) 2001-2009 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public License
9  * (>=v2). Read the file COPYING that comes with GRASS for details.
10  *
11  * \author Original author CERL
12  */
13 
14 #include <string.h>
15 #include <grass/gis.h>
16 #include <grass/glocale.h>
17 
18 /*!
19  * \brief Returns location title.
20  *
21  * Returns a one line title for the database location. This title is
22  * read from the file MYNAME in the PERMANENT mapset. See also \ref
23  * Permanent_Mapset for a discussion of the PERMANENT mapset.
24  *
25  * <b>Note:</b> This name is the first line in the file
26  * $GISDBASE/$LOCATION_NAME/PERMANENT/MYNAME
27  *
28  * \return pointer to a string
29  */
30 
31 char *G_myname(void)
32 {
33  char name[GNAME_MAX];
34  char path[GPATH_MAX];
35  FILE *fd;
36  int ok;
37 
38  ok = 0;
39 
40  G_file_name(path, "", "MYNAME", "PERMANENT");
41  if ((fd = fopen(path, "r"))) {
42  ok = G_getl(name, sizeof name, fd);
43  fclose(fd);
44  }
45  if (!ok)
46  strcpy(name, _("This location has no description."));
47 
48  return G_store(name);
49 }
char * G_myname(void)
Returns location title.
Definition: myname.c:31
int G_getl(char *, int, FILE *)
Gets a line of text from a file.
Definition: getl.c:31
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
Definition: file_name.c:61
#define GPATH_MAX
Definition: gis.h:180
#define GNAME_MAX
Definition: gis.h:177
Definition: path.h:16
#define _(str)
Definition: glocale.h:10
char * G_store(const char *)
Copy string to allocated memory.
Definition: strings.c:87
const char * name
Definition: named_colr.c:7