GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /************************************************************* 00003 * I_ask_group_old (prompt,group) 00004 * 00005 * prompt the user for an imagery group file name 00006 *************************************************************/ 00007 #include <string.h> 00008 #include <grass/gis.h> 00009 #include <grass/imagery.h> 00010 static int ask_group(char *, char *); 00011 00012 00024 int I_ask_group_old(char *prompt, char *group) 00025 { 00026 while (1) { 00027 if (*prompt == 0) 00028 prompt = "Select an imagery group file"; 00029 if (!ask_group(prompt, group)) 00030 return 0; 00031 if (I_find_group(group)) 00032 return 1; 00033 fprintf(stderr, "\n** %s - not found **\n\n", group); 00034 } 00035 } 00036 00037 static int ask_group(char *prompt, char *group) 00038 { 00039 char buf[1024]; 00040 00041 while (1) { 00042 fprintf(stderr, "\n%s\n", prompt); 00043 fprintf(stderr, 00044 "Enter 'list' for a list of existing imagery groups\n"); 00045 fprintf(stderr, "Enter 'list -f' for a verbose listing\n"); 00046 fprintf(stderr, "Hit RETURN %s\n", G_get_ask_return_msg()); 00047 fprintf(stderr, "> "); 00048 if (!G_gets(buf)) 00049 continue; 00050 00051 G_squeeze(buf); 00052 fprintf(stderr, "<%s>\n", buf); 00053 if (*buf == 0) 00054 return 0; 00055 00056 if (strcmp(buf, "list") == 0) 00057 I_list_groups(0); 00058 else if (strcmp(buf, "list -f") == 0) 00059 I_list_groups(1); 00060 else if (G_legal_filename(buf) < 0) 00061 fprintf(stderr, "\n** <%s> - illegal name **\n\n", buf); 00062 else 00063 break; 00064 } 00065 strcpy(group, buf); 00066 return 1; 00067 }