]> code.citadel.org Git - citadel.git/blobdiff - citadel/textclient/commands.c
Remove unused variable
[citadel.git] / citadel / textclient / commands.c
index 6371cb46e800fdcee5e58f76f19e1f103f35d768..e6cbffc774add40160b9eccd602ace210eb69f98 100644 (file)
@@ -2,21 +2,15 @@
  * This file contains functions which implement parts of the
  * text-mode user interface.
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2012 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -67,6 +61,7 @@
 #include "rooms.h"
 #include "client_chat.h"
 #include "citadel_dirs.h"
+#include "tuiconfig.h"
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
 #endif
@@ -135,7 +130,7 @@ char was_a_key_pressed(void) {
         * in the middle of a data transfer from the server, in which case
         * sending a NOOP would throw the client protocol out of sync.
         */
-       if (FD_ISSET(0, &rfds)) {
+       if ((retval > 0) && FD_ISSET(0, &rfds)) {
                set_keepalives(KA_NO);
                the_character = inkey();
                set_keepalives(KA_YES);
@@ -284,7 +279,6 @@ void set_keepalives(int s)
 
 static time_t idlet = 0;
 static void really_do_keepalive(void) {
-       int r;                          /* IPC response code */
 
        time(&idlet);
 
@@ -298,7 +292,7 @@ static void really_do_keepalive(void) {
         * wait for a response.
         */
        if (keepalives_enabled == KA_YES) {
-               r = CtdlIPCNoop(ipc_for_signal_handlers);
+               CtdlIPCNoop(ipc_for_signal_handlers);
                if (instant_msgs > 0) {
                        if (ok_to_interrupt == 1) {
                                scr_printf("\r%64s\r", "");
@@ -493,24 +487,26 @@ int yesno_d(int d)
 
 
 
-/* Gets a line from the terminal */
-/* string == Pointer to string buffer */
-/* lim == Maximum length - if negative, no-show */
+/*
+ * Function to read a line of text from the terminal.
+ *
+ * string              Pointer to string buffer
+ * lim                 Maximum length - if negative, echo asterisks instead of characters
+ */
 void ctdl_getline(char *string, int lim) 
 {
        int a, b;
-       char flag = 0;
+       char noshow = 0;
 
        if (lim < 0) {
                lim = (0 - lim);
-               flag = 1;
+               noshow = 1;
        }
        strcpy(string, "");
        gl_string = string;
        async_ka_start();
 
 GLA:   a = inkey();
-       /* a = (a & 127); ** commented out because it isn't just an ASCII world anymore */
        if ((a == 8 || a == 23) && (IsEmptyStr(string)))
                goto GLA;
        if ((a != 10) && (a != 8) && (strlen(string) == lim))
@@ -532,15 +528,18 @@ GLA:      a = inkey();
                async_ka_end();
                return;
        }
-       if (a < 32)
+       if (a < 32) {
                a = '.';
+       }
        b = strlen(string);
        string[b] = a;
        string[b + 1] = 0;
-       if (flag == 0)
-               scr_putc(a);
-       if (flag == 1)
+       if (noshow) {
                scr_putc('*');
+       }
+       else {
+               scr_putc(a);
+       }
        goto GLA;
 }
 
@@ -576,8 +575,9 @@ void strprompt(char *prompt, char *str, int len)
        scr_printf(": ");
        color(BRIGHT_CYAN);
        ctdl_getline(buf, len);
-       if (buf[0] != 0)
+       if (buf[0] != 0) {
                strcpy(str, buf);
+       }
        color(DIM_WHITE);
 }
 
@@ -637,6 +637,7 @@ int intprompt(char *prompt, int ival, int imin, int imax)
  */
 void newprompt(char *prompt, char *str, int len)
 {
+       str[0] = 0;
        color(BRIGHT_MAGENTA);
        scr_printf("%s", prompt);
        color(DIM_MAGENTA);
@@ -661,18 +662,14 @@ void load_command_set(void)
 {
        FILE *ccfile;
        char buf[1024];
-       char editor_key[100];
        struct citcmd *cptr;
        struct citcmd *lastcmd = NULL;
        int a, d;
        int b = 0;
-       int i;
-
 
        /* first, set up some defaults for non-required variables */
 
-       for (i = 0; i < MAX_EDITORS; i++)
-               strcpy(editor_paths[i], "");
+       strcpy(editor_path, "");
        strcpy(printcmd, "");
        strcpy(imagecmd, "");
        strcpy(rc_username, "");
@@ -692,7 +689,6 @@ void load_command_set(void)
 #ifdef HAVE_OPENSSL
        rc_encrypt = RC_DEFAULT;
 #endif
-       rc_alt_semantics = 0;
 
        /* now try to open the citadel.rc file */
 
@@ -737,14 +733,8 @@ void load_command_set(void)
 #endif
                }
 
-               if (!strncasecmp(buf, "editor=", 7))
-                       strcpy(editor_paths[0], &buf[7]);
-
-               for (i = 0; i < MAX_EDITORS; i++)
-               {
-                       sprintf(editor_key, "editor%d=", i);
-                       if (!strncasecmp(buf, editor_key, strlen(editor_key)))
-                               strcpy(editor_paths[i], &buf[strlen(editor_key)]);
+               if (!strncasecmp(buf, "editor=", 7)) {
+                       strcpy(editor_path, &buf[7]);
                }
 
                if (!strncasecmp(buf, "printcmd=", 9))
@@ -756,9 +746,6 @@ void load_command_set(void)
                if (!strncasecmp(buf, "expcmd=", 7))
                        strcpy(rc_exp_cmd, &buf[7]);
 
-               if (!strncasecmp(buf, "local_screen_dimensions=", 24))
-                       have_xterm = (char) atoi(&buf[24]);
-
                if (!strncasecmp(buf, "use_floors=", 11)) {
                        if (!strcasecmp(&buf[11], "yes"))
                                rc_floor_mode = RC_YES;
@@ -793,6 +780,10 @@ void load_command_set(void)
                        if (!strncasecmp(&buf[11], "user", 4))
                                rc_ansi_color = 3;      /* user config */
                }
+               if (!strncasecmp(buf, "status_line=", 12)) {
+                       if (!strncasecmp(&buf[12], "on", 2))
+                               enable_status_line = 1;
+               }
                if (!strncasecmp(buf, "use_background=", 15)) {
                        if (!strncasecmp(&buf[15], "on", 2))
                                rc_color_use_bg = 9;
@@ -818,15 +809,6 @@ void load_command_set(void)
                if (!strncasecmp(buf, "gotmailcmd=", 11))
                        strcpy(rc_gotmail_cmd, &buf[11]);
 
-               if (!strncasecmp(buf, "alternate_semantics=", 20)) {
-                       if (!strncasecmp(&buf[20], "yes", 3)) {
-                               rc_alt_semantics = 1;
-                       }
-                       else {
-                               rc_alt_semantics = 0;
-                       }
-               }
-
                if (!strncasecmp(buf, "cmd=", 4)) {
                        strcpy(buf, &buf[4]);
 
@@ -1021,7 +1003,6 @@ int getcmd(CtdlIPC *ipc, char *argbuf)
        scr_printf("\n%s", room_name);
        color(DIM_WHITE);
        scr_printf("%c ", room_prompt(room_flags));
-       scr_flush();
 
        while (1) {
                ch = inkey();
@@ -1075,6 +1056,7 @@ int getcmd(CtdlIPC *ipc, char *argbuf)
                        if (cmdmatch(cmdbuf, cptr, 5)) {
                                /* We've found our command. */
                                if (requires_string(cptr, cmdpos)) {
+                                       argbuf[0] = 0;
                                        ctdl_getline(argbuf, 64);
                                } else {
                                        scr_printf("\n");
@@ -1421,7 +1403,6 @@ void color(int colornum)
                                        (colornum & 7),
                                        rc_color_use_bg);
 
-               scr_flush();
        }
 }
 
@@ -1430,7 +1411,6 @@ void cls(int colornum)
        if (enable_color) {
                printf("\033[4%dm\033[2J\033[H\033[0m",
                                colornum ? colornum : rc_color_use_bg);
-               scr_flush();
        }
 }
 
@@ -1479,6 +1459,11 @@ void look_for_ansi(void)
                        if (FD_ISSET(0, &rfds)) {
                                abuf[strlen(abuf) + 1] = 0;
                                rv = read(0, &abuf[strlen(abuf)], 1);
+                               if (rv < 0) {
+                                       scr_printf("failed to read after select: %s", 
+                                                  strerror(errno));
+                                       break;
+                               }
                        }
                } while (FD_ISSET(0, &rfds));