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
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 */
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!)
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);
int inkey(void);
void set_keepalives(int s);
extern int enable_color;
+int yesno(void);
+int yesno_d(int d);
#include "control.h"
#include "sysdep_decls.h"
#include "support.h"
+#include "config.h"
+#include "msgbase.h"
struct CitControl CitControl;
struct config config;
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",
}
}
+ /* 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);
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);
{
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);
}
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);
#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);
}
}
-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;
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);
#include "citadel.h"
#include "routines2.h"
#include "routines.h"
+#include "commands.h"
void interr(int errnum);
void strprompt(char *prompt, char *str, int len);
*/
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)
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");
}
/* 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);
+ }
}