From d180c0718c679c90f73bb5c3f349e7d4e4e65dc7 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 1 Sep 1999 01:51:49 +0000 Subject: [PATCH] * Added the ability to handle embedded URL's from the text client --- citadel/ChangeLog | 4 ++++ citadel/citadel.rc | 7 +++++++ citadel/commands.c | 31 +++++++++++++++++++++++++++---- citadel/commands.h | 6 ++++++ citadel/messages.c | 34 +++++++++++++++++++++++++++++++++- citadel/messages.h | 1 + 6 files changed, 78 insertions(+), 5 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 4f8cda8c0..276605069 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 1.357 1999/09/01 01:51:48 ajc +* Added the ability to handle embedded URL's from the text client + Revision 1.356 1999/09/01 01:02:47 ajc * Implemented "maximum message length" in global system config @@ -1214,3 +1217,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.rc b/citadel/citadel.rc index 2b8867ba5..0c94c8d2f 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -78,6 +78,13 @@ allow_attachments=0 # #password=mypassword +# If URLCMD is defined, users can hit 'U' after reading a message which +# contains embedded URL's, and the command will be executed. Usually this +# will be used to remote-control a web browser. (Do not enable this command +# for 'safe' public clients.) +# +#urlcmd=netscape -remote "openURL(%s)" + # COMMAND SET CONFIGURATION # diff --git a/citadel/commands.c b/citadel/commands.c index 8e437bd9b..2b91bca8b 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -39,6 +39,7 @@ #include "citadel_decls.h" #include "routines.h" #include "routines2.h" +#include "tools.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" #endif @@ -59,6 +60,9 @@ int rc_allow_attachments; int rc_display_message_numbers; int rc_force_mail_prompts; int rc_ansi_color; +int num_urls = 0; +char urls[MAXURLS][256]; +char rc_url_cmd[256]; char *gl_string; int next_lazy_cmd = 5; @@ -412,6 +416,7 @@ void load_command_set(void) rc_display_message_numbers = 0; rc_force_mail_prompts = 0; rc_ansi_color = 0; + strcpy(rc_url_cmd, ""); /* now try to open the citadel.rc file */ @@ -471,11 +476,11 @@ void load_command_set(void) rc_force_mail_prompts = atoi(&buf[19]); } if (!struncmp(buf, "ansi_color=", 11)) { - if (!strncasecmp(&buf[11], "on", 2)) + if (!struncmp(&buf[11], "on", 2)) rc_ansi_color = 1; - if (!strncasecmp(&buf[11], "auto", 4)) + if (!struncmp(&buf[11], "auto", 4)) rc_ansi_color = 2; /* autodetect */ - if (!strncasecmp(&buf[11], "user", 4)) + if (!struncmp(&buf[11], "user", 4)) rc_ansi_color = 3; /* user config */ } if (!struncmp(buf, "username=", 9)) @@ -484,6 +489,9 @@ void load_command_set(void) if (!struncmp(buf, "password=", 9)) strcpy(rc_password, &buf[9]); + if (!struncmp(buf, "urlcmd=", 7)) + strcpy(rc_url_cmd, &buf[7]); + if (!struncmp(buf, "cmd=", 4)) { strcpy(buf, &buf[4]); @@ -882,6 +890,8 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su char buffer[512]; int eof_flag = 0; + num_urls = 0; /* Start with a clean slate of embedded URL's */ + if (starting_lp >= 0) { lines_printed = starting_lp; } @@ -893,7 +903,8 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su sigcaught = 0; sttybbs(1); - FMTA:while ((eof_flag == 0) && (strlen(buffer) < 126)) { +FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) { + if (sigcaught) goto OOPS; if (fp != NULL) { /* read from file */ @@ -921,6 +932,18 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su } } + if ( (!struncmp(buffer, "http://", 7)) + || (!struncmp(buffer, "ftp://", 6)) ) { + safestrncpy(urls[num_urls], buffer, 255); + for (a=0; a') || (b==10) + || (b==13) || (b==9) ) + urls[num_urls][a] = 0; + } + ++num_urls; + } + buffer[strlen(buffer) + 1] = 0; a = buffer[0]; strcpy(buffer, &buffer[1]); diff --git a/citadel/commands.h b/citadel/commands.h index 60e1403f5..cef70d16d 100644 --- a/citadel/commands.h +++ b/citadel/commands.h @@ -22,6 +22,8 @@ #define COLOR_PUSH 16 /* Save current color */ #define COLOR_POP 17 /* Restore saved color */ +#define MAXURLS 50 /* Max embedded URL's per message */ + /* * declarations */ @@ -45,3 +47,7 @@ extern int enable_color; int yesno(void); int yesno_d(int d); void keyopt(char *); + +extern int num_urls; +extern char urls[MAXURLS][256]; +extern char rc_url_cmd[256]; diff --git a/citadel/messages.c b/citadel/messages.c index 0b2204e66..ba2cf2a83 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -904,6 +904,31 @@ int line,qstart,qend; } + +/* + * List the URL's which were embedded in the previous message + */ +void list_urls() { + int i; + char cmd[256]; + + if (num_urls == 0) { + printf("There were no URL's in the previous message.\n\n"); + return; + } + + for (i=0; i\r"); break; } if (userflags & US_DISAPPEAR) @@ -1085,6 +1113,8 @@ RMSGREAD: fflush(stdout); printf(" R Reply to this message\n"); if (rc_allow_attachments) printf(" F (save attachments to a file)\n"); + if (strlen(rc_url_cmd)>0) + printf(" U (list URL's for display)\n"); printf("\n"); goto RMSGREAD; case 'p': fflush(stdout); @@ -1149,6 +1179,8 @@ RMSGREAD: fflush(stdout); goto RMSGREAD; case 'r': entmsg(1,(DEFAULT_ENTRY==46 ? 2 : 0)); goto RMSGREAD; + case 'u': list_urls(); + goto RMSGREAD; } } /* end for loop */ } /* end read routine */ diff --git a/citadel/messages.h b/citadel/messages.h index 2d3bf21b9..73523f76e 100644 --- a/citadel/messages.h +++ b/citadel/messages.h @@ -5,3 +5,4 @@ void readmsgs(int c, int rdir, int q); void edit_system_message(char *which_message); extern int lines_printed; pid_t ka_wait(int *kstatus); +void list_urls(void); -- 2.39.2