GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
target.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <grass/gis.h>
3 #include <grass/imagery.h>
4 #include <grass/glocale.h>
5 
22 int I_get_target(const char *group, char *location, char *mapset)
23 {
24  FILE *fd;
25  int ok;
26 
27  *location = *mapset = 0;
29  fd = I_fopen_group_file_old(group, "TARGET");
31  if (fd == NULL)
32  return 0;
33 
34  ok = (fscanf(fd, "%s %s", location, mapset) == 2);
35  fclose(fd);
36  if (!ok) {
37  *location = *mapset = 0;
38  G_warning(_("Unable to read target file for group [%s]"), group);
39  }
40 
41  return ok;
42 }
43 
44 
62 int I_put_target(const char *group, const char *location, const char *mapset)
63 {
64  FILE *fd;
65 
66  fd = I_fopen_group_file_new(group, "TARGET");
67  if (fd == NULL)
68  return 0;
69 
70  fprintf(fd, "%s\n%s\n", location, mapset);
71  fclose(fd);
72 
73  return 1;
74 }
FILE * fd
Definition: g3dcolor.c:368
int G_suppress_warnings(int flag)
Suppress printing a warning message to stderr.
int I_put_target(const char *group, const char *location, const char *mapset)
write target information
Definition: target.c:62
int I_get_target(const char *group, char *location, char *mapset)
read target information
Definition: target.c:22
FILE * I_fopen_group_file_old(const char *group, const char *file)
Definition: fopen.c:43
FILE * I_fopen_group_file_new(const char *group, const char *file)
Definition: fopen.c:17
return NULL
Definition: dbfopen.c:1394
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
fclose(fd)