diff options
-rw-r--r-- | CHANGES | 38 | ||||
-rw-r--r-- | LYMessages_en.h | 1 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 89 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 189 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.h | 15 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 69 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.h | 28 | ||||
-rw-r--r-- | WWW/Library/Implementation/www_tcp.h | 71 | ||||
-rw-r--r-- | lynx_help/about_lynx.html | 5 | ||||
-rw-r--r-- | lynx_help/lynx_help_main.html | 4 | ||||
-rw-r--r-- | makefile.msc | 8 | ||||
-rw-r--r-- | src/GridText.c | 216 | ||||
-rw-r--r-- | src/HTFWriter.c | 16 | ||||
-rw-r--r-- | src/HTInit.c | 2 | ||||
-rw-r--r-- | src/LYCurses.c | 30 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 27 | ||||
-rw-r--r-- | src/LYKeymap.c | 2 | ||||
-rw-r--r-- | src/LYMail.c | 1664 | ||||
-rw-r--r-- | src/LYMail.h | 33 | ||||
-rw-r--r-- | src/LYMain.c | 20 | ||||
-rw-r--r-- | src/LYMainLoop.c | 5 | ||||
-rw-r--r-- | src/LYPrint.c | 83 | ||||
-rw-r--r-- | src/LYReadCFG.c | 2 | ||||
-rw-r--r-- | src/LYStrings.c | 6 | ||||
-rw-r--r-- | src/LYUtils.c | 4 | ||||
-rw-r--r-- | userdefs.h | 4 |
26 files changed, 1184 insertions, 1447 deletions
diff --git a/CHANGES b/CHANGES index 87b9c92c..d0d72ed4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,11 +1,41 @@ Changes since Lynx 2.8 release =============================================================================== +2000-09-21 (2.8.4dev.10) +* modified www_tcp.h and makefile.msc to allow compile with winsock2 if + USE_WINSOCK2_H is defined -TD +* fix: the recently added code to enable external programs to replace normal + lynx handling of individual URL types was not refreshing the screen after the + external program finished (EXTERNAL set TRUE:TRUE) -DK +* fixed two URLs in lynx_help_main.html -DK +* add symbol USE_VMS_MAILER, use to distinguish VMS mail ifdef's for test + compiles -TD +* use new function LYSendMailFile() to consolidate details of non-VMS/non-piped + email, e.g., DOS or Win32, and eliminate some minor inconsistencies in that + area -TD +* correct order of ifdef's in send_file_to_mail() which could leave unsent + email on some systems without popen/pclose -TD +* add some checks in LYhandlePopupList() to prevent popup of an empty list -TD +* change a few messages written to stderr to end lines with \r\n rather than + \n, since Lynx may already be in screen mode when they are written -TD +* treat .Z, .gz and .bz2 suffixes more symmetrically using new function + HTCompressFileType() for parsing them -TD +* change mime type for bzip2 files to bzip2, x-bzip2 -HN +* move IPV6 definitions in www_tcp.h to the end, to build on FreeBSD 4.1, since + SIN6_LEN must not be checked before including netinet/in.h (patch by + Munechika SUMIKAWA @ KAME Project <sumikawa@ebina.hitachi.co.jp>) +* make HTParseInet() private, simplify some ifdef's -TD +* change shell expression used to process stdin for mailcap to "(command)<file" + form, which is a little more robust than "cat file|command" (suggested by PG) + -TD +* update URLs in about_lynx.html -DK +* remove spurious 'FREE(leaf);' from LYLocalFileToURL() introduced in dev.5 -DK + 2000-09-01 (2.8.4dev.9) * improve ifdef's for endwin/newterm logic, making a fallback for LYscreen variable -PG * modify CF_CURSES_LIBS to check if both initscr() and tgoto() are in the - $LIBS list before deciding not to try to look for them -T + $LIBS list before deciding not to try to look for them -TD * add %s substitution to mailcap_substitute(), overlooked when implementing the logic to read from stdin when %s is omitted (reported by IC) -TD * restore endwin/newterm code for ncurses (as PG notes it really is needed). @@ -145,7 +175,7 @@ Changes since Lynx 2.8 release invoked in dired mode, the listing of destination directory will be automatically loaded. Dired file operations menu lists this command too as the first item. To disable it, comment the line - #define SUPPORT_CHDIR + #define SUPPORT_CHDIR in userdefs.h -VH * add definitions to allow slang configuration to implement scrollbars. This will not work for any termcap/terminfo-based systems, appears specific to @@ -165,7 +195,7 @@ Changes since Lynx 2.8 release copied -TD 2000-06-02 (2.8.4dev.3) -* initial support for SOURCE_CACHE_FOR_ABORTED -VH +* initial support for SOURCE_CACHE_FOR_ABORTED -VH * change default_keypad_mode_fun() to use config_enum() -TD * modify config_enum() to check if the given name in lynx.cfg is ambiguous, matching more than one name -TD @@ -247,7 +277,7 @@ Changes since Lynx 2.8 release * correct an overlooked change of ifdef's from CONV_JISX0201KANA_TO_JISX0208KANA to CONV_JISX0201KANA_JISX0208KANA -TH * move include of LYClean.h in LYexit.c to ensure that cleanup_files() is - prototyped on VMS (report by Jerome Lauret) + prototyped on VMS (report by Jerome Lauret) * move assignment of HadVMSInterrupt in cleanup_sig() to avoid interaction with logic in HTConfirmDefault() on VMS (reported/tested by Jerome Lauret) -KW * minor fixes to lynx.man / lynx.hlp for descriptions of -get_data, -post_data, diff --git a/LYMessages_en.h b/LYMessages_en.h index 9c019a85..e42751db 100644 --- a/LYMessages_en.h +++ b/LYMessages_en.h @@ -192,7 +192,6 @@ #define NO_ADDRESS_IN_MAILTO_URL gettext("No email address is present in mailto URL!") #define MAILTO_URL_TEMPOPEN_FAILED \ gettext("Unable to open temporary file for mailto URL!") -#define COMMENT_REQUEST_CANCELLED gettext("Comment request cancelled!!!") #define INC_ORIG_MSG_PROMPT \ gettext("Do you wish to include the original message?") #define INC_PREPARSED_MSG_PROMPT \ diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 5c3df4f0..91cbc282 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -908,8 +908,7 @@ PRIVATE int get_connection ARGS2( status = response(command); FREE(command); if (status == HT_INTERRUPTED) { - CTRACE((tfp, - "HTFTP: Interrupted while sending password.\n")); + CTRACE((tfp, "HTFTP: Interrupted while sending password.\n")); _HTProgress (CONNECTION_INTERRUPTED); NETCLOSE(control->socket); control->socket = -1; @@ -997,10 +996,10 @@ PRIVATE int get_connection ARGS2( CTRACE((tfp, "HTFTP: Treating as Window_NT server.\n")); set_unix_dirstyle(&server_type, &use_list); - } else if (strncmp(response_text+4, "Windows2000", 11) == 0) { - server_type = WINDOWS_2K_SERVER; - CTRACE((tfp, "HTFTP: Treating as Window_2K server.\n")); - set_unix_dirstyle(&server_type, &use_list); + } else if (strncmp(response_text+4, "Windows2000", 11) == 0) { + server_type = WINDOWS_2K_SERVER; + CTRACE((tfp, "HTFTP: Treating as Window_2K server.\n")); + set_unix_dirstyle(&server_type, &use_list); } else if (strncmp(response_text+4, "MS Windows", 10) == 0) { server_type = MS_WINDOWS_SERVER; @@ -1202,9 +1201,9 @@ PRIVATE int get_listen_socket NOARGS if (status<0) return HTInetStatus("getsockname"); #ifdef INET6 CTRACE((tfp, "HTFTP: This host is %s\n", - HTInetString((SockA *)soc_in))); - - soc_in->sin_port = 0; /* Unspecified: please allocate */ + HTInetString((SockA *)soc_in))); + + soc_in->sin_port = 0; /* Unspecified: please allocate */ #else CTRACE((tfp, "HTFTP: This host is %s\n", HTInetString(soc_in))); @@ -1252,7 +1251,7 @@ PRIVATE int get_listen_socket NOARGS #ifdef INET6 CTRACE((tfp, "HTFTP: bound to port %d on %s\n", (int)ntohs(soc_in->sin_port), - HTInetString((SockA *)soc_in))); + HTInetString((SockA *)soc_in))); #else CTRACE((tfp, "HTFTP: bound to port %d on %s\n", (int)ntohs(soc_in->sin_port), @@ -1572,16 +1571,16 @@ PRIVATE void parse_dls_line ARGS3( int len; char *cps = NULL; - /* README 763 Information about this server\0 - bin/ - \0 - etc/ = \0 - ls-lR 0 \0 - ls-lR.Z 3 \0 - pub/ = Public area\0 - usr/ - \0 - morgan 14 -> ../real/morgan\0 + /* README 763 Information about this server\0 + bin/ - \0 + etc/ = \0 + ls-lR 0 \0 + ls-lR.Z 3 \0 + pub/ = Public area\0 + usr/ - \0 + morgan 14 -> ../real/morgan\0 TIMIT.mostlikely.Z\0 - 79215 \0 + 79215 \0 */ len = strlen(line); @@ -2202,7 +2201,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS3( case MACHTEN_SERVER: case MSDOS_SERVER: case WINDOWS_NT_SERVER: - case WINDOWS_2K_SERVER: + case WINDOWS_2K_SERVER: case APPLESHARE_SERVER: case NETPRESENZ_SERVER: /* @@ -2960,7 +2959,7 @@ PUBLIC int HTFTPLoad ARGS4( NETCLOSE (control->socket); control->socket = -1; #ifdef INET6 - if (master_socket >= 0) + if (master_socket >= 0) (void)close_master_socket (); #else close_master_socket (); @@ -3005,9 +3004,9 @@ PUBLIC int HTFTPLoad ARGS4( if (status < 0) /* retry or Bad return */ continue; else if (status != 2) { - return -status; /* bad reply */ + return -status; /* bad reply */ } - } + } if (strncmp(command, "PASV", 4) == 0) { for (p = response_text; *p && *p != ','; p++) @@ -3042,7 +3041,7 @@ PUBLIC int HTFTPLoad ARGS4( h2 = c2; h3 = c3; passive_port = p0; - } + } #else status = send_cmd_1("PASV"); if (status != 2) { @@ -3566,7 +3565,7 @@ listen: if(!ftp_passive) { /* Wait for the connection */ #ifdef INET6 - struct sockaddr_storage soc_address; + struct sockaddr_storage soc_address; #else struct sockaddr_in soc_address; #endif /* INET6 */ @@ -3626,7 +3625,6 @@ listen: status = final_status; } else { int rv; - int len; char *FileName = HTParse(name, "", PARSE_PATH + PARSE_PUNCTUATION); /** Clear any login messages **/ @@ -3644,29 +3642,29 @@ listen: StrAllocCopy(anchor->content_encoding, HTAtom_name(encoding)); format = HTAtom_for("www/compressed"); - } else if ((len = strlen(FileName)) > 2) { - if ((FileName[len - 1] == 'Z') && - (FileName[len - 2] == '.' || - FileName[len - 2] == '-' || - FileName[len - 2] == '_')) { + } else { + char *dot; + CompressFileType cft = HTCompressFileType(FileName, "._-", &dot); - FileName[len - 2] = '\0'; + if (cft != cftNone) { + *dot = '\0'; format = HTFileFormat(FileName, &encoding, NULL); format = HTCharsetFormat(format, anchor, -1); StrAllocCopy(anchor->content_type, format->name); - StrAllocCopy(anchor->content_encoding, "x-compress"); format = HTAtom_for("www/compressed"); - } else if ((len > 3) && - !strcasecomp((char *)&FileName[len - 2], "gz")) { - if (FileName[len - 3] == '.' || - FileName[len - 3] == '-' || - FileName[len - 3] == '_') { - FileName[len - 3] = '\0'; - format = HTFileFormat(FileName, &encoding, NULL); - format = HTCharsetFormat(format, anchor, -1); - StrAllocCopy(anchor->content_type, format->name); + + switch (cft) { + case cftCompress: + StrAllocCopy(anchor->content_encoding, "x-compress"); + break; + case cftGzip: StrAllocCopy(anchor->content_encoding, "x-gzip"); - format = HTAtom_for("www/compressed"); + break; + case cftBzip2: + StrAllocCopy(anchor->content_encoding, "x-bzip2"); + break; + default: + break; } } } @@ -3675,11 +3673,6 @@ listen: _HTProgress (gettext("Receiving FTP file.")); rv = HTParseSocket(format, format_out, anchor, data_soc, sink); -#if 0 /* already done in HTCopy - kw */ - if (rv == HT_INTERRUPTED) - _HTProgress(TRANSFER_INTERRUPTED); -#endif - HTInitInput(control->socket); /* Reset buffering to control connection DD 921208 */ diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index 103b1651..c0a44bb3 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -46,7 +46,6 @@ #include <GridText.h> #endif -#define INFINITY 512 /* file name length @@ FIXME */ #define MULTI_SUFFIX ".multi" /* Extension for scanning formats */ #include <HTParse.h> @@ -1205,6 +1204,42 @@ PUBLIC float HTFileValue ARGS1( return (float)0.3; /* Dunno! */ } +/* +** Determine compression type from file name, by looking at its suffix. +** Sets as side-effect a pointer to the "dot" that begins the suffix. +*/ +PUBLIC CompressFileType HTCompressFileType ARGS3( + char *, filename, + char *, dots, + char **, suffix) +{ + CompressFileType result = cftNone; + size_t len = strlen(filename); + char *ftype = filename + len; + + if ((len > 4) + && !strcasecomp((ftype - 3), "bz2") + && strchr(dots, ftype[-4]) != 0) { + result = cftBzip2; + ftype -= 4; + } else if ((len > 3) + && !strcasecomp((ftype - 2), "gz") + && strchr(dots, ftype[-3]) != 0) { + result = cftGzip; + ftype -= 3; + } else if ((len > 2) + && !strcmp((ftype - 1), "Z") + && strchr(dots, ftype[-2]) != 0) { + result = cftCompress; + ftype -= 2; + } + + *suffix = ftype; + CTRACE((tfp, "HTCompressFileType(%s) returns %d:%s\n", + filename, result, *suffix)); + return result; +} + /* Determine write access to a file. ** --------------------------------- ** @@ -2007,6 +2042,7 @@ PUBLIC int HTLoadFile ARGS4( HTAtom * encoding; /* @@ not used yet */ HTAtom * myEncoding = NULL; /* enc of this file, may be gzip etc. */ int status; + char *dot; #ifdef VMS struct stat stat_info; #endif /* VMS */ @@ -2141,8 +2177,6 @@ PUBLIC int HTLoadFile ARGS4( FREE(ultrixname); } if (fp) { - int len; - char *cp = NULL; char *semicolon = NULL; if (HTEditable(vmsname)) { @@ -2187,50 +2221,50 @@ PUBLIC int HTLoadFile ARGS4( StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); format = HTAtom_for("www/compressed"); } - } else if ((len = strlen(vmsname)) > 2) { - if ((vmsname[len - 1] == 'Z') && - (vmsname[len - 2] == '.' || - vmsname[len - 2] == '-' || - vmsname[len - 2] == '_') && - vmsname[len - 3] != ']' && - vmsname[len - 3] != ':') { + } else { + /* FIXME: should we check if suffix is after ']' or ':' ? */ + CompressFileType cft = HTCompressFileType(vmsname, "._-", &dot); + + if (cft != cftNone) { + char *cp = NULL; + StrAllocCopy(cp, vmsname); - cp[len - 2] = '\0'; + cp[dot - vmsname] = '\0'; format = HTFileFormat(cp, &encoding, NULL); FREE(cp); format = HTCharsetFormat(format, anchor, UCLYhndl_HTFile_for_unspec); StrAllocCopy(anchor->content_type, format->name); + } + + switch (cft) { + case cftCompress: StrAllocCopy(anchor->content_encoding, "x-compress"); format = HTAtom_for("www/compressed"); - } else if ((len > 3) && - !strcasecomp(&vmsname[len - 2], "gz")) { - if (vmsname[len - 3] == '.' || - vmsname[len - 3] == '-' || - vmsname[len - 3] == '_') { - StrAllocCopy(cp, vmsname); - cp[len - 3] = '\0'; - format = HTFileFormat(cp, &encoding, NULL); - FREE(cp); - format = HTCharsetFormat(format, anchor, - UCLYhndl_HTFile_for_unspec); - StrAllocCopy(anchor->content_type, format->name); - StrAllocCopy(anchor->content_encoding, "x-gzip"); + break; + case cftGzip: + StrAllocCopy(anchor->content_encoding, "x-gzip"); #ifdef USE_ZLIB - if (strcmp(format_out->name, "www/download") != 0) { - fclose(fp); - if (semicolon != NULL) - *semicolon = ';'; - gzfp = gzopen(vmsname, "rb"); + if (strcmp(format_out->name, "www/download") != 0) { + fclose(fp); + if (semicolon != NULL) + *semicolon = ';'; + gzfp = gzopen(vmsname, "rb"); - CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", - vmsname, (void*)gzfp)); - use_gzread = YES; - } + CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + vmsname, (void*)gzfp)); + use_gzread = YES; + } #else /* USE_ZLIB */ - format = HTAtom_for("www/compressed"); + format = HTAtom_for("www/compressed"); #endif /* USE_ZLIB */ - } + break; + case cftBzip2: + StrAllocCopy(anchor->content_encoding, "x-bzip2"); + format = HTAtom_for("www/compressed"); + break; + case cftNone: + break; } } if (semicolon != NULL) @@ -2350,40 +2384,38 @@ PUBLIC int HTLoadFile ARGS4( filevalue, 0L /* @@@@@@ */); if (value <= 0.0) { + char *atomname = NULL; + CompressFileType cft = HTCompressFileType(dirbuf->d_name, ".", &dot); char * cp = NULL; - int len = strlen(dirbuf->d_name); + enc = NULL; - if (len > 2 && - dirbuf->d_name[len - 1] == 'Z' && - dirbuf->d_name[len - 2] == '.') { + if (cft != cftNone) { StrAllocCopy(cp, dirbuf->d_name); - cp[len - 2] = '\0'; + cp[dot - dirbuf->d_name] = '\0'; format = HTFileFormat(cp, NULL, NULL); FREE(cp); value = HTStackValue(format, format_out, filevalue, 0); - if (value <= 0.0) { - format = HTAtom_for("application/x-compressed"); - value = HTStackValue(format, format_out, - filevalue, 0); - } - if (value <= 0.0) { - format = HTAtom_for("www/compressed"); - value = HTStackValue(format, format_out, - filevalue, 0); + switch (cft) { + case cftCompress: + atomname = "application/x-compressed"; + break; + case cftGzip: + atomname = "application/x-gzip"; + break; + case cftBzip2: + atomname = "application/x-bzip2"; + break; + case cftNone: + break; } - } else if ((len > 3) && - !strcasecomp((char *)&dirbuf->d_name[len - 2], - "gz") && - dirbuf->d_name[len - 3] == '.') { - StrAllocCopy(cp, dirbuf->d_name); - cp[len - 3] = '\0'; - format = HTFileFormat(cp, NULL, NULL); - FREE(cp); + } + + if (atomname != NULL) { value = HTStackValue(format, format_out, filevalue, 0); if (value <= 0.0) { - format = HTAtom_for("application/x-gzip"); + format = HTAtom_for(atomname); value = HTStackValue(format, format_out, filevalue, 0); } @@ -2515,8 +2547,7 @@ PUBLIC int HTLoadFile ARGS4( #endif /* HAVE_READDIR */ { # if defined(__EMX__) || defined(WIN_EX) - int len = strlen(localname); - int bin = ((len > 3) && !strcasecomp(localname + len - 3, ".gz")); + int bin = HTCompressFileType(localname, ".", &dot) != cftNone; FILE * fp = fopen(localname, (bin ? "rb" : "r")); # else /* !( defined __EMX__ ) */ FILE * fp = fopen(localname, "r"); @@ -2525,9 +2556,6 @@ PUBLIC int HTLoadFile ARGS4( CTRACE((tfp, "HTLoadFile: Opening `%s' gives %p\n", localname, (void*)fp)); if (fp) { /* Good! */ - int len2; - char *cp = NULL; - if (HTEditable(localname)) { HTAtom * put = HTAtom_for("PUT"); HTList * methods = HTAnchor_methods(anchor); @@ -2561,29 +2589,27 @@ PUBLIC int HTLoadFile ARGS4( StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); format = HTAtom_for("www/compressed"); } - } else if ((len2 = strlen(localname)) > 2) { - if (localname[len2 - 1] == 'Z' && - localname[len2 - 2] == '.') { + } else { + CompressFileType cft = HTCompressFileType(localname, ".", &dot); + + if (cft != cftNone) { + char *cp = NULL; + StrAllocCopy(cp, localname); - cp[len2 - 2] = '\0'; + cp[dot - localname] = '\0'; format = HTFileFormat(cp, &encoding, NULL); FREE(cp); format = HTCharsetFormat(format, anchor, UCLYhndl_HTFile_for_unspec); StrAllocCopy(anchor->content_type, format->name); + } + + switch (cft) { + case cftCompress: StrAllocCopy(anchor->content_encoding, "x-compress"); format = HTAtom_for("www/compressed"); - } else if ((len2 > 3) && - !strcasecomp((char *)&localname[len2 - 2], - "gz") && - localname[len2 - 3] == '.') { - StrAllocCopy(cp, localname); - cp[len2 - 3] = '\0'; - format = HTFileFormat(cp, &encoding, NULL); - FREE(cp); - format = HTCharsetFormat(format, anchor, - UCLYhndl_HTFile_for_unspec); - StrAllocCopy(anchor->content_type, format->name); + break; + case cftGzip: StrAllocCopy(anchor->content_encoding, "x-gzip"); #ifdef USE_ZLIB if (strcmp(format_out->name, "www/download") != 0) { @@ -2597,6 +2623,13 @@ PUBLIC int HTLoadFile ARGS4( #else /* USE_ZLIB */ format = HTAtom_for("www/compressed"); #endif /* USE_ZLIB */ + break; + case cftBzip2: + StrAllocCopy(anchor->content_encoding, "x-bzip2"); + format = HTAtom_for("www/compressed"); + break; + case cftNone: + break; } } FREE(localname); diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h index 2cb1d92a..f0a3178a 100644 --- a/WWW/Library/Implementation/HTFile.h +++ b/WWW/Library/Implementation/HTFile.h @@ -194,6 +194,21 @@ extern float HTFileValue PARAMS(( CONST char * filename)); /* +** Determine compression type from file name, by looking at its suffix. +*/ +typedef enum { + cftNone + , cftCompress + , cftGzip + , cftBzip2 +} CompressFileType; + +extern CompressFileType HTCompressFileType PARAMS(( + char * filename, + char * dots, + char ** suffix)); + +/* ** Determine write access to a file. ** ** ON EXIT, diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index 5b528bc2..bc696abd 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -306,7 +306,7 @@ PUBLIC CONST char * HTInetString ARGS1( hostbuf, sizeof(hostbuf), NULL, 0, NI_NUMERICHOST); return hostbuf; #else - static char string[16]; + static char string[20]; sprintf(string, "%d.%d.%d.%d", (int)*((unsigned char *)(&soc_in->sin_addr)+0), (int)*((unsigned char *)(&soc_in->sin_addr)+1), @@ -687,7 +687,7 @@ PUBLIC struct hostent * LYGetHostByName ARGS1( } #ifdef _WINDOWS_NSL - strncpy(host, str, (size_t)512); + strncpy(host, str, sizeof(host)); #endif /* _WINDOWS_NSL */ if (!valid_hostname(host)) { @@ -1171,21 +1171,23 @@ failed: ** field is left unchanged in *soc_in. */ #ifdef INET6 -PUBLIC int HTParseInet ARGS3( - SockA *, soc_in, +PRIVATE int HTParseInet ARGS3( + SockA *, soc_in, CONST char *, str, - int, default_port) -{ - char portstr[NI_MAXSERV]; + int, default_port) #else -PUBLIC int HTParseInet ARGS2( +PRIVATE int HTParseInet ARGS2( SockA *, soc_in, CONST char *, str) -{ #endif /* INET6 */ +{ char *port; +#ifdef INET6 + char portstr[NI_MAXSERV]; +#else int dotcount_ip = 0; /* for dotted decimal IP addr */ char *strptr; +#endif #ifndef _WINDOWS_NSL char *host = NULL; #endif /* _WINDOWS_NSL */ @@ -1200,7 +1202,7 @@ PUBLIC int HTParseInet ARGS2( return -1; } #ifdef _WINDOWS_NSL - strncpy(host, str, (size_t)512); + strncpy(host, str, sizeof(host)); #else StrAllocCopy(host, str); /* Make a copy we can mutilate */ #endif /* _WINDOWS_NSL */ @@ -1214,11 +1216,12 @@ PUBLIC int HTParseInet ARGS2( port = strrchr(strrchr(host, ']'), ':'); if (port) { - *port++ = 0; /* Chop off port */ + *port++ = 0; /* Chop off port */ } else { - sprintf(portstr,"%d", default_port); - port = portstr; + sprintf(portstr,"%d", default_port); + port = portstr; + } #else if ((port = strchr(host, ':')) != NULL) { *port++ = 0; /* Chop off port */ @@ -1233,7 +1236,7 @@ PUBLIC int HTParseInet ARGS2( soc_in->sin_port = htons((unsigned short)strtol(port,&strptr,10)); #endif /* Decnet */ #endif /* Unix vs. VMS */ -#ifdef SUPPRESS /* 1. crashes!?!. 2. URL syntax has number not name */ +#ifdef SUPPRESS /* 1. crashes!?!. 2. URL syntax has number not name */ } else { struct servent * serv = getservbyname(port, (char*)0); if (serv) { @@ -1250,8 +1253,8 @@ PUBLIC int HTParseInet ARGS2( HTAlwaysAlert(NULL, gettext("Address has invalid port")); return -1; } -#endif /* INET6 */ } +#endif /* INET6 */ #ifdef DECNET /* @@ -1424,11 +1427,11 @@ failed: FREE(host); #endif /* _WINDOWS_NSL */ switch (lynx_nsl_status) { - case HT_NOT_ACCEPTABLE: - case HT_INTERRUPTED: + case HT_NOT_ACCEPTABLE: + case HT_INTERRUPTED: return lynx_nsl_status; - default: - return -1; + default: + return -1; } } @@ -1589,14 +1592,12 @@ PUBLIC int HTDoConnect ARGS4( int, default_port, int *, s) { - int status; + int status = 0; char *line = NULL; char *p1 = NULL; char *at_sign = NULL; char *host = NULL; #ifdef INET6 - int error; - struct sockaddr *sa; struct addrinfo *res, *res0; #else struct sockaddr_in soc_address; @@ -1631,11 +1632,12 @@ PUBLIC int HTDoConnect ARGS4( _HTProgress(host); res0 = HTGetAddrInfo(host, default_port); if (res0 == NULL) { - sprintf (line, "Unable to locate remote host %s.", host); + HTSprintf0 (&line, gettext("Unable to locate remote host %s."), host); _HTProgress(line); FREE(host); FREE(line); return HT_NO_DATA; + } #else status = HTParseInet(soc_in, host); if (status) { @@ -1656,8 +1658,8 @@ PUBLIC int HTDoConnect ARGS4( FREE(host); FREE(line); return status; -#endif /* INET6 */ } +#endif /* INET6 */ HTSprintf0 (&line, gettext("Making %s connection to %s"), protocol, host); _HTProgress (line); @@ -1675,7 +1677,7 @@ PUBLIC int HTDoConnect ARGS4( getnameinfo(res->ai_addr, res->ai_addrlen, hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf), NI_NUMERICHOST|NI_NUMERICSERV); - HTSprintf0 (&line, "socket failed: family %d addr %s port %s.", + HTSprintf0 (&line, gettext("socket failed: family %d addr %s port %s."), res->ai_family, hostbuf, portbuf); _HTProgress (line); FREE(line); @@ -1753,7 +1755,11 @@ PUBLIC int HTDoConnect ARGS4( ** the normal case. */ if ((status < 0) && - (SOCKET_ERRNO == EINPROGRESS || SOCKET_ERRNO == EAGAIN)) { + (SOCKET_ERRNO == EINPROGRESS +#ifdef EAGAIN + || SOCKET_ERRNO == EAGAIN +#endif + )) { struct timeval timeout; int ret; int tries=0; @@ -1895,7 +1901,11 @@ PUBLIC int HTDoConnect ARGS4( sizeof(soc_address)); #endif /* INET6 */ if ((status < 0) && - (SOCKET_ERRNO != EALREADY && SOCKET_ERRNO != EAGAIN) && + (SOCKET_ERRNO != EALREADY +#ifdef EAGAIN + && SOCKET_ERRNO != EAGAIN +#endif + ) && #ifdef UCX (SOCKET_ERRNO != 18242) && #endif /* UCX */ @@ -1934,10 +1944,11 @@ PUBLIC int HTDoConnect ARGS4( #endif /* INET6 */ #endif /* !__DJGPP__ */ #ifdef INET6 - if (*s < 0) { + if (*s < 0) #else - if (status < 0) { + if (status < 0) #endif /* INET6 */ + { /* ** The connect attempt failed or was interrupted, ** so close up the socket. diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h index 345f6077..91f98c80 100644 --- a/WWW/Library/Implementation/HTTCP.h +++ b/WWW/Library/Implementation/HTTCP.h @@ -93,34 +93,6 @@ extern int lynx_nsl_status; extern struct hostent * LYGetHostByName PARAMS((char * str)); #endif - -/* Parse an internet node address and port -** --------------------------------------- -** -** On entry: -** str points to a string with a node name or number, -** with optional trailing colon and port number. -** sin points to the binary internet or decnet address field. -** -** On exit: -** Regular case: -** *sin is filled in. If no port is specified in str, that -** field is left unchanged in *sin. -** INET6 case: -** *sin is filled in. If no port is specified in str, -** default_port is used -*/ -#if defined(__STDC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#ifdef INET6 - extern int HTParseInet(SockA * mysin, CONST char * str, int default_port); -#else - extern int HTParseInet(struct sockaddr_in * mysin, CONST char * str); -#endif /* INET6 */ - /*!! had to change this to get it to compile. CTB */ -#else - extern int HTParseInet(); -#endif - /* Get Name of This Machine ** ------------------------ ** diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h index d0ed557f..e808919b 100644 --- a/WWW/Library/Implementation/www_tcp.h +++ b/WWW/Library/Implementation/www_tcp.h @@ -56,29 +56,6 @@ Default values #define INVSOC (-1) /* Unix invalid socket */ /* NB: newer libwww has something different for Windows */ -/* IPv6 support */ -#if defined(HAVE_GETADDRINFO) && defined(HAVE_GAI_STRERROR) && defined(ENABLE_IPV6) -# define INET6 -#endif /* HAVE_GETADDRINFO && HAVE_GAI_STRERROR && ENABLE_IPV6 */ - -#if !defined(__MINGW32__) -#ifdef INET6 -typedef struct sockaddr_storage SockA; /* See netinet/in.h */ -#else -typedef struct sockaddr_in SockA; /* See netinet/in.h */ -#endif /* INET6 */ -#endif - -#ifdef INET6 -#ifdef SIN6_LEN -#define SOCKADDR_LEN(soc_address) ((struct sockaddr *)&soc_address)->sa_len -#else -#define SOCKADDR_LEN(soc_address) SA_LEN((struct sockaddr *)&soc_address) -#endif /* SIN6_LEN */ -#else -#define SOCKADDR_LEN(soc_address) sizeof(soc_address) -#endif /* INET6 */ - #ifndef VMS #include <sys/types.h> @@ -208,9 +185,29 @@ extern int ws_netread(int fd, char *buf, int len); #include <direct.h> /* FIXME: someone might consider porting to winsock2.h */ -#define USE_WINSOCK_H +#ifdef USE_WINSOCK2_H +#include <winsock.h> + +#undef EINPROGRESS +#undef EALREADY +#undef EISCONN +#undef EINTR +#undef EAGAIN +#undef ENOTCONN +#undef ECONNRESET +#undef ETIMEDOUT + +#define EINPROGRESS WSAEINPROGRESS +#define EALREADY WSAEALREADY +#define EISCONN WSAEISCONN +#define EINTR WSAEINTR +/* fine EAGAIN WSAEAGAIN */ +#define ENOTCONN WSAENOTCONN +#define ECONNRESET WSAECONNRESET +#define ETIMEDOUT WSAETIMEDOUT + +#else /* USE_WINSOCK_H */ -#ifdef USE_WINSOCK_H #include <winsock.h> typedef struct sockaddr_in SockA; /* See netinet/in.h */ @@ -230,6 +227,7 @@ typedef struct sockaddr_in SockA; /* See netinet/in.h */ #undef SOCKET_ERRNO /* 1997/10/19 (Sun) 18:01:46 */ #define SOCKET_ERRNO WSAGetLastError() + #endif /* USE_WINSOCK_H */ #define INCLUDES_DONE @@ -804,4 +802,27 @@ typedef unsigned int fd_set; #define set_errno(value) /* we do not know how */ #endif +/* IPv6 support */ +#if defined(HAVE_GETADDRINFO) && defined(HAVE_GAI_STRERROR) && defined(ENABLE_IPV6) +# define INET6 +#endif /* HAVE_GETADDRINFO && HAVE_GAI_STRERROR && ENABLE_IPV6 */ + +#if !defined(__MINGW32__) +#ifdef INET6 +typedef struct sockaddr_storage SockA; /* See netinet/in.h */ +#else +typedef struct sockaddr_in SockA; /* See netinet/in.h */ +#endif /* INET6 */ +#endif + +#ifdef INET6 +#ifdef SIN6_LEN +#define SOCKADDR_LEN(soc_address) ((struct sockaddr *)&soc_address)->sa_len +#else +#define SOCKADDR_LEN(soc_address) SA_LEN((struct sockaddr *)&soc_address) +#endif /* SIN6_LEN */ +#else +#define SOCKADDR_LEN(soc_address) sizeof(soc_address) +#endif /* INET6 */ + #endif /* TCP_H */ diff --git a/lynx_help/about_lynx.html b/lynx_help/about_lynx.html index 0162d149..1133f978 100644 --- a/lynx_help/about_lynx.html +++ b/lynx_help/about_lynx.html @@ -27,7 +27,7 @@ Procomm running on PCs or Macs. Lynx was a product of the Distributed Computing Group within Academic Computing Services of <A -HREF="http://www.cc.ukans.edu/index.html">The University of Kansas</A>. +HREF="http://www.cc.ukans.edu/">The University of Kansas</A>. <P>Lynx was originally developed by <A HREF="http://www.cc.ukans.edu/cwis/people/Lou.Montulli.html" @@ -60,8 +60,7 @@ Lynx contains other sections of code that are copyrighted by other institutions or individuals. The Lynx copyright does not override or invalidate those copyrights. -<P>Thanks to <A NAME="13" -HREF="http://www.w3.org/hypertext/WWW/People.html#BernersLee" +<P>Thanks to <A NAME="13" HREF="http://www.w3.org/People/Berners-Lee/" >Tim Berners-Lee</A> and the other <A NAME="14" HREF="http://www.w3.org/hypertext/WWW/People.html">CERN World Wide Web wizards</A> for the WWW client library code and all of their other diff --git a/lynx_help/lynx_help_main.html b/lynx_help/lynx_help_main.html index c22d69a4..e1983f56 100644 --- a/lynx_help/lynx_help_main.html +++ b/lynx_help/lynx_help_main.html @@ -72,11 +72,11 @@ SSL & security, and more <h2>Other browsing software:</h2> <ul> -<li><a href="ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/">WGET</a> +<li><a href="http://www.cg.tuwien.ac.at/~prikryl/wget.html">WGET</a> -- powerful & flexible non-interactive downloader <li><a href="http://www.idata.sk/~ondrej/pavuk/">Pavuk</a> -- powerful & an even more-featured downloader -<li><a href="http://curl.haxx.nu/">cURL</a> +<li><a href="http://curl.haxx.se/">cURL</a> -- non-interactive downloader which supports HTTPS <li><a href="http://www.xach.com/snarf/">SNARF</a> -- small simple 1-file non-interactive downloader diff --git a/makefile.msc b/makefile.msc index 54fb2476..a2ece4d5 100644 --- a/makefile.msc +++ b/makefile.msc @@ -16,13 +16,16 @@ ETC_LIB = lib #CS_DEFS = /D "CHAR_BIT=8" /D "USE_HASH" /D "USE_COLOR_STYLE" /D "LINKEDSTYLES" #CS_OBJS = "LYHash.obj" "LYStyle.obj" +# Uncomment SOCK_DEFS if you wish to build with winsock2. +#SOCK_DEFS = /D "USE_WINSOCK2_H" + INCLUDES = \ /I "." \ /I "$(SRC_DIR)" \ /I "$(SRC_DIR)\chrtrans" \ /I "$(WWW_DIR)" \ /I "$(ETC_LIB)" -DEFS = $(CS_DEFS) \ +DEFS = $(CS_DEFS) $(SOCK_DEFS) \ /D "__WIN32__" \ /D "_CONSOLE" \ /D "_MBCS" \ @@ -69,7 +72,7 @@ LIBS = kernel32.lib user32.lib wsock32.lib /NODEFAULTLIB:libc\ $(ETC_LIB)\pdcurses.lib $(ETC_LIB)\zlib.lib dirent.obj COMPILE = $(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -LINK = $(LD) $(LDFLAGS) /out:$@ +LINK = $(LD) $(LDFLAGS) /map:lynx.map /out:$@ OBJS = $(CS_OBJS) \ "DefaultStyle.obj" \ @@ -159,6 +162,7 @@ OBJS = $(CS_OBJS) \ all : lynx.exe clean : + -del *.map -del *.obj lynx.exe: $(OBJS) dirent.obj diff --git a/src/GridText.c b/src/GridText.c index dc68cf1b..57eed192 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1085,7 +1085,7 @@ PRIVATE int display_line ARGS4( HTLine *, line, HText *, text, int, scrline GCC_UNUSED, - CONST char*, target) + CONST char*, target GCC_UNUSED) { register int i, j; char buffer[7]; @@ -2788,12 +2788,11 @@ PRIVATE void split_line ARGS2( inew ++; for (n = 0; n < line->numstyles; n++) line->styles[n] = line->styles[n + inew]; - } else - if (line->numstyles == 0) - /* FIXME: RJP - shouldn't use 0xffffffff for largest integer */ - line->styles[0].horizpos = 0xffffffff; + } else if (line->numstyles == 0) { + line->styles[0].horizpos = ~0; + } if (previous->numstyles == 0) - previous->styles[0].horizpos = 0xffffffff; + previous->styles[0].horizpos = ~0; #endif /*USE_COLOR_STYLE*/ temp = (HTLine *)LY_CALLOC(1, LINE_SIZE(previous->size)); @@ -6906,25 +6905,23 @@ PUBLIC void HTCheckFnameForCompression ARGS3( { char *fn = *fname; char *dot = NULL, *cp = NULL; + char *suffix; CONST char *ct = NULL; CONST char *ce = NULL; - BOOLEAN method = 0; + CompressFileType method = cftNone; + CompressFileType second; /* * Make sure we have a string and anchor. - FM */ - if (!(fn && *fn && anchor)) + if (!(fn && anchor)) return; /* * Make sure we have a file, not directory, name. -FM */ - if ((cp = strrchr(fn, '/')) != NULL) { - fn = (cp +1); - if (*fn == '\0') { - return; - } - } + if (*(fn = LYPathLeaf(fn)) == '\0') + return; /* * Check the anchor's content_type and content_encoding @@ -6932,32 +6929,32 @@ PUBLIC void HTCheckFnameForCompression ARGS3( */ ct = HTAnchor_content_type(anchor); ce = HTAnchor_content_encoding(anchor); - if (ce == NULL) { + if (ce == NULL && ct != 0) { /* * No Content-Encoding, so check * the Content-Type. - FM */ - if (!strncasecomp((ct ? ct : ""), "application/gzip", 16) || - !strncasecomp((ct ? ct : ""), "application/x-gzip", 18)) { - method = 1; - } else if (!strncasecomp((ct ? ct : ""), - "application/compress", 20) || - !strncasecomp((ct ? ct : ""), - "application/x-compress", 22)) { - method = 2; - } - } else if (!strcasecomp(ce, "gzip") || - !strcasecomp(ce, "x-gzip")) { - /* - * It's gzipped. - FM - */ - method = 1; - } else if (!strcasecomp(ce, "compress") || - !strcasecomp(ce, "x-compress")) { - /* - * It's Unix compressed. - FM - */ - method = 2; + if (!strncasecomp(ct, "application/gzip", 16) || + !strncasecomp(ct, "application/x-gzip", 18)) { + method = cftGzip; + } else if (!strncasecomp(ct, "application/compress", 20) || + !strncasecomp(ct, "application/x-compress", 22)) { + method = cftCompress; + } else if (!strncasecomp(ct, "application/bzip2", 17) || + !strncasecomp(ct, "application/x-bzip2", 19)) { + method = cftBzip2; + } + } else if (ce != 0) { + if (!strcasecomp(ce, "gzip") || + !strcasecomp(ce, "x-gzip")) { + method = cftGzip; + } else if (!strcasecomp(ce, "compress") || + !strcasecomp(ce, "x-compress")) { + method = cftCompress; + } else if (!strcasecomp(ce, "bzip2") || + !strcasecomp(ce, "x-bzip2")) { + method = cftBzip2; + } } /* @@ -6965,121 +6962,96 @@ PUBLIC void HTCheckFnameForCompression ARGS3( * pointer, but strip_ok is not set, there is nothing left * to do. - kw */ - if (method == 0 && !strip_ok) + if ((method == cftNone) && !strip_ok) + return; + + /* + * Treat .tgz specially + */ + if ((dot = strrchr(fn, '.')) != NULL + && !strcasecomp(dot, ".tgz")) { + if (method == cftNone) { + strcpy(dot, ".tar"); + } return; + } /* * Seek the last dot, and check whether * we have a gzip or compress suffix. - FM */ if ((dot = strrchr(fn, '.')) != NULL) { - if (!strcasecomp(dot, ".tgz") || - !strcasecomp(dot, ".gz") || - !strcasecomp(dot, ".Z")) { - if (!method) { + if (HTCompressFileType(fn, ".", &cp) != cftNone) { + if (method == cftNone) { /* * It has a suffix which signifies a gzipped * or compressed file for us, but the anchor * claims otherwise, so tweak the suffix. - FM */ - cp = (dot + 1); *dot = '\0'; - if (!strcasecomp(cp, "tgz")) { - StrAllocCat(*fname, ".tar"); - } } return; } - if (strlen(dot) > 4) { - cp = ((dot + strlen(dot)) - 3); - if (!strcasecomp(cp, "-gz") || - !strcasecomp(cp, "_gz")) { - if (!method) { - /* - * It has a tail which signifies a gzipped - * file for us, but the anchor claims otherwise, - * so tweak the suffix. - FM - */ - if (cp == dot+1) - cp--; - *cp = '\0'; - } else { - /* - * The anchor claims it's gzipped, and we - * believe it, so force this tail to the - * conventional suffix. - FM - */ -#ifdef VMS - *cp = '-'; -#else - *cp = '.'; -#endif /* VMS */ - cp++; - *cp = (char) TOLOWER(*cp); - cp++; - *cp = (char) TOLOWER(*cp); - } - return; - } - } - if (strlen(dot) > 3) { - cp = ((dot + strlen(dot)) - 2); - if (!strcasecomp(cp, "-Z") || - !strcasecomp(cp, "_Z")) { - if (!method) { - /* - * It has a tail which signifies a compressed - * file for us, but the anchor claims otherwise, - * so tweak the suffix. - FM - */ - if (cp == dot+1) - cp--; - *cp = '\0'; - } else { - /* - * The anchor claims it's compressed, and - * we believe it, so force this tail to the - * conventional suffix. - FM - */ + if ((second = HTCompressFileType(fn, "-_", &cp)) != cftNone) { + if (method == cftNone) { + /* + * It has a tail which signifies a gzipped + * file for us, but the anchor claims otherwise, + * so tweak the suffix. - FM + */ + if (cp == dot+1) + cp--; + *cp = '\0'; + } else { + /* + * The anchor claims it's gzipped, and we + * believe it, so force this tail to the + * conventional suffix. - FM + */ #ifdef VMS - *cp = '-'; + *cp = '-'; #else - *cp = '.'; + *cp = '.'; #endif /* VMS */ - cp++; - *cp = (char) TOUPPER(*cp); - } - return; + if (second == cftCompress) + LYUpperCase(cp); + else + LYLowerCase(cp); } + return; } } - if (!method) { - /* - * Don't know what compression method - * was used, if any, so we won't do - * anything. - FM - */ - return; + + switch (method) { + default: + suffix = ""; + break; + case cftCompress: + suffix = ".Z"; + break; + case cftGzip: + suffix = ".gz"; + break; + case cftBzip2: + suffix = ".bz2"; + break; } /* * Add the appropriate suffix. - FM */ - if (!dot) { - StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z")); - return; - } - dot++; - if (*dot == '\0') { - StrAllocCat(*fname, ((method == 1) ? "gz" : "Z")); - return; - } + if (*suffix) { + if (!dot) { + StrAllocCat(*fname, suffix); + } else if (*++dot == '\0') { + StrAllocCat(*fname, suffix + 1); + } else { + StrAllocCat(*fname, suffix); #ifdef VMS - StrAllocCat(*fname, ((method == 1) ? "-gz" : "-Z")); -#else - StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z")); + (*fname)[strlen(*fname) - strlen(suffix)] = '-'; #endif /* !VMS */ - return; + } + } } /* diff --git a/src/HTFWriter.c b/src/HTFWriter.c index c5e6fbf8..6329cdc0 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -579,8 +579,9 @@ PRIVATE char *mailcap_substitute ARGS3( /* if we don't have a "%s" token, expect to provide the file via stdin */ if (strstr(pres->command, "%s") == 0) { char *prepend = 0; - HTAddParam(&prepend, "cat %s", 1, fnam); /* ...to quote if needed */ - HTSprintf(&prepend, "|%s", pres->command); /* ...avoid quoting */ + char *format = "( %s ) < %s"; + HTSprintf(&prepend, "( %s", pres->command); /* ...avoid quoting */ + HTAddParam(&prepend, format, 2, fnam); /* ...to quote if needed */ FREE(result); result = prepend; } @@ -706,7 +707,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( StrAllocCopy(me->viewer_command, pres->command); - me->end_command = mailcap_substitute(anchor, pres, view_fnam); + me->end_command = mailcap_substitute(anchor, pres, view_fname); me->remove_command = NULL; return me; @@ -1029,6 +1030,7 @@ PUBLIC HTStream* HTCompressed ARGS3( * or a download request, in which case we won't bother to * uncompress the file. - FM */ + CTRACE((tfp, "FIXME %s @%d\n", __FILE__, __LINE__)); if (!(anchor && anchor->content_encoding && anchor->content_type)) { /* * We have no idea what we're dealing with, @@ -1039,10 +1041,16 @@ PUBLIC HTStream* HTCompressed ARGS3( return me; } n = HTList_count(HTPresentations); + CTRACE((tfp, "FIXME %s @%d\n", __FILE__, __LINE__)); for (i = 0; i < n; i++) { Pres = (HTPresentation *)HTList_objectAt(HTPresentations, i); + CTRACE((tfp, "FIXME %s @%d '%s', '%s' (%s)\n", __FILE__, __LINE__, + Pres->rep->name, + anchor->content_type, + anchor->content_encoding)); if (!strcasecomp(Pres->rep->name, anchor->content_type) && Pres->rep_out == WWW_PRESENT) { + CTRACE((tfp, "FIXME %s @%d\n", __FILE__, __LINE__)); /* * We have a presentation mapping for it. - FM */ @@ -1057,7 +1065,7 @@ PUBLIC HTStream* HTCompressed ARGS3( compress_suffix = "gz"; #ifdef BZIP2_PATH } else if (!strcasecomp(anchor->content_encoding, "x-bzip2") || - !strcasecomp(anchor->content_encoding, "bzip")) { + !strcasecomp(anchor->content_encoding, "bzip2")) { StrAllocCopy(uncompress_mask, BZIP2_PATH); StrAllocCat(uncompress_mask, " -d %s"); compress_suffix = "bz2"; diff --git a/src/HTInit.c b/src/HTInit.c index b86ade2d..9ec737b0 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -816,7 +816,7 @@ PUBLIC void HTFileInit NOARGS HTSetSuffix(".bz2", "application/x-bzip2", "binary", 1.0); - HTSetSuffix(".bz2", "application/x-bzip2", "binary", 1.0); + HTSetSuffix(".bz2", "application/bzip2", "binary", 1.0); #ifdef TRADITIONAL_SUFFIXES HTSetSuffix(".uu", "application/x-UUencoded", "8bit", 1.0); diff --git a/src/LYCurses.c b/src/LYCurses.c index 14f8e0b2..41cc1946 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1031,7 +1031,7 @@ PUBLIC void lynx_enable_mouse ARGS1(int,state) #if defined(PDCURSES) if (state) mouse_set( - BUTTON1_CLICKED | BUTTON1_PRESSED | BUTTON1_RELEASED | + BUTTON1_CLICKED | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON2_CLICKED | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON3_CLICKED | BUTTON3_PRESSED | BUTTON3_RELEASED); #endif @@ -1066,7 +1066,7 @@ PUBLIC void stop_curses NOARGS if(LYscreen) { endwin(); /* stop curses */ LYDELSCR(); - } + } #endif } #ifdef SH_EX @@ -1102,7 +1102,7 @@ PUBLIC void stop_curses NOARGS * Check terminal type, start curses & setup terminal. */ PUBLIC BOOLEAN setup ARGS1( - char *, terminal) + char *, terminal) { int c; int status; @@ -1180,7 +1180,7 @@ PUBLIC BOOLEAN setup ARGS1( * Check terminal type, start curses & setup terminal. */ PUBLIC BOOLEAN setup ARGS1( - char *, terminal) + char *, terminal) { char *term_putenv = NULL; char *buffer = NULL; @@ -1310,7 +1310,7 @@ PUBLIC BOOLEAN setup ARGS1( } PRIVATE int dumbterm ARGS1( - char *, terminal) + char *, terminal) { int dumb = FALSE; @@ -1547,11 +1547,11 @@ PUBLIC void LYwaddnstr ARGS3( #define EFN 0 /* Event flag */ -static unsigned char buffer[20]; /* Input buffer */ -static int in_pos, in_len; /* For escape sequences */ +static unsigned char buffer[20]; /* Input buffer */ +static int in_pos, in_len; /* For escape sequences */ static int oldmode[3]; /* Old TTY mode bits */ static int newmode[3]; /* New TTY mode bits */ -static short iochan; /* TTY I/O channel */ +static short iochan; /* TTY I/O channel */ static $DESCRIPTOR(term_nam_dsc,"TT"); /* Descriptor for iochan */ static unsigned long mask = LIB$M_CLI_CTRLY|LIB$M_CLI_CTRLT; /* ^Y and ^T */ static unsigned long old_msk; /* Saved control mask */ @@ -1560,7 +1560,7 @@ BOOLEAN DidCleanup = FALSE; /* Exit handler flag */ static char VersionVMS[20]; /* Version of VMS */ PUBLIC int VMSVersion ARGS2( - char *, VerString, + char *, VerString, int, VerLen) { unsigned long status, itm_cod = SYI$_VERSION; @@ -1880,12 +1880,12 @@ void (*func)(); */ #ifdef __DECC PRIVATE unsigned int DCLspawn_exception ARGS2( - void *, sigarr, - void *, mecharr) + void *, sigarr, + void *, mecharr) #else PRIVATE int DCLspawn_exception ARGS2( - void *, sigarr, - void *, mecharr) + void *, sigarr, + void *, mecharr) #endif /* __DECC */ { int status; @@ -1895,7 +1895,7 @@ PRIVATE int DCLspawn_exception ARGS2( } PRIVATE int spawn_DCLprocess ARGS1( - char *, command) + char *, command) { int status; unsigned long Status = 0; @@ -1945,7 +1945,7 @@ PRIVATE int spawn_DCLprocess ARGS1( } PUBLIC int DCLsystem ARGS1( - char *, command) + char *, command) { int status; extern void controlc(); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 3def0c78..f03d7cf2 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -38,30 +38,7 @@ #include <HTChunk.h> #endif -/* - * Ifdef's in case we have a working popen/pclose, useful for piping to the - * mail program. - */ -#if !defined(HAVE_POPEN) || defined(VMS) || defined(DOSPATH) || defined(__CYGWIN__) -#define CAN_PIPE_TO_MAILER 0 -#else -#define CAN_PIPE_TO_MAILER 1 -#endif - -/* - * Ifdef's for specific mailers: - */ -#ifdef VMS -#define USE_PMDF_MAILER 1 -#else -#define USE_PMDF_MAILER 0 -#endif - -#ifdef SH_EX -#define USE_BLAT_MAILER 1 -#else -#define USE_BLAT_MAILER 0 -#endif +#include <LYMail.h> /* to get ifdef's for mail-variables */ #ifdef SOCKS extern BOOLEAN socks_flag; @@ -71,7 +48,7 @@ extern BOOLEAN socks_flag; extern BOOLEAN sigint; #endif /* IGNORE_CTRL_C */ -#ifdef VMS +#if USE_VMS_MAILER extern char *mail_adrs; extern BOOLEAN UseFixedRecords; /* convert binary files to FIXED 512 records */ #endif /* VMS */ diff --git a/src/LYKeymap.c b/src/LYKeymap.c index a94749b2..b36d0ebf 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1055,7 +1055,7 @@ PUBLIC HTList *LYcommandList NOARGS myList = HTList_new(); for (j = 0; revmap[j].name != 0; j++) { if (revmap[j].doc != 0) - HTList_addObject(myList, revmap[j].name); + HTList_addObject(myList, (char *)revmap[j].name); } } return myList; diff --git a/src/LYMail.c b/src/LYMail.c index d586cf8a..8cda4971 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -13,13 +13,301 @@ #include <LYLeaks.h> +#define MAX_SUBJECT 70 +#define EMPTY(s) ((s) == 0 || *(s) == 0) +#define NIL_OK(s) (((s) != 0) ? (s) : "<nil>") + BOOLEAN term_letter; /* Global variable for async i/o. */ -PRIVATE void terminate_letter PARAMS((int sig)); -PRIVATE void remove_tildes PARAMS((char *string)); -#ifdef _WINDOWS -#define system(p) xsystem(p) /* 1998/06/05 (Fri) 21:53:30 */ -#endif +PRIVATE void terminate_letter ARGS1(int,sig GCC_UNUSED) +{ + term_letter = TRUE; + /* Reassert the AST */ + signal(SIGINT, terminate_letter); +#if USE_VMS_MAILER || defined(DOSPATH) || defined(WIN_EX) + /* + * Refresh the screen to get rid of the "interrupt" message. + */ + if (!dump_output_immediately) { + lynx_force_repaint(); + refresh(); + } +#endif /* VMS */ +} + +/* HTUnEscape with control-code nuking */ +PRIVATE void SafeHTUnEscape ARGS1( + char *, string) +{ + int i; + int flg = FALSE; + + HTUnEscape(string); + for (i=0; string[i] != '\0'; i++) + { + /* FIXME: this is no longer explicitly 7-bit ASCII, + but are there portability problems? */ + if ((!LYIsASCII(string[i])) || !isprint(string[i])) + { + string[i] = '?'; + flg = TRUE; + } + } + if (flg) + HTAlert(MAILTO_SQUASH_CTL); +} + +PRIVATE void remove_tildes ARGS1(char *,string) +{ + /* + * Change the first character to + * a space if it is a '~'. + */ + if (*string == '~') + *string = ' '; +} + +PRIVATE void comma_append ARGS2( + char **, dst, + char *, src) +{ + if (*src) { + while (*src == ',' || isspace((unsigned char)*src)) + src++; + if (*src) { + if (EMPTY(*dst)) { + StrAllocCopy(*dst, src); + } else { + StrAllocCat(*dst, ","); + StrAllocCat(*dst, src); + } + } + } +} + +PRIVATE void extract_field ARGS3( + char **, dst, + char *, src, + char *, keyword) +{ + int len = strlen(keyword); + char *cp, *cp1; + + cp = (src + 1); + while (*cp != '\0') { + if ((*(cp - 1) == '?' || *(cp - 1) == '&') && + !strncasecomp(cp, keyword, len)) { + cp += len; + if ((cp1 = strchr(cp, '&')) != NULL) { + *cp1 = '\0'; + } + comma_append(dst, cp); + if (cp1) { + *cp1 = '&'; + cp = cp1; + cp1 = NULL; + } else { + break; + } + } + cp++; + } + CTRACE((tfp, "extract_field(%s) = '%s'\n", keyword, NIL_OK(*dst))); +} + +/* + * Seek and handle a subject=foo. - FM + */ +PRIVATE void extract_subject ARGS2( + char *, dst, + char *, src) +{ + CONST char *keyword = "subject="; + int len = strlen(keyword); + char *cp, *cp1; + + cp = (src + 1); + while (*cp != '\0') { + if ((*(cp - 1) == '?' || *(cp - 1) == '&') && + !strncasecomp(cp, keyword, len)) + break; + cp++; + } + if (*cp) { + cp += len; + if ((cp1 = strchr(cp, '&')) != NULL) { + *cp1 = '\0'; + } + if (*cp) { + strncpy(dst, cp, MAX_SUBJECT); + dst[MAX_SUBJECT] = '\0'; + SafeHTUnEscape(dst); + } + if (cp1) { + *cp1 = '&'; + cp1 = NULL; + } + } + CTRACE((tfp, "extract_subject(%s) = '%s'\n", keyword, NIL_OK(dst))); +} + +/* + * Seek and handle body=foo fields. - FM + */ +PRIVATE void extract_body ARGS2( + char **, dst, + char *, src) +{ + CONST char *keyword = "body="; + int len = strlen(keyword); + int i; + char *cp, *cp0, *cp1, *temp = 0; + + cp = (src + 1); + while (*cp != '\0') { + if ((*(cp - 1) == '?' || *(cp - 1) == '&') && + !strncasecomp(cp, keyword, len)) { + cp += len; + if ((cp1 = strchr(cp, '&')) != NULL) { + *cp1 = '\0'; + } + if (*cp) { + /* + * Break up the value into lines with + * a maximum length of 78. - FM + */ + StrAllocCopy(temp, cp); + HTUnEscape(temp); + cp0 = temp; + while((cp = strchr(cp0, '\n')) != NULL) { + *cp = '\0'; + if (cp > cp0) { + if (*(cp - 1) == '\r') { + *(cp - 1) = '\0'; + } + } + i = 0; + len = strlen(cp0); + while (len > 78) { + HTSprintf(dst, "%.78s\n", &cp0[i]); + i += 78; + len = strlen(&cp0[i]); + } + HTSprintf(dst, "%s\n", &cp0[i]); + cp0 = (cp + 1); + } + i = 0; + len = strlen(cp0); + while (len > 78) { + HTSprintf(dst, "%.78s\n", &cp0[i]); + i += 78; + len = strlen(&cp0[i]); + } + if (len) { + HTSprintf(dst, "%s\n", &cp0[i]); + } + FREE(temp); + } + if (cp1) { + *cp1 = '&'; + cp = cp1; + cp1 = NULL; + } else { + break; + } + } + cp++; + } + CTRACE((tfp, "extract_body(%s) = '%s'\n", keyword, NIL_OK(*dst))); +} + +/* + * Convert any Explorer semi-colon Internet address separators to commas - FM + */ +PRIVATE BOOLEAN trim_comma ARGS1( + char *, address) +{ + if (address[(strlen(address) - 1)] == ',') + address[(strlen(address) - 1)] = '\0'; + return *address == '\0'; +} + +/* + * Convert any Explorer semi-colon Internet address separators to commas - FM + */ +PRIVATE BOOLEAN convert_explorer ARGS1( + char *, address) +{ + char *cp = address; + char *cp0; + char *cp1; + + while ((cp1 = strchr(cp, '@')) != NULL) { + cp1++; + if ((cp0 = strchr(cp1, ';')) != NULL) { + *cp0 = ','; + cp1 = cp0 + 1; + } + cp = cp1; + } + return trim_comma(address); +} + +/* + * reply_by_mail() prompts line-by-line for header information, allowing + * scrolling of the screen. + */ +PRIVATE int header_prompt ARGS3( + char *, label, + char **, result, + unsigned, limit) +{ + char buffer[LINESIZE]; + int ok; + + if (*result != 0) { + addstr(CTRL_U_TO_ERASE); + LYstrncpy(buffer, *result, sizeof(buffer)-1); + } else + *buffer = 0; + + if (limit > sizeof(buffer)) + limit = sizeof(buffer); + + printw("%s: ", gettext(label)); + ok = (LYgetstr(buffer, VISIBLE, limit, NORECALL) >= 0 + && !term_letter); + addstr("\n"); + + if (ok) { + remove_tildes(buffer); + StrAllocCopy(*result, buffer); + } + term_letter = FALSE; + return ok; +} + +PRIVATE void show_addresses ARGS1( + char *, addresses) +{ + char *cp = addresses; + char *cp1; + + while ((cp1 = strchr(cp, ',')) != NULL) { + *cp1 = '\0'; + while (*cp == ' ') + cp++; + if (*cp) { + addstr(cp); + addstr(",\n "); + } + *cp1 = ','; + cp = (cp1 + 1); + } + if (*cp) { + addstr(cp); + } +} #if USE_BLAT_MAILER @@ -41,7 +329,6 @@ Blat <filename> -t <recipient> [optional switches (see below)] */ - PRIVATE char *blat_cmd( char *mail_cmd, char *filename, @@ -87,10 +374,10 @@ PRIVATE char *blat_cmd( fprintf(fp, "-t\n%s\n", address); if (subject) fprintf(fp, "-s\n%s\n", subject); - if (mail_addr && strlen(mail_addr) > 0) { + if (!EMPTY(mail_addr)) { fprintf(fp, "-f\n%s\n", mail_addr); } - if (ccaddr && strlen(ccaddr) > 0) { + if (!EMPTY(ccaddr)) { fprintf(fp, "-c\n%s\n", ccaddr); } LYCloseOutput(fp); @@ -109,61 +396,157 @@ PRIVATE char *blat_cmd( #endif /* USE_BLAT_MAILER */ -/* HTUnEscape with control-code nuking */ -PRIVATE void SafeHTUnEscape ARGS1( - char *, string) +#if USE_VMS_MAILER +PUBLIC BOOLEAN LYMailPMDF(void) { - int i; - int flg = FALSE; + return !strncasecomp(system_mail, "PMDF SEND", 9); +} - HTUnEscape(string); - for (i=0; string[i] != '\0'; i++) - { - /* FIXME: this is no longer explicitly 7-bit ASCII, - but are there portability problems? */ - if ((!LYIsASCII(string[i])) || !isprint(string[i])) - { - string[i] = '?'; - flg = TRUE; +/* + * Add all of the people in the address field to the command + */ +PRIVATE void vms_append_addrs (char **cmd, char *address, char *option) +{ + BOOLEAN first = TRUE; + char *cp; + char *address_ptr1; + char *address_ptr2; + + address_ptr1 = address; + do { + if ((cp = strchr(address_ptr1, ',')) != NULL) { + address_ptr2 = (cp+1); + *cp = '\0'; + } else { + address_ptr2 = NULL; } - } - if (flg) - HTAlert(MAILTO_SQUASH_CTL); + + /* + * 4 letters is arbitrarily the smallest possible mail + * address, at least for lynx. That way extra spaces + * won't confuse the mailer and give a blank address. + */ + if (strlen(address_ptr1) > 3) { + if (!first) { + StrAllocCat(*cmd, ","); + } + HTSprintf(cmd, mail_adrs, address_ptr1); + if (*option && LYMailPMDF()) + StrAllocCat(*cmd, option); + first = FALSE; + } + address_ptr1 = address_ptr2; + } while (address_ptr1 != NULL); +} + +PRIVATE void remove_quotes (char * string) +{ + while (*string != 0) { + if (strchr("\"&|", *string) != 0) + *string = ' '; + string++; + } +} +#else +#if CAN_PIPE_TO_MAILER + +/* + * Open a pipe to the mailer + */ +PUBLIC FILE *LYPipeToMailer NOARGS +{ + char *buffer = NULL; + FILE *fp; + + HTSprintf0(&buffer, "%s %s", system_mail, system_mail_flags); + fp = popen(buffer, "w"); + CTRACE((tfp, "popen(%s) %s\n", buffer, fp != 0 ? "OK" : "FAIL")); + FREE(buffer); + return fp; +} +#else /* DOS, Win32, etc. */ + +PUBLIC int LYSendMailFile ARGS5( + char *, the_address, + char *, the_filename, + char *, the_subject GCC_UNUSED, + char *, the_ccaddr GCC_UNUSED, + char *, message) +{ + char *cmd = NULL; + int code; + +#if USE_BLAT_MAILER + if (mail_is_blat) + StrAllocCopy(cmd, + blat_cmd( + system_mail, + the_filename, + the_address, + the_subject, + the_ccaddr, + personal_mail_address + ) + ); + else +#endif + HTSprintf0(&cmd, "%s -t \"%s\" -F %s", + system_mail, + the_address, + the_filename); + + stop_curses(); + SetOutputMode(O_TEXT); + printf("%s\n\n$ %s\n\n%s", + *message ? message : gettext("Sending"), + cmd, PLEASE_WAIT); + code = LYSystem(cmd); + LYSleepMsg(); + start_curses(); + SetOutputMode( O_BINARY ); + + FREE(cmd); + + return code; } +#endif /* CAN_PIPE_TO_FILE */ +#endif /* USE_VMS_MAILER */ /* ** mailform() sends form content to the mailto address(es). - FM */ PUBLIC void mailform ARGS4( - CONST char *, mailto_address, - CONST char *, mailto_subject, - CONST char *, mailto_content, - CONST char *, mailto_type) + CONST char *, mailto_address, + CONST char *, mailto_subject, + CONST char *, mailto_content, + CONST char *, mailto_type) { - static char *cmd; FILE *fd; char *address = NULL; char *ccaddr = NULL; char *keywords = NULL; char *cp = NULL; - char self[80]; - char subject[80]; + char self[MAX_SUBJECT + 10]; + char subject[MAX_SUBJECT + 10]; char *searchpart = NULL; char buf[512]; - char *cp0 = NULL, *cp1 = NULL; int ch, len, i; -#ifdef VMS - char *address_ptr1, *address_ptr2; - BOOLEAN isPMDF = !strncasecomp(system_mail, "PMDF SEND", 9); - BOOLEAN first = TRUE; - FILE *hfd; +#if USE_VMS_MAILER + static char *cmd; + char *command = NULL; + BOOLEAN isPMDF = LYMailPMDF(); char hdrfile[LY_MAXPATH]; #endif #if !CAN_PIPE_TO_MAILER - char *command = NULL; char my_tmpfile[LY_MAXPATH]; #endif + CTRACE((tfp, "mailform(\"%s\", \"%s\", \"%s\", \"%s\")\n", + NIL_OK(mailto_address), + NIL_OK(mailto_subject), + NIL_OK(mailto_content), + NIL_OK(mailto_type))); + if (!mailto_address || !mailto_content) { HTAlert(BAD_FORM_MAILTO); return; @@ -186,123 +569,26 @@ PUBLIC void mailform ARGS4( /* * Seek and handle a subject=foo. - FM */ - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "subject=", 8)) - break; - cp++; - } - if (*cp) { - cp += 8; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - if (*cp) { - SafeHTUnEscape(subject); - LYstrncpy(subject, cp, 70); - } - if (cp1) { - *cp1 = '&'; - cp1 = NULL; - } - } + extract_subject(subject, searchpart); /* * Seek and handle to=address(es) fields. * Appends to address. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "to=", 3)) { - cp += 3; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (*address) { - StrAllocCat(address, ","); - } - StrAllocCat(address, cp); - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&address, searchpart, "to="); /* * Seek and handle cc=address(es) fields. Excludes * Bcc=address(es) as unsafe. We may append our own * cc (below) as a list for the actual mailing. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "cc=", 3)) { - cp += 3; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (ccaddr == NULL) { - StrAllocCopy(ccaddr, cp); - } else { - StrAllocCat(ccaddr, ","); - StrAllocCat(ccaddr, cp); - } - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&ccaddr, searchpart, "cc="); /* * Seek and handle keywords=term(s) fields. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "keywords=", 9)) { - cp += 9; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (keywords == NULL) { - StrAllocCopy(keywords, cp); - } else { - StrAllocCat(keywords, cp); - StrAllocCat(keywords, ", "); - } - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&keywords, searchpart, "keywords="); + if (keywords != NULL) { if (*keywords != '\0') { SafeHTUnEscape(keywords); @@ -315,42 +601,12 @@ PUBLIC void mailform ARGS4( } } - /* - * Convert any Explorer semi-colon Internet address - * separators to commas. - FM - */ - cp = address; - while ((cp1 = strchr(cp, '@')) != NULL) { - cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { - *cp0 = ','; - cp1 = cp0 + 1; - } - cp = cp1; - } - if (address[(strlen(address) - 1)] == ',') - address[(strlen(address) - 1)] = '\0'; - if (*address == '\0') { - FREE(address); - FREE(ccaddr); - FREE(keywords); + if (convert_explorer(address)) { HTAlert(BAD_FORM_MAILTO); - return; + goto cleanup; } if (ccaddr != NULL) { - cp = ccaddr; - while ((cp1 = strchr(cp, '@')) != NULL) { - cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { - *cp0 = ','; - cp1 = cp0 + 1; - } - cp = cp1; - } - if (ccaddr[(strlen(ccaddr) - 1)] == ',') { - ccaddr[(strlen(ccaddr) - 1)] = '\0'; - } - if (*ccaddr == '\0') { + if (convert_explorer(ccaddr)) { FREE(ccaddr); } } @@ -366,24 +622,20 @@ PUBLIC void mailform ARGS4( /* * Allow user to edit the default Subject - FM */ - if (subject[0] == '\0') { - if (mailto_subject && *mailto_subject) { - LYstrncpy(subject, mailto_subject, 70); + if (EMPTY(subject)) { + if (!EMPTY(mailto_subject)) { + LYstrncpy(subject, mailto_subject, MAX_SUBJECT); } else { - strcpy(subject, "mailto:"); - LYstrncpy((char*)&subject[7], address, 63); + sprintf(subject, "mailto:%.63s", address); } } _statusline(SUBJECT_PROMPT); - if ((ch = LYgetstr(subject, VISIBLE, 71, NORECALL)) < 0) { + if ((ch = LYgetstr(subject, VISIBLE, MAX_SUBJECT, NORECALL)) < 0) { /* * User cancelled via ^G. - FM */ HTInfoMsg(FORM_MAILTO_CANCELLED); - FREE(address); - FREE(ccaddr); - FREE(keywords); - return; + goto cleanup; } /* @@ -391,19 +643,15 @@ PUBLIC void mailform ARGS4( * entry, if permitted. - FM */ if (!LYNoCc) { - sprintf(self, "%.79s", (personal_mail_address ? - personal_mail_address : "")); - self[79] = '\0'; + sprintf(self, "%.*s", MAX_SUBJECT, + EMPTY(personal_mail_address) ? "" : personal_mail_address); _statusline("Cc: "); - if ((ch = LYgetstr(self, VISIBLE, sizeof(self), NORECALL)) < 0) { + if ((ch = LYgetstr(self, VISIBLE, MAX_SUBJECT, NORECALL)) < 0) { /* * User cancelled via ^G. - FM */ HTInfoMsg(FORM_MAILTO_CANCELLED); - FREE(address); - FREE(ccaddr); - FREE(keywords); - return; + goto cleanup; } remove_tildes(self); if (ccaddr == NULL) { @@ -415,54 +663,52 @@ PUBLIC void mailform ARGS4( } #if CAN_PIPE_TO_MAILER - HTSprintf0(&cmd, "%s %s", system_mail, system_mail_flags); - if ((fd = popen(cmd, "w")) == NULL) { + if ((fd = LYPipeToMailer()) == 0) { HTAlert(FORM_MAILTO_FAILED); - FREE(address); - FREE(ccaddr); - FREE(keywords); - return; + goto cleanup; } - if (mailto_type && *mailto_type) { + if (!EMPTY(mailto_type)) { fprintf(fd, "Mime-Version: 1.0\n"); fprintf(fd, "Content-Type: %s\n", mailto_type); } fprintf(fd, "To: %s\n", address); - if (personal_mail_address && *personal_mail_address) + if (!EMPTY(personal_mail_address)) fprintf(fd, "From: %s\n", personal_mail_address); - if (ccaddr != NULL && *ccaddr != '\0') + if (!EMPTY(ccaddr)) fprintf(fd, "Cc: %s\n", ccaddr); fprintf(fd, "Subject: %s\n\n", subject); - if (keywords != NULL && *keywords != '\0') + if (!EMPTY(keywords)) fprintf(fd, "Keywords: %s\n", keywords); _statusline(SENDING_FORM_CONTENT); #else /* e.g., VMS, DOSPATH */ if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); - FREE(address); - FREE(ccaddr); - FREE(keywords); - return; + goto cleanup; } -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF) { + FILE *hfd; if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(FORM_MAILTO_FAILED); LYCloseTempFP(fd); - FREE(address); - FREE(ccaddr); - FREE(keywords); - return; + goto cleanup; } - } - if (isPMDF) { - if (mailto_type && *mailto_type) { + if (!EMPTY(mailto_type)) { fprintf(hfd, "Mime-Version: 1.0\n"); fprintf(hfd, "Content-Type: %s\n", mailto_type); - if (personal_mail_address && *personal_mail_address) + if (!EMPTY(personal_mail_address)) fprintf(hfd, "From: %s\n", personal_mail_address); - } + } + /* + * For PMDF, put any keywords and the subject + * in the header file and close it. - FM + */ + if (!EMPTY(keywords)) { + fprintf(hfd, "Keywords: %s\n", keywords); + } + fprintf(hfd, "Subject: %s\n\n", subject); + LYCloseTempFP(hfd); } else if (mailto_type && !strncasecomp(mailto_type, "multipart/form-data", 19)) { /* @@ -475,19 +721,18 @@ PUBLIC void mailform ARGS4( #else /* !VMS (DOS) */ #if USE_BLAT_MAILER if (mail_is_blat) { - if (strlen(subject) > 70) - subject[70] = '\0'; + if (strlen(subject) > MAX_SUBJECT) + subject[MAX_SUBJECT] = '\0'; } else #endif { - if (mailto_type && *mailto_type) { + if (!EMPTY(mailto_type)) { fprintf(fd, "Mime-Version: 1.0\n"); fprintf(fd, "Content-Type: %s\n", mailto_type); } fprintf(fd,"To: %s\n", address); - if (personal_mail_address && *personal_mail_address) + if (!EMPTY(personal_mail_address)) fprintf(fd,"From: %s\n", personal_mail_address); - remove_tildes(self); fprintf(fd,"Subject: %.70s\n\n", subject); } #endif /* VMS */ @@ -528,24 +773,14 @@ PUBLIC void mailform ARGS4( #if CAN_PIPE_TO_MAILER pclose(fd); LYSleepMsg(); -#endif /* UNIX */ -#if defined(VMS) || defined(DOSPATH) || defined(SH_EX) +#else LYCloseTempFP(fd); -#ifdef VMS +#if USE_VMS_MAILER /* * Set the mail command. - FM */ if (isPMDF) { /* - * For PMDF, put any keywords and the subject - * in the header file and close it. - FM - */ - if (keywords != NULL && *keywords != '\0') { - fprintf(hfd, "Keywords: %s\n", keywords); - } - fprintf(hfd, "Subject: %s\n\n", subject); - LYCloseTempFP(hfd); - /* * Now set up the command. - FM */ HTSprintf0(&cmd, @@ -571,61 +806,9 @@ PUBLIC void mailform ARGS4( } StrAllocCopy(command, cmd); - /* - * Now add all the people in the address field. - FM - */ - address_ptr1 = address; - do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { - address_ptr2 = (cp+1); - *cp = '\0'; - } else { - address_ptr2 = NULL; - } - - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - */ - if (strlen(address_ptr1) > 3) { - if (!first) { - StrAllocCat(command, ","); - } - HTSprintf0(&cmd, mail_adrs, address_ptr1); - StrAllocCat(command, cmd); - first = FALSE; - } - address_ptr1 = address_ptr2; - } while (address_ptr1 != NULL); - - /* - * Now add all the people in the CC field. - FM - */ - if (ccaddr != NULL && *ccaddr != '\0') { - address_ptr1 = ccaddr; - do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { - address_ptr2 = (cp+1); - *cp = '\0'; - } else { - address_ptr2 = NULL; - } - - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - */ - if (strlen(address_ptr1) > 3) { - StrAllocCat(command, ","); - HTSprintf(&command, mail_adrs, address_ptr1); - if (isPMDF) { - StrAllocCat(command, "/CC"); - } - } - address_ptr1 = address_ptr2; - } while (address_ptr1 != NULL); + vms_append_addrs(&command, address, ""); + if (!EMPTY(ccaddr)) { + vms_append_addrs(&command, ccaddr, "/CC"); } stop_curses(); @@ -635,41 +818,20 @@ PUBLIC void mailform ARGS4( LYSleepAlert(); start_curses(); LYRemoveTemp(my_tmpfile); - LYRemoveTemp(hdrfile); + if (isPMDF) + LYRemoveTemp(hdrfile); #else /* DOSPATH */ -#if USE_BLAT_MAILER - if (mail_is_blat) { - StrAllocCopy(command, - blat_cmd( - system_mail, - my_tmpfile, - address, - subject, - ccaddr, - personal_mail_address - ) - ); - } else -#endif - { - /* for sendmail.exe */ - StrAllocCopy(command, system_mail); - StrAllocCat(command, " -t \""); - StrAllocCat(command, address); - StrAllocCat(command, "\" -F "); - StrAllocCat(command, my_tmpfile); - } - - stop_curses(); - printf("%s\n\n$ %s\n\n%s", SENDING_FORM_CONTENT, command, PLEASE_WAIT); - LYSystem(command); /* Mail sending form content (DOS/Windows) */ - FREE(command); - LYSleepMsg(); - start_curses(); + LYSendMailFile ( + address, + my_tmpfile, + subject, + ccaddr, + SENDING_FORM_CONTENT); LYRemoveTemp(my_tmpfile); -#endif -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ +#endif /* CAN_PIPE_TO_MAILER */ +cleanup: FREE(address); FREE(ccaddr); FREE(keywords); @@ -689,7 +851,7 @@ PUBLIC void mailmsg ARGS4( FILE *fd, *fp; char *address = NULL; char *searchpart = NULL; - char *cmd = NULL, *cp, *cp0, *cp1; + char *cmd = NULL, *cp; #ifdef ALERTMAIL BOOLEAN skip_parsing = FALSE; #endif @@ -698,22 +860,16 @@ PUBLIC void mailmsg ARGS4( char subject[128]; char my_tmpfile[LY_MAXPATH]; #endif -#ifdef VMS - char *address_ptr1, *address_ptr2; - BOOLEAN first = TRUE; - BOOLEAN isPMDF = FALSE; +#if USE_VMS_MAILER + BOOLEAN isPMDF = LYMailPMDF(); char hdrfile[LY_MAXPATH]; - FILE *hfd; char *command = NULL; CTRACE((tfp, "mailmsg(%d, \"%s\", \"%s\", \"%s\")\n", cur, - owner_address?owner_address:"<nil>", - filename?filename:"<nil>", - linkname?linkname:"<nil>")); + NIL_OK(owner_address), + NIL_OK(filename), + NIL_OK(linkname))); - if (!strncasecomp(system_mail, "PMDF SEND", 9)) { - isPMDF = TRUE; - } #endif /* VMS */ #ifdef ALERTMAIL @@ -760,70 +916,30 @@ PUBLIC void mailmsg ARGS4( cp = (searchpart + 1); if (*cp != '\0') { /* - * Seek and handle to=address(es) fields. - * Appends to address. We ignore any other - * headers in the ?searchpart. - FM + * Seek and handle to=address(es) fields. + * Appends to address. We ignore any other + * headers in the ?searchpart. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "to=", 3)) { - cp += 3; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (*address) { - StrAllocCat(address, ","); - } - StrAllocCat(address, cp); - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&address, searchpart, "to="); } } - /* - * Convert any Explorer semi-colon Internet address - * separators to commas. - FM - */ - cp = address; - while ((cp1 = strchr(cp, '@')) != NULL) { - cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { - *cp0 = ','; - cp1 = cp0 + 1; - } - cp = cp1; - } + convert_explorer(address); /* - * Unescape the address field. - FM + * Unescape the address field. - FM */ SafeHTUnEscape(address); } - if (address[(strlen(address) - 1)] == ',') - address[(strlen(address) - 1)] = '\0'; - if (*address == '\0') { + if (trim_comma(address)) { FREE(address); CTRACE((tfp, "mailmsg: No address in '%s'.\n", owner_address)); return; } #if CAN_PIPE_TO_MAILER - HTSprintf0(&cmd, "%s %s", system_mail, system_mail_flags); - if ((fd = popen(cmd, "w")) == NULL) { + if ((fd = LYPipeToMailer()) == 0) { FREE(address); CTRACE((tfp, "mailmsg: '%s' failed.\n", cmd)); return; @@ -831,7 +947,7 @@ PUBLIC void mailmsg ARGS4( fprintf(fd, "To: %s\n", address); fprintf(fd, "Subject: Lynx Error in %s\n", filename); - if (personal_mail_address != NULL && *personal_mail_address != '\0') { + if (!EMPTY(personal_mail_address)) { fprintf(fd, "Cc: %s\n", personal_mail_address); } fprintf(fd, "X-URL: %s\n", filename); @@ -842,24 +958,30 @@ PUBLIC void mailmsg ARGS4( FREE(address); return; } -#ifdef VMS + sprintf(subject, "Lynx Error in %.56s", filename); + ccaddr = personal_mail_address; +#if USE_VMS_MAILER if (isPMDF) { + FILE *hfd; if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { CTRACE((tfp, "mailmsg: Could not fopen '%s'.\n", hdrfile)); FREE(address); return; } - if (personal_mail_address != NULL && *personal_mail_address != '\0') { + if (!EMPTY(personal_mail_address)) { fprintf(fd, "Cc: %s\n", personal_mail_address); } fprintf(fd, "X-URL: %s\n", filename); fprintf(fd, "X-Mailer: %s, Version %s\n\n", LYNX_NAME, LYNX_VERSION); + /* + * For PMDF, put the subject in the + * header file and close it. - FM + */ + fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename); + LYCloseTempFP(hfd); } -#else /* !VMS, e.g., DOSPATH */ - sprintf(subject, "Lynx Error in %.56s", filename); - ccaddr = personal_mail_address; -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ fprintf(fd, gettext("The link %s :?: %s \n"), @@ -878,20 +1000,13 @@ PUBLIC void mailmsg ARGS4( fputs(cmd, fd); LYCloseInput(fp); } -#if defined(UNIX) && !defined(__CYGWIN__) +#if CAN_PIPE_TO_MAILER pclose(fd); -#endif /* UNIX */ -#if defined(VMS) || defined(DOSPATH) || defined(WIN_EX) +#else LYCloseTempFP(fd); -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF) { /* - * For PMDF, put the subject in the - * header file and close it. - FM - */ - fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename); - LYCloseTempFP(hfd); - /* * Now set up the command. - FM */ HTSprintf0(&command, @@ -912,27 +1027,7 @@ PUBLIC void mailmsg ARGS4( filename, my_tmpfile); } - address_ptr1 = address; - do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { - address_ptr2 = (cp+1); - *cp = '\0'; - } else - address_ptr2 = NULL; - - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - */ - if (!first) { - StrAllocCat(command, ","); - } - HTSprintf0(&cmd, mail_adrs, address_ptr1); - StrAllocCat(command, cmd); - first = FALSE; - address_ptr1 = address_ptr2; - } while (address_ptr1 != NULL); + vms_append_addrs(&command, address, ""); LYSystem(command); /* VMS */ FREE(command); @@ -942,28 +1037,15 @@ PUBLIC void mailmsg ARGS4( LYRemoveTemp(hdrfile); } #else /* DOSPATH */ -#if USE_BLAT_MAILER - if (mail_is_blat) - StrAllocCopy(cmd, - blat_cmd( - system_mail, - my_tmpfile, - address, - subject, - ccaddr, - personal_mail_address - ) - ); - else -#endif - HTSprintf0(&cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile); - - LYSystem(cmd); /* Mail (DOS/Windows) */ - FREE(cmd); - + LYSendMailFile ( + address, + my_tmpfile, + subject, + ccaddr, + ""); LYRemoveTemp(my_tmpfile); -#endif -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ +#endif /* CAN_PIPE_TO_MAILER */ if (traversal) { FILE *ofp; @@ -986,7 +1068,7 @@ PUBLIC void mailmsg ARGS4( /* ** reply_by_mail() invokes sendmail on Unix or mail on VMS to send -** a comment from the users to the owner +** a comment from the users to the owner */ PUBLIC void reply_by_mail ARGS4( char *, mail_address, @@ -994,62 +1076,58 @@ PUBLIC void reply_by_mail ARGS4( CONST char *, title, CONST char *, refid) { - char user_input[1000]; +#ifndef NO_ANONYMOUS_EMAIL + static char *personal_name = NULL; +#endif + char user_input[LINESIZE]; FILE *fd, *fp; - char *address = NULL; + char *label = NULL; + char *from_address = NULL; + char *cc_address = NULL; + char *to_address = NULL; + char *the_subject = NULL; char *ccaddr = NULL; char *keywords = NULL; char *searchpart = NULL; char *body = NULL; - char *cp = NULL, *cp0 = NULL, *cp1 = NULL; - char *temp = NULL; - int i, len; + char *cp = NULL, *cp1 = NULL; + int i; int c = 0; /* user input */ char my_tmpfile[LY_MAXPATH]; char *command = NULL; + char default_subject[MAX_SUBJECT + 10]; +#if USE_VMS_MAILER + BOOLEAN isPMDF = LYMailPMDF(); + char hdrfile[LY_MAXPATH]; + FILE *hfd = 0; +#else #if !CAN_PIPE_TO_MAILER char tmpfile2[LY_MAXPATH]; #endif -#ifndef NO_ANONYMOUS_EMAIL - static char *personal_name = NULL; -#endif - char subject[80]; -#ifdef VMS - char *address_ptr1 = NULL, *address_ptr2 = NULL; - BOOLEAN first = TRUE; - BOOLEAN isPMDF = FALSE; - char hdrfile[LY_MAXPATH]; - FILE *hfd; - - if (!strncasecomp(system_mail, "PMDF SEND", 9)) { - isPMDF = TRUE; - } -#else char buf[4096]; /* 512 */ char *header = NULL; int n; -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ CTRACE((tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\", \"%s\")\n", - mail_address?mail_address:"<nil>", - filename?filename:"<nil>", - title?title:"<nil>", - refid?refid:"<nil>")); + NIL_OK(mail_address), + NIL_OK(filename), + NIL_OK(title), + NIL_OK(refid))); term_letter = FALSE; - if (mail_address && *mail_address) { - StrAllocCopy(address, mail_address); - } else { + if (EMPTY(mail_address)) { HTAlert(NO_ADDRESS_IN_MAILTO_URL); return; } + StrAllocCopy(to_address, mail_address); if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF) { if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); @@ -1057,12 +1135,12 @@ PUBLIC void reply_by_mail ARGS4( } } #endif /* VMS */ - subject[0] = '\0'; + default_subject[0] = '\0'; /* * Check for a ?searchpart. - FM */ - if ((cp = strchr(address, '?')) != NULL) { + if ((cp = strchr(to_address, '?')) != NULL) { StrAllocCopy(searchpart, cp); *cp = '\0'; cp = (searchpart + 1); @@ -1070,125 +1148,26 @@ PUBLIC void reply_by_mail ARGS4( /* * Seek and handle a subject=foo. - FM */ - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "subject=", 8)) - break; - cp++; - } - if (*cp) { - cp += 8; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - if (*cp) { - strncpy(subject, cp, 70); - subject[70] = '\0'; - SafeHTUnEscape(subject); - } - if (cp1) { - *cp1 = '&'; - cp1 = NULL; - } - } + extract_subject(default_subject, searchpart); /* * Seek and handle to=address(es) fields. * Appends to address. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "to=", 3)) { - cp += 3; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (*address) { - StrAllocCat(address, ","); - } - StrAllocCat(address, cp); - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&to_address, searchpart, "to="); /* * Seek and handle cc=address(es) fields. Excludes * Bcc=address(es) as unsafe. We may append our own * cc (below) as a list for the actual mailing. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "cc=", 3)) { - cp += 3; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (ccaddr == NULL) { - StrAllocCopy(ccaddr, cp); - } else { - StrAllocCat(ccaddr, ","); - StrAllocCat(ccaddr, cp); - } - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&ccaddr, searchpart, "cc="); /* * Seek and handle keywords=term(s) fields. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "keywords=", 9)) { - cp += 9; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (keywords == NULL) { - StrAllocCopy(keywords, cp); - } else { - StrAllocCat(keywords, cp); - StrAllocCat(keywords, ", "); - } - StrAllocCat(keywords, cp); - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_field(&keywords, searchpart, "keywords="); + if (keywords != NULL) { if (*keywords != '\0') { SafeHTUnEscape(keywords); @@ -1200,105 +1179,18 @@ PUBLIC void reply_by_mail ARGS4( /* * Seek and handle body=foo fields. - FM */ - cp = (searchpart + 1); - while (*cp != '\0') { - if ((*(cp - 1) == '?' || *(cp - 1) == '&') && - !strncasecomp(cp, "body=", 5)) { - cp += 5; - if ((cp1 = strchr(cp, '&')) != NULL) { - *cp1 = '\0'; - } - if (*cp) { - /* - * Break up the value into lines with - * a maximum length of 78. - FM - */ - StrAllocCopy(temp, cp); - HTUnEscape(temp); - cp0 = temp; - while((cp = strchr(cp0, '\n')) != NULL) { - *cp = '\0'; - if (cp > cp0) { - if (*(cp - 1) == '\r') { - *(cp - 1) = '\0'; - } - } - i = 0; - len = strlen(cp0); - while (len > 78) { - HTSprintf(&body, "%.78s\n", &cp0[i]); - i += 78; - len = strlen(&cp0[i]); - } - HTSprintf(&body, "%s\n", &cp0[i]); - cp0 = (cp + 1); - } - i = 0; - len = strlen(cp0); - while (len > 78) { - HTSprintf(&body, "%.78s\n", &cp0[i]); - i += 78; - len = strlen(&cp0[i]); - } - if (len) { - HTSprintf(&body, "%s\n", &cp0[i]); - } - FREE(temp); - } - if (cp1) { - *cp1 = '&'; - cp = cp1; - cp1 = NULL; - } else { - break; - } - } - cp++; - } + extract_body(&body, searchpart); FREE(searchpart); } } - /* - * Convert any Explorer semi-colon Internet address - * separators to commas. - FM - */ - cp = address; - while ((cp1 = strchr(cp, '@')) != NULL) { - cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { - *cp0 = ','; - cp1 = cp0 + 1; - } - cp = cp1; - } - if (address[(strlen(address) - 1)] == ',') - address[(strlen(address) - 1)] = '\0'; - if (*address == '\0') { - FREE(address); - FREE(ccaddr); - FREE(keywords); - FREE(body); - LYCloseTempFP(fd); /* Close the tmpfile. */ - LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ + if (convert_explorer(to_address)) { HTAlert(NO_ADDRESS_IN_MAILTO_URL); - return; + goto cancelled; } if (ccaddr != NULL) { - cp = ccaddr; - while ((cp1 = strchr(cp, '@')) != NULL) { - cp1++; - if ((cp0 = strchr(cp1, ';')) != NULL) { - *cp0 = ','; - cp1 = cp0 + 1; - } - cp = cp1; - } - if (ccaddr[(strlen(ccaddr) - 1)] == ',') { - ccaddr[(strlen(ccaddr) - 1)] = '\0'; - } - if (*ccaddr == '\0') { + if (convert_explorer(ccaddr)) { FREE(ccaddr); } } @@ -1306,7 +1198,7 @@ PUBLIC void reply_by_mail ARGS4( /* * Unescape the address and ccaddr fields. - FM */ - SafeHTUnEscape(address); + SafeHTUnEscape(to_address); if (ccaddr != NULL) { SafeHTUnEscape(ccaddr); } @@ -1314,9 +1206,9 @@ PUBLIC void reply_by_mail ARGS4( /* * Set the default subject. - FM */ - if (subject[0] == '\0' && title && *title) { - strncpy(subject, title, 70); - subject[70] = '\0'; + if (EMPTY(default_subject) && !EMPTY(title)) { + strncpy(default_subject, title, MAX_SUBJECT); + default_subject[MAX_SUBJECT] = '\0'; } /* @@ -1325,8 +1217,7 @@ PUBLIC void reply_by_mail ARGS4( */ signal(SIGINT, terminate_letter); - -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF || !body) { /* * Put the X-URL and X-Mailer lines in the hdrfile @@ -1334,8 +1225,8 @@ PUBLIC void reply_by_mail ARGS4( */ fprintf((isPMDF ? hfd : fd), "X-URL: %s%s\n", - (filename && *filename) ? filename : "mailto:", - (filename && *filename) ? "" : address); + EMPTY(filename) ? "mailto:" : filename, + EMPTY(filename) ? to_address : ""); fprintf((isPMDF ? hfd : fd), "X-Mailer: %s, Version %s\n", LYNX_NAME, LYNX_VERSION); #ifdef NO_ANONYMOUS_EMAIL @@ -1349,9 +1240,7 @@ PUBLIC void reply_by_mail ARGS4( * Put the To: line in the header. */ #ifndef DOSPATH - StrAllocCopy(header, "To: "); - StrAllocCat(header, address); - StrAllocCat(header, "\n"); + HTSprintf(&header, "To: %s\n", to_address); #endif /* @@ -1380,21 +1269,15 @@ PUBLIC void reply_by_mail ARGS4( /* * Put the X-URL and X-Mailer lines in the header. */ - StrAllocCat(header, "X-URL: "); - if (filename && *filename) { - StrAllocCat(header, filename); - } - else { - StrAllocCat(header, "mailto:"); - StrAllocCat(header, address); + if (!EMPTY(filename)) { + HTSprintf(&header, "X-URL: %s\n", filename); + } else { + HTSprintf(&header, "X-URL: mailto:%s\n", to_address); } - StrAllocCat(header, "\n"); HTSprintf(&header, "X-Mailer: %s, Version %s\n", LYNX_NAME, LYNX_VERSION); - if (refid && *refid) { - StrAllocCat(header, "In-Reply-To: <"); - StrAllocCat(header, refid); - StrAllocCat(header, ">\n"); + if (!EMPTY(refid)) { + HTSprintf(&header, "In-Reply-To: <%s>\n", refid); } #endif /* VMS */ @@ -1408,93 +1291,47 @@ PUBLIC void reply_by_mail ARGS4( addstr(SENDING_MESSAGE_WITH_BODY_TO); else addstr(SENDING_COMMENT_TO); - cp = address; - while ((cp1 = strchr(cp, ',')) != NULL) { - *cp1 = '\0'; - while (*cp == ' ') - cp++; - if (*cp) { - addstr(cp); - addstr(",\n "); - } - *cp1 = ','; - cp = (cp1 + 1); - } - if (*cp) { - addstr(cp); - } -#ifdef VMS - if ((isPMDF == TRUE) && - (cp = ccaddr) != NULL) -#else - if ((cp = ccaddr) != NULL) + show_addresses(to_address); + if ( +#if USE_VMS_MAILER + (isPMDF == TRUE) && #endif /* VMS */ + (cp = ccaddr) != NULL) { if (strchr(cp, ',') != NULL) { addstr(WITH_COPIES_TO); } else { addstr(WITH_COPY_TO); } - while ((cp1 = strchr(cp, ',')) != NULL) { - *cp1 = '\0'; - while (*cp == ' ') - cp++; - if (*cp) { - addstr(cp); - addstr(",\n "); - } - *cp1 = ','; - cp = (cp1 + 1); - } - if (*cp) { - addstr(cp); - } + show_addresses(ccaddr); } addstr(CTRL_G_TO_CANCEL_SEND); -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF || !body) { -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ #ifndef NO_ANONYMOUS_EMAIL /* * Get the user's personal name. */ addstr(ENTER_NAME_OR_BLANK); - if (personal_name == NULL) - *user_input = '\0'; - else { - addstr(CTRL_U_TO_ERASE); - LYstrncpy(user_input, personal_name, sizeof(user_input)-1); - } -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF) { - addstr(gettext("Personal_name: ")); + label = "Personal_name: "; } else { - addstr(gettext("X_Personal_name: ")); + label = "X-Personal_name: "; } #else - addstr(gettext("Personal Name: ")); -#endif /* VMS */ - if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || - term_letter) { - addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr,FALSE); /* Stop scrolling. */ - goto cleanup; - } - addstr("\n"); - remove_tildes(user_input); - StrAllocCopy(personal_name, user_input); - term_letter = FALSE; - if (*user_input) { -#ifdef VMS - fprintf((isPMDF ? hfd : fd), - "X-Personal_name: %s\n",user_input); + label = "X-Personal_Name: "; +#endif /* USE_VMS_MAILER */ + if (!header_prompt(label, &personal_name, LINESIZE)) { + goto cancelled; + } + if (*personal_name) { +#if USE_VMS_MAILER + fprintf((isPMDF ? hfd : fd), "%s: %s\n", label, personal_name); #else - StrAllocCat(header, "X-Personal_name: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); + HTSprintf(&header, "%s: %s\n", label, personal_name); #endif /* VMS */ } @@ -1503,153 +1340,86 @@ PUBLIC void reply_by_mail ARGS4( */ addstr(ENTER_MAIL_ADDRESS_OR_OTHER); addstr(MEANS_TO_CONTACT_FOR_RESPONSE); - if (personal_mail_address) - addstr(CTRL_U_TO_ERASE); -#ifdef VMS +#if USE_VMS_MAILER if (isPMDF) { - addstr("From: "); + label = "From"; } else { - addstr("X-From: "); + label = "X-From"; } #else - addstr("From: "); + label = "From"; #endif /* VMS */ /* Add the personal mail address if there is one. */ - sprintf(user_input, "%.*s", (int)(sizeof(user_input) - 1), - (personal_mail_address - ? personal_mail_address - : "")); - if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || - term_letter) { - addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr,FALSE); /* Stop scrolling. */ - goto cleanup; + if (personal_mail_address) + StrAllocCopy(from_address, personal_mail_address); + if (!header_prompt(label, &from_address, LINESIZE)) { + goto cancelled; } - addstr("\n"); - remove_tildes(user_input); -#ifdef VMS - if (*user_input) { - if (isPMDF) { - fprintf(hfd, "From: %s\n", user_input); - } else { - fprintf(fd, "X-From: %s\n\n", user_input); - } - } else if (!isPMDF) { +#if USE_VMS_MAILER + if (*from_address) { + fprintf(isPMDF ? hfd : fd, "%s: %s\n", label, from_address); + } + if (!isPMDF) { fprintf(fd, "\n"); } #else - StrAllocCat(header, "From: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); -#endif /* VMS */ + HTSprintf(&header, "%s: %s\n", label, from_address); +#endif /* USE_VMS_MAILER */ #endif /* !NO_ANONYMOUS_EMAIL */ -#ifdef VMS +#if USE_VMS_MAILER } -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ /* * Get the subject line. */ addstr(ENTER_SUBJECT_LINE); - addstr(CTRL_U_TO_ERASE); - addstr(SUBJECT_PROMPT); - /* Add the default subject. */ - sprintf(user_input, "%.70s%.63s", - (subject[0] != '\0') ? - subject : - ((filename && *filename) ? - filename : "mailto:"), - (subject[0] != '\0') ? - "" : - ((filename && *filename) ? - "" : address)); - if (LYgetstr(user_input, VISIBLE, 71, NORECALL) < 0 || - term_letter) { - addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr,FALSE); /* Stop scrolling. */ - goto cleanup; + label = "Subject"; + if (*default_subject) { + StrAllocCopy(the_subject, default_subject); + } else if (!EMPTY(filename)) { + HTSprintf(&the_subject, "%s", filename); + } else { + HTSprintf(&the_subject, "mailto:%s", to_address); + } + if (!header_prompt(label, &the_subject, MAX_SUBJECT)) { + goto cancelled; } - addstr("\n"); - remove_tildes(user_input); - sprintf(subject, "%.70s", user_input); -#ifndef VMS - StrAllocCat(header, "Subject: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); -#endif /* VMS */ /* * Offer a CC line, if permitted. - FM */ - user_input[0] = '\0'; if (!LYNoCc) { addstr(ENTER_ADDRESS_FOR_CC); - if (personal_mail_address) - addstr(CTRL_U_TO_ERASE); addstr(BLANK_FOR_NO_COPY); - addstr("Cc: "); - /* - * Add the mail address if there is one. - */ - sprintf(user_input, "%.*s", (int) (sizeof(user_input) - 1), - (personal_mail_address - ? personal_mail_address - : "")); - if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || - term_letter) { - addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ - goto cleanup; - } - addstr("\n"); - } - remove_tildes(user_input); - - if (*user_input) { - cp = user_input; - while (*cp == ',' || isspace((unsigned char)*cp)) - cp++; - if (*cp) { - if (ccaddr == NULL) { - StrAllocCopy(ccaddr, cp); - } else { - StrAllocCat(ccaddr, ","); - StrAllocCat(ccaddr, cp); - } + if (personal_mail_address) + StrAllocCopy(cc_address, personal_mail_address); + if (!header_prompt("Cc", &cc_address, LINESIZE)) { + goto cancelled; } + comma_append(&ccaddr, cc_address); } -#if defined(DOSPATH) || defined(SH_EX) - if (*address) { - StrAllocCat(header, "To: "); - StrAllocCat(header, address); - StrAllocCat(header, "\n"); +#if !USE_VMS_MAILER + HTSprintf(&header, "%s: %s\n", label, the_subject); +#if !CAN_PIPE_TO_MAILER + if (*to_address) { + HTSprintf(&header, "To: %s\n", to_address); } #endif -#ifndef VMS /* ** Add the Cc: header. - FM */ - if (ccaddr != NULL && *ccaddr != '\0') { - StrAllocCat(header, "Cc: "); - StrAllocCat(header, ccaddr); - StrAllocCat(header, "\n"); + if (!EMPTY(ccaddr)) { + HTSprintf(&header, "Cc: %s\n", ccaddr); } /* ** Add the Keywords: header. - FM */ - if (keywords != NULL && *keywords != '\0') { - StrAllocCat(header, "Keywords: "); - StrAllocCat(header, keywords); - StrAllocCat(header, "\n"); + if (!EMPTY(keywords)) { + HTSprintf(&header, "Keywords: %s\n", keywords); } /* @@ -1659,7 +1429,7 @@ PUBLIC void reply_by_mail ARGS4( CTRACE((tfp,"**header==\n%s",header)); #endif /* !VMS */ - if (!no_editor && editor && *editor != '\0') { + if (!no_editor && !EMPTY(editor)) { /* * Use an external editor for the message. */ @@ -1725,11 +1495,7 @@ PUBLIC void reply_by_mail ARGS4( c = LYgetch(); addstr("\n"); if (term_letter || c == 7 || c == 3) { - addstr(CANCELLED); - LYSleepInfo(); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ - goto cleanup; + goto cancelled; } i = (LYlines - 2); } @@ -1760,10 +1526,7 @@ PUBLIC void reply_by_mail ARGS4( *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter || STREQ(user_input, ".")) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr,FALSE); /* Stop scrolling. */ - goto cleanup; + goto cancelled; } while (!STREQ(user_input, ".") && !term_letter) { @@ -1773,10 +1536,7 @@ PUBLIC void reply_by_mail ARGS4( *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ - scrollok(stdscr,FALSE); /* Stop scrolling. */ - goto cleanup; + goto cancelled; } } @@ -1785,7 +1545,7 @@ PUBLIC void reply_by_mail ARGS4( scrollok(stdscr,FALSE); /* Stop scrolling. */ } -#ifndef VMS +#if !USE_VMS_MAILER /* * Ignore CTRL-C on this last question. */ @@ -1819,6 +1579,7 @@ PUBLIC void reply_by_mail ARGS4( fputs(buffer, fd); } LYCloseOutput(fd); + FREE(buffer); } } LYCloseInput(fp); @@ -1828,7 +1589,7 @@ PUBLIC void reply_by_mail ARGS4( /* * Send the message. */ -#ifdef VMS +#if USE_VMS_MAILER /* * Set the mail command. - FM */ @@ -1837,10 +1598,10 @@ PUBLIC void reply_by_mail ARGS4( * For PMDF, put any keywords and the subject * in the header file and close it. - FM */ - if (keywords != NULL && *keywords != '\0') { + if (!EMPTY(keywords)) { fprintf(hfd, "Keywords: %s\n", keywords); } - fprintf(hfd, "Subject: %s\n\n", subject); + fprintf(hfd, "Subject: %s\n\n", the_subject); LYCloseTempFP(hfd); /* * Now set up the command. - FM @@ -1861,64 +1622,13 @@ PUBLIC void reply_by_mail ARGS4( system_mail, system_mail_flags, (strncasecomp(system_mail, "MAIL", 4) ? "" : "/noself"), - subject, + the_subject, my_tmpfile); } - /* - * Now add all the people in the address field. - FM - */ - address_ptr1 = address; - do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { - address_ptr2 = (cp+1); - *cp = '\0'; - } else { - address_ptr2 = NULL; - } - - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - */ - if (strlen(address_ptr1) > 3) { - if (!first) { - StrAllocCat(command, ","); - } - HTSprintf(&command, mail_adrs, address_ptr1); - first = FALSE; - } - address_ptr1 = address_ptr2; - } while (address_ptr1 != NULL); - - /* - * Now add all the people in the CC field. - FM - */ - if (ccaddr != NULL && *ccaddr != '\0') { - address_ptr1 = ccaddr; - do { - if ((cp = strchr(address_ptr1, ',')) != NULL) { - address_ptr2 = (cp+1); - *cp = '\0'; - } else { - address_ptr2 = NULL; - } - - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - */ - if (strlen(address_ptr1) > 3) { - StrAllocCat(command, ","); - HTSprintf(&command, mail_adrs, address_ptr1); - if (isPMDF) { - StrAllocCat(command, "/CC"); - } - } - address_ptr1 = address_ptr2; - } while (address_ptr1 != NULL); + vms_append_addrs(&command, to_address, ""); + if (!EMPTY(ccaddr)) { + vms_append_addrs(&command, ccaddr, "/CC"); } stop_curses(); @@ -1934,11 +1644,8 @@ PUBLIC void reply_by_mail ARGS4( _statusline(SENDING_YOUR_MSG); #if CAN_PIPE_TO_MAILER signal(SIGINT, SIG_IGN); - HTSprintf0(&command, "%s %s", system_mail, system_mail_flags); - CTRACE((tfp, "%s\n", command)); - fp = popen(command, "w"); - if (fp == NULL) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); + if ((fp = LYPipeToMailer()) == 0) { + HTInfoMsg(CANCELLED); } FREE(command); #else @@ -1949,7 +1656,7 @@ PUBLIC void reply_by_mail ARGS4( if (fp != 0) { fd = fopen(my_tmpfile, TXT_R); if (fd == NULL) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); + HTInfoMsg(CANCELLED); #if CAN_PIPE_TO_MAILER pclose(fp); #else @@ -1969,48 +1676,32 @@ PUBLIC void reply_by_mail ARGS4( pclose(fp); #else LYCloseTempFP(fp); /* Close the tmpfile. */ -#if USE_BLAT_MAILER - if (mail_is_blat) { - StrAllocCopy(command, - blat_cmd( - system_mail, - tmpfile2, - address, - subject, - ccaddr, - personal_mail_address - ) - ); - } else -#endif /* SH_EX */ - { - StrAllocCopy(command, system_mail); - StrAllocCat(command, " -t \""); - StrAllocCat(command, address); - StrAllocCat(command, "\" -F "); - StrAllocCat(command, tmpfile2); - } - stop_curses(); - printf("%s\n\n$ %s\n\n%s", SENDING_COMMENT, command, PLEASE_WAIT); - LYSystem(command); /* SENDING COMMENT (DOS/Windows/Unix) */ - FREE(command); - LYSleepMsg(); - start_curses(); + LYSendMailFile ( + to_address, + tmpfile2, + the_subject, + ccaddr, + SENDING_COMMENT); LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ #endif /* CAN_PIPE_TO_MAILER */ LYCloseInput(fd); /* Close the tmpfile. */ } } -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ + goto cleanup; /* * Come here to cleanup and exit. */ +cancelled: + HTInfoMsg(CANCELLED); + LYCloseTempFP(fd); /* Close the tmpfile. */ + scrollok(stdscr,FALSE); /* Stop scrolling. */ cleanup: signal(SIGINT, cleanup_sig); term_letter = FALSE; -#ifdef VMS +#if USE_VMS_MAILER FREE(command); while (LYRemoveTemp(my_tmpfile) == 0) ; /* Delete the tmpfile(s). */ @@ -2022,35 +1713,12 @@ cleanup: LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ #endif /* VMS */ - FREE(address); + FREE(from_address); + FREE(the_subject); + FREE(cc_address); + FREE(to_address); FREE(ccaddr); FREE(keywords); FREE(body); return; } - -PRIVATE void terminate_letter ARGS1(int,sig GCC_UNUSED) -{ - term_letter = TRUE; - /* Reassert the AST */ - signal(SIGINT, terminate_letter); -#if defined(VMS) || defined(DOSPATH) || defined(WIN_EX) - /* - * Refresh the screen to get rid of the "interrupt" message. - */ - if (!dump_output_immediately) { - lynx_force_repaint(); - refresh(); - } -#endif /* VMS */ -} - -PRIVATE void remove_tildes ARGS1(char *,string) -{ - /* - * Change the first character to - * a space if it is a '~'. - */ - if (*string == '~') - *string = ' '; -} diff --git a/src/LYMail.h b/src/LYMail.h index 00728e38..ec887318 100644 --- a/src/LYMail.h +++ b/src/LYMail.h @@ -1,4 +1,3 @@ - #ifndef LYMAIL_H #define LYMAIL_H @@ -6,15 +5,45 @@ #include <LYStructs.h> #endif /* LYSTRUCTS_H */ +#ifdef SH_EX +#define USE_BLAT_MAILER 1 +#else +#define USE_BLAT_MAILER 0 +#endif + +#ifdef VMS +#define USE_VMS_MAILER 1 +#else +#define USE_VMS_MAILER 0 +#endif + +/* + * Ifdef's in case we have a working popen/pclose, useful for piping to the + * mail program. + */ +#if !defined(HAVE_POPEN) || USE_VMS_MAILER || defined(DOSPATH) || defined(__CYGWIN__) +#define CAN_PIPE_TO_MAILER 0 +#else +#define CAN_PIPE_TO_MAILER 1 +#endif + extern BOOLEAN term_letter; +extern BOOLEAN LYMailPMDF NOPARAMS; +extern FILE *LYPipeToMailer NOPARAMS; +extern int LYSendMailFile PARAMS(( + char * the_address, + char * the_filename, + char * the_subject, + char * the_ccaddr, + char * message)); extern void mailform PARAMS(( CONST char * mailto_address, CONST char * mailto_subject, CONST char * mailto_content, CONST char * mailto_type)); extern void mailmsg PARAMS(( - int cur, + int cur, char * owner_address, char * filename, char * linkname)); diff --git a/src/LYMain.c b/src/LYMain.c index 5be08daa..fcd8d5c6 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -76,8 +76,11 @@ PUBLIC BOOLEAN sigint = FALSE; char init_ctrl_break[1]; #endif /* __DJGPP__ */ -#ifdef VMS +#if USE_VMS_MAILER PUBLIC char *mail_adrs = NULL; /* the mask for a VMS mail transport */ +#endif + +#ifdef VMS /* create FIXED 512 binaries */ PUBLIC BOOLEAN UseFixedRecords = USE_FIXED_RECORDS; #endif /* VMS */ @@ -593,10 +596,13 @@ PRIVATE void free_lynx_globals NOARGS #ifdef VMS Define_VMSLogical("LYNX_VERSION", ""); - FREE(mail_adrs); FREE(LYCSwingPath); #endif /* VMS */ +#if USE_VMS_MAILER + FREE(mail_adrs); +#endif + FREE(LynxHome); FREE(homepage); FREE(original_dir); @@ -1076,12 +1082,20 @@ PUBLIC int main ARGS2( #else LYAddPathSep(&lynx_temp_space); #endif /* VMS */ + #ifdef VMS - StrAllocCopy(mail_adrs, MAIL_ADRS); #ifdef CSWING_PATH StrAllocCopy(LYCSwingPath, CSWING_PATH); #endif /* CSWING_PATH */ #endif /* VMS */ + +#if USE_VMS_MAILER +#ifndef MAIL_ADRS +#define MAIL_ADRS "\"IN%%\"\"%s\"\"\"" +#endif + StrAllocCopy(mail_adrs, MAIL_ADRS); +#endif + #ifdef LYNX_HOST_NAME StrAllocCopy(LYHostName, LYNX_HOST_NAME); #else diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 9f8733f4..9f40df98 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1301,8 +1301,13 @@ gettext("Enctype multipart/form-data not yet supported! Cannot submit.")); return 0; } +#ifdef USE_EXTERNALS if (run_external(links[curdoc.link].lname, TRUE)) + { + *refresh_screen = TRUE; return 0; + } +#endif /* USE_EXTERNALS */ /* * Follow a normal link or anchor. diff --git a/src/LYPrint.c b/src/LYPrint.c index 393abbaa..f5508f2d 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -56,9 +56,9 @@ #define MAIL 4 #define PRINTER 5 -#ifdef VMS +#if USE_VMS_MAILER PRIVATE int remove_quotes PARAMS((char *string)); -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ PRIVATE char* subject_translate8bit PARAMS((char *source)); @@ -478,17 +478,17 @@ PRIVATE void send_file_to_mail ARGS3( { static BOOLEAN first_mail_preparsed = TRUE; -#ifdef VMS - BOOLEAN isPMDF = !strncasecomp(system_mail, "PMDF SEND", 9); +#if USE_VMS_MAILER + BOOLEAN isPMDF = LYMailPMDF(); FILE *hfd; char hdrfile[LY_MAXPATH]; #endif + BOOL use_mime; #if !CAN_PIPE_TO_MAILER char my_temp[LY_MAXPATH]; #endif BOOL use_cte; - BOOL use_mime; BOOL use_type; CONST char *disp_charset; FILE *outfile_fp; @@ -536,19 +536,19 @@ PRIVATE void send_file_to_mail ARGS3( * and 8-bit letters shouldn't be a problem - LP */ /* change_sug_filename(sug_filename); */ - subject = subject_translate8bit(newdoc->title); - - if (newdoc->isHEAD) { - /* - * Special case for mailing HEAD responce: this is rather technical - * information, show URL. - */ - FREE(subject); - StrAllocCopy(subject, "HEAD "); - StrAllocCat(subject, newdoc->address); + subject = subject_translate8bit(newdoc->title); + + if (newdoc->isHEAD) { + /* + * Special case for mailing HEAD responce: this is rather technical + * information, show URL. + */ + FREE(subject); + StrAllocCopy(subject, "HEAD "); + StrAllocCat(subject, newdoc->address); } -#ifdef VMS +#if USE_VMS_MAILER if (strchr(user_response,'@') && !strchr(user_response,':') && !strchr(user_response,'%') && !strchr(user_response,'"')) { char *temp = 0; @@ -604,6 +604,11 @@ PRIVATE void send_file_to_mail ARGS3( * X-URL header. - FM */ fprintf(hfd, "X-URL: %s\n", newdoc->address); + /* + * For PMDF, put the subject in the header file and close it. - FM + */ + fprintf(hfd, "Subject: %.70s\n\n", subject); + LYCloseTempFP(hfd); } /* @@ -630,11 +635,6 @@ PRIVATE void send_file_to_mail ARGS3( buffer = NULL; if (isPMDF) { /* - * For PMDF, put the subject in the header file and close it. - FM - */ - fprintf(hfd, "Subject: %.70s\n\n", subject); - LYCloseTempFP(hfd); - /* * Now set up the command. - FM */ HTSprintf0(&buffer, @@ -672,8 +672,7 @@ PRIVATE void send_file_to_mail ARGS3( #else /* !VMS (Unix or DOS) */ #if CAN_PIPE_TO_MAILER - HTSprintf0(&buffer, "%s %s", system_mail, system_mail_flags); - outfile_fp = popen(buffer, "w"); + outfile_fp = LYPipeToMailer(); #else outfile_fp = LYOpenTemp(my_temp, ".txt", "w"); #endif @@ -773,30 +772,18 @@ PRIVATE void send_file_to_mail ARGS3( if (keypad_mode) printlist(outfile_fp, FALSE); -#if defined(WIN_EX) || defined(__DJGPP__) -#if USE_BLAT_MAILER - if (mail_is_blat) - HTSprintf0(&buffer, "%s %s -t \"%s\"", - system_mail, my_temp, user_response); - else -#endif - HTSprintf0(&buffer, "%s -t \"%s\" -F %s", - system_mail, user_response, my_temp); - LYCloseTempFP(outfile_fp); /* Close the tmpfile. */ - - stop_curses(); - SetOutputMode(O_TEXT); - printf("%s\n\n$ %s\n\n%s", gettext("Sending"), buffer, PLEASE_WAIT); - LYSystem(buffer); - LYSleepMsg(); - start_curses(); - SetOutputMode( O_BINARY ); - - LYRemoveTemp(my_temp); /* Delete the tmpfile. */ -#else /* !WIN_EX && !__DJGPP__ */ +#if CAN_PIPE_TO_MAILER pclose(outfile_fp); -#endif /* WIN_EX || __DJGPP__ */ -#endif /* VMS */ +#else + LYSendMailFile ( + user_response, + my_temp, + subject, + "", + ""); + LYRemoveTemp(my_temp); /* Delete the tmpfile. */ +#endif /* CAN_PIPE_TO_MAILER */ +#endif /* USE_VMS_MAILER */ done: /* send_file_to_mail() */ FREE(buffer); @@ -1201,7 +1188,7 @@ PUBLIC int printfile ARGS1( return(NORMAL); } -#ifdef VMS +#if USE_VMS_MAILER PRIVATE int remove_quotes ARGS1( char *, string) { @@ -1217,7 +1204,7 @@ PRIVATE int remove_quotes ARGS1( return(0); } -#endif /* VMS */ +#endif /* USE_VMS_MAILER */ /* * Mail subject may have 8-bit characters and they are in display charset. diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 3a51949a..36d2b79d 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1489,7 +1489,7 @@ static Config_Type Config_Table [] = PARSE_STR("lynx_host_name", CONF_STR, &LYHostName), PARSE_FUN("lynx_sig_file", CONF_FUN, lynx_sig_file_fun), PARSE_SET("mail_system_error_logging", CONF_BOOL, &error_logging), -#ifdef VMS +#if USE_VMS_MAILER PARSE_STR("mail_adrs", CONF_STR, &mail_adrs), #endif PARSE_SET("make_links_for_all_images", CONF_BOOL, &clickable_images), diff --git a/src/LYStrings.c b/src/LYStrings.c index 3457e501..33b0ded1 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -3692,7 +3692,9 @@ PUBLIC int LYhandlePopupList ARGS9( * Set up the overall window, including the boxing characters ('*'), * if it all fits. Otherwise, set up the widest window possible. - FM */ - if ((form_window = LYstartPopup(top, lx, bottom - top, Lnum + width)) == 0) + if (num_choices <= 0 + || cur_choice > num_choices + || (form_window = LYstartPopup(top, lx, bottom - top, Lnum + width)) == 0) return(orig_choice); /* @@ -4515,7 +4517,7 @@ again: CurModif |= LKC_MOD2; break; case LYE_TAB: - if (xlec == last_xlec) { + if (xlec == last_xlec && recall != NORECALL) { HTList *list = whichRecall(recall); if (!HTList_isEmpty(list)) { char **data = sortedList(list, recall == RECALL_CMD); diff --git a/src/LYUtils.c b/src/LYUtils.c index 5abe0bac..6adefb15 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -5059,7 +5059,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( StrAllocCat(MsgStr, FIRST_SEGMENT); HTProgress(MsgStr); } else if (Startup && !dump_output_immediately) { - fprintf(stdout, "%s '%s'%s\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT); + fprintf(stdout, "%s '%s'%s\r\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT); } #ifdef INET6 @@ -7266,8 +7266,6 @@ PUBLIC void LYLocalFileToURL ARGS2( if (!LYIsHtmlSep(*leaf)) LYAddHtmlSep(target); StrAllocCat(*target, leaf); - if (leaf != source) - FREE(leaf); } #ifdef NOTDEFINED diff --git a/userdefs.h b/userdefs.h index 6d85a2e4..f96ff8ff 100644 --- a/userdefs.h +++ b/userdefs.h @@ -1345,11 +1345,11 @@ * the version definition with the Project Version on checkout. Just * ignore it. - kw */ /* $Format: "#define LYNX_VERSION \"$ProjectVersion$\""$ */ -#define LYNX_VERSION "2.8.4dev.9" +#define LYNX_VERSION "2.8.4dev.10" #define LYNX_WWW_HOME "http://lynx.browser.org/" #define LYNX_WWW_DIST "http://lynx.isc.org/current/" /* $Format: "#define LYNX_DATE \"$ProjectDate$\""$ */ -#define LYNX_DATE "Fri, 01 Sep 2000 04:23:46 -0700" +#define LYNX_DATE "Thu, 21 Sep 2000 19:21:59 -0700" #define LYNX_DATE_OFF 5 /* truncate the automatically-generated date */ #define LYNX_DATE_LEN 11 /* truncate the automatically-generated date */ |