GRASS Programmer's Manual
6.4.2(2012)
|
00001 00014 #include <string.h> 00015 #include <grass/imagery.h> 00016 #include <grass/glocale.h> 00017 00026 int I_list_group(const char *group, const struct Ref *ref, FILE * fd) 00027 { 00028 char buf[80]; 00029 int i; 00030 int len, tot_len; 00031 int max; 00032 00033 if (ref->nfiles <= 0) { 00034 fprintf(fd, _("group <%s> is empty\n"), group); 00035 return 0; 00036 } 00037 max = 0; 00038 for (i = 0; i < ref->nfiles; i++) { 00039 sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset); 00040 len = strlen(buf) + 4; 00041 if (len > max) 00042 max = len; 00043 } 00044 fprintf(fd, _("group <%s> references the following raster maps\n"), group); 00045 fprintf(fd, "-------------\n"); 00046 tot_len = 0; 00047 for (i = 0; i < ref->nfiles; i++) { 00048 sprintf(buf, "<%s@%s>", ref->file[i].name, ref->file[i].mapset); 00049 tot_len += max; 00050 if (tot_len > 78) { 00051 fprintf(fd, "\n"); 00052 tot_len = max; 00053 } 00054 fprintf(fd, "%-*s", max, buf); 00055 } 00056 if (tot_len) 00057 fprintf(fd, "\n"); 00058 fprintf(fd, "-------------\n"); 00059 00060 return 0; 00061 } 00062 00073 int I_list_group_simple(const struct Ref *ref, FILE * fd) 00074 { 00075 int i; 00076 00077 if (ref->nfiles <= 0) 00078 return 0; 00079 00080 for (i = 0; i < ref->nfiles; i++) 00081 fprintf(fd, "%s@%s\n", ref->file[i].name, ref->file[i].mapset); 00082 00083 return 0; 00084 }