From a5ab852c043f1932a052b7d9b7a235b237f0ab24 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 7 Nov 1998 06:00:17 +0000 Subject: [PATCH] * 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 --- citadel/ChangeLog | 6 ++++- citadel/commands.c | 39 +++++++++++++++++++++++++++++ citadel/commands.h | 3 +++ citadel/control.c | 61 ++++++++++++++++++++++++++++++++++++++++++--- citadel/room_ops.c | 12 +++++++++ citadel/rooms.c | 7 ++---- citadel/routines.c | 23 +---------------- citadel/routines.h | 1 - citadel/routines2.c | 43 ++++++++++++++++++++++++++++---- 9 files changed, 158 insertions(+), 37 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 9da9eff5d..e07c44a25 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,7 +1,11 @@ Fri Nov 6 20:22:20 EST 1998 Art Cancro * 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 * snprintf.c: warning fix propagated over from gcit diff --git a/citadel/commands.c b/citadel/commands.c index 50bf0e7c6..ec036fdf2 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -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!) diff --git a/citadel/commands.h b/citadel/commands.h index eb57ef5d5..8c23ccdcc 100644 --- a/citadel/commands.h +++ b/citadel/commands.h @@ -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); diff --git a/citadel/control.c b/citadel/control.c index 44d8cdb4a..c8f6a5c3e 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -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", diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 77ed9b28e..13022f258 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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); diff --git a/citadel/rooms.c b/citadel/rooms.c index 821a3a6cb..d0e3c3ce6 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -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); diff --git a/citadel/routines.c b/citadel/routines.c index 9cb387ef1..a66f3dbc8 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -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; diff --git a/citadel/routines.h b/citadel/routines.h index 6adfac88c..c8e373e16 100644 --- a/citadel/routines.h +++ b/citadel/routines.h @@ -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); diff --git a/citadel/routines2.c b/citadel/routines2.c index e6c3fe3c6..5945e6fec 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -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); + } } -- 2.30.2