]> code.citadel.org Git - citadel.git/blobdiff - citadel/commands.c
* Implemented CONF server command for site-global configs
[citadel.git] / citadel / commands.c
index 50bf0e7c6b8da9841c95afd3333b22786e653b24..ec036fdf2055783edaac49a48dd1c8f6c06bd46d 100644 (file)
@@ -193,6 +193,30 @@ int inkey(void) {          /* get a character from the keyboard, with   */
        return(a);
        }
 
+
+int yesno(void) { /* Returns 1 for yes, 0 for no */
+int a;
+       while (1) {
+               a=inkey(); a=tolower(a);
+               if (a=='y') { printf("Yes\n"); return(1); }
+               if (a=='n') { printf("No\n");  return(0); }
+               }
+       }
+
+int yesno_d(int d) /* Returns 1 for yes, 0 for no, arg is default value */
+       {
+int a;
+       while (1) {
+               a=inkey(); a=tolower(a);
+               if (a==13) a=(d ? 'y' : 'n');
+               if (a=='y') { printf("Yes\n"); return(1); }
+               if (a=='n') { printf("No\n");  return(0); }
+               }
+       }
+
+
+
+
 void getline(char *string, int lim)    /* Gets a line from the terminal */
                                /* Pointer to string buffer */
                        /* Maximum length - if negative, no-show */
@@ -244,6 +268,21 @@ void strprompt(char *prompt, char *str, int len)
        if (buf[0]!=0) strcpy(str,buf);
        }
 
+/*
+ * boolprompt()  -  prompt for a yes/no, print the existing value and
+ *                  allow the user to press return to keep it...
+ */
+int boolprompt(char *prompt, int prev_val) {
+       color(3);
+       printf("%s [", prompt);
+       color(1);
+       printf("%s", (prev_val ? "Yes" : "No"));
+       color(3);
+       printf("]: ");
+       color(7);
+       return(yesno_d(prev_val));
+       }
+
 /* 
  * intprompt()  -  like strprompt(), except for an integer
  *                 (note that it RETURNS the new value!)