myname.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * \file myname.c
  3. *
  4. * \brief GIS Library - Database name functions.
  5. *
  6. * (C) 2001-2008 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 GRASS GIS Development Team
  12. *
  13. * \date 1999-2008
  14. */
  15. #include <string.h>
  16. #include <grass/gis.h>
  17. #include <grass/glocale.h>
  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
  23. * Permanent_Mapset for a discussion of the PERMANENT mapset.<br>
  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. static char name[GNAME_MAX];
  33. char path[GPATH_MAX];
  34. FILE *fd;
  35. int ok;
  36. ok = 0;
  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, _("Unknown Location"));
  44. return name;
  45. }