From b96332f2e1848702185739bbb44d65e4c14436ca Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 13 Feb 2003 20:13:51 +0000 Subject: [PATCH] * Applied "multi editor" patch supplied by georbit --- citadel/ChangeLog | 4 +++- citadel/citadel.c | 13 ++++++++++++- citadel/citadel.h | 2 ++ citadel/citadel.rc | 18 ++++++++++++++++-- citadel/citadel_decls.h | 2 +- citadel/commands.c | 14 ++++++++++++-- citadel/docs/citadel.html | 6 ++++++ citadel/messages.c | 15 +++++++++++---- citadel/rooms.c | 11 +++++------ citadel/routines2.c | 4 ++-- 10 files changed, 70 insertions(+), 19 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 53b689c4d..796c53d3e 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 601.130 2003/02/13 20:13:51 ajc + * Applied "multi editor" patch supplied by georbit + Revision 601.129 2003/02/12 04:51:44 ajc * More docs update @@ -4459,4 +4462,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.c b/citadel/citadel.c index 2e28ef9d9..40e8e3d38 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -65,7 +65,7 @@ struct march *march = NULL; char temp[PATH_MAX]; /* Name of general temp file */ char temp2[PATH_MAX]; /* Name of general temp file */ char tempdir[PATH_MAX]; /* Name of general temp dir */ -char editor_path[SIZ]; /* path to external editor */ +char editor_paths[MAX_EDITORS][SIZ]; /* paths to external editors */ char printcmd[SIZ]; /* print command */ int editor_pid = (-1); char fullname[USERNAME_SIZE]; @@ -1699,6 +1699,17 @@ NEWUSR: if (strlen(rc_password) == 0) { page_user(ipc); break; + default: /* allow some math on the command */ + /* commands 100... to 100+MAX_EDITORS-1 will + call the appropriate editor... in other + words, command numbers 100+ will match + the citadel.rc keys editor0, editor1, etc.*/ + if (mcmd >= 100 && mcmd < (100+MAX_EDITORS)) + { + /* entmsg mode >=2 select editor */ + entmsg(ipc, 0, mcmd - 100 + 2); + break; + } } /* end switch */ } while (termn8 == 0); diff --git a/citadel/citadel.h b/citadel/citadel.h index 74fb0bf97..5abb38919 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -68,6 +68,8 @@ extern "C" { */ #define USERNAME_SIZE 64 /* The size of a username string */ +#define MAX_EDITORS 5 /* # of external editors supported */ + /* MUST be at least 1 */ /* * Message expiration policy stuff diff --git a/citadel/citadel.rc b/citadel/citadel.rc index ef3704b1c..d5f1e8d54 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -27,7 +27,14 @@ fullscreen=no # messages. If you want the external editor to be used by default, be sure # to reflect this in the command set below. # -editor=pico +# editor=pico + +# Or, you could have multiple editors available, like this: +# ("editor" and "editor0" are the same internally) +# You can go up to MAX_EDITORS number of editors (5 by default) +# editor0=pico +# editor1=vi +# editor2=nano # If you define PRINTCMD, it will be a pipe through which messages are # printed when the user hits the

rint key after a message. @@ -308,8 +315,15 @@ cmd=44,0,&.,&Enter,file using &Zmodem # cmd=41,0,&.,&Enter,re&Gistration cmd=4,0,&.,&Enter,&Message + +# If you have an external editor defined, it will appear on command 46. cmd=46,0,&.,&Enter,message with &Editor -# + +# If you have multiple editors defined, they will appear on +# commands 46, 101, 102, 103... up to MAX_EDITORS (5 by default) +#cmd=101,0,&.,&Enter,message with &VI +#cmd=102,0,&.,&Enter,message with &Nano + cmd=59,0,&;,&Configure floor mode cmd=60,0,&;,&Goto floor: cmd=61,0,&;,&Skip to floor: diff --git a/citadel/citadel_decls.h b/citadel/citadel_decls.h index edae28ae2..32bbf3a5e 100644 --- a/citadel/citadel_decls.h +++ b/citadel/citadel_decls.h @@ -7,7 +7,7 @@ extern char axlevel; extern char is_room_aide; extern unsigned userflags; extern char sigcaught; -extern char editor_path[SIZ]; +extern char editor_paths[MAX_EDITORS][SIZ]; extern char printcmd[SIZ]; extern char have_xterm; extern char rc_username[USERNAME_SIZE]; diff --git a/citadel/commands.c b/citadel/commands.c index bb9d20cb9..0232dec39 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -719,15 +719,18 @@ 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 */ - strcpy(editor_path, ""); + for (i = 0; i < MAX_EDITORS; i++) + strcpy(editor_paths[i], ""); strcpy(printcmd, ""); strcpy(rc_username, ""); strcpy(rc_password, ""); @@ -804,7 +807,14 @@ void load_command_set(void) #endif if (!strncasecmp(buf, "editor=", 7)) - strcpy(editor_path, &buf[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, "printcmd=", 9)) strcpy(printcmd, &buf[9]); diff --git a/citadel/docs/citadel.html b/citadel/docs/citadel.html index d73a617b0..23c1c1b38 100644 --- a/citadel/docs/citadel.html +++ b/citadel/docs/citadel.html @@ -44,6 +44,12 @@ access, and others
cosmetics, additional commands
+ + Nick Georbit
+ + additional client features
+
+ Michael Hampton
diff --git a/citadel/messages.c b/citadel/messages.c index e222b0012..4b0c777f5 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -81,7 +81,6 @@ extern char fullname[]; extern char axlevel; extern unsigned userflags; extern char sigcaught; -extern char editor_path[]; extern char printcmd[]; extern int rc_allow_attachments; extern int rc_display_message_numbers; @@ -733,14 +732,21 @@ int client_make_message(CtdlIPC *ipc, long beg; char datestr[SIZ]; char header[SIZ]; + char *editor_path = NULL; int cksum = 0; - if (mode == 2) - if (strlen(editor_path) == 0) { + if (mode >= 2) + { + if((mode-2) < MAX_EDITORS && strlen(editor_paths[mode-2]) > 0) { + editor_path = editor_paths[mode-2]; + } else if (strlen(editor_paths[0]) > 0) { + editor_path = editor_paths[0]; + } else { err_printf ("*** No editor available, using built-in editor\n"); mode = 0; } + } fmt_date(datestr, sizeof datestr, time(NULL), 0); header[0] = 0; @@ -825,6 +831,7 @@ ME1: switch (mode) { break; case 2: + default: /* allow 2+ modes */ e_ex_code = 1; /* start with a failed exit code */ editor_pid = fork(); cksum = file_checksum(filename); @@ -850,7 +857,7 @@ ME1: switch (mode) { break; } -MECR: if (mode == 2) { +MECR: if (mode >= 2) { if (file_checksum(filename) == cksum) { err_printf("*** Aborted message.\n"); e_ex_code = 1; diff --git a/citadel/rooms.c b/citadel/rooms.c index e612b7dd0..d107eceb4 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -47,7 +47,6 @@ extern char room_name[]; extern char temp[]; extern char tempdir[]; extern int editor_pid; -extern char editor_path[]; extern int screenwidth; extern int screenheight; extern char fullname[]; @@ -1037,7 +1036,7 @@ void do_edit(CtdlIPC *ipc, char cmd[SIZ]; int b, cksum, editor_exit; - if (strlen(editor_path) == 0) { + if (strlen(editor_paths[0]) == 0) { scr_printf("Do you wish to re-enter %s? ", desc); if (yesno() == 0) return; @@ -1053,7 +1052,7 @@ void do_edit(CtdlIPC *ipc, return; } - if (strlen(editor_path) > 0) { + if (strlen(editor_paths[0]) > 0) { CtdlIPC_putline(ipc, read_cmd); CtdlIPC_getline(ipc, cmd); if (cmd[0] == '1') { @@ -1067,7 +1066,7 @@ void do_edit(CtdlIPC *ipc, cksum = file_checksum(temp); - if (strlen(editor_path) > 0) { + if (strlen(editor_paths[0]) > 0) { char tmp[SIZ]; snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc); @@ -1077,7 +1076,7 @@ void do_edit(CtdlIPC *ipc, editor_pid = fork(); if (editor_pid == 0) { chmod(temp, 0600); - execlp(editor_path, editor_path, temp, NULL); + execlp(editor_paths[0], editor_paths[0], temp, NULL); exit(1); } if (editor_pid > 0) @@ -1086,7 +1085,7 @@ void do_edit(CtdlIPC *ipc, b = ka_wait(&editor_exit); } while ((b != editor_pid) && (b >= 0)); editor_pid = (-1); - scr_printf("Executed %s\n", editor_path); + scr_printf("Executed %s\n", editor_paths[0]); sttybbs(0); screen_set(); } else { diff --git a/citadel/routines2.c b/citadel/routines2.c index 30aaa3795..10f852340 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -917,7 +917,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) FILE *tempfp; FILE *changefp; - if (strlen(editor_path) == 0) { + if (strlen(editor_paths[0]) == 0) { scr_printf("You must have an external editor configured in" " order to use this function.\n"); return; @@ -958,7 +958,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) if (editor_pid == 0) { chmod(filename, 0600); putenv("WINDOW_TITLE=Network configuration"); - execlp(editor_path, editor_path, filename, NULL); + execlp(editor_paths[0], editor_paths[0], filename, NULL); exit(1); } if (editor_pid > 0) { -- 2.39.2