]> code.citadel.org Git - citadel.git/blobdiff - citadel/setup.c
Tue Aug 18 00:42:33 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
[citadel.git] / citadel / setup.c
index ee16f00cf7b49c2f580ece3bc321c16443f00083..bf05610ea9551c2f385cab9618a5f9283233471c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Citadel/UX setup program
- * v3.3 / by Art Cancro
+ * v4.1 / by Art Cancro
  * see copyright.txt for copyright information
  *
  * *** YOU MUST EDIT sysconfig.h >BEFORE< COMPILING SETUP ***
 #include <sys/stat.h>
 #include <netdb.h>
 #include <errno.h>
+#include <limits.h>
 
 #include "citadel.h"
 #include "axdefs.h"
 #include "sysdep.h"
+#include "config.h"
 
 #ifdef CURSES_INC
 # ifdef OK
@@ -28,7 +30,7 @@
 #include CURSES_INC
 #endif
 
-#define MAXSETUP 21
+#define MAXSETUP 19
 
 #define UI_TEXT                0       /* Default setup type -- text only */
 #define UI_DIALOG      1       /* Use the 'dialog' program */
@@ -50,7 +52,6 @@ char *setup_titles[] = {
        "BBS City and State",
        "System Administrator",
        "BBS User ID",
-       "Password encryption seed",
        "'Room Creator = Room Aide' flag",
        "Server timeout period",
        "Initial access level",
@@ -60,7 +61,6 @@ char *setup_titles[] = {
        "Maximum concurrent sessions",
        "Paginator prompt",
        "Restrict Internet mail flag",
-       "Nothing",
        "Name of bit bucket subdirectory",
        "System net password",
        "Server port number",
@@ -103,7 +103,8 @@ char *setup_text[] = {
 "to have the networker automatically build a BBS list.",
 
 "5",
-"Enter the city and state your system is located in.",
+"Enter the geographical location of your system (city and",
+"state/province/country etc.)",
 
 "6",
 "Enter the name of the system administrator (which is probably you).",
@@ -116,14 +117,6 @@ char *setup_text[] = {
 "under this user ID.  Please specify that (numeric) user ID here.",
 
 "8",
-"Citadel uses a (very) simple password encryption scheme",
-"to thwart breakins that could occur if someone snatched",
-"a copy of your userlog.  This parameter is part of the",
-"algorithm, so that the code can be different on each",
-"system.  Once it has been set, DO NOT change it --",
-"otherwise no one will be able to log in!",
-
-"9",
 "This is a boolean value.  If you set it to 1, anyone who",
 "creates a class 3 (passworded) or class 4 (invitation",
 "only) room will automatically become the Room Aide for",
@@ -132,7 +125,7 @@ char *setup_text[] = {
 "some systems, and not so well on others.  Set this to 0 to",
 "disable this function.",
 
-"10",
+"9",
 "This setting specifies how long a server session may sit idle before it is",
 "automatically terminated.  The recommended value is 900 seconds (15",
 "minutes).  Note that this has *nothing* to do with any watchdog timer that",
@@ -141,7 +134,7 @@ char *setup_text[] = {
 "You MUST set this to a reasonable value.  Setting it to zero will cause",
 "the server to malfunction.",
 
-"11",
+"10",
 "This is the access level new users are assigned.",
 "",
 "The most common settings for this will be either 1, for",
@@ -150,7 +143,7 @@ char *setup_text[] = {
 "boards!), or 4, for systems which give instant access.",
 "The current access levels available are:",
 
-"12",
+"11",
 "'Registration' refers to the boring part of logging into a BBS for the first",
 "time: typing your name, address, and telephone number.  Set this value to 1",
 "to automatically do registration for new users, or 0 to not auto-register.",
@@ -159,7 +152,7 @@ char *setup_text[] = {
 "value is 1 if you've set your inital access level to 1, or 0 if you've set",
 "your initial access level to something higher.",
 
-"13",
+"12",
 "Every BBS has its share of problem users.  This is one",
 "good way to deal with them: if you enable this option,",
 "anyone you flag as a 'problem user' (access level 2) can",
@@ -167,24 +160,24 @@ char *setup_text[] = {
 "automatically moved to a room of your choosing.  Set this",
 "value to 1 to enable Twit Detect, or 0 to disable it.",
 
-"14",
+"13",
 "This is the name of the room that problem user messages",
 "get moved to if you have Twit Detect enabled.",
 "(Note: don't forget to *create* this room!)",
 
-"15",
+"14",
 "This is the maximum number of concurrent Citadel sessions which may be",
 "running at any given time.  Use this to keep very busy systems from being",
 "overloaded.",
 "  Set this value to 0 to allow an unlimited number of sessions.",
 
-"16",
+"15",
 "This is the prompt that appears after each screenful of",
 "text - for users that have chosen that option.  Usually",
 "a simple '<more>' will do, but some folks like to be",
 "creative...",
 
-"17",
+"16",
 "If you have a gateway set up to allow Citadel users to",
 "send Internet mail, with sendmail, qmail, or whatever, and",
 "you wish to restrict this to only users to whom you have",
@@ -193,27 +186,26 @@ char *setup_text[] = {
 "(Obviously, if your system doesn't have the ability to",
 "send mail to the outside world, this is all irrelevant.)",
 
-"18",
-"This parameter is meaningless and should be removed.",
-
-"19",
+"17",
 "Select the name of a subdirectory (relative to the main",
 "Citadel directory - do not type an absolute pathname!) in",
 "which to place arriving file transfers that otherwise",
 "don't have a home.",
 
-"20",
+"18",
 "If you use Citadel client/server sessions to transport network spool data",
 "between systems, this is the password other systems will use to authenticate",
 "themselves as network nodes rather than regular callers.",
 
-"21",
+"19",
 "Specify the TCP port number on which your server will run.  Normally, this",
 "will be port 504, which is the official port assigned by the IANA for",
 "Citadel servers.  You'll only need to specify a different port number if",
 "you run multiple BBS's on the same computer and there's something else",
 "already using port 504.",
 
+"20",
+"21",
 "22",
 "23",
 "24",
@@ -223,10 +215,6 @@ char *setup_text[] = {
 "28",
 "29",
 "30",
-"DO NOT re-create files that you wish to keep intact!",
-"They will be permanently ERASED if you do so!",
-"(Obviously, if this is the first time you are setting up the BBS,",
-"then you will want to create all of the files.)",
 
 "31",
 "Setup has detected that you currently have data files from a Citadel/UX",
@@ -239,9 +227,6 @@ char *setup_text[] = {
 
 };
 
-
-long atol();
-void get_config();
 struct config config;
 int direction;
 
@@ -272,10 +257,10 @@ void cleanup(int exitcode) {
 
 
 #ifdef CURSES_INC
-void getlin(yp,xp,string,lim)  /* Gets a line from the terminal */
-int yp,xp;                     /* Where on the screen to start */
-char string[];                 /* Pointer to string buffer */
-int lim;                       /* Maximum length - if negative, no-show */
+void getlin(int yp, int xp, char *string, int lim)     /* Gets a line from the terminal */
+                               /* Where on the screen to start */
+                               /* Pointer to string buffer */
+                               /* Maximum length - if negative, no-show */
 {
 int a,b; char flag;
 
@@ -322,15 +307,15 @@ GLA:      move(yp,xp+strlen(string));
 
 
 
-void title(text)
-char *text; {
+void title(char *text)
+{
        if (setup_type == UI_TEXT) {
                printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<%s>\n",text);
                }
        }
 
 
-void hit_any_key() {
+void hit_any_key(void) {
        char junk[5];
 
 #ifdef CURSES_INC
@@ -345,8 +330,8 @@ void hit_any_key() {
        fgets(junk, 5, stdin);
        }
 
-int yesno(question)
-char *question; {
+int yesno(char *question)
+{
        int answer = 0;
        char buf[4096];
 
@@ -391,7 +376,7 @@ char *question; {
 
 
 
-void dump_access_levels() {
+void dump_access_levels(void) {
        int a;
        for (a=0; a<=6; ++a) printf("%d %s\n",a,axdefs[a]);
        }
@@ -410,7 +395,7 @@ void get_setup_msg(char *dispbuf, int msgnum) {
                } while(atol(setup_text[a])!=(msgnum+1));
        }
 
-void print_setup(msgnum) {
+void print_setup(int msgnum) {
        char dispbuf[4096];
 
        get_setup_msg(dispbuf, msgnum);
@@ -462,10 +447,8 @@ void display_error(char *error_message) {
        important_message("Error", error_message);
        }
 
-void progress(text,curr,cmax)
-char *text;
-long curr;
-long cmax; {
+void progress(char *text, long int curr, long int cmax)
+{
        static long dots_printed;
        long a;
        static long prev;
@@ -553,103 +536,12 @@ long cmax; {
        }
 
 
-void cre8floors() {
-       int a,main_ref_count;
-       FILE *fp;
-       struct quickroom quickroom;
-       struct floor floor_rec;
-
-       /*
-        * first, put all existing rooms on floor 0 (the main floor) and
-        * count the room records that are in use so we can set the main
-        * floor's reference count
-        */
-       main_ref_count = 0;
-       fp = fopen("quickroom", "rb+");
-       for (a=0; a<MAXROOMS; ++a) {
-               progress("Preparing room files for addition of floors",
-                       (long)a,
-                       (long)MAXROOMS-1);
-               fseek(fp, (a*((long)sizeof(struct quickroom))), 0);
-               fread((char *)&quickroom,sizeof(struct quickroom),1,fp);
-               if (quickroom.QRflags & QR_INUSE) ++main_ref_count;
-               quickroom.QRfloor = 0;
-               fseek(fp, (a*((long)sizeof(struct quickroom))), 0);
-               fwrite((char *)&quickroom,sizeof(struct quickroom),1,fp);
-               }
-       fclose(fp);
-
-       /* Open a new floortab file */
-       fp=fopen("floortab","wb");
-
-       /* Create the main floor */
-       floor_rec.f_flags = (F_INUSE);
-       strcpy(floor_rec.f_name, "Main Floor");
-       floor_rec.f_ref_count = main_ref_count;
-       floor_rec.f_reserved = 0;
-       fwrite((char *)&floor_rec,sizeof(struct floor),1,fp);
-
-
-       /* make the remaining floors blanks */
-       floor_rec.f_flags = 0;
-       strcpy(floor_rec.f_name, "");
-       floor_rec.f_ref_count = 0;
-       floor_rec.f_reserved = 0;
-
-       for (a=1; a<MAXFLOORS; ++a) {
-               progress("Creating floor table (floortab)",
-                       (long)a,
-                       (long)MAXFLOORS-1
-                       );
-               fwrite((char *)&floor_rec,sizeof(struct floor),1,fp);
-               }
-       fclose(fp);
-
-       }
-
-
-/*
- * check (and fix) floor reference counts
- */
-void check_ref_counts() {
-       int ref[MAXFLOORS];
-       int a;
-       FILE *fp;
-       struct quickroom qrbuf;
-       struct floor flbuf;
-
-       for (a=0; a<MAXFLOORS; ++a) ref[a] = 0;
-
-       fp = fopen("quickroom","rb");
-       for (a=0; a<MAXROOMS; ++a) {
-               progress("Checking reference counts - phase 1 of 2",
-                       a,MAXROOMS-1);
-               fread((char *)&qrbuf,sizeof(struct quickroom),1,fp);
-               if (qrbuf.QRflags & QR_INUSE) {
-                       ++ref[(int)qrbuf.QRfloor];
-                       }
-               }
-       fclose(fp);
-
-       fp = fopen("floortab","rb+");
-       for (a=0; a<MAXFLOORS; ++a) {
-               progress("Checking reference counts - phase 2 of 2",
-                       a,MAXFLOORS-1);
-               fseek(fp,(long)a*(long)sizeof(struct floor),0);
-               fread((char *)&flbuf,sizeof(struct floor),1,fp);
-               flbuf.f_ref_count = ref[a];
-               fseek(fp,(long)a*(long)sizeof(struct floor),0);
-               fwrite((char *)&flbuf,sizeof(struct floor),1,fp);
-               }
-       fclose(fp);
-       }       
-
 
 /*
  * check_services_entry()  -- Make sure "citadel" is in /etc/services
  *
  */
-void check_services_entry() {
+void check_services_entry(void) {
        char question[128];
        FILE *sfp;
 
@@ -678,7 +570,7 @@ void check_services_entry() {
  * check_inittab_entry()  -- Make sure "citadel" is in /etc/inittab
  *
  */
-void check_inittab_entry() {
+void check_inittab_entry(void) {
        FILE *infp;
        char buf[256];
        char looking_for[256];
@@ -755,36 +647,6 @@ void check_inittab_entry() {
 
 
 
-/*
- * Create a blank call log
- */
-void cre8clog() {
-       int file,a;
-       struct calllog calllog;
-
-       calllog.CLfullname[0]=0;
-       calllog.CLtime=0L;
-       calllog.CLflags=0;
-       a=0;
-
-       file=creat("calllog.pos",0666);
-       chmod("calllog.pos",0666);
-       write(file,&a,sizeof(int));
-       close(file);
-
-       file=creat("calllog",0666);
-       chmod("calllog",0666);
-       for (a=0; a<CALLLOG; ++a) {
-               progress("Creating call log file",
-                       (long)a,
-                       (long)CALLLOG-1
-                       );
-               write(file,&calllog,sizeof(struct calllog));
-               }
-       close(file);
-       }
-
-
 void set_str_val(int msgpos, char str[]) {
        char buf[4096];
        char setupmsg[4096];
@@ -837,9 +699,8 @@ void set_str_val(int msgpos, char str[]) {
                }
        }
 
-void set_int_val(msgpos, ip)
-int msgpos;
-int *ip; {
+void set_int_val(int msgpos, int *ip)
+{
        char buf[16];
        sprintf(buf,"%d",(int)*ip);
        set_str_val(msgpos, buf);
@@ -847,9 +708,8 @@ int *ip; {
        }
 
 
-void set_char_val(msgpos, ip)
-int msgpos;
-char *ip; {
+void set_char_val(int msgpos, char *ip)
+{
        char buf[16];
        sprintf(buf,"%d",(int)*ip);
        set_str_val(msgpos, buf);
@@ -857,9 +717,8 @@ char *ip; {
        }
 
 
-void set_long_val(msgpos, ip)
-int msgpos;
-long *ip; {
+void set_long_val(int msgpos, long int *ip)
+{
        char buf[16];
        sprintf(buf,"%ld",*ip);
        set_str_val(msgpos, buf);
@@ -867,7 +726,8 @@ long *ip; {
        }
 
 
-int yesno_s(question) {
+#if 0 /* FIXME: this isn't used, can we remove it? */
+int yesno_s(char *question) {
        int a;
        char buf[4096];
        char tempfile[64];
@@ -907,10 +767,11 @@ int yesno_s(question) {
 
        return(0); /* just in case */
        }
+#endif
 
 
-void edit_value(curr)
-int curr; {
+void edit_value(int curr)
+{
  int a;
  
  switch(curr) {
@@ -944,50 +805,42 @@ case 7:
        break;
 
 case 8:
-       set_int_val(curr, &config.c_pwcrypt);
-       break;
-
-case 9:
        set_char_val(curr, &config.c_creataide);
        break;
 
-case 10:
+case 9:
        set_int_val(curr, &config.c_sleeping);
        break;
 
-case 11:
+case 10:
        set_char_val(curr, &config.c_initax);
        break;
 
-case 12:
+case 11:
        set_char_val(curr, &config.c_regiscall);
        break;
 
-case 13:
+case 12:
        set_char_val(curr, &config.c_twitdetect);
        break;
 
-case 14:
+case 13:
        set_str_val(curr, config.c_twitroom);
        break;
 
-case 15:
+case 14:
        set_int_val(curr, &config.c_maxsessions);
        break;
 
-case 16:
+case 15:
        set_str_val(curr, config.c_moreprompt);
        break;
 
-case 17:
+case 16:
        set_char_val(curr, &config.c_restrict);
        break;
 
-case 18:
-       set_long_val(curr, &config.c_msgbase);
-       break;
-
-case 19:
+case 17:
        set_str_val(curr, config.c_bucket_dir);
        config.c_bucket_dir[14] = 0;
        for (a=0; a<strlen(config.c_bucket_dir); ++a)
@@ -996,11 +849,11 @@ case 19:
                                &config.c_bucket_dir[a+1]);
        break;
 
-case 20:
+case 18:
        set_str_val(curr, config.c_net_password);
        break;
 
-case 21:
+case 19:
        set_int_val(curr, &config.c_port_number);
        break;
 
@@ -1011,7 +864,7 @@ case 21:
 /*
  * (re-)write the config data to disk
  */
-void write_config_to_disk() {
+void write_config_to_disk(void) {
        FILE *fp;
 
        fp=fopen("citadel.config","wb");
@@ -1029,7 +882,7 @@ void write_config_to_disk() {
 /*
  * Figure out what type of user interface we're going to use
  */
-int discover_ui() {
+int discover_ui(void) {
 
 #ifdef CURSES_INC
        return UI_CURSES;
@@ -1151,16 +1004,12 @@ void main(int argc, char *argv[]) {
                strcpy(config.c_phonenum,"US 800 555 1212");
        if (config.c_initax == 0)
                config.c_initax = 1;
-       /* if (config.c_regiscall == 0)
-               config.c_regiscall = 1; */
        if (strlen(config.c_moreprompt)==0)
                strcpy(config.c_moreprompt,"<more>");
        if (strlen(config.c_twitroom)==0)
                strcpy(config.c_twitroom,"Trashcan");
        if (strlen(config.c_bucket_dir)==0)
                strcpy(config.c_bucket_dir,"bitbucket");
-       if (config.c_msgbase == 0L)
-               config.c_msgbase = 2000000;
        if (strlen(config.c_net_password)==0)
                strcpy(config.c_net_password,"netpassword");
        if (config.c_port_number == 0) {
@@ -1224,7 +1073,6 @@ NEW_INST:
        write_config_to_disk();
 
        system("mkdir info 2>/dev/null");               /* Create these */
-       system("mkdir rooms 2>/dev/null");
        system("mkdir bio 2>/dev/null");
        system("mkdir userpics 2>/dev/null");
        system("mkdir messages 2>/dev/null");
@@ -1238,20 +1086,6 @@ NEW_INST:
        system("rm -fr ./expressmsgs 2>/dev/null");
        unlink("sessions");
 
-       important_msgnum(30);
-
-
-       a=0;
-       fp=fopen("calllog","r");
-       if (fp==NULL) {
-               cre8clog();
-               }
-       else {
-               fclose(fp);
-               if (yesno_s("Create call log?")==1) cre8clog();
-               }
-
-       check_ref_counts();             /* Check reference counts */
        check_services_entry();         /* Check /etc/services */
        check_inittab_entry();          /* Check /etc/inittab */