myname.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include <string.h>
  14. #include <grass/gis.h>
  15. #include <grass/glocale.h>
  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. */
  28. char *G_myname(void)
  29. {
  30. char name[GNAME_MAX];
  31. char path[GPATH_MAX];
  32. FILE *fd;
  33. int ok;
  34. ok = 0;
  35. G_file_name(path, "", "MYNAME", "PERMANENT");
  36. if ((fd = fopen(path, "r"))) {
  37. ok = G_getl(name, sizeof name, fd);
  38. fclose(fd);
  39. }
  40. if (!ok)
  41. strcpy(name, _("This location has no description."));
  42. return G_store(name);
  43. }