* Added a per-user client option to always compose messages using the
[citadel.git] / citadel / commands.c
index 149f09581a03628d519db4ce67a9360305f5e794..17cb60853a9343c015602885ae92b42d18b5bb65 100644 (file)
@@ -94,7 +94,7 @@ struct citcmd *cmdlist = NULL;
 
 /* these variables are local to this module */
 char keepalives_enabled = KA_YES;      /* send NOOPs to server when idle */
-int ok_to_interrupt = 0;               /* print express msgs asynchronously */
+int ok_to_interrupt = 0;               /* print instant msgs asynchronously */
 time_t AnsiDetect;                     /* when did we send the detect code? */
 int enable_color = 0;                  /* nonzero for ANSI color */
 
@@ -199,21 +199,21 @@ void pprintf(const char *format, ...) {
 
 
 /*
- * print_express()  -  print express messages if there are any
+ * print_instant()  -  print instant messages if there are any
  */
-void print_express(void)
+void print_instant(void)
 {
        char buf[1024];
        FILE *outpipe;
        time_t timestamp;
-       struct tm *stamp;
+       struct tm stamp;
        int flags = 0;
        char sender[64];
        char node[64];
        char *listing = NULL;
        int r;                  /* IPC result code */
 
-       if (express_msgs == 0)
+       if (instant_msgs == 0)
                return;
 
        if (rc_exp_beep) {
@@ -224,19 +224,19 @@ void print_express(void)
                scr_printf("\r---");
        }
        
-       while (express_msgs != 0) {
+       while (instant_msgs != 0) {
                r = CtdlIPCGetInstantMessage(ipc_for_signal_handlers, &listing, buf);
                if (r / 100 != 1)
                        return;
        
-               express_msgs = extract_int(buf, 0);
+               instant_msgs = extract_int(buf, 0);
                timestamp = extract_long(buf, 1);
                flags = extract_int(buf, 2);
-               extract(sender, buf, 3);
-               extract(node, buf, 4);
+               extract_token(sender, buf, 3, '|', sizeof sender);
+               extract_token(node, buf, 4, '|', sizeof node);
                strcpy(last_paged, sender);
        
-               stamp = localtime(&timestamp);
+               localtime_r(&timestamp, &stamp);
 
                /* If the page is a Logoff Request, honor it. */
                if (flags & 2) {
@@ -258,28 +258,28 @@ void print_express(void)
                                else
                                        fprintf(outpipe, "Message ");
                                /* Timestamp.  Can this be improved? */
-                               if (stamp->tm_hour == 0 || stamp->tm_hour == 12)
+                               if (stamp.tm_hour == 0 || stamp.tm_hour == 12)
                                        fprintf(outpipe, "at 12:%02d%cm",
-                                               stamp->tm_min, 
-                                               stamp->tm_hour ? 'p' : 'a');
-                               else if (stamp->tm_hour > 12)           /* pm */
+                                               stamp.tm_min, 
+                                               stamp.tm_hour ? 'p' : 'a');
+                               else if (stamp.tm_hour > 12)            /* pm */
                                        fprintf(outpipe, "at %d:%02dpm",
-                                               stamp->tm_hour - 12,
-                                               stamp->tm_min);
+                                               stamp.tm_hour - 12,
+                                               stamp.tm_min);
                                else                                    /* am */
                                        fprintf(outpipe, "at %d:%02dam",
-                                               stamp->tm_hour, stamp->tm_min);
+                                               stamp.tm_hour, stamp.tm_min);
                                fprintf(outpipe, " from %s", sender);
                                if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
                                        fprintf(outpipe, " @%s", node);
                                fprintf(outpipe, ":\n%s\n", listing);
                                pclose(outpipe);
-                               if (express_msgs == 0)
+                               if (instant_msgs == 0)
                                        return;
                                continue;
                        }
                }
-               /* fall back to built-in express message display */
+               /* fall back to built-in instant message display */
                scr_printf("\n");
                lines_printed++;
 
@@ -294,14 +294,14 @@ void print_express(void)
                        scr_printf("Message ");
        
                /* Timestamp.  Can this be improved? */
-               if (stamp->tm_hour == 0 || stamp->tm_hour == 12)/* 12am/12pm */
-                       scr_printf("at 12:%02d%cm", stamp->tm_min, 
-                               stamp->tm_hour ? 'p' : 'a');
-               else if (stamp->tm_hour > 12)                   /* pm */
+               if (stamp.tm_hour == 0 || stamp.tm_hour == 12)/* 12am/12pm */
+                       scr_printf("at 12:%02d%cm", stamp.tm_min, 
+                               stamp.tm_hour ? 'p' : 'a');
+               else if (stamp.tm_hour > 12)                    /* pm */
                        scr_printf("at %d:%02dpm",
-                               stamp->tm_hour - 12, stamp->tm_min);
+                               stamp.tm_hour - 12, stamp.tm_min);
                else                                            /* am */
-                       scr_printf("at %d:%02dam", stamp->tm_hour, stamp->tm_min);
+                       scr_printf("at %d:%02dam", stamp.tm_hour, stamp.tm_min);
                
                /* Sender */
                scr_printf(" from %s", sender);
@@ -361,10 +361,10 @@ static void really_do_keepalive(void) {
         */
        if (keepalives_enabled == KA_YES) {
                r = CtdlIPCNoop(ipc_for_signal_handlers);
-               if (express_msgs > 0) {
+               if (instant_msgs > 0) {
                        if (ok_to_interrupt == 1) {
                                scr_printf("\r%64s\r", "");
-                               print_express();
+                               print_instant();
                                scr_printf("%s%c ", room_name,
                                       room_prompt(room_flags));
                                scr_flush();
@@ -506,8 +506,9 @@ int inkey(void)
 
 #ifndef DISABLE_CURSES
 #if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H)
-               if (a == ERR)
+               if (a == ERR) {
                        logoff(NULL, 3);
+               }
 #endif
 #endif
 
@@ -616,7 +617,7 @@ void strprompt(char *prompt, char *str, int len)
        int i;
        char buf[128];
 
-       print_express();
+       print_instant();
        color(DIM_WHITE);
        scr_printf("%s ", prompt);
        color(DIM_MAGENTA);
@@ -748,7 +749,6 @@ void load_command_set(void)
        rc_force_mail_prompts = 0;
        rc_ansi_color = 0;
        rc_color_use_bg = 0;
-       rc_reply_extedit = 0;
        strcpy(rc_url_cmd, "");
        strcpy(rc_gotmail_cmd, "");
 #ifdef HAVE_OPENSSL
@@ -767,7 +767,13 @@ void load_command_set(void)
                ccfile = fopen(buf, "r");
        }
        if (ccfile == NULL) {
-               snprintf(buf, sizeof buf, "%s/citadel.rc", BBSDIR);
+               snprintf(buf, sizeof buf, 
+#ifndef HAVE_ETC_DIR
+                                CTDLDIR
+#else
+                                ETC_DIR
+#endif
+                                "/citadel.rc");
                ccfile = fopen(buf, "r");
        }
        if (ccfile == NULL) {
@@ -898,14 +904,7 @@ void load_command_set(void)
                                rc_alt_semantics = 0;
                        }
                }
-               if (!strncasecmp(buf, "reply_with_external_editor=", 27)) {
-                       if (!strncasecmp(&buf[27], "yes", 3)) {
-                               rc_reply_extedit = 1;
-                       }
-                       else {
-                               rc_reply_extedit = 0;
-                       }
-               }
+
                if (!strncasecmp(buf, "cmd=", 4)) {
                        strcpy(buf, &buf[4]);
 
@@ -1086,7 +1085,7 @@ int getcmd(CtdlIPC *ipc, char *argbuf)
        /* if we're running in idiot mode, display a cute little menu */
        IFNEXPERT formout(ipc, "mainmenu");
 
-       print_express();
+       print_instant();
        strcpy(argbuf, "");
        cmdpos = 0;
        for (a = 0; a < 5; ++a)
@@ -1214,13 +1213,13 @@ int getcmd(CtdlIPC *ipc, char *argbuf)
 /*
  * set tty modes.  commands are:
  * 
- * 01- set to bbs mode
+ * 01- set to Citadel mode
  * 2 - save current settings for later restoral
  * 3 - restore saved settings
  */
 #ifdef HAVE_TERMIOS_H
-void sttybbs(int cmd)
-{                              /* SysV version of sttybbs() */
+void stty_ctdl(int cmd)
+{                              /* SysV version of stty_ctdl() */
        struct termios live;
        static struct termios saved_settings;
        static int last_cmd = 0;
@@ -1263,8 +1262,8 @@ void sttybbs(int cmd)
 
 }
 #else
-void sttybbs(int cmd)
-{                              /* BSD version of sttybbs() */
+void stty_ctdl(int cmd)
+{                              /* BSD version of stty_ctdl() */
        struct sgttyb live;
        static struct sgttyb saved_settings;
        static int last_cmd = 0;
@@ -1626,7 +1625,7 @@ char keymenu(char *menuprompt, char *menustring) {
                        } 
                        else {
                                for (i=0; i<choices; ++i) {
-                                       extract(buf, menustring, i);
+                                       extract_token(buf, menustring, i, '|', sizeof buf);
                                        keyopt(buf);
                                        scr_printf(" ");
                                }
@@ -1640,7 +1639,7 @@ char keymenu(char *menuprompt, char *menustring) {
                        scr_printf("\rOne of...                               ");
                        scr_printf("                                      \n");
                        for (i=0; i<choices; ++i) {
-                               extract(buf, menustring, i);
+                               extract_token(buf, menustring, i, '|', sizeof buf);
                                scr_printf("   ");
                                keyopt(buf);
                                scr_printf("\n");
@@ -1650,7 +1649,7 @@ char keymenu(char *menuprompt, char *menustring) {
                }
 
                for (i=0; i<choices; ++i) {
-                       extract(buf, menustring, i);
+                       extract_token(buf, menustring, i, '|', sizeof buf);
                        for (c=1; c<strlen(buf); ++c) {
                                if ( (ch == tolower(buf[c]))
                                   && (buf[c-1]=='<')