X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcommands.c;h=0a2042e3ad1efcc773f8a05a020f48a613c882dd;hb=a2a06e5d6767d0e45eeccf4032153764e8a5520f;hp=ea3e527cb03695cddea6507830fd8b4919e6f750;hpb=f2aca546a9ccd98b10e0cebd87a06fbeb9a75e24;p=citadel.git diff --git a/citadel/commands.c b/citadel/commands.c index ea3e527cb..0a2042e3a 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -53,6 +53,7 @@ #include "tools.h" #include "rooms.h" #include "client_chat.h" +#include "citadel_dirs.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" #endif @@ -206,7 +207,7 @@ 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]; @@ -219,7 +220,7 @@ void print_instant(void) if (rc_exp_beep) { ctdl_beep(); } - if (strlen(rc_exp_cmd) == 0) { + if (IsEmptyStr(rc_exp_cmd)) { color(BRIGHT_RED); scr_printf("\r---"); } @@ -232,11 +233,11 @@ void print_instant(void) 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(×tamp); + localtime_r(×tamp, &stamp); /* If the page is a Logoff Request, honor it. */ if (flags & 2) { @@ -244,7 +245,7 @@ void print_instant(void) return; } - if (strlen(rc_exp_cmd) > 0) { + if (!IsEmptyStr(rc_exp_cmd)) { outpipe = popen(rc_exp_cmd, "w"); if (outpipe != NULL) { /* Header derived from flags */ @@ -258,17 +259,17 @@ void print_instant(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); @@ -294,14 +295,14 @@ void print_instant(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); @@ -494,15 +495,21 @@ int inkey(void) * (There's a hole in the bucket...) */ a = scr_getc(SCR_BLOCK); - if (a == 127) + if (a == 127) { a = 8; - if (a > 126) - a = 0; - if (a == 13) + } + if (a == 13) { a = 10; + } +/* not so fast there dude, we have to handle UTF-8 and ISO-8859-1... + if (a > 126) { + a = 0; + } if (((a != 23) && (a != 4) && (a != 10) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY)) - && ((a < 32) || (a > 126))) + && ((a < 32) || (a > 126))) { a = 0; + } + */ #ifndef DISABLE_CURSES #if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H) @@ -560,7 +567,7 @@ int yesno_d(int d) /* Gets a line from the terminal */ /* string == Pointer to string buffer */ /* lim == Maximum length - if negative, no-show */ -void getline(char *string, int lim) +void ctdl_getline(char *string, int lim) { int a, b; char flag = 0; @@ -572,9 +579,10 @@ void getline(char *string, int lim) strcpy(string, ""); gl_string = string; async_ka_start(); - GLA:a = inkey(); - a = (a & 127); - if ((a == 8 || a == 23) && (strlen(string) == 0)) + +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)) goto GLA; @@ -587,7 +595,7 @@ void getline(char *string, int lim) do { string[strlen(string) - 1] = 0; scr_putc(8); scr_putc(32); scr_putc(8); - } while (strlen(string) && string[strlen(string) - 1] != ' '); + } while (!IsEmptyStr(string) && string[strlen(string) - 1] != ' '); goto GLA; } if ((a == 10)) { @@ -638,7 +646,7 @@ void strprompt(char *prompt, char *str, int len) color(DIM_WHITE); scr_printf(": "); color(BRIGHT_CYAN); - getline(buf, len); + ctdl_getline(buf, len); if (buf[0] != 0) strcpy(str, buf); color(DIM_WHITE); @@ -703,7 +711,7 @@ void newprompt(char *prompt, char *str, int len) color(BRIGHT_MAGENTA); scr_printf("%s", prompt); color(DIM_MAGENTA); - getline(str, len); + ctdl_getline(str, len); color(DIM_WHITE); } @@ -749,7 +757,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 @@ -768,8 +775,7 @@ void load_command_set(void) ccfile = fopen(buf, "r"); } if (ccfile == NULL) { - snprintf(buf, sizeof buf, "%s/citadel.rc", BBSDIR); - ccfile = fopen(buf, "r"); + ccfile = fopen(file_citadel_rc, "r"); } if (ccfile == NULL) { ccfile = fopen("/etc/citadel.rc", "r"); @@ -782,7 +788,7 @@ void load_command_set(void) logoff(NULL, 3); } while (fgets(buf, sizeof buf, ccfile) != NULL) { - while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0) + while ((!IsEmptyStr(buf)) ? (isspace(buf[strlen(buf) - 1])) : 0) buf[strlen(buf) - 1] = 0; if (!strncasecmp(buf, "encrypt=", 8)) { @@ -899,14 +905,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]); @@ -930,7 +929,7 @@ void load_command_set(void) a = 0; b = 0; buf[strlen(buf) + 1] = 0; - while (strlen(buf) > 0) { + while (!IsEmptyStr(buf)) { b = strlen(buf); for (d = strlen(buf); d >= 0; --d) if (buf[d] == ',') @@ -986,8 +985,11 @@ char *cmd_expand(char *strbuf, int mode) for (a = 0; a < strlen(exp); ++a) { if (strbuf[a] == '&') { + /* dont echo these non mnemonic command keys */ + int noecho = strbuf[a+1] == '<' || strbuf[a+1] == '>' || strbuf[a+1] == '+' || strbuf[a+1] == '-'; + if (mode == 0) { - strcpy(&exp[a], &exp[a + 1]); + strcpy(&exp[a], &exp[a + 1 + noecho]); } if (mode == 1) { exp[a] = '<'; @@ -1152,7 +1154,7 @@ int getcmd(CtdlIPC *ipc, char *argbuf) if (cmdmatch(cmdbuf, cptr, 5)) { /* We've found our command. */ if (requires_string(cptr, cmdpos)) { - getline(argbuf, 32); + ctdl_getline(argbuf, 64); } else { scr_printf("\n"); } @@ -1186,11 +1188,13 @@ int getcmd(CtdlIPC *ipc, char *argbuf) for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) { if (cmdmatch(cmdbuf, cptr, cmdpos)) { for (a = 0; a < 5; ++a) { - pprintf("%s ", cmd_expand(cptr->c_keys[a], 1)); + keyopt(cmd_expand(cptr->c_keys[a], 1)); + pprintf(" "); } pprintf("\n"); } } + sigcaught = 0; pprintf("\n%s%c ", room_name, room_prompt(room_flags)); got = 0; @@ -1215,13 +1219,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; @@ -1264,8 +1268,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; @@ -1378,11 +1382,15 @@ int fmout( old = '\n'; continue; } - /* Are we looking at a nonprintable? */ + + /* Are we looking at a nonprintable? + * (This section is now commented out because we could be displaying + * a character set like UTF-8 or ISO-8859-1.) if ( (*e < 32) || (*e > 126) ) { e++; continue; - } + } */ + /* Or are we looking at a space? */ if (*e == ' ') { e++; @@ -1590,13 +1598,13 @@ void keyopt(char *buf) { color(DIM_WHITE); for (i=0; i') { + if (buf[i]=='>'&& buf[i+1] != '>') { color(DIM_WHITE); } - scr_putc(buf[i]); + pprintf("%c", buf[i]); } } color(DIM_WHITE); @@ -1627,7 +1635,7 @@ char keymenu(char *menuprompt, char *menustring) { } else { for (i=0; i