GRASS 8 Programmer's Manual
8.5.0(2026)-8d6ceba290
Toggle main menu visibility
Loading...
Searching...
No Matches
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
char
*
G_myname
(
void
)
31
{
32
char
name
[GNAME_MAX];
33
char
path
[GPATH_MAX];
34
FILE *fd;
35
int
ok;
36
37
ok = 0;
38
39
G_file_name
(
path
,
""
,
"MYNAME"
,
"PERMANENT"
);
40
if
((fd = fopen(
path
,
"r"
))) {
41
ok =
G_getl
(
name
,
sizeof
name
, fd);
42
fclose(fd);
43
}
44
if
(!ok)
45
strcpy
(
name
, _(
"This location has no description."
));
46
47
return
G_store
(
name
);
48
}
G_file_name
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
Definition
file_name.c:61
G_getl
int G_getl(char *buf, int n, FILE *fd)
Gets a line of text from a file.
Definition
getl.c:33
G_myname
char * G_myname(void)
Returns location title.
Definition
myname.c:30
name
const char * name
Definition
named_colr.c:6
strcpy
#define strcpy
Definition
parson.c:66
G_store
char * G_store(const char *s)
Copy string to allocated memory.
Definition
strings.c:87
path
Definition
path.h:15
gis
myname.c
Generated on
for GRASS 8 Programmer's Manual by
1.17.0