diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1999-06-29 13:01:29 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1999-06-29 13:01:29 -0400 |
commit | 83824f14360f92f8a3a47ac5f136bb077b141065 (patch) | |
tree | 9b21f7145d93e54ad67f57e8807f20493dfcbc3d /WWW | |
parent | 5be99e2ee1a17028574fcbd90b9ba2c09555585e (diff) | |
download | lynx-snapshots-83824f14360f92f8a3a47ac5f136bb077b141065.tar.gz |
snapshot of project "lynx", label v2-8-3_3
Diffstat (limited to 'WWW')
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 211 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 101 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.h | 1 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 8 | ||||
-rw-r--r-- | WWW/Library/djgpp/makefile | 2 | ||||
-rw-r--r-- | WWW/Library/djgpp/makefile.sla | 2 |
7 files changed, 295 insertions, 32 deletions
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 5507254c..86544009 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -177,6 +177,7 @@ PRIVATE char *last_username_and_host = NULL; #define MSDOS_SERVER 11 #define APPLESHARE_SERVER 12 #define NETPRESENZ_SERVER 13 +#define DLS_SERVER 14 PRIVATE int server_type = GENERIC_SERVER; /* the type of ftp host */ PRIVATE int unsure_type = FALSE; /* sure about the type? */ @@ -606,6 +607,45 @@ PRIVATE void get_ftp_pwd ARGS2( } } +/* This function turns MSDOS-like directory output off for + * Windows NT servers. + */ + +PRIVATE void set_unix_dirstyle ARGS2( + int *, ServerType, + BOOLEAN *, UseList) +{ + + char *cp; + /* This is a toggle. It seems we have to toggle in order to see + * the current state (after toggling), so we may end up toggling + * twice. - kw + */ + int status = response("SITE DIRSTYLE\r\n"); + if (status != 2) { + *ServerType = GENERIC_SERVER; + CTRACE(tfp, "HTFTP: DIRSTYLE failed, treating as Generic server.\n"); + return; + } else { + *UseList = TRUE; + /* Expecting one of: + * 200 MSDOS-like directory output is off + * 200 MSDOS-like directory output is on + * The following code doesn't look for the full exact string - + * who knows how the wording may change in some future version. + * If the first response isn't recognized, we toggle again + * anyway, under the assumption that it's more likely that + * the MSDOS setting was "off" originally. - kw + */ + cp = strstr(response_text+4, "MSDOS"); + if (cp && strstr(cp, " off")) { + return; /* already off now. */ + } else { + response("SITE DIRSTYLE\r\n"); + } + } +} + /* Get a valid connection to the host ** ---------------------------------- ** @@ -889,6 +929,7 @@ PRIVATE int get_connection ARGS2( } else if (strstr(response_text+4, "UNIX") != NULL || strstr(response_text+4, "Unix") != NULL) { server_type = UNIX_SERVER; + unsure_type = FALSE; /* to the best of out knowledge... */ use_list = TRUE; CTRACE(tfp, "HTFTP: Treating as Unix server.\n"); @@ -931,8 +972,8 @@ PRIVATE int get_connection ARGS2( } else if (strncmp(response_text+4, "Windows_NT", 10) == 0) { server_type = WINDOWS_NT_SERVER; - use_list = TRUE; CTRACE(tfp, "HTFTP: Treating as Window_NT server.\n"); + set_unix_dirstyle(&server_type, &use_list); } else if (strncmp(response_text+4, "MS Windows", 10) == 0) { server_type = MS_WINDOWS_SERVER; @@ -1404,6 +1445,111 @@ PRIVATE void parse_ls_line ARGS2( } /* parse_ls_line() */ /* + * parse_sls_line() -- + * Extract the name and size info and whether it refers to a + * directory from a LIST line in OS/2 "dls" format. + */ +PRIVATE void parse_dls_line ARGS3( + char *, line, + EntryInfo *, entry_info, + char **, pspilledname) +{ + short j; + int base=1; + int size_num=0; + 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 + TIMIT.mostlikely.Z\0 + 79215 \0 + */ + + len = strlen(line); + if (len == 0) { + FREE(*pspilledname); + entry_info->display = FALSE; + return; + } + cps = LYSkipNonBlanks(line); + if (*cps == '\0') { /* only a filename, save it and return. */ + StrAllocCopy(*pspilledname, line); + entry_info->display = FALSE; + return; + } + if (len < 24 || line[23] != ' ' || + (isspace(line[0]) && !*pspilledname)) { + /* this isn't the expected "dls" format! */ + if (!isspace(line[0])) + *cps = '\0'; + if (*pspilledname && !*line) { + entry_info->filename = *pspilledname; + *pspilledname = NULL; + if (entry_info->filename[strlen(entry_info->filename)-1] == '/') + StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY); + else + StrAllocCopy(entry_info->type, ""); + } else { + StrAllocCopy(entry_info->filename, line); + if (cps && cps != line && *(cps-1) == '/') + StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY); + else + StrAllocCopy(entry_info->type, ""); + FREE(*pspilledname); + } + return; + } + + j = 22; + if (line[j] == '=' || line[j] == '-') { + StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY); + } else { + while (isdigit(line[j])) { + size_num += (line[j] - '0') * base; + base *= 10; + j--; + } + } + entry_info->size = size_num; + + cps = LYSkipBlanks(&line[23]); + if (!strncmp(cps, "-> ", 3) && cps[3] != '\0' && cps[3] != ' ') { + StrAllocCopy(entry_info->type, gettext("Symbolic Link")); + entry_info->size = 0; /* don't display size */ + } + + if (j > 0) + line[j] = '\0'; + + LYTrimTrailing(line); + + len = strlen(line); + if (len == 0 && *pspilledname && **pspilledname) { + line = *pspilledname; + len = strlen(*pspilledname); + } + if (len > 0 && line[len-1] == '/') { + /* + ** It's a dir, remove / and mark it as such. + */ + if (len > 1) + line[len-1] = '\0'; + if (!entry_info->type) + StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY); + } + + StrAllocCopy(entry_info->filename, line); + FREE(*pspilledname); +} /* parse_dls_line() */ + +/* * parse_vms_dir_entry() * Format the name, date, and size from a VMS LIST line * into the EntryInfo structure - FM @@ -1884,9 +2030,10 @@ PRIVATE void parse_cms_dir_entry ARGS2( * If first is true, this is the first name in a directory. */ -PRIVATE EntryInfo * parse_dir_entry ARGS2( +PRIVATE EntryInfo * parse_dir_entry ARGS3( char *, entry, - BOOLEAN *, first) + BOOLEAN *, first, + char **, pspilledname) { EntryInfo *entry_info; int i; @@ -1904,6 +2051,51 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2( entry_info->display = TRUE; switch (server_type) { + case DLS_SERVER: + + /* + ** Interpret and edit LIST output from OS/2 server in + ** "dls" format. + ** This one must have claimed to be Unix in order to + ** get here; if the first line looks fishy, we revert + ** to Unix and hope that fits better (this recovery is + ** untested). - kw + */ + + if (*first) { + len = strlen(entry); + if (!len || entry[0] == ' ' || + (len >= 24 && entry[23] != ' ') || + (len < 24 && strchr(entry, ' '))) { + server_type = UNIX_SERVER; + CTRACE(tfp, + "HTFTP: Falling back to treating as Unix server.\n"); + } else { + *first = FALSE; + } + } + + if (server_type == DLS_SERVER) { + /* if still unchanged... */ + parse_dls_line(entry, entry_info, pspilledname); + + if (!entry_info->filename || *entry_info->filename == '\0') { + entry_info->display = FALSE; + return(entry_info); + } + if (!strcmp(entry_info->filename,"..") || + !strcmp(entry_info->filename,".")) + entry_info->display = FALSE; + if (entry_info->type && *entry_info->type == '\0') { + FREE(entry_info->type); + return(entry_info); + } + /* + ** Goto the bottom and get real type. + */ + break; + } /* fall through if server_type changed for *first == TRUE ! */ + case UNIX_SERVER: case PETER_LEWIS_SERVER: case MACHTEN_SERVER: @@ -2365,6 +2557,7 @@ PRIVATE int read_directory ARGS4( int BytesReceived = 0; int BytesReported = 0; char NumBytes[64]; + char *spilledname = NULL; PUTC('\n'); /* prettier LJM */ for (ic = 0; ic != EOF;) { /* For each entry in the directory */ HTChunkClear(chunk); @@ -2376,6 +2569,7 @@ PRIVATE int read_directory ARGS4( } else { ABORT_TARGET; HTBTreeAndObject_free(bt); + FREE(spilledname); return HT_INTERRUPTED; } } @@ -2392,6 +2586,7 @@ AgainForMultiNet: } else { ABORT_TARGET; HTBTreeAndObject_free(bt); + FREE(spilledname); return HT_INTERRUPTED; } } else if ((char)ic == CR || (char)ic == LF) { /* Terminator? */ @@ -2447,8 +2642,9 @@ AgainForMultiNet: CTRACE(tfp, "HTFTP: Line in %s is %s\n", lastpath, chunk->data); - entry_info = parse_dir_entry(chunk->data, &first); + entry_info = parse_dir_entry(chunk->data, &first, &spilledname); if (entry_info->display) { + FREE(spilledname); CTRACE(tfp, "Adding file to BTree: %s\n", entry_info->filename); HTBTree_add(bt, (EntryInfo *)entry_info); @@ -2462,6 +2658,7 @@ AgainForMultiNet: unload_btree: HTChunkFree(chunk); + FREE(spilledname); /* print out the handy help message if it exits :) */ if (help_message_cache_non_empty()) { @@ -3185,6 +3382,12 @@ listen: /* @@ */ #endif /* LISTEN */ if (isDirectory) { + if (server_type == UNIX_SERVER && !unsure_type && + !strcmp(response_text, + "150 Opening ASCII mode data connection for /bin/dl.\n")) { + CTRACE(tfp, "HTFTP: Treating as OS/2 \"dls\" server.\n"); + server_type = DLS_SERVER; + } status = read_directory (anchor, name, format_out, sink); NETCLOSE(data_soc); NETCLOSE(control->socket); diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index f8280243..f4699191 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -26,7 +26,6 @@ #ifdef DOSPATH #define LONG_LIST /* Define this for long style unix listings (ls -l), the actual style is configurable from lynx.cfg */ -#define lstat stat #endif /* #define NO_PARENT_DIR_REFERENCE */ /* Define this for no parent links */ #endif /* !VMS */ @@ -558,6 +557,50 @@ PRIVATE int HTCreatePath ARGS1(CONST char *,path) } #endif /* NOT_IMPLEMENTED */ +/* Convert filename from URL-path syntax to local path format +** ---------------------------------------------------------- +** Input name is assumed to be the URL-path of a local file +** URL, i.e. what comes after the "file://localhost". +** '#'-fragments to be treated as such must already be stripped. +** If expand_all is FALSE, unescape only escaped '/'. - kw +** +** On exit: +** Returns a malloc'ed string which must be freed by the caller. +*/ +PUBLIC char * HTURLPath_toFile ARGS2( + CONST char *, name, + BOOL, expand_all) +{ + char * path = NULL; + char * result = NULL; + + StrAllocCopy(path, name); + if (expand_all) + HTUnEscape(path); /* Interpret all % signs */ + else + HTUnEscapeSome(path, "/"); /* Interpret % signs for path delims */ + + CTRACE(tfp, "URLPath `%s' means path `%s'\n", name, path); +#ifdef DOSPATH + StrAllocCopy(result, HTDOS_name(path)); +#else +#ifdef __EMX__ + if (path[0] == '/' + && isalpha(path[1]) + && path[2] == ':') /* pesky leading slash */ + StrAllocCopy(result, path+1); + else + StrAllocCopy(result, path); + CTRACE(tfp, "EMX hack changed `%s' to `%s'\n", path, result); +#else + StrAllocCopy(result, path); +#endif /* __EMX__ */ +#endif /* DOSPATH */ + + FREE(path); + + return result; +} /* Convert filenames between local and WWW formats. ** ------------------------------------------------ ** Make up a suitable name for saving the node in @@ -568,6 +611,11 @@ PRIVATE int HTCreatePath ARGS1(CONST char *,path) ** On exit: ** Returns a malloc'ed string which must be freed by the caller. */ +/* NOTE: Don't use this function if you know that the input is a URL path + rather than a full URL, use HTURLPath_toFile instead. Otherwise + this function will return the wrong thing for some unusual + paths (like ones containing "//", possibly escaped). - kw +*/ PUBLIC char * HTnameOfFile_WWW ARGS3( CONST char *, name, BOOL, WWW_prefix, @@ -579,9 +627,9 @@ PUBLIC char * HTnameOfFile_WWW ARGS3( char * home; char * result = NULL; - if (expand_all) + if (expand_all) { HTUnEscape(path); /* Interpret all % signs */ - else + } else HTUnEscapeSome(path, "/"); /* Interpret % signs for path delims */ if (0 == strcmp(acc_method, "file") /* local file */ @@ -1193,9 +1241,9 @@ PUBLIC void HTDirEntry ARGS3( ** On exit: ** Returns TRUE if an "Up to <parent>" link was not created ** for a readable local directory because LONG_LIST is defined -** and NO_PARENT_DIR_REFERENCE is not defined, such that the -** calling function use LYListFmtParse() to create a link to -** the parent directory. Otherwise, it returns FALSE. - FM +** and NO_PARENT_DIR_REFERENCE is not defined, so that the +** calling function should use LYListFmtParse() to create a link +** to the parent directory. Otherwise, it returns FALSE. - FM */ PUBLIC BOOL HTDirTitles ARGS3( HTStructured *, target, @@ -1211,7 +1259,7 @@ PUBLIC BOOL HTDirTitles ARGS3( #ifdef DOSPATH BOOL local_link = FALSE; - if (logical[18] == ':') local_link = TRUE; + if (strlen(logical) > 18 && logical[18] == ':') local_link = TRUE; #endif /* ** Check tildeIsTop for treating home directory as Welcome @@ -1246,10 +1294,11 @@ PUBLIC BOOL HTDirTitles ARGS3( char * printable = NULL; #ifdef DIRED_SUPPORT - printable = HTfullURL_toFile( + printable = HTURLPath_toFile( (0 == strncasecomp(path, "/%2F", 4)) /* "//" ? */ ? (path+1) - : path); + : path, + TRUE); if (0 == strncasecomp(printable, "/vmsysu:", 8) || 0 == strncasecomp(printable, "/anonymou.", 10)) { StrAllocCopy(cp, (printable+1)); @@ -1441,8 +1490,8 @@ PRIVATE void do_readme ARGS2(HTStructured *, target, CONST char *, localname) targetClass = *target->isa; /* (Can't init agregate in K&R) */ START(HTML_PRE); for (;;){ - char c = fgetc(fp); - if (c == (char)EOF) break; + int c = fgetc(fp); + if (c == EOF) break; #ifdef NOTDEFINED switch (c) { case '&': @@ -1458,10 +1507,10 @@ PRIVATE void do_readme ARGS2(HTStructured *, target, CONST char *, localname) PUTC('\r'); Bug removed thanks to joe@athena.mit.edu */ default: - PUTC(c); + PUTC((char)c); } #else - PUTC(c); + PUTC((char)c); #endif /* NOTDEFINED */ } END(HTML_PRE); @@ -1652,7 +1701,7 @@ PRIVATE int print_local_dir ARGS5( { HTBTElement * next_element = HTBTree_next(bt,NULL); /* pick up the first element of the list */ - int num_of_entries_partial = 0; /* lines counter */ + int num_of_entries_output = 0; /* lines counter */ char state; /* I for initial (.. file), @@ -1667,19 +1716,28 @@ PRIVATE int print_local_dir ARGS5( while (next_element != NULL) { char *entry, *file_extra; +#ifndef DISP_PARTIAL + if (num_of_entries_output % HTMAX(display_lines,10) == 0) { + if (HTCheckForInterrupt()) { + _HTProgress ("Data transfer interrupted."); + status = HT_PARTIAL_CONTENT; + break; + } + } +#endif StrAllocCopy(tmpfilename,localname); if (strcmp(localname, "/")) /* ** If filename is not root directory. */ - StrAllocCat(tmpfilename, "/"); + LYAddHtmlSep(&tmpfilename); - StrAllocCat(tmpfilename, - (char *)HTBTree_object(next_element)+1); + entry = (char*)HTBTree_object(next_element)+1; /* ** Append the current entry's filename ** to the path. */ + StrAllocCat(tmpfilename, entry); HTSimplify(tmpfilename); /* ** Output the directory entry. @@ -1753,7 +1811,6 @@ PRIVATE int print_local_dir ARGS5( START(HTML_LI); #endif /* !LONG_LIST */ } - entry = (char*)HTBTree_object(next_element)+1; file_extra = NULL; #ifdef LONG_LIST @@ -1777,10 +1834,10 @@ PRIVATE int print_local_dir ARGS5( /* optimize for expensive operation: */ #ifdef DISP_PARTIAL - if (num_of_entries_partial % + if (num_of_entries_output % (partial_threshold > 0 ? partial_threshold : display_lines) == 0) { - /* num_of_entries, num_of_entries_partial... */ + /* num_of_entries, num_of_entries_output... */ /* HTReadProgress...(bytes, 0); */ HTDisplayPartial(); @@ -1790,7 +1847,7 @@ PRIVATE int print_local_dir ARGS5( break; } } - num_of_entries_partial++; + num_of_entries_output++; #endif /* DISP_PARTIAL */ } /* end while next_element */ @@ -2131,7 +2188,7 @@ PUBLIC int HTLoadFile ARGS4( FREE(filename); } -#else /* Unix: */ +#else /* not VMS: */ FREE(filename); diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h index a88b1285..50e38273 100644 --- a/WWW/Library/Implementation/HTFile.h +++ b/WWW/Library/Implementation/HTFile.h @@ -42,6 +42,7 @@ extern int HTDirReadme; /* Include readme files in listing? */ /* ** Convert filenames between local and WWW formats */ +extern char * HTURLPath_toFile PARAMS((CONST char * name, BOOL expand_all)); extern char * HTnameOfFile_WWW PARAMS((CONST char * name, BOOL WWW_prefix, BOOL expand_all)); #define HTLocalName(name) HTnameOfFile_WWW(name,TRUE,TRUE) #define HTfullURL_toFile(name) HTnameOfFile_WWW(name,FALSE,TRUE) diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index a45d7d0c..b2c933ef 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -490,7 +490,7 @@ PUBLIC void HTDisplayPartial NOARGS #ifdef DISP_PARTIAL if (display_partial) { /* - ** HText_getNumOfLines() = "current" number of lines received + ** HText_getNumOfLines() = "current" number of complete lines received ** NumOfLines_partial = number of lines at the moment of last repaint. ** ** We update NumOfLines_partial only when we repaint the display. diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index ab5b3bc7..2dd3ac84 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -117,7 +117,7 @@ PRIVATE int HTLoadHTTP ARGS4 ( BOOL show_407 = FALSE; BOOL auth_proxy = NO; /* Generate a proxy authorization. - AJL */ - int length, rv; + int length, rawlength, rv; BOOL doing_redirect, already_retrying = FALSE, bad_location = FALSE; int len = 0; @@ -768,6 +768,8 @@ try_again: while (!eol && !end_of_file && bytes_already_read < 100); } /* Scope of loop variables */ + /* save total length, in case we decide later to show it all - kw */ + rawlength = length; /* We now have a terminated unfolded line. Parse it. ** -------------------------------------------------- @@ -1462,7 +1464,7 @@ Cookie2_continuation: doing_redirect = FALSE; permanent_redirection = FALSE; start_of_data = line_kept_clean; - length = strlen(start_of_data); + length = rawlength; if (!bad_location) { HTAlert(gettext("Got redirection with no Location header.")); HTProgress(line_buffer); @@ -1718,7 +1720,7 @@ Cookie2_continuation: ** It was a HEAD request, or we want the headers and source. */ start_of_data = line_kept_clean; - length = strlen(start_of_data); + length = rawlength; format_in = HTAtom_for("text/plain"); } diff --git a/WWW/Library/djgpp/makefile b/WWW/Library/djgpp/makefile index 06e6f2e7..b91e2c52 100644 --- a/WWW/Library/djgpp/makefile +++ b/WWW/Library/djgpp/makefile @@ -8,7 +8,7 @@ WWW_MACH = djgpp #ASIS_MACH = hardware/os CFLAGS = -O3 -DUSE_ZLIB -DDOSPATH -DNOUSERS -DDISP_PARTIAL \ --DSOURCE_CACHE -DUSE_PSRC \ +-DSOURCE_CACHE -DUSE_PSRC -DNOPORT \ -I../Implementation \ -I../../../djgpp/tcplib/include \ -I../../../djgpp/tcplib/include/tcp \ diff --git a/WWW/Library/djgpp/makefile.sla b/WWW/Library/djgpp/makefile.sla index aa45ac45..78b63da9 100644 --- a/WWW/Library/djgpp/makefile.sla +++ b/WWW/Library/djgpp/makefile.sla @@ -8,7 +8,7 @@ WWW_MACH = djgpp #ASIS_MACH = hardware/os CFLAGS = -O3 -DUSE_SLANG -DUSE_ZLIB -DDOSPATH -DNOUSERS -DDISP_PARTIAL \ --DDIRED_SUPPORT -DSOURCE_CACHE -DUSE_PSRC \ +-DDIRED_SUPPORT -DSOURCE_CACHE -DUSE_PSRC -DNOPORT \ -I../Implementation \ -I../../../djgpp/tcplib/include \ -I../../../djgpp/tcplib/include/tcp \ |