GRASS 8 Programmer's Manual 8.6.0dev(2026)-55de52a352
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 * SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Original author CERL
10 */
11
12#include <string.h>
13#include <grass/gis.h>
14#include <grass/glocale.h>
15
16/*!
17 * \brief Returns location title.
18 *
19 * Returns a one line title for the database location. This title is
20 * read from the file MYNAME in the PERMANENT mapset. See also \ref
21 * Permanent_Mapset for a discussion of the PERMANENT mapset.
22 *
23 * <b>Note:</b> This name is the first line in the file
24 * $GISDBASE/$LOCATION_NAME/PERMANENT/MYNAME
25 *
26 * \return pointer to a string
27 */
28char *G_myname(void)
29{
30 char name[GNAME_MAX];
31 char path[GPATH_MAX];
32 FILE *fd;
33 int ok;
34
35 ok = 0;
36
37 G_file_name(path, "", "MYNAME", "PERMANENT");
38 if ((fd = fopen(path, "r"))) {
39 ok = G_getl(name, sizeof name, fd);
40 fclose(fd);
41 }
42 if (!ok)
43 strcpy(name, _("This location has no description."));
44
45 return G_store(name);
46}
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
Definition file_name.c:59
char * G_store(const char *)
Copy string to allocated memory.
Definition strings.c:85
int G_getl(char *, int, FILE *)
Gets a line of text from a file.
Definition getl.c:31
#define GPATH_MAX
Definition gis.h:196
#define GNAME_MAX
Definition gis.h:193
#define _(str)
Definition glocale.h:10
char * G_myname(void)
Returns location title.
Definition myname.c:28
const char * name
Definition named_colr.c:6
#define strcpy
Definition parson.c:66
Definition path.h:15