GRASS Programmer's Manual  6.4.2(2012)
list_subgp.c
Go to the documentation of this file.
00001 
00014 #include <string.h>
00015 #include <grass/imagery.h>
00016 #include <grass/glocale.h>
00017 
00027 int I_list_subgroup(const char *group,
00028                     const char *subgroup, const struct Ref *ref, FILE * fd)
00029 {
00030     char buf[80];
00031     int i;
00032     int len, tot_len;
00033     int max;
00034 
00035     if (ref->nfiles <= 0) {
00036         fprintf(fd, _("subgroup <%s> of group <%s> is empty\n"),
00037                 subgroup, group);
00038         return 0;
00039     }
00040     max = 0;
00041     for (i = 0; i < ref->nfiles; i++) {
00042         sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
00043         len = strlen(buf) + 4;
00044         if (len > max)
00045             max = len;
00046     }
00047     fprintf(fd,
00048             _("subgroup <%s> of group <%s> references the following raster maps\n"),
00049             subgroup, group);
00050     fprintf(fd, "-------------\n");
00051     tot_len = 0;
00052     for (i = 0; i < ref->nfiles; i++) {
00053         sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset);
00054         tot_len += max;
00055         if (tot_len > 78) {
00056             fprintf(fd, "\n");
00057             tot_len = max;
00058         }
00059         fprintf(fd, "%-*s", max, buf);
00060     }
00061     if (tot_len)
00062         fprintf(fd, "\n");
00063     fprintf(fd, "-------------\n");
00064 
00065     return 0;
00066 }
00067 
00078 /* same as above, but one map per line in map@mapset form */
00079 int I_list_subgroup_simple(const struct Ref *ref, FILE * fd)
00080 {
00081     return I_list_group_simple(ref, fd);
00082 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines