GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <stdio.h> 00002 #include <grass/gis.h> 00003 #include <grass/imagery.h> 00004 #include <grass/glocale.h> 00005 00022 int I_get_target(const char *group, char *location, char *mapset) 00023 { 00024 FILE *fd; 00025 int ok; 00026 00027 *location = *mapset = 0; 00028 G_suppress_warnings(1); 00029 fd = I_fopen_group_file_old(group, "TARGET"); 00030 G_suppress_warnings(0); 00031 if (fd == NULL) 00032 return 0; 00033 00034 ok = (fscanf(fd, "%s %s", location, mapset) == 2); 00035 fclose(fd); 00036 if (!ok) { 00037 *location = *mapset = 0; 00038 G_warning(_("Unable to read target file for group [%s]"), group); 00039 } 00040 00041 return ok; 00042 } 00043 00044 00062 int I_put_target(const char *group, const char *location, const char *mapset) 00063 { 00064 FILE *fd; 00065 00066 fd = I_fopen_group_file_new(group, "TARGET"); 00067 if (fd == NULL) 00068 return 0; 00069 00070 fprintf(fd, "%s\n%s\n", location, mapset); 00071 fclose(fd); 00072 00073 return 1; 00074 }