Loading...
Searching...
No Matches
myname.c
Go to the documentation of this file.
/*!
* \file lib/gis/myname.c
*
* \brief GIS Library - Database name functions.
*
* (C) 2001-2009 by the GRASS Development Team
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author Original author CERL
*/
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
/*!
* \brief Returns location title.
*
* Returns a one line title for the database location. This title is
* read from the file MYNAME in the PERMANENT mapset. See also \ref
* Permanent_Mapset for a discussion of the PERMANENT mapset.
*
* <b>Note:</b> This name is the first line in the file
* $GISDBASE/$LOCATION_NAME/PERMANENT/MYNAME
*
* \return pointer to a string
*/
char *G_myname(void)
{
char name[GNAME_MAX];
char path[GPATH_MAX];
FILE *fd;
int ok;
ok = 0;
G_file_name(path, "", "MYNAME", "PERMANENT");
if ((fd = fopen(path, "r"))) {
ok = G_getl(name, sizeof name, fd);
fclose(fd);
}
if (!ok)
strcpy(name, _("This location has no description."));
return G_store(name);
}
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