]> code.citadel.org Git - citadel.git/blobdiff - citadel/commands.c
Trust the compiler to do short-circuit evaluation.
[citadel.git] / citadel / commands.c
index 3222637dd480651866c6b8626ccfe648273eb3fb..4b71f698e2fcba024445719baf145b82f0df6d3c 100644 (file)
@@ -43,6 +43,7 @@
 #include <signal.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "citadel_ipc.h"
 #include "commands.h"
@@ -50,7 +51,6 @@
 #include "citadel_decls.h"
 #include "routines.h"
 #include "routines2.h"
-#include "tools.h"
 #include "rooms.h"
 #include "client_chat.h"
 #include "citadel_dirs.h"
@@ -58,6 +58,7 @@
 #include "snprintf.h"
 #endif
 #include "screen.h"
+#include "ecrash.h"
 
 struct citcmd {
        struct citcmd *next;
@@ -80,6 +81,7 @@ int rc_color_use_bg;
 int rc_prompt_control = 0;
 time_t rc_idle_threshold = (time_t)900;
 char rc_url_cmd[SIZ];
+char rc_open_cmd[SIZ];
 char rc_gotmail_cmd[SIZ];
 
 char *gl_string;
@@ -393,9 +395,22 @@ static int async_ka_enabled = 0;
 
 static void *ka_thread(void *arg)
 {
+#ifdef HAVE_BACKTRACE
+       char threadName[256];
+
+       // Set up our name
+       sprintf(threadName, "ka_Thread n");
+
+       // Register for tracing
+       eCrash_RegisterThread(threadName, 0);
+#endif
        really_do_keepalive();
        pthread_detach(ka_thr_handle);
        ka_thr_active = 0;
+       
+#ifdef HAVE_BACKTRACE
+       eCrash_UnregisterThread();
+#endif
        return NULL;
 }
 
@@ -758,6 +773,7 @@ void load_command_set(void)
        rc_ansi_color = 0;
        rc_color_use_bg = 0;
        strcpy(rc_url_cmd, "");
+       strcpy(rc_open_cmd, "");
        strcpy(rc_gotmail_cmd, "");
 #ifdef HAVE_OPENSSL
        rc_encrypt = RC_DEFAULT;
@@ -894,6 +910,9 @@ void load_command_set(void)
                if (!strncasecmp(buf, "urlcmd=", 7))
                        strcpy(rc_url_cmd, &buf[7]);
 
+               if (!strncasecmp(buf, "opencmd=", 7))
+                       strcpy(rc_open_cmd, &buf[8]);
+
                if (!strncasecmp(buf, "gotmailcmd=", 11))
                        strcpy(rc_gotmail_cmd, &buf[11]);
 
@@ -979,37 +998,34 @@ char *cmd_expand(char *strbuf, int mode)
        int a;
        static char exp[64];
        char buf[1024];
-       char *ptr;
 
        strcpy(exp, strbuf);
 
-       ptr = exp;
-       while (!IsEmptyStr(ptr)){
-               if (*ptr == '&') {
+       for (a = 0; exp[a]; ++a) {
+               if (strbuf[a] == '&') {
 
                        /* dont echo these non mnemonic command keys */
-                       int noecho = *(ptr+1) == '<' || *(ptr+1) == '>' || 
-                               *(ptr+1) == '+' || *(ptr+1) == '-';
+                       int noecho = strbuf[a+1] == '<' || strbuf[a+1] == '>' || strbuf[a+1] == '+' || strbuf[a+1] == '-';
 
                        if (mode == 0) {
-                               strcpy(ptr, ptr + 1 + noecho);
+                               strcpy(&exp[a], &exp[a + 1 + noecho]);
                        }
                        if (mode == 1) {
-                               *ptr = '<';
-                               strcpy(buf, ptr + 2);
-                               *(ptr + 2) = '>';
-                               *(ptr+ 3) = 0;
+                               exp[a] = '<';
+                               strcpy(buf, &exp[a + 2]);
+                               exp[a + 2] = '>';
+                               exp[a + 3] = 0;
                                strcat(exp, buf);
                        }
                }
-               if (!strncmp(ptr, "^r", 2)) {
+               if (!strncmp(&exp[a], "^r", 2)) {
                        strcpy(buf, exp);
-                       strcpy(ptr, room_name);
-                       strcat(exp, &buf[ptr - exp + 2]);
+                       strcpy(&exp[a], room_name);
+                       strcat(exp, &buf[a + 2]);
                }
-               if (!strncmp(ptr, "^c", 2)) {
-                       *ptr = ',';
-                       strcpy(ptr + 1, ptr + 2);
+               if (!strncmp(&exp[a], "^c", 2)) {
+                       exp[a] = ',';
+                       strcpy(&exp[a + 1], &exp[a + 2]);
                }
        }
 
@@ -1629,7 +1645,7 @@ char keymenu(char *menuprompt, char *menustring) {
        choices = num_tokens(menustring, '|');
 
        if (menuprompt != NULL) do_prompt = 1;
-       if (menuprompt != NULL) if (IsEmptyStr(menuprompt)) do_prompt = 0;
+       if ((menuprompt != NULL) && (IsEmptyStr(menuprompt))) do_prompt = 0;
 
        while (1) {
                if (display_prompt) {