GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
list_gp.c
Go to the documentation of this file.
1 
14 #include <string.h>
15 #include <grass/imagery.h>
16 #include <grass/glocale.h>
17 
26 int I_list_group(const char *group, const struct Ref *ref, FILE * fd)
27 {
28  char buf[80];
29  int i;
30  int len, tot_len;
31  int max;
32 
33  if (ref->nfiles <= 0) {
34  fprintf(fd, _("group <%s> is empty\n"), group);
35  return 0;
36  }
37  max = 0;
38  for (i = 0; i < ref->nfiles; i++) {
39  sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
40  len = strlen(buf) + 4;
41  if (len > max)
42  max = len;
43  }
44  fprintf(fd, _("group <%s> references the following raster maps\n"), group);
45  fprintf(fd, "-------------\n");
46  tot_len = 0;
47  for (i = 0; i < ref->nfiles; i++) {
48  sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
49  tot_len += max;
50  if (tot_len > 78) {
51  fprintf(fd, "\n");
52  tot_len = max;
53  }
54  fprintf(fd, "%-*s", max, buf);
55  }
56  if (tot_len)
57  fprintf(fd, "\n");
58  fprintf(fd, "-------------\n");
59 
60  return 0;
61 }
62 
73 int I_list_group_simple(const struct Ref *ref, FILE * fd)
74 {
75  int i;
76 
77  if (ref->nfiles <= 0)
78  return 0;
79 
80  for (i = 0; i < ref->nfiles; i++)
81  fprintf(fd, "%s@%s\n", ref->file[i].name, ref->file[i].mapset);
82 
83  return 0;
84 }