yes.c

Go to the documentation of this file.
00001 #include "gis.h"
00002 /*****************************************************************
00003  *
00004  * G_yes (question, dflt)
00005  *
00006  * print the question and get a yes/no response from the user
00007  * if dflt is 1 a RETURN is taken to be yes
00008  * if dflt is 0 a RETURN is taken to be no
00009  * if dflt is -1 a RETURN is not a valid response
00010  *
00011  * returns 0 no, 1 yes
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 }

Generated on Wed Aug 23 17:49:23 2006 for GRASS by  doxygen 1.4.7