GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ask_group.c
Go to the documentation of this file.
1 
2 /*************************************************************
3 * I_ask_group_old (prompt,group)
4 *
5 * prompt the user for an imagery group file name
6 *************************************************************/
7 #include <string.h>
8 #include <grass/gis.h>
9 #include <grass/imagery.h>
10 static int ask_group(char *, char *);
11 
12 
24 int I_ask_group_old(char *prompt, char *group)
25 {
26  while (1) {
27  if (*prompt == 0)
28  prompt = "Select an imagery group file";
29  if (!ask_group(prompt, group))
30  return 0;
31  if (I_find_group(group))
32  return 1;
33  fprintf(stderr, "\n** %s - not found **\n\n", group);
34  }
35 }
36 
37 static int ask_group(char *prompt, char *group)
38 {
39  char buf[1024];
40 
41  while (1) {
42  fprintf(stderr, "\n%s\n", prompt);
43  fprintf(stderr,
44  "Enter 'list' for a list of existing imagery groups\n");
45  fprintf(stderr, "Enter 'list -f' for a verbose listing\n");
46  fprintf(stderr, "Hit RETURN %s\n", G_get_ask_return_msg());
47  fprintf(stderr, "> ");
48  if (!G_gets(buf))
49  continue;
50 
51  G_squeeze(buf);
52  fprintf(stderr, "<%s>\n", buf);
53  if (*buf == 0)
54  return 0;
55 
56  if (strcmp(buf, "list") == 0)
57  I_list_groups(0);
58  else if (strcmp(buf, "list -f") == 0)
59  I_list_groups(1);
60  else if (G_legal_filename(buf) < 0)
61  fprintf(stderr, "\n** <%s> - illegal name **\n\n", buf);
62  else
63  break;
64  }
65  strcpy(group, buf);
66  return 1;
67 }
int G_gets(char *buf)
Definition: gets.c:39
char * G_get_ask_return_msg()
get Hit RETURN msg
Definition: ask.c:337
int I_find_group(const char *group)
does group exist?
Definition: imagery/find.c:21
int I_ask_group_old(char *prompt, char *group)
prompt for an existing group
Definition: ask_group.c:24
int I_list_groups(int full)
Definition: ls_groups.c:16
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
char * G_squeeze(char *line)
Remove superfluous white space.
Definition: squeeze.c:45