GRASS Programmer's Manual
6.4.1(2011)
|
00001 00002 /************************************************************** 00003 * char *G_get_cell_title (name, mapset) 00004 * char *name name of map file 00005 * char *mapset mapset containing name 00006 * 00007 * returns pointer to string containing cell title. (from cats file) 00008 *************************************************************/ 00009 00010 #include <grass/gis.h> 00011 00012 00027 char *G_get_cell_title(const char *name, const char *mapset) 00028 { 00029 FILE *fd; 00030 int stat; 00031 char title[1024]; 00032 00033 stat = -1; 00034 fd = G_fopen_old("cats", name, mapset); 00035 if (fd) { 00036 stat = 1; 00037 if (!fgets(title, sizeof title, fd)) /* skip number of cats */ 00038 stat = -1; 00039 else if (!G_getl(title, sizeof title, fd)) /* read title */ 00040 stat = -1; 00041 00042 fclose(fd); 00043 } 00044 00045 if (stat < 0) 00046 *title = 0; 00047 else 00048 G_strip(title); 00049 return G_store(title); 00050 }