$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
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
#
#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
#
#include "citadel_decls.h"
#include "routines.h"
#include "routines2.h"
+#include "tools.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#endif
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;
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 */
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))
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]);
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;
}
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 */
}
}
+ if ( (!struncmp(buffer, "http://", 7))
+ || (!struncmp(buffer, "ftp://", 6)) ) {
+ safestrncpy(urls[num_urls], buffer, 255);
+ for (a=0; a<strlen(urls[num_urls]); ++a) {
+ b = urls[num_urls][a];
+ if ( (b==' ') || (b==')') || (b=='>') || (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]);
#define COLOR_PUSH 16 /* Save current color */
#define COLOR_POP 17 /* Restore saved color */
+#define MAXURLS 50 /* Max embedded URL's per message */
+
/*
* declarations
*/
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];
}
+
+/*
+ * 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<num_urls; ++i) {
+ printf("%3d %s\n", i+1, urls[i]);
+ }
+
+ i = intprompt("Display which one", 1, 1, num_urls);
+
+ sprintf(cmd, rc_url_cmd, urls[i-1]);
+ system(cmd);
+ printf("\n");
+}
+
+
void readmsgs(int c, int rdir, int q) /* read contents of a room */
/* 0=Read all 1=Read new 2=Read old 3=Read last q */
/* 1=Forward (-1)=Reverse */
/* print only if available */ if ((e=='p')&&(strlen(printcmd)==0)) e=0;
/* can't reply in public rms */ if ((e=='r')&&(is_mail!=1)) e=0;
/* can't file if not allowed */ if ((e=='f')&&(rc_allow_attachments==0)) e=0;
+/* link only if browser avail*/ if ((e=='u')&&(strlen(rc_url_cmd)==0)) e=0;
} while((e!='a')&&(e!='n')&&(e!='s')
&&(e!='d')&&(e!='m')&&(e!='p')
&&(e!='q')&&(e!='b')&&(e!='h')
- &&(e!='r')&&(e!='f')&&(e!='?'));
+ &&(e!='r')&&(e!='f')&&(e!='?')
+ &&(e!='u'));
switch(e) {
case 's': printf("Stop\r"); break;
case 'a': printf("Again\r"); break;
case 'h': printf("Header\r"); break;
case 'r': printf("Reply\r"); break;
case 'f': printf("File\r"); break;
+ case 'u': printf("URL's\r"); break;
case '?': printf("? <help>\r"); break;
}
if (userflags & US_DISAPPEAR)
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);
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 */
void edit_system_message(char *which_message);
extern int lines_printed;
pid_t ka_wait(int *kstatus);
+void list_urls(void);