$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
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];
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);
*/
#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
# 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 <P>rint key after a message.
#
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:
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];
{
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, "");
#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]);
<td valign="top"><i>cosmetics, additional commands<br>
</i></td>
</tr>
+ <tr>
+ <td valign="top">Nick Georbit<br>
+ </td>
+ <td valign="top"><i>additional client features<br>
+ </i></td>
+ </tr>
<tr>
<td valign="top">Michael Hampton<br>
</td>
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;
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;
break;
case 2:
+ default: /* allow 2+ modes */
e_ex_code = 1; /* start with a failed exit code */
editor_pid = fork();
cksum = file_checksum(filename);
break;
}
-MECR: if (mode == 2) {
+MECR: if (mode >= 2) {
if (file_checksum(filename) == cksum) {
err_printf("*** Aborted message.\n");
e_ex_code = 1;
extern char temp[];
extern char tempdir[];
extern int editor_pid;
-extern char editor_path[];
extern int screenwidth;
extern int screenheight;
extern char fullname[];
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;
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') {
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);
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)
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 {
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;
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) {