]> code.citadel.org Git - citadel.git/blobdiff - citadel/setup.c
* The size constant "256" which shows up everywhere as a buffer size has now
[citadel.git] / citadel / setup.c
index 8a19ead50d8eb93642ed257e9b0c51a3a1ae986c..fb6cb0333d57fd57432e8f0b51e5f7247939086c 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Citadel/UX setup program
  * $Id$
  *
- * *** YOU MUST EDIT sysconfig.h >BEFORE< COMPILING SETUP ***
+ * Citadel/UX setup utility
+ *
  */
 
 #include <stdlib.h>
@@ -35,7 +35,7 @@
 #define MAXSETUP 5
 
 #define UI_TEXT                0       /* Default setup type -- text only */
-#define UI_DIALOG      1       /* Use the 'dialog' program */
+#define UI_DIALOG      1       /* Use the 'dialog' program (REMOVED) */
 #define UI_CURSES      2       /* Use curses */
 
 #define SERVICE_NAME   "citadel"
@@ -261,10 +261,6 @@ int yesno(char *question)
                } while ((answer < 0) || (answer > 1));
                break;
 
-       case UI_DIALOG:
-               sprintf(buf, "dialog --yesno \"%s\" 7 80", question);
-               answer = ((system(buf) == 0) ? 1 : 0);
-               break;
 #ifdef HAVE_CURSES_H
        case UI_CURSES:
                do {
@@ -326,7 +322,6 @@ void print_setup(int msgnum)
 
 void important_message(char *title, char *msgtext)
 {
-       char buf[4096];
 
        switch (setup_type) {
 
@@ -336,11 +331,6 @@ void important_message(char *title, char *msgtext)
                hit_any_key();
                break;
 
-       case UI_DIALOG:
-               sprintf(buf, "dialog --title \"%s\" --msgbox \"\n%s\" 20 80",
-                       title, msgtext);
-               system(buf);
-               break;
 #ifdef HAVE_CURSES_H
        case UI_CURSES:
                clear();
@@ -375,9 +365,6 @@ void progress(char *text, long int curr, long int cmax)
 {
        static long dots_printed;
        long a;
-       static long prev;
-       static FILE *gauge = NULL;
-       char gcmd[256];
 
        switch (setup_type) {
 
@@ -433,25 +420,6 @@ void progress(char *text, long int curr, long int cmax)
                break;
 #endif
 
-       case UI_DIALOG:
-               if ((curr == 0) && (gauge == NULL)) {
-                       sprintf(gcmd, "dialog --guage \"%s\" 7 80 0",
-                               text);
-                       gauge = (FILE *) popen(gcmd, "w");
-                       prev = 0;
-               } else if (curr == cmax) {
-                       fprintf(gauge, "100\n");
-                       pclose(gauge);
-                       gauge = NULL;
-               } else {
-                       a = (curr * 100) / cmax;
-                       if (a != prev) {
-                               fprintf(gauge, "%ld\n", a);
-                               fflush(gauge);
-                       }
-                       prev = a;
-               }
-               break;
        }
 }
 
@@ -492,8 +460,8 @@ void check_services_entry(void)
 void check_inittab_entry(void)
 {
        FILE *infp;
-       char buf[256];
-       char looking_for[256];
+       char buf[SIZ];
+       char looking_for[SIZ];
        char question[128];
        char *ptr;
        int have_entry = 0;
@@ -509,7 +477,7 @@ void check_inittab_entry(void)
        if (infp == NULL) {
                return;
        } else {
-               while (fgets(buf, 256, infp) != NULL) {
+               while (fgets(buf, sizeof buf, infp) != NULL) {
                        buf[strlen(buf) - 1] = 0;
                        ptr = strtok(buf, ":");
                        ptr = strtok(NULL, ":");
@@ -570,11 +538,11 @@ void check_inittab_entry(void)
 void set_str_val(int msgpos, char str[])
 {
        char buf[4096];
-       char setupmsg[4096];
        char tempfile[64];
-       FILE *fp;
+       char setupmsg[SIZ];
 
-       sprintf(tempfile, "/tmp/setup.%ld", (long) getpid());
+       strcpy(tempfile, tmpnam(NULL));
+       strcpy(setupmsg, "");
 
        switch (setup_type) {
        case UI_TEXT:
@@ -589,22 +557,6 @@ void set_str_val(int msgpos, char str[])
                if (strlen(buf) != 0)
                        strcpy(str, buf);
                break;
-       case UI_DIALOG:
-               get_setup_msg(setupmsg, msgpos);
-               sprintf(buf,
-                       "dialog --title \"%s\" --inputbox \"\n%s\n\" 20 80 \"%s\" 2>%s",
-                       setup_titles[msgpos],
-                       setupmsg,
-                       str, tempfile);
-               if (system(buf) == 0) {
-                       fp = fopen(tempfile, "rb");
-                       fgets(str, 4095, fp);
-                       fclose(fp);
-                       if (strlen(str) > 0)
-                               if (str[strlen(str) - 1] == 10)
-                                       str[strlen(str) - 1] = 0;
-               }
-               break;
 #ifdef HAVE_CURSES_H
        case UI_CURSES:
                clear();
@@ -652,6 +604,7 @@ void set_long_val(int msgpos, long int *ip)
 void edit_value(int curr)
 {
        int a;
+       long l;
 
        switch (curr) {
 
@@ -660,7 +613,9 @@ void edit_value(int curr)
                break;
 
        case 2:
-               set_int_val(curr, &config.c_bbsuid);
+               l = config.c_bbsuid;
+               set_long_val(curr, &l);
+               config.c_bbsuid = l;
                break;
 
        case 3:
@@ -713,10 +668,6 @@ int discover_ui(void)
 #ifdef HAVE_CURSES_H
        return UI_CURSES;
 #endif
-
-       if (system("dialog -h </dev/null 2>&1 |grep Savio") == 0) {
-               return UI_DIALOG;
-       }
        return UI_TEXT;
 }
 
@@ -789,10 +740,6 @@ int main(int argc, char *argv[])
                printf("\n\n\n               *** Citadel/UX setup program ***\n\n");
                break;
 
-       case UI_DIALOG:
-               system("exec clear");
-               break;
-
        }
 
        /*
@@ -898,6 +845,15 @@ int main(int argc, char *argv[])
                config.c_ep.expire_mode = EXPIRE_NUMMSGS;
                config.c_ep.expire_value = 150;
        }
+
+       /*
+        * Default port numbers for various services
+        */
+       if (config.c_smtp_port == 0) config.c_smtp_port = 25;
+       if (config.c_pop3_port == 0) config.c_pop3_port = 110;
+       if (config.c_imap_port == 0) config.c_imap_port = 143;
+
+
        /* Go through a series of dialogs prompting for config info */
        for (curr = 1; curr <= MAXSETUP; ++curr) {
                edit_value(curr);
@@ -941,21 +897,21 @@ int main(int argc, char *argv[])
 
        /* end of version update section */
 
-      NEW_INST:
+NEW_INST:
        config.c_setup_level = REV_LEVEL;
 
 /******************************************/
 
        write_config_to_disk();
 
-       system("mkdir info 2>/dev/null");       /* Create these */
-       system("mkdir bio 2>/dev/null");
-       system("mkdir userpics 2>/dev/null");
-       system("mkdir messages 2>/dev/null");
-       system("mkdir help 2>/dev/null");
-       system("mkdir images 2>/dev/null");
-       sprintf(aaa, "mkdir %s 2>/dev/null", config.c_bucket_dir);
-       system(aaa);
+       mkdir("info", 0700);
+       mkdir("bio", 0700);
+       mkdir("userpics", 0700);
+       mkdir("messages", 0700);
+       mkdir("help", 0700);
+       mkdir("images", 0700);
+       mkdir("netconfigs", 0700);
+       mkdir(config.c_bucket_dir, 0700);
 
        /* Delete a bunch of old files from Citadel v4; don't need anymore */
        system("rm -fr ./chatpipes ./expressmsgs sessions 2>/dev/null");
@@ -973,8 +929,8 @@ int main(int argc, char *argv[])
        progress("Setting file permissions", 1, 5);
        chown("citadel.config", config.c_bbsuid, gid);
        progress("Setting file permissions", 2, 5);
-       sprintf(aaa, "find . | grep -v chkpwd | xargs chown %d:%d 2>/dev/null",
-               config.c_bbsuid, gid);
+       sprintf(aaa, "find . | grep -v chkpwd | xargs chown %ld:%ld 2>/dev/null",
+               (long)config.c_bbsuid, (long)gid);
        system(aaa);
        progress("Setting file permissions", 3, 5);
        chmod("citadel.config", S_IRUSR | S_IWUSR);