From 03b222bbbdbc58cbe5a4eb93e500d490800dee9c Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Thu, 17 Sep 1998 12:13:52 -0400 Subject: snapshot of project "lynx", label v2-8-1dev_28 --- src/GridText.c | 14 +- src/HTAlert.c | 14 +- src/HTFWriter.c | 12 +- src/HTInit.c | 2 + src/HTML.c | 22 +-- src/LYBookmark.c | 6 +- src/LYCgi.c | 3 +- src/LYCharSets.c | 61 +++------ src/LYCharUtils.c | 12 +- src/LYCookie.c | 26 ++-- src/LYDownload.c | 17 +-- src/LYGlobalDefs.h | 1 + src/LYHistory.c | 49 ++----- src/LYList.c | 6 +- src/LYLocal.c | 332 ++++++++++++++++++--------------------------- src/LYMain.c | 9 +- src/LYMainLoop.c | 24 +--- src/LYNews.c | 4 +- src/LYOptions.c | 8 +- src/LYPrint.c | 11 +- src/LYShowInfo.c | 52 +++---- src/LYShowInfo.h | 4 - src/LYStrings.c | 6 +- src/LYUpload.c | 27 ++-- src/LYUtils.c | 74 +++++----- src/LYUtils.h | 4 +- src/LYrcFile.c | 2 +- src/UCdomap.c | 8 +- src/chrtrans/cp437_uni.tbl | 19 +-- 29 files changed, 337 insertions(+), 492 deletions(-) (limited to 'src') diff --git a/src/GridText.c b/src/GridText.c index be443759..a390b8c1 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -2458,18 +2458,14 @@ PUBLIC void HText_appendCharacter ARGS2( else { /* * If we're displaying document source, wrap long lines to keep all of - * the source visible. Note that we splice the pieces together with - * a recursion on this function to supply the character that is removed - * by 'split_line'. + * the source visible. */ int target = (int)(line->offset + line->size); - if ((target > (LYcols-1) - style->rightIndent) && + if ((target >= (LYcols-1) - style->rightIndent) && HTisDocumentSource()) { - int gap = line->data[line->size - 1]; new_line(text); line = text->last_line; HText_appendCharacter (text, LY_SOFT_NEWLINE); - HText_appendCharacter (text, gap); } } @@ -4746,8 +4742,7 @@ PUBLIC void print_wwwfile_to_fd ARGS2( line = HTMainText->last_line->next; for (;; line = line->next) { if (!first - && line->data[0] != LY_SOFT_NEWLINE - && line->data[0] != '\0') + && line->data[0] != LY_SOFT_NEWLINE) fputc('\n',fp); first = FALSE; @@ -4836,8 +4831,7 @@ PUBLIC void print_crawl_to_fd ARGS3( for (;; line = line->next) { if (!first - && line->data[0] != LY_SOFT_NEWLINE - && line->data[0] != '\0') + && line->data[0] != LY_SOFT_NEWLINE) fputc('\n',fp); first = FALSE; /* diff --git a/src/HTAlert.c b/src/HTAlert.c index 0482ca1e..a4c57b8f 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -41,8 +41,10 @@ PUBLIC void HTInfoMsg ARGS1( CONST char *, Msg) { _statusline(Msg); - if (Msg && *Msg) + if (Msg && *Msg) { + CTRACE(tfp, "Info: %s\n", Msg); sleep(InfoSecs); + } } /* Issue an important message. HTUserMsg() @@ -52,8 +54,10 @@ PUBLIC void HTUserMsg ARGS1( CONST char *, Msg) { _statusline(Msg); - if (Msg && *Msg) + if (Msg && *Msg) { + CTRACE(tfp, "User: %s\n", Msg); sleep(MessageSecs); + } } PUBLIC void HTUserMsg2 ARGS2( @@ -61,8 +65,10 @@ PUBLIC void HTUserMsg2 ARGS2( CONST char *, Arg) { _user_message(Msg, Arg); - if (Msg && *Msg) + if (Msg && *Msg) { + CTRACE(tfp, "User: %s (%s)\n", Msg, Arg); sleep(MessageSecs); + } } /* Issue a progress message. HTProgress() @@ -120,7 +126,7 @@ PUBLIC void HTReadProgress ARGS2( if (total <= 0) sprintf (line, "Read %ld %s of data.", bytes, units); if (transfer_rate > 0) - sprintf (line + strlen(line), " %ld kb/sec.", transfer_rate / 1024); + sprintf (line + strlen(line), " %ld KB/sec.", transfer_rate / 1024); if (total < 0) { if (total < -1) strcat(line, " (Press 'z' to abort)"); diff --git a/src/HTFWriter.c b/src/HTFWriter.c index f171905a..92665d1d 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -237,17 +237,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) } } #endif /* FNAMES_8_3 */ - StrAllocCopy(addr, "file://localhost"); -#ifdef DOSPATH - StrAllocCat(addr, "/"); - StrAllocCat(addr, HTDOS_wwwName(path)); -#else -#ifdef VMS - StrAllocCat(addr, HTVMS_wwwName(path)); -#else - StrAllocCat(addr, path); -#endif /* VMS */ -#endif /* DOSPATH */ + LYLocalFileToURL (&addr, path); if (!use_gzread) { StrAllocCopy(me->anchor->FileCache, path); StrAllocCopy(me->anchor->content_encoding, "binary"); diff --git a/src/HTInit.c b/src/HTInit.c index 9e6eccf1..6d46ee30 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -687,6 +687,8 @@ PUBLIC void HTFileInit NOARGS HTSetSuffix(".zip", "application/x-Zip File", "binary", 1.0); + HTSetSuffix(".bz2", "application/x-bzip2", "binary", 1.0); + HTSetSuffix(".uu", "application/x-UUencoded", "8bit", 1.0); HTSetSuffix(".hqx", "application/x-Binhex", "8bit", 1.0); diff --git a/src/HTML.c b/src/HTML.c index c54761d6..964af7f8 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -222,14 +222,18 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) case HTML_TITLE: if (c == LY_SOFT_HYPHEN) return; - if (c != '\n' && c != '\t' && c != '\r') + if (c != '\n' && c != '\t' && c != '\r') { HTChunkPutc(&me->title, c); - else if (HTCJK == CHINESE || HTCJK == JAPANESE || HTCJK == TAIPEI) - if (c == '\t') + } else if (HTCJK == CHINESE || HTCJK == JAPANESE || HTCJK == TAIPEI) { + if (c == '\t') { HTChunkPutc(&me->title, ' '); - else return; + } else { + return; + } /* don't replace '\n' with ' ' if Chinese or Japanese - HN */ - else HTChunkPutc(&me->title, ' '); + } else { + HTChunkPutc(&me->title, ' '); + } return; case HTML_STYLE: @@ -7256,16 +7260,16 @@ PUBLIC HTStructured* HTML_new ARGS3( LYUCcharset *p_in = HTAnchor_getUCInfoStage(me->node_anchor, UCT_STAGE_MIME); if (p_in->enc == UCT_ENC_CJK && HTCJK == NOCJK) { - HTAnchor_resetUCInfoStage(me->node_anchor, 0, + HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1, UCT_STAGE_MIME, UCT_SETBY_DEFAULT); - HTAnchor_setUCInfoStage(me->node_anchor, 0, + HTAnchor_setUCInfoStage(me->node_anchor, LATIN1, UCT_STAGE_MIME, UCT_SETBY_DEFAULT); - HTAnchor_resetUCInfoStage(me->node_anchor, 0, + HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1, UCT_STAGE_PARSER, UCT_SETBY_DEFAULT); - HTAnchor_setUCInfoStage(me->node_anchor, 0, + HTAnchor_setUCInfoStage(me->node_anchor, LATIN1, UCT_STAGE_PARSER, UCT_SETBY_DEFAULT); } diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 60dcda52..31e27beb 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -44,7 +44,6 @@ PRIVATE char * convert_mosaic_bookmark_file PARAMS((char *filename_buffer)); PUBLIC char * get_bookmark_filename ARGS1( char **, URL) { - char URL_buffer[256]; static char filename_buffer[256]; char string_buffer[256]; FILE *fp; @@ -113,14 +112,13 @@ success: is_mosaic_hotlist = TRUE; fclose(fp); newname = convert_mosaic_bookmark_file(filename_buffer); - LYLocalFileToURL(URL_buffer, newname); + LYLocalFileToURL(URL, newname); } else { fclose(fp); is_mosaic_hotlist = FALSE; - LYLocalFileToURL(URL_buffer, filename_buffer); + LYLocalFileToURL(URL, filename_buffer); } - StrAllocCopy(*URL, URL_buffer); return(filename_buffer); /* bookmark file exists */ } /* big end */ diff --git a/src/LYCgi.c b/src/LYCgi.c index b5cdcb2e..5e7ea902 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -230,8 +230,7 @@ PRIVATE int LYLoadCGI ARGS4( return(status); } - StrAllocCopy(new_arg, "file://localhost"); - StrAllocCat(new_arg, orig_pgm); + LYLocalFileToURL (&new_arg, orig_pgm); CTRACE(tfp, "%s is not an executable file, passing the buck.\n", arg); status = HTLoadFile(new_arg, anAnchor, format_out, sink); diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 5858b4e1..c2540e13 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -467,16 +467,15 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { HTCJK = NOCJK; kanji_code = NOKANJI; + if (i == chndl) + LYRawMode = LYUseDefaultRawMode; + else + LYRawMode = (!LYUseDefaultRawMode); HTPassEightBitNum = ((LYCharSet_UC[i].codepoints & UCT_CP_SUPERSETOF_LAT1) || (LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT)); - if (i == chndl) { - LYRawMode = LYUseDefaultRawMode ? TRUE : FALSE; - } else { - LYRawMode = LYUseDefaultRawMode ? FALSE : TRUE; - } if (LYRawMode) { HTPassEightBitRaw = (LYlowest_eightbit[i] <= 160); } else { @@ -494,51 +493,30 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) CONST char *mime = LYCharSet_UC[i].MIMEname; if (!strcmp(mime, "euc-cn")) { - HTCJK = LYUseDefaultRawMode ? CHINESE : NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTCJK = CHINESE; kanji_code = EUC; - HTPassEightBitRaw = FALSE; - HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; - HTPassHighCtrlNum = FALSE; - } else if (!strcmp(mime, "euc-jp")) { - HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTCJK = JAPANESE; kanji_code = EUC; - HTPassEightBitRaw = FALSE; - HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; - HTPassHighCtrlNum = FALSE; - } else if (!strcmp(mime, "shift_jis")) { - HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTCJK = JAPANESE; kanji_code = SJIS; - HTPassEightBitRaw = FALSE; - HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; - HTPassHighCtrlNum = FALSE; - } else if (!strcmp(mime, "euc-kr")) { - HTCJK = LYUseDefaultRawMode ? KOREAN : NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTCJK = KOREAN; kanji_code = EUC; - HTPassEightBitRaw = FALSE; - HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; - HTPassHighCtrlNum = FALSE; - } else if (!strcmp(mime, "big5")) { - HTCJK = LYUseDefaultRawMode ? TAIPEI : NOCJK; - LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTCJK = TAIPEI; kanji_code = EUC; - HTPassEightBitRaw = FALSE; - HTPassEightBitNum = FALSE; - HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; - HTPassHighCtrlNum = FALSE; - } + + /* for any CJK: */ + if (!LYUseDefaultRawMode) + HTCJK = NOCJK; + LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassEightBitRaw = FALSE; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlNum = FALSE; } /* @@ -608,6 +586,9 @@ PUBLIC void Set_HTCJK ARGS2( /* * Function to set the LYDefaultRawMode value * based on the selected character set. - FM + * + * Currently unused: the default value so obvious + * that LYUseDefaultRawMode utilized directly by someone's mistake. - LP */ PRIVATE void HTMLSetRawModeDefault ARGS1(int,i) { diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 8dda30ef..d9f01c15 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -333,12 +333,10 @@ PUBLIC void LYFillLocalFileURL ARGS2( StrAllocCat(*href, "localhost"); } else if (!strncmp(*href, "file:///", 8)) { StrAllocCopy(temp, (*href+7)); - StrAllocCopy(*href, "file://localhost"); - StrAllocCat(*href, temp); + LYLocalFileToURL (href, temp); } else if (!strncmp(*href, "file:/", 6) && !LYIsHtmlSep(*(*href+6))) { StrAllocCopy(temp, (*href+5)); - StrAllocCopy(*href, "file://localhost"); - StrAllocCat(*href, temp); + LYLocalFileToURL (href, temp); } } @@ -1257,7 +1255,7 @@ PUBLIC void LYExpandString ARGS2( ** back translate for our character set. - FM */ if (code > 160 && code < 256 && - me->outUCLYhndl != 0 && + me->outUCLYhndl != LATIN1 && (!(HTPassEightBitRaw || (me->T.do_8bitraw && !me->T.trans_from_uni)))) { value = (code - 160); @@ -2279,9 +2277,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( */ } else if (code < 161 || (code < 256 && - (HTPassEightBitNum || - !strncmp(LYchar_set_names[cs_to], - "ISO Latin 1", 11)))) { + (HTPassEightBitNum || cs_to == LATIN1))) { /* ** No conversion needed. */ diff --git a/src/LYCookie.c b/src/LYCookie.c index e586cf04..1cbf6966 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -354,18 +354,20 @@ PRIVATE void store_cookie ARGS3( if (msg == 0) outofmem(__FILE__, "store_cookie"); - sprintf(msg, - INVALID_COOKIE_DOMAIN_CONFIRMATION, - co->domain, - hostname); - if (!HTConfirm(msg)) { - CTRACE(tfp, "store_cookie: Rejecting domain '%s' for host '%s'.\n", - co->domain, - hostname); - freeCookie(co); - co = NULL; - FREE(msg); - return; + if (!LYAcceptAllCookies) { + sprintf(msg, + INVALID_COOKIE_DOMAIN_CONFIRMATION, + co->domain, + hostname); + if (!HTConfirm(msg)) { + CTRACE(tfp, "store_cookie: Rejecting domain '%s' for host '%s'.\n", + co->domain, + hostname); + freeCookie(co); + co = NULL; + FREE(msg); + return; + } } FREE(msg); } diff --git a/src/LYDownload.c b/src/LYDownload.c index 26b1eef9..5c4473be 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -33,7 +33,7 @@ PUBLIC BOOLEAN LYDidRename = FALSE; #endif /* VMS */ -PRIVATE char LYValidDownloadFile[256] = "\0"; +PRIVATE char LYValidDownloadFile[LY_MAXPATH] = "\0"; PUBLIC void LYDownload ARGS1( char *, line) @@ -100,6 +100,7 @@ PUBLIC void LYDownload ARGS1( } #ifdef DIRED_SUPPORT + /* FIXME: use HTLocalName */ if (!strncmp(file, "file://localhost", 16)) file += 16; else if (!strncmp(file, "file:", 5)) @@ -586,8 +587,7 @@ PUBLIC int LYdownload_options ARGS2( char **, newfile, char *, data_file) { - static char tempfile[256]; - static char download_filename[256]; + static char tempfile[LY_MAXPATH]; char *sug_filename = NULL; FILE *fp0; lynx_html_item_type *cur_download; @@ -604,12 +604,11 @@ PUBLIC int LYdownload_options ARGS2( HTAlert(CANNOT_OPEN_TEMP); return(-1); } - LYLocalFileToURL(download_filename, tempfile); + LYLocalFileToURL(newfile, tempfile); LYstrncpy(LYValidDownloadFile, data_file, (sizeof(LYValidDownloadFile) - 1)); - StrAllocCopy(*newfile, download_filename); LYforce_no_cache = TRUE; /* don't cache this doc */ @@ -622,7 +621,7 @@ PUBLIC int LYdownload_options ARGS2( data_file, (lynx_save_space ? lynx_save_space : ""), sug_filename); fprintf(fp0, "\nStandard download options:\n"); - if(!no_disk_save && !child_lynx) + if(!no_disk_save && !child_lynx) { #ifdef DIRED_SUPPORT /* * Disable save to disk option for local files. @@ -632,11 +631,9 @@ PUBLIC int LYdownload_options ARGS2( fprintf(fp0," \ Save to disk\n", data_file, (lynx_save_space ? lynx_save_space : ""), sug_filename); -#ifdef DIRED_SUPPORT - else {} -#endif /* DIRED_SUPPORT */ - else + } else { fprintf(fp0," Save to disk disabled.\n"); + } fprintf(fp0, "\nLocal additions:\n"); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 37550ce3..d4840f91 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -142,6 +142,7 @@ extern BOOLEAN LYNewsPosting; /* News posting supported if TRUE */ extern char *LynxSigFile; /* Signature file, in or off home */ extern char *system_mail; extern char *system_mail_flags; +extern char *lynx_cfg_file; /* location of active lynx.cfg file */ extern char *lynx_temp_space; extern char *lynx_save_space; extern BOOLEAN LYforce_HTML_mode; diff --git a/src/LYHistory.c b/src/LYHistory.c index e046a9e5..f09099e3 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -187,35 +187,6 @@ PUBLIC void LYpush ARGS2( return; } } - -#ifdef NOTDEFINED -/* -** The following segment not used any more - What's it good for, -** anyway?? Doing a pop when a push is requested is confusing, -** also to the user. Moreover, the way it was done seems to cause -** a memory leak. - KW -*/ /* - * If file is identical to one two before it, don't push it. - */ - if (nhist > 2 && - STREQ(history[nhist-2].address, doc->address) && - !strcmp(history[nhist-2].post_data ? - history[nhist-2].post_data : "", - doc->post_data ? - doc->post_data : "") && - !strcmp(history[nhist-2].bookmark ? - history[nhist-2].bookmark : "", - doc->bookmark ? - doc->bookmark : "") && - history[nhist-2].isHEAD == doc->isHEAD) { - /* - * Pop one off the stack. - */ - nhist--; - return; - } -#endif /* NOTDEFINED */ - /* * OK, push it if we have stack space. */ @@ -320,9 +291,9 @@ PUBLIC void LYpush ARGS2( "but didn't check out!"); } } + CTRACE(tfp, "\nLYpush[%d]: address:%s\n title:%s\n", + nhist, doc->address, doc->title); nhist++; - CTRACE(tfp, "\nLYpush: address:%s\n title:%s\n", - doc->address, doc->title); } else { if (LYCursesON) { HTAlert(MAXHIST_REACHED); @@ -355,8 +326,8 @@ PUBLIC void LYpop ARGS1( doc->isHEAD = history[nhist].isHEAD; doc->safe = history[nhist].safe; doc->internal_link = history[nhist].internal_link; - CTRACE(tfp, "LYpop: address:%s\n title:%s\n", - doc->address, doc->title); + CTRACE(tfp, "LYpop[%d]: address:%s\n title:%s\n", + nhist, doc->address, doc->title); } } @@ -389,8 +360,7 @@ PUBLIC void LYpop_num ARGS2( PUBLIC int showhistory ARGS1( char **, newfile) { - static char tempfile[256]; - static char hist_filename[256]; + static char tempfile[LY_MAXPATH]; char *Title = NULL; int x = 0; FILE *fp0; @@ -401,9 +371,8 @@ PUBLIC int showhistory ARGS1( return(-1); } - LYLocalFileToURL(hist_filename, tempfile); + LYLocalFileToURL(newfile, tempfile); - StrAllocCopy(*newfile, hist_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ @@ -530,8 +499,7 @@ PUBLIC BOOLEAN historytarget ARGS1( PUBLIC int LYShowVisitedLinks ARGS1( char **, newfile) { - static char tempfile[256]; - static char vl_filename[256]; + static char tempfile[LY_MAXPATH]; char *Title = NULL; char *Address = NULL; int x; @@ -548,9 +516,8 @@ PUBLIC int LYShowVisitedLinks ARGS1( return(-1); } - LYLocalFileToURL(vl_filename, tempfile); + LYLocalFileToURL(newfile, tempfile); - StrAllocCopy(*newfile, vl_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ diff --git a/src/LYList.c b/src/LYList.c index e31036fb..7f669db9 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -32,7 +32,7 @@ ** Clear: we only get addresses. */ -static char list_filename[256] = "\0"; +static char *list_filename = 0; /* * Returns the name of the file used for the List Page, if one has @@ -41,7 +41,7 @@ static char list_filename[256] = "\0"; */ PUBLIC char * LYlist_temp_url NOARGS { - return list_filename; + return list_filename ? list_filename : ""; } PUBLIC int showlist ARGS2( @@ -74,7 +74,7 @@ PUBLIC int showlist ARGS2( return(-1); } - LYLocalFileToURL(list_filename, tempfile); + LYLocalFileToURL(&list_filename, tempfile); StrAllocCopy(newdoc->address, list_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ diff --git a/src/LYLocal.c b/src/LYLocal.c index 21288e67..0037d5c9 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -29,6 +29,7 @@ */ #include +#include #include #include #include @@ -47,7 +48,6 @@ #ifdef HAVE_SYS_WAIT_H #include #endif -#include #include #endif /*_WINDOWS */ #endif /* VMS */ @@ -76,8 +76,8 @@ PRIVATE int LYExecv PARAMS(( char * msg)); #ifdef DIRED_SUPPORT -PUBLIC char LYPermitFileURL[256] = "\0"; -PUBLIC char LYDiredFileURL[256] = "\0"; +PUBLIC char LYPermitFileURL[LY_MAXPATH] = "\0"; +PUBLIC char LYDiredFileURL[LY_MAXPATH] = "\0"; PRIVATE char *filename PARAMS(( char * prompt, @@ -236,6 +236,59 @@ struct dired_menu { NULL, NULL, NULL } }; +PRIVATE BOOLEAN ok_stat ARGS2(char *, name, struct stat*, sb) +{ + char tmpbuf[512]; + + if (stat(name, sb) < 0) { + sprintf(tmpbuf, "Unable to get status of '%s'.", name); + HTAlert(tmpbuf); + return FALSE; + } + return TRUE; +} + +#ifdef HAVE_LSTAT +PRIVATE BOOLEAN ok_lstat ARGS2(char *, name, struct stat*, sb) +{ + char tmpbuf[512]; + + if (lstat(name, sb) < 0) { + sprintf(tmpbuf, "Unable to get status of '%s'.", name); + HTAlert(tmpbuf); + return FALSE; + } + return TRUE; +} +#else +#define ok_lstat(name,sb) ok_stat(name,sb) +#endif + +PRIVATE BOOLEAN ok_file_or_dir ARGS1(struct stat*, sb) +{ + if (!S_ISDIR(sb->st_mode) + && !S_ISREG(sb->st_mode)) { + HTAlert("The selected item is not a file or a directory! Request ignored."); + return FALSE; + } + return TRUE; +} + +PRIVATE BOOLEAN ok_localname ARGS2(char*, dst, char*, src) +{ + char *s = HTfullURL_toFile(strip_trailing_slash(src)); + struct stat dir_info; + + if (!ok_stat(s, &dir_info) + || !ok_file_or_dir(&dir_info)) { + free(s); + return FALSE; + } + strcpy(dst, s); + free(s); + return TRUE; +} + /* * Remove all tagged files and directories. */ @@ -261,24 +314,16 @@ PRIVATE BOOLEAN remove_tagged NOARGS tag = tagged; while (ans == 'Y' && (cp = (char *)HTList_nextObject(tag)) != NULL) { if (is_url(cp) == FILE_URL_TYPE) { /* unnecessary check */ - tp = cp; - if (!strncmp(tp, "file://localhost", 16)) { - tp += 16; - } else if (!strncmp(tp, "file:", 5)) { - tp += 5; - } + tp = HTfullURL_toFile(cp); StrAllocCopy(testpath, tp); - HTUnEscape(testpath); + free(tp); + LYTrimPathSep(testpath); /* * Check the current status of the path to be deleted. */ - if (stat(testpath,&dir_info) == -1) { - sprintf(tmpbuf, - "System error - failed to get status of '%s'.", - testpath); - HTAlert(tmpbuf); + if (!ok_stat(testpath, &dir_info)) { return count; } else { args[0] = "rm"; @@ -353,24 +398,20 @@ PRIVATE BOOLEAN modify_tagged ARGS1( if (!cp) /* Last resort, should never happen. */ cp = "/"; } - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } + if (testpath == NULL) { /* * Get the directory containing the file or subdir. */ - cp = strip_trailing_slash(cp); + cp = HTfullURL_toFile(strip_trailing_slash(cp)); savepath = HTParse(".", cp, PARSE_PATH+PARSE_PUNCTUATION); } else { + cp = HTfullURL_toFile(cp); StrAllocCopy(savepath, cp); } - HTUnEscape(savepath); - if (stat(savepath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", savepath); - HTAlert(tmpbuf); + free(cp); + + if (!ok_stat(savepath, &dir_info)) { FREE(savepath); return 0; } @@ -414,9 +455,7 @@ PRIVATE BOOLEAN modify_tagged ARGS1( /* * stat() the target location to determine type and ownership. */ - if (stat(savepath, &dir_info) == -1) { - sprintf(tmpbuf,"Unable to get status of '%s'.",savepath); - HTAlert(tmpbuf); + if (!ok_stat(savepath, &dir_info)) { FREE(savepath); return 0; } @@ -443,13 +482,9 @@ PRIVATE BOOLEAN modify_tagged ARGS1( * Move all tagged items to the target location. */ while ((cp = (char *)HTList_nextObject(tag)) != NULL) { - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } + cp = HTfullURL_toFile(cp); StrAllocCopy(srcpath, cp); - HTUnEscape(srcpath); + free(cp); sprintf(tmpbuf, "move %s to %s", srcpath, savepath); args[0] = "mv"; @@ -500,10 +535,7 @@ PRIVATE BOOLEAN modify_name ARGS1( */ testpath = strip_trailing_slash(testpath); - if (stat(testpath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", testpath); - HTAlert(tmpbuf); - } else { + if (ok_stat(testpath, &dir_info)) { /* * Change the name of the file or directory. */ @@ -582,9 +614,7 @@ PRIVATE BOOLEAN modify_location ARGS1( */ testpath = strip_trailing_slash(testpath); - if (stat(testpath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", testpath); - HTAlert(tmpbuf); + if (!ok_stat(testpath, &dir_info)) { return 0; } @@ -632,9 +662,7 @@ PRIVATE BOOLEAN modify_location ARGS1( mode = dir_info.st_mode; inode = dir_info.st_ino; owner = dir_info.st_uid; - if (stat(newpath, &dir_info) == -1) { - sprintf(tmpbuf,"Unable to get status of '%s'.",newpath); - HTAlert(tmpbuf); + if (!ok_stat(newpath, &dir_info)) { return 0; } if (S_ISDIR(dir_info.st_mode)) { @@ -679,14 +707,10 @@ PUBLIC BOOLEAN local_modify ARGS2( int count; if (!HTList_isEmpty(tagged)) { - cp = doc->address; - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } + cp = HTpartURL_toFile(doc->address); strcpy(testpath, cp); - HTUnEscapeSome(testpath, "/"); + free(cp); + count = modify_tagged(testpath); if (doc->link > (nlinks-count - 1)) @@ -715,14 +739,9 @@ PUBLIC BOOLEAN local_modify ARGS2( ans = TOUPPER(c); if (strchr("NLP", ans) != NULL) { - cp = links[doc->link].lname; - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if(!strncmp(cp, "file:", 5)) { - cp += 5; - } + cp = HTfullURL_toFile(links[doc->link].lname); strcpy(testpath, cp); - HTUnEscape(testpath); + free(cp); if (ans == 'N') { return(modify_name(testpath)); @@ -877,14 +896,9 @@ PUBLIC BOOLEAN local_create ARGS1( c = LYgetch(); ans = TOUPPER(c); - cp = doc->address; - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } + cp = HTfullURL_toFile(doc->address); strcpy(testpath,cp); - HTUnEscape(testpath); + free(cp); if (ans == 'F') { return(create_file(testpath)); @@ -907,14 +921,7 @@ PRIVATE BOOLEAN remove_single ARGS1( struct stat dir_info; char *args[5]; - /* - * lstat() first in case it's a symbolic link. - */ - if (lstat(testpath, &dir_info) == -1 && - stat(testpath, &dir_info) == -1) { - sprintf(tmpbuf, - "System error - failed to get status of '%s'.", testpath); - HTAlert(tmpbuf); + if (!ok_lstat(testpath, &dir_info)) { return 0; } @@ -991,23 +998,10 @@ PUBLIC BOOLEAN local_remove ARGS1( } cp = links[doc->link].lname; if (is_url(cp) == FILE_URL_TYPE) { - tp = cp; -#ifndef __EMX__ - if (!strncmp(tp, "file://localhost", 16)) { - tp += 16; - } else if (!strncmp(tp, "file:", 5)) { - tp += 5; - } -#else - if (!strncmp(tp, "file://localhost/", 17)) { - tp += 17; - } else if (!strncmp(tp, "file:/", 6)) { - tp +=6; - } -#endif /* !EMX */ - + tp = HTfullURL_toFile(cp); strcpy(testpath, tp); - HTUnEscape(testpath); + free(tp); + if ((i = strlen(testpath)) && testpath[i - 1] == '/') testpath[(i - 1)] = '\0'; @@ -1042,7 +1036,7 @@ static struct { use shell access for that. */ }; -PRIVATE char LYValidPermitFile[256] = "\0"; +PRIVATE char LYValidPermitFile[LY_MAXPATH] = "\0"; /* * Handle DIRED permissions. @@ -1056,7 +1050,7 @@ PRIVATE BOOLEAN permit_location ARGS3( HTAlert("Sorry, don't know how to permit non-UNIX files yet."); return(0); #else - static char tempfile[256] = "\0"; + static char tempfile[LY_MAXPATH] = "\0"; char *cp; char tmpbuf[LINESIZE]; struct stat dir_info; @@ -1066,31 +1060,23 @@ PRIVATE BOOLEAN permit_location ARGS3( * Create form. */ FILE *fp0; + char local_src[LY_MAXPATH]; char * user_filename; struct group * grp; char * group_name; + cp = HTfullURL_toFile(strip_trailing_slash(srcpath)); + strcpy(local_src, cp); + free(cp); + /* * A couple of sanity tests. */ - srcpath = strip_trailing_slash(srcpath); - if (strncmp(srcpath, "file://localhost", 16) == 0) - srcpath += 16; - if (lstat(srcpath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", srcpath); - HTAlert(tmpbuf); + if (!ok_lstat(local_src, &dir_info) + || !ok_file_or_dir(&dir_info)) return 0; - } else if (!S_ISDIR(dir_info.st_mode) && - !S_ISREG(dir_info.st_mode)) { - HTAlert("The specified item is not a file nor a directory - request ignored."); - return(0); - } - user_filename = srcpath; - cp = strrchr(srcpath, '/'); - if (cp != NULL) { - user_filename = (cp + 1); - } + user_filename = LYPathLeaf(local_src); LYRemoveTemp(tempfile); if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { @@ -1101,9 +1087,8 @@ PRIVATE BOOLEAN permit_location ARGS3( /* * Make the tempfile a URL. */ - strcpy(LYPermitFileURL, "file://localhost"); - strcat(LYPermitFileURL, tempfile); - StrAllocCopy(*newpath, LYPermitFileURL); + LYLocalFileToURL(newpath, tempfile); + strcpy(LYPermitFileURL, *newpath); grp = getgrgid(dir_info.st_gid); if (grp == NULL) { @@ -1238,13 +1223,8 @@ form to permit %s %s.\n\n\n", * A couple of sanity tests. */ destpath = strip_trailing_slash(destpath); - if (stat(destpath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", destpath); - HTAlert(tmpbuf); - return 0; - } else if (!S_ISDIR(dir_info.st_mode) && - !S_ISREG(dir_info.st_mode)) { - HTAlert("The specified item is not a file nor a directory - request ignored."); + if (!ok_stat(destpath, &dir_info) + || !ok_file_or_dir(&dir_info)) { return 0; } @@ -1601,20 +1581,14 @@ PUBLIC int dired_options ARGS2( document *, doc, char **, newfile) { - static char tempfile[256]; + static char tempfile[LY_MAXPATH]; char path[512], dir[512]; /* much too large */ - char tmpbuf[LINESIZE]; lynx_html_item_type *nxt; struct stat dir_info; FILE *fp0; char *cp = NULL; - char *dir_url = NULL; /* Will hold URL-escaped path of - directory from where DIRED_MENU was - invoked (NOT its full URL). */ - char *path_url = NULL; /* Will hold URL-escaped path of file - (or directory) which was selected - when DIRED_MENU was invoked (NOT - its full URL). */ + char *dir_url; + char *path_url; BOOLEAN nothing_tagged; int count; struct dired_menu *mp; @@ -1629,49 +1603,26 @@ PUBLIC int dired_options ARGS2( /* * Make the tempfile a URL. */ - strcpy(LYDiredFileURL, "file://localhost"); - strcat(LYDiredFileURL, tempfile); - StrAllocCopy(*newfile, LYDiredFileURL); - - cp = doc->address; - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } - StrAllocCopy(dir_url, cp); - LYTrimHtmlSep(dir_url); + LYLocalFileToURL(newfile, tempfile); + strcpy(LYDiredFileURL, *newfile); + cp = HTpartURL_toFile(doc->address); strcpy(dir, cp); - HTUnEscape(dir); LYTrimPathSep(dir); if (doc->link > -1 && doc->link < (nlinks+1)) { - cp = links[doc->link].lname; - if (!strncmp(cp, "file://localhost", 16)) { - cp += 16; - } else if (!strncmp(cp, "file:", 5)) { - cp += 5; - } - StrAllocCopy(path_url, cp); - LYTrimHtmlSep(path_url); - + cp = HTfullURL_toFile(links[doc->link].lname); strcpy(path, cp); - HTUnEscape(path); LYTrimPathSep(path); + free(cp); - if (lstat(path, &dir_info) == -1 && stat(path, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", path); - HTAlert(tmpbuf); + if (!ok_lstat(path, &dir_info)) { LYCloseTempFP(fp0); - FREE(dir_url); - FREE(path_url); return 0; } } else { path[0] = '\0'; - StrAllocCopy(path_url, path); } nothing_tagged = (HTList_isEmpty(tagged)); @@ -1749,12 +1700,16 @@ PUBLIC int dired_options ARGS2( (strlen(path) < strlen(mp->sfx) || strcmp(mp->sfx, &path[(strlen(path) - strlen(mp->sfx))]) != 0)) continue; + dir_url = HTEscape(dir, URL_PATH); + path_url = HTEscape(path, URL_PATH); fprintf(fp0, "href, path_url, dir_url, buf,2048, YES)); + render_item(mp->href, path_url, dir_url, buf,sizeof(buf), YES)); fprintf(fp0, "\">%s ", - render_item(mp->link, path, dir, buf,2048, NO)); + render_item(mp->link, path, dir, buf,sizeof(buf), NO)); fprintf(fp0, "%s
\n", - render_item(mp->rest, path, dir, buf,2048, NO)); + render_item(mp->rest, path, dir, buf,sizeof(buf), NO)); + FREE(dir_url); + FREE(path_url); } if (uploaders != NULL) { @@ -1771,9 +1726,6 @@ PUBLIC int dired_options ARGS2( EndInternalPage(fp0); LYCloseTempFP(fp0); - FREE(dir_url); - FREE(path_url); - LYforce_no_cache = TRUE; return(0); @@ -1833,32 +1785,18 @@ PUBLIC BOOLEAN local_install ARGS3( * Determine the status of the selected item. */ if (srcpath) { - srcpath = strip_trailing_slash(srcpath); - if (strncmp(srcpath, "file://localhost", 16) == 0) - srcpath += 16; - if (stat(srcpath, &dir_info) == -1) { - sprintf(tmpbuf, "Unable to get status of '%s'.", srcpath); - HTAlert(tmpbuf); - return 0; - } else if (!S_ISDIR(dir_info.st_mode) && - !S_ISREG(dir_info.st_mode)) { - HTAlert("The selected item is not a file or a directory! Request ignored."); + if (!ok_localname(savepath, srcpath)) return 0; - } - strcpy(savepath, srcpath); + LYforce_no_cache = TRUE; - strcpy(tmpbuf, "file://localhost"); - strcat(tmpbuf, Home_Dir()); - strcat(tmpbuf, "/.installdirs.html"); - StrAllocCopy(*newpath, tmpbuf); + LYLocalFileToURL(newpath, Home_Dir()); + StrAllocCat(*newpath, "/.installdirs.html"); return 0; } destpath = strip_trailing_slash(destpath); - if (stat(destpath,&dir_info) == -1) { - sprintf(tmpbuf,"Unable to get status of '%s'.",destpath); - HTAlert(tmpbuf); + if (!ok_stat(destpath, &dir_info)) { return 0; } else if (!S_ISDIR(dir_info.st_mode)) { HTAlert("The selected item is not a directory! Request ignored."); @@ -1887,11 +1825,11 @@ PUBLIC BOOLEAN local_install ARGS3( } else { char *name; while ((name = (char *)HTList_nextObject(tag))) { - args[src] = name; - if (strncmp("file://localhost", args[src], 16) == 0) - args[src] = (name + 16); - - if (LYExecv(INSTALL_PATH, args, tmpbuf) <= 0) + int err; + args[src] = HTfullURL_toFile(name); + err = (LYExecv(INSTALL_PATH, args, tmpbuf) <= 0); + free(args[src]); + if (err) return ((count == 0) ? -1 : count); count++; } @@ -2001,17 +1939,6 @@ PRIVATE char * render_item ARGS6( switch (*s) { case '%': *BP_INC = '%'; -#ifdef NOTDEFINED - /* - * These chars come from lynx.cfg or the default, let's - * just assume there won't be any improper %'s there that - * would need escaping. - */ - if(url_syntax) { - *BP_INC = '2'; - *BP_INC = '5'; - } -#endif /* NOTDEFINED */ break; case 'p': cp = path; @@ -2058,12 +1985,6 @@ PRIVATE char * render_item ARGS6( break; default: *BP_INC = '%'; -#ifdef NOTDEFINED - if (url_syntax) { - *BP_INC = '2'; - *BP_INC = '5'; - } -#endif /* NOTDEFINED */ *BP_INC =*s; break; } @@ -2108,6 +2029,13 @@ PRIVATE int LYExecv ARGS3( int wstatus; #endif + if (TRACE) { + int n; + CTRACE(tfp, "LYExecv path='%s'\n", path); + for (n = 0; argv[n] != 0; n++) + CTRACE(tfp, "argv[%d] = '%s'\n", n, argv[n]); + } + rc = 1; /* It will work */ tmpbuf[0] = '\0'; /* empty buffer for alert messages */ stop_curses(); diff --git a/src/LYMain.c b/src/LYMain.c index 3322b390..6ab74c50 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -264,6 +264,7 @@ PUBLIC BOOLEAN LYNewsPosting = NEWS_POSTING; /* News posting supported? */ PUBLIC char *LynxSigFile = NULL; /* Signature file, in or off home */ PUBLIC char *system_mail = NULL; /* The path for sending mail */ PUBLIC char *system_mail_flags = NULL; /* Flags for sending mail */ +PUBLIC char *lynx_cfg_file = NULL; /* location of active lynx.cfg */ PUBLIC char *lynx_temp_space = NULL; /* The prefix for temporary file paths */ PUBLIC char *lynx_save_space = NULL; /* The prefix for save to disk paths */ PUBLIC char *LYHostName = NULL; /* treat as a local host name */ @@ -514,7 +515,6 @@ PUBLIC int main ARGS2( { int i; /* indexing variable */ int status = 0; /* exit status */ - char *lynx_cfg_file = NULL; char *temp = NULL; char *cp; FILE *fp; @@ -1238,7 +1238,6 @@ PUBLIC int main ARGS2( * Process the configuration file. */ read_cfg(lynx_cfg_file, "main program", 1); - FREE(lynx_cfg_file); HTSwitchDTD(New_DTD); @@ -2478,7 +2477,11 @@ static int version_fun ARGS3( { SetOutputMode( O_TEXT ); - printf("\n%s Version %s (1998)\n", LYNX_NAME, LYNX_VERSION); + printf("\n%s Version %s (%.*s)\n", + LYNX_NAME, LYNX_VERSION, + LYNX_DATE_LEN, + LYNX_RELEASE ? LYNX_RELEASE_DATE : &LYNX_DATE[LYNX_DATE_OFF] + ); printf( "Copyrights held by the University of Kansas, CERN, and other contributors.\n" ); diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index bba831b3..23d2de7a 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -4214,22 +4214,15 @@ check_goto_URL: if (nlinks > 0) { cp = links[curdoc.link].lname; if (is_url(cp) == FILE_URL_TYPE) { - if (!strncmp(cp, "file://localhost", 16)) { - /* - * This is the only case that should occur. - kw - */ - StrAllocCopy(tp, cp + 16); - } else if (!strncmp(cp, "file:", 5)) { - StrAllocCopy(tp, cp + 5); - } else { - StrAllocCopy(tp, cp); - } - HTUnEscape(tp); + cp = HTfullURL_toFile(cp); + StrAllocCopy(tp, cp); + free(cp); + if (stat(tp, &dir_info) == -1) { HTAlert(NO_STATUS); } else { if (S_ISREG(dir_info.st_mode)) { - StrAllocCopy(tp, cp); + StrAllocCopy(tp, links[curdoc.link].lname); HTUnEscapeSome(tp, "/"); if (edit_current_file(tp, curdoc.link, Newline)) { @@ -5134,12 +5127,7 @@ check_add_bookmark_to_self: if (!LYReopenTracelog(&trace_mode_flag)) break; - StrAllocCopy(newdoc.address, "file://localhost"); -#ifdef VMS - StrAllocCat(newdoc.address, HTVMS_wwwName(LYTraceLogPath)); -#else - StrAllocCat(newdoc.address, LYTraceLogPath); -#endif /* VMS */ + LYLocalFileToURL (&(newdoc.address), LYTraceLogPath); StrAllocCopy(newdoc.title, LYNX_TRACELOG_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); diff --git a/src/LYNews.c b/src/LYNews.c index 97e93e24..d644de6c 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -75,8 +75,8 @@ PUBLIC char *LYNewsPost ARGS2( * open a temporary file for a conversion to JIS. - FM */ CJKfile[0] = '\0'; - if (!strncmp(LYchar_set_names[current_char_set], "Japanese (EUC)", 14) || - !strncmp(LYchar_set_names[current_char_set], "Japanese (SJIS)", 15)) { + if (current_char_set == UCGetLYhndl_byMIME("euc-jp") || + current_char_set == UCGetLYhndl_byMIME("shift_jis")) { if ((fc = LYOpenTemp(CJKfile, HTML_SUFFIX, "w")) == NULL) { HTAlert(CANNOT_OPEN_TEMP); LYRemoveTemp(my_tempfile); diff --git a/src/LYOptions.c b/src/LYOptions.c index 50643fb8..8d22ad30 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -3210,7 +3210,7 @@ static char * user_agent_string = "user_agent"; #define PutTextInput(fp, name, value, size, disable) \ fprintf(fp,\ "\n",\ - size, name, value, disable) + (int) size, name, value, disable) #define PutOption(fp, flag, html, name) \ fprintf(fp,"