* Implemented CONF server command for site-global configs
authorArt Cancro <ajc@citadel.org>
Sat, 7 Nov 1998 06:00:17 +0000 (06:00 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 7 Nov 1998 06:00:17 +0000 (06:00 +0000)
* Shuffled yesno() and yesno_d() from routines.c to commands.c
* commands.c: implemented boolprompt()
* routines2.c: started adding CONF questions to <.AS> command
* room_ops.c: began a fix for the mysterious disappearing Aide room

citadel/ChangeLog
citadel/commands.c
citadel/commands.h
citadel/control.c
citadel/room_ops.c
citadel/rooms.c
citadel/routines.c
citadel/routines.h
citadel/routines2.c

index 9da9eff5d8c20248486046a019cd21f9c7c0093e..e07c44a25572d494c94cf9ed74435a50e1ded2f4 100644 (file)
@@ -1,7 +1,11 @@
 Fri Nov  6 20:22:20 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * citadel.h (and related files): removed defunct parameters,
          c_defent and c_msgbase (erase your test bbs)
-       * Began implementing CONF server command for site-global configs
+       * Implemented CONF server command for site-global configs
+       * Shuffled yesno() and yesno_d() from routines.c to commands.c
+       * commands.c: implemented boolprompt()
+       * routines2.c: started adding CONF questions to <.AS> command
+       * room_ops.c: began a fix for the mysterious disappearing Aide room
 
 1998-11-05 Nathan Bryant <bryant@cs.usm.maine.edu>
        * snprintf.c: warning fix propagated over from gcit
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!)
index eb57ef5d526eefdf7048633c25945f8f6dd2788a..8c23ccdcc0bb5b496289cfe75483336fad0b2752 100644 (file)
@@ -3,6 +3,7 @@ void load_command_set(void);
 void sttybbs(int cmd);
 void newprompt(char *prompt, char *str, int len);
 void strprompt(char *prompt, char *str, int len);
+int boolprompt(char *prompt, int prev_val);
 int fmout(int width, FILE *fp, char pagin, int height, int starting_lp,
          char subst);
 int getcmd(char *argbuf);
@@ -14,3 +15,5 @@ void look_for_ansi(void);
 int inkey(void);
 void set_keepalives(int s);
 extern int enable_color;
+int yesno(void);
+int yesno_d(int d);
index 44d8cdb4a48db9fed5ea2ec5a3bcd6b63d08de15..c8f6a5c3ee5917e833193e6c3b67eb1dae7a758c 100644 (file)
@@ -23,6 +23,8 @@
 #include "control.h"
 #include "sysdep_decls.h"
 #include "support.h"
+#include "config.h"
+#include "msgbase.h"
 
 struct CitControl CitControl;
 struct config config;
@@ -128,11 +130,64 @@ void cmd_conf(char *argbuf) {
                cprintf("000\n");
                }
 
-       /*      
        else if (!strcasecmp(cmd, "SET")) {
-               cprintf("%d Send configuration...\n");
+               cprintf("%d Send configuration...\n", SEND_LISTING);
+               a = 0;
+               while (client_gets(buf), strcmp(buf, "000")) {
+                   switch(a) {
+                       case 0: strncpy(config.c_nodename, buf, 16);
+                               break;
+                       case 1: strncpy(config.c_fqdn, buf, 64);
+                               break;
+                       case 2: strncpy(config.c_humannode, buf, 21);
+                               break;
+                       case 3: strncpy(config.c_phonenum, buf, 16);
+                               break;
+                       case 4: config.c_creataide = atoi(buf);
+                               break;
+                       case 5: config.c_sleeping = atoi(buf);
+                               break;
+                       case 6: config.c_initax = atoi(buf);
+                               if (config.c_initax < 1) config.c_initax = 1;
+                               if (config.c_initax > 6) config.c_initax = 6;
+                               break;
+                       case 7: config.c_regiscall = atoi(buf);
+                               if (config.c_regiscall != 0)
+                                       config.c_regiscall = 1;
+                               break;
+                       case 8: config.c_twitdetect = atoi(buf);
+                               if (config.c_twitdetect != 0)
+                                       config.c_twitdetect = 1;
+                               break;
+                       case 9: strncpy(config.c_twitroom,
+                                       buf, ROOMNAMELEN);
+                               break;
+                       case 10: strncpy(config.c_moreprompt, buf, 80);
+                               break;
+                       case 11: config.c_restrict = atoi(buf);
+                               if (config.c_restrict != 0)
+                                       config.c_restrict = 1;
+                               break;
+                       case 12: strncpy(config.c_bbs_city, buf, 32);
+                               break;
+                       case 13: strncpy(config.c_sysadm, buf, 26);
+                               break;
+                       case 14: config.c_maxsessions = atoi(buf);
+                               if (config.c_maxsessions < 1)
+                                       config.c_maxsessions = 1;
+                               break;
+                       case 15: strncpy(config.c_net_password, buf, 20);
+                               break;
+                       case 16: config.c_userpurge = atoi(buf);
+                               break;
+                               }
+                   ++a;
+                   }
+               put_config();
+               sprintf(buf,"Global system configuration edited by %s",
+                       CC->curr_user);
+               aide_message(buf);
                }
-       */
 
        else {
                cprintf("%d The only valid options are GET and SET.\n",
index 77ed9b28e97b50d117e6b4ba52fcb85785359104..13022f258fb18b438b791a8d78e22ca0d6c0bad1 100644 (file)
@@ -38,6 +38,18 @@ int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf) {
                        }
                }
 
+       /* Force the properties of the Aide room */
+       /* FIX FIX FIX ... this doesn't work */
+       if (!strcasecmp(roombuf->QRname, AIDEROOM)) {
+               if (userbuf->axlevel >= 6) {
+                       retval = UA_KNOWN | UA_GOTOALLOWED;
+                       }
+               else {
+                       retval=0;
+                       }
+               goto NEWMSG;
+               }
+
        /* Locate any applicable user/room relationships */
        CtdlGetRelationship(&vbuf, userbuf, roombuf);
 
index 821a3a6cbaedb7c20e9adf63651f134359842562..d0e3c3ce68e672ccaadd45e70a57723b3d6d79a7 100644 (file)
@@ -27,7 +27,6 @@ void extract(char *dest, char *source, int parmnum);
 int extract_int(char *source, int parmnum);
 void hit_any_key(void);
 int yesno(void);
-int yesno_d(int d);
 void strprompt(char *prompt, char *str, int len);
 void newprompt(char *prompt, char *str, int len);
 int struncmp(char *lstr, char *rstr, int len);
@@ -205,8 +204,7 @@ int set_room_attr(int ibuf, char *prompt, unsigned int sbit)
 {
        int a;
 
-       printf("%s [%s]? ",prompt,((ibuf&sbit) ? "Yes":"No"));
-       a=yesno_d(ibuf&sbit);
+       a = boolprompt(prompt, (ibuf&sbit));
        ibuf=(ibuf|sbit);
        if (!a) ibuf=(ibuf^sbit);
        return(ibuf);
@@ -330,8 +328,7 @@ void editthisroom(void) {
                }
 
        if ((rflags&QR_PRIVATE)==QR_PRIVATE) {
-               printf("Cause current users to forget room [No] ? ");
-               if (yesno_d(0)==1) rbump = 1;
+               rbump = boolprompt("Cause current users to forget room", 0);
                }
 
        rflags = set_room_attr(rflags,"Preferred users only",QR_PREFONLY);
index 9cb387ef1d2c348c9bfd0f0bd1809e3caac5e85a..a66f3dbc843999544607ddedfaef40ea82a3a7ab 100644 (file)
@@ -20,8 +20,8 @@
 
 #include "citadel.h"
 #include "routines.h"
+#include "commands.h"
 
-char inkey(void);
 void sttybbs(int cmd);
 void newprompt(char *prompt, char *str, int len);
 void val_user(char *user);
@@ -143,27 +143,6 @@ int 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 hit_any_key(void) {               /* hit any key to continue */
        int a,b;
 
index 6adfac88c2ffd80124f4c8ff831f35e5c72c303a..c8e373e168410de1374c8f5ff66271cbc3fe4f1b 100644 (file)
@@ -5,7 +5,6 @@ long extract_long(char *source, int parmnum);
 int extract_int(char *source, int parmnum);
 void interr(int errnum);
 int struncmp(char *lstr, char *rstr, int len);
-int yesno(void);
 int checkpagin(int lp, int pagin, int height);
 int pattern(char *search, char *patn);
 int num_parms(char *source);
index e6c3fe3c6e652520d4020fd955b9b9b8088772b0..5945e6fec87c1b71eadd0f09a43e34e763eb4d03 100644 (file)
@@ -19,6 +19,7 @@
 #include "citadel.h"
 #include "routines2.h"
 #include "routines.h"
+#include "commands.h"
 
 void interr(int errnum);
 void strprompt(char *prompt, char *str, int len);
@@ -584,8 +585,24 @@ void read_bio(void) {
  */
 void do_system_configuration(void) {
        char buf[256];
+       char sc[17][256];
        int expire_mode = 0;
        int expire_value = 0;
+       int a;
+
+       /* Clear out the config buffers */
+       bzero(&sc[0][0], sizeof(sc));
+
+       /* Fetch the current config */
+       serv_puts("CONF get");
+       serv_gets(buf);
+       if (buf[0] == '1') {
+               a = 0;
+               while (serv_gets(buf), strcmp(buf, "000")) {
+                       if (a<17) strcpy(&sc[a][0], buf);
+                       ++a;
+                       }
+               }
 
        /* Fetch the expire policy (this will silently fail on old servers,
         * resulting in "default" policy)
@@ -597,10 +614,16 @@ void do_system_configuration(void) {
                expire_value = extract_int(&buf[4], 1);
                }
 
+       strprompt("Node name", &sc[0][0], 15);
+       strprompt("Fully qualified domain name", &sc[1][0], 63);
+       strprompt("Human readable node name", &sc[2][0], 20);
+       strprompt("Modem dialup number", &sc[3][0], 15);
+       /* FIX add the rest of them */
+
        /* Angels and demons dancing in my head... */
        do {
                sprintf(buf, "%d", expire_mode);
-               strprompt("System default essage expire policy (? for list)",
+               strprompt("System default message expire policy (? for list)",
                        buf, 1);
                if (buf[0] == '?') {
                        printf("\n");
@@ -625,8 +648,18 @@ void do_system_configuration(void) {
                }
 
        /* Save it */
-       snprintf(buf, sizeof buf, "SPEX site|%d|%d",
-               expire_mode, expire_value);
-       serv_puts(buf);
-       serv_gets(buf);
+       printf("Save this configuration? ");
+       if (yesno()) {
+               serv_puts("CONF set");
+               serv_gets(buf);
+               if (buf[0] == '4') {
+                       for (a=0; a<17; ++a) serv_puts(&sc[a][0]);
+                       serv_puts("000");
+                       }
+
+               snprintf(buf, sizeof buf, "SPEX site|%d|%d",
+                       expire_mode, expire_value);
+               serv_puts(buf);
+               serv_gets(buf);
+               }
        }