dig_title.c 829 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**************************************************************
  2. * char *G_get_cell_title (name, mapset)
  3. * char *name name of map file
  4. * char *mapset mapset containing name
  5. *
  6. * returns pointer to string containing cell title. (from cats file)
  7. *************************************************************/
  8. #include <stdio.h>
  9. #include <grass/gis.h>
  10. char *G_get_dig_title(const char *name, const char *mapset)
  11. {
  12. FILE *fd;
  13. int stat = -1;
  14. char title[100];
  15. fd = G_fopen_old("dig_cats", name, mapset);
  16. if (fd) {
  17. stat = 1;
  18. if (!fgets(title, sizeof title, fd)) /* skip number of cats */
  19. stat = -1;
  20. else if (!G_getl(title, sizeof title, fd)) /* read title */
  21. stat = -1;
  22. fclose(fd);
  23. }
  24. if (stat < 0)
  25. *title = 0;
  26. else
  27. G_strip(title);
  28. return G_store(title);
  29. }