GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
list_subgp.c
Go to the documentation of this file.
1 
14 #include <string.h>
15 #include <grass/imagery.h>
16 #include <grass/glocale.h>
17 
27 int I_list_subgroup(const char *group,
28  const char *subgroup, const struct Ref *ref, FILE * fd)
29 {
30  char buf[80];
31  int i;
32  int len, tot_len;
33  int max;
34 
35  if (ref->nfiles <= 0) {
36  fprintf(fd, _("subgroup <%s> of group <%s> is empty\n"),
37  subgroup, group);
38  return 0;
39  }
40  max = 0;
41  for (i = 0; i < ref->nfiles; i++) {
42  sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
43  len = strlen(buf) + 4;
44  if (len > max)
45  max = len;
46  }
47  fprintf(fd,
48  _("subgroup <%s> of group <%s> references the following raster maps\n"),
49  subgroup, group);
50  fprintf(fd, "-------------\n");
51  tot_len = 0;
52  for (i = 0; i < ref->nfiles; i++) {
53  sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
54  tot_len += max;
55  if (tot_len > 78) {
56  fprintf(fd, "\n");
57  tot_len = max;
58  }
59  fprintf(fd, "%-*s", max, buf);
60  }
61  if (tot_len)
62  fprintf(fd, "\n");
63  fprintf(fd, "-------------\n");
64 
65  return 0;
66 }
67 
78 /* same as above, but one map per line in map@mapset form */
79 int I_list_subgroup_simple(const struct Ref *ref, FILE * fd)
80 {
81  return I_list_group_simple(ref, fd);
82 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
FILE * fd
Definition: g3dcolor.c:368
#define max(x, y)
Definition: draw2.c:69
int I_list_group_simple(const struct Ref *ref, FILE *fd)
Prints maps in a group (simple version)
Definition: list_gp.c:73
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
int I_list_subgroup(const char *group, const char *subgroup, const struct Ref *ref, FILE *fd)
Prints maps in a subgroup (fancy version)
Definition: list_subgp.c:27
int I_list_subgroup_simple(const struct Ref *ref, FILE *fd)
Prints maps in a subgroup (simple version)
Definition: list_subgp.c:79