00001 #include <grass/gis.h>
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdio.h>
00014
00015
00035 int G_yes (char *question,int dflt)
00036 {
00037 char answer[100];
00038
00039 fflush (stdout);
00040 while (1)
00041 {
00042 fprintf (stderr,"%s", question);
00043 while (1)
00044 {
00045 fprintf (stderr,"(y/n) ");
00046 if (dflt >= 0) fprintf (stderr,dflt==0?"[n] ":"[y] ");
00047 fflush (stderr);
00048 if (!G_gets(answer)) break;
00049 G_strip (answer);
00050 switch (*answer)
00051 {
00052 case 'y': case 'Y': return (1);
00053 case 'n': case 'N': return (0);
00054 case 0: if (dflt >= 0) return (dflt);
00055 }
00056 }
00057 }
00058 }