aboutsummaryrefslogtreecommitdiffstats
path: root/WWW/Library
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-02-13 12:01:00 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-02-13 12:01:00 -0500
commitc82d2a4041724afe1dce249c78c4f034ca6a8d69 (patch)
tree2ba37d862e4b417a690a34a4dfa731a9042addd9 /WWW/Library
parent4b034492d7e0a45781e340312e0570e5052c42d9 (diff)
downloadlynx-snapshots-c82d2a4041724afe1dce249c78c4f034ca6a8d69.tar.gz
snapshot of project "lynx", label v2-7-1ac-0_114
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTAccess.c2
-rw-r--r--WWW/Library/Implementation/HTFile.c4
-rw-r--r--WWW/Library/Implementation/HTMIME.c6
-rw-r--r--WWW/Library/Implementation/HTMLDTD.c5
-rw-r--r--WWW/Library/Implementation/HTPlain.c6
-rw-r--r--WWW/Library/Implementation/HTTP.c1045
-rw-r--r--WWW/Library/Implementation/SGML.c321
-rw-r--r--WWW/Library/Implementation/SGML.h4
-rw-r--r--WWW/Library/Implementation/UCAux.h22
9 files changed, 660 insertions, 755 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index edb91b51..90b56d3b 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -311,7 +311,7 @@ PUBLIC BOOL override_proxy ARGS1(
if ((!templ_port || templ_port == port) &&
(t_len > 0 && t_len <= h_len &&
- !strncmp(Host + h_len - t_len, no_proxy, t_len))) {
+ !strncasecomp(Host + h_len - t_len, no_proxy, t_len))) {
FREE(host);
return YES;
}
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 0b0a830c..5459cbf6 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -877,7 +877,7 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
*cp4 = '\0';
cp4 = cp3;
chndl = UCGetLYhndl_byMIME(cp3);
- if (UCCanTranslateFromTo(chndl, current_char_set) != TQ_NO) {
+ if (UCCanTranslateFromTo(chndl, current_char_set)) {
chartrans_ok = YES;
*cp1 = '\0';
format = HTAtom_for(cp);
@@ -890,7 +890,7 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
** Got something but we don't recognize it.
*/
chndl = UCLYhndl_for_unrec;
- if (UCCanTranslateFromTo(chndl, current_char_set) != TQ_NO) {
+ if (UCCanTranslateFromTo(chndl, current_char_set)) {
chartrans_ok = YES;
HTAnchor_setUCInfoStage(anchor, chndl,
UCT_STAGE_MIME,
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index f165a6a2..556459c5 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -378,7 +378,7 @@ PRIVATE void HTMIME_put_character ARGS2(
cp4 = cp3;
chndl = UCGetLYhndl_byMIME(cp3);
if (UCCanTranslateFromTo(chndl,
- current_char_set) != TQ_NO) {
+ current_char_set)) {
chartrans_ok = YES;
*cp1 = '\0';
me->format = HTAtom_for(cp);
@@ -391,7 +391,7 @@ PRIVATE void HTMIME_put_character ARGS2(
recognize it */
chndl = UCLYhndl_for_unrec;
if (UCCanTranslateFromTo(chndl,
- current_char_set) != TQ_NO) {
+ current_char_set)) {
chartrans_ok = YES;
*cp1 = '\0';
me->format = HTAtom_for(cp);
@@ -2284,7 +2284,7 @@ PUBLIC void HTmmdecode ARGS2(
*p = TOLOWER(*p);
invalid = ((LYhndl = UCGetLYhndl_byMIME(s+2)) < 0 ||
UCCanTranslateFromTo(LYhndl,
- current_char_set) != TQ_NO);
+ current_char_set));
*qm2 = '?';
}
if (!invalid) {
diff --git a/WWW/Library/Implementation/HTMLDTD.c b/WWW/Library/Implementation/HTMLDTD.c
index 58326ed7..e0dbe2e8 100644
--- a/WWW/Library/Implementation/HTMLDTD.c
+++ b/WWW/Library/Implementation/HTMLDTD.c
@@ -1215,7 +1215,6 @@ static CONST UC_entity_info extra_entities[] = {
/* {"smid", 0x????}, shortmid # ISOamsr */
};
-
/* Attribute Lists
** ---------------
**
@@ -2662,9 +2661,9 @@ PUBLIC CONST SGML_dtd HTML_dtd = {
tags,
HTML_ELEMENTS,
entities,
- sizeof(entities)/sizeof(char*),
+ sizeof(entities)/sizeof(entities[0]),
extra_entities,
- sizeof(extra_entities)/sizeof(UC_entity_info),
+ sizeof(extra_entities)/sizeof(extra_entities[0])
};
/* This function fills the "tags" part of the HTML_dtd structure with
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index cc121ce6..73feeccc 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -153,7 +153,8 @@ PRIVATE void HTPlain_put_character ARGS2(
} else if ((unsigned char)c > 160) {
if (!HTPassEightBitRaw &&
current_char_set != 0) {
- int len, high, low, i, diff = 1;
+ size_t len, high, low, i;
+ int diff = 1;
CONST char * name;
UCode_t value = (UCode_t)((unsigned char)c - 160);
@@ -528,7 +529,8 @@ PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l)
/*
** Out of luck, so use the UHHH notation (ugh). - FM
*/
- int len, high, low, i, diff=1;
+ size_t len, high, low, i;
+ int diff = 1;
CONST char * name;
int value = (int)(code - 160);
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 268cb4d0..d1354911 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,9 +1,9 @@
-/* HyperText Tranfer Protocol - Client implementation HTTP.c
+/* HyperText Tranfer Protocol - Client implementation HTTP.c
** ==========================
** Modified:
-** 27 Jan 1994 PDM Added Ari Luotonen's Fix for Reload when using proxy
-** servers.
-** 28 Apr 1997 AJL,FM Do Proxy Authorisation.
+** 27 Jan 1994 PDM Added Ari Luotonen's Fix for Reload when using proxy
+** servers.
+** 28 Apr 1997 AJL,FM Do Proxy Authorisation.
*/
#include "HTUtils.h"
@@ -19,7 +19,7 @@
#define INIT_LINE_SIZE 1024 /* Start with line buffer this big */
#define LINE_EXTEND_THRESH 256 /* Minimum read size */
-#define VERSION_LENGTH 20 /* for returned protocol version */
+#define VERSION_LENGTH 20 /* for returned protocol version */
#include "HTParse.h"
#include "HTTCP.h"
@@ -37,7 +37,7 @@
/* #define TRACE 1 */
-struct _HTStream
+struct _HTStream
{
HTStreamClass * isa;
};
@@ -47,7 +47,7 @@ extern char * HTAppVersion; /* Application version: please supply */
extern char * personal_mail_address; /* User's name/email address */
extern char * LYUserAgent; /* Lynx User-Agent string */
extern BOOL LYNoRefererHeader; /* Never send Referer header? */
-extern BOOL LYNoRefererForThis; /* No Referer header for this URL? */
+extern BOOL LYNoRefererForThis; /* No Referer header for this URL? */
extern BOOL LYNoFromHeader; /* Never send From header? */
extern BOOL LYSetCookies; /* Act on Set-Cookie headers? */
@@ -59,9 +59,9 @@ PUBLIC BOOL redirect_post_content = FALSE; /* Don't convert to GET? */
extern char LYUserSpecifiedURL; /* Is the URL a goto? */
-extern BOOL keep_mime_headers; /* Include mime headers and force source dump */
+extern BOOL keep_mime_headers; /* Include mime headers and force source dump */
extern BOOL no_url_redirection; /* Don't follow Location: URL for */
-extern char *http_error_file; /* Store HTTP status code in this file */
+extern char *http_error_file; /* Store HTTP status code in this file */
extern BOOL traversal; /* TRUE if we are doing a traversal */
extern BOOL dump_output_immediately; /* TRUE if no interactive user */
@@ -92,7 +92,7 @@ extern char * LYCookie PARAMS((
** arg is the hypertext reference of the article to be loaded.
**
** On exit,
-** returns >=0 If no error, a good socket number
+** returns >=0 If no error, a good socket number
** <0 Error.
**
** The socket must be closed by the caller after the document has been
@@ -100,23 +100,23 @@ extern char * LYCookie PARAMS((
**
*/
PRIVATE int HTLoadHTTP ARGS4 (
- CONST char *, arg,
+ CONST char *, arg,
HTParentAnchor *, anAnchor,
HTFormat, format_out,
HTStream*, sink)
{
int s; /* Socket number for returned data */
CONST char *url = arg; /* The URL which get_physical() returned */
- char *command = NULL; /* The whole command */
+ char *command = NULL; /* The whole command */
char *eol; /* End of line if found */
char *start_of_data; /* Start of body of reply */
int status; /* tcp return */
int bytes_already_read;
- char crlf[3]; /* A CR LF equivalent string */
+ char crlf[3]; /* A CR LF equivalent string */
HTStream *target; /* Unconverted data */
HTFormat format_in; /* Format arriving in the message */
- BOOL do_head = FALSE; /* Whether or not we should do a head */
- BOOL do_post = FALSE; /* ARE WE posting ? */
+ BOOL do_head = FALSE; /* Whether or not we should do a head */
+ BOOL do_post = FALSE; /* ARE WE posting ? */
char *METHOD;
BOOL had_header; /* Have we had at least one header? */
@@ -128,7 +128,7 @@ PRIVATE int HTLoadHTTP ARGS4 (
BOOL first_Accept = TRUE;
BOOL show_401 = FALSE;
BOOL show_407 = FALSE;
- BOOL auth_proxy = NO; /* Generate a proxy authorization. - AJL */
+ BOOL auth_proxy = NO; /* Generate a proxy authorization. - AJL */
int length, rv;
BOOL doing_redirect, already_retrying = FALSE, bad_location = FALSE;
@@ -187,16 +187,16 @@ try_again:
** Interrupt cleanly.
*/
if (TRACE)
- fprintf (stderr,
- "HTTP: Interrupted on connect; recovering cleanly.\n");
+ fprintf (stderr,
+ "HTTP: Interrupted on connect; recovering cleanly.\n");
_HTProgress ("Connection interrupted.");
status = HT_NOT_LOADED;
goto done;
}
if (status < 0) {
- if (TRACE)
- fprintf(stderr,
- "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n",
+ if (TRACE)
+ fprintf(stderr,
+ "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n",
url, SOCKET_ERRNO);
HTAlert("Unable to connect to remote host.");
status = HT_NOT_LOADED;
@@ -210,25 +210,25 @@ try_again:
char * p1 = (HTParse(url, "", PARSE_PATH|PARSE_PUNCTUATION));
if (do_post) {
- METHOD = "POST";
- StrAllocCopy(command, "POST ");
+ METHOD = "POST";
+ StrAllocCopy(command, "POST ");
} else if (do_head) {
- METHOD = "HEAD";
- StrAllocCopy(command, "HEAD ");
+ METHOD = "HEAD";
+ StrAllocCopy(command, "HEAD ");
} else {
- METHOD = "GET";
- StrAllocCopy(command, "GET ");
+ METHOD = "GET";
+ StrAllocCopy(command, "GET ");
}
/*
- ** If we are using a proxy gateway don't copy in the first slash
- ** of say: /gopher://a;lkdjfl;ajdf;lkj/;aldk/adflj
- ** so that just gopher://.... is sent.
+ ** If we are using a proxy gateway don't copy in the first slash
+ ** of say: /gopher://a;lkdjfl;ajdf;lkj/;aldk/adflj
+ ** so that just gopher://.... is sent.
*/
if (using_proxy)
- StrAllocCat(command, p1+1);
+ StrAllocCat(command, p1+1);
else
- StrAllocCat(command, p1);
+ StrAllocCat(command, p1);
FREE(p1);
}
if (extensions) {
@@ -249,33 +249,33 @@ try_again:
}
if (!HTPresentations)
- HTFormatInit();
+ HTFormatInit();
n = HTList_count(HTPresentations);
first_Accept = TRUE;
len = 0;
for (i = 0; i < n; i++) {
- HTPresentation *pres =
+ HTPresentation *pres =
(HTPresentation *)HTList_objectAt(HTPresentations, i);
- if (pres->rep_out == WWW_PRESENT) {
+ if (pres->rep_out == WWW_PRESENT) {
if (pres->rep != WWW_SOURCE &&
strcasecomp(HTAtom_name(pres->rep), "www/mime") &&
strcasecomp(HTAtom_name(pres->rep), "www/compressed") &&
pres->quality <= 1.0 && pres->quality >= 0.0) {
if (pres->quality < 1.0) {
if (pres->maxbytes > 0) {
- sprintf(temp, ";q=%4.3f;mxb=%ld",
- pres->quality, pres->maxbytes);
+ sprintf(temp, ";q=%4.3f;mxb=%ld",
+ pres->quality, pres->maxbytes);
} else {
- sprintf(temp, ";q=%4.3f", pres->quality);
+ sprintf(temp, ";q=%4.3f", pres->quality);
}
} else if (pres->maxbytes > 0) {
sprintf(temp, ";mxb=%ld", pres->maxbytes);
} else {
temp[0] = '\0';
}
- sprintf(line, "%s%s%s",
- (first_Accept ?
+ sprintf(line, "%s%s%s",
+ (first_Accept ?
"Accept: " : ", "),
HTAtom_name(pres->rep),
temp);
@@ -283,28 +283,28 @@ try_again:
if (len > 252 && !first_Accept) {
StrAllocCat(command, crlf);
sprintf(line, "Accept: %s%s",
- HTAtom_name(pres->rep),
+ HTAtom_name(pres->rep),
temp);
len = strlen(line);
}
- StrAllocCat(command, line);
+ StrAllocCat(command, line);
first_Accept = FALSE;
}
- }
+ }
}
sprintf(line, "%s*/*;q=0.01%c%c",
- (first_Accept ?
+ (first_Accept ?
"Accept: " : ", "), CR, LF);
StrAllocCat(command, line);
first_Accept = FALSE;
len = 0;
sprintf(line, "Accept-Encoding: %s, %s%c%c",
- "gzip", "compress", CR, LF);
+ "gzip", "compress", CR, LF);
StrAllocCat(command, line);
if (language && *language) {
- sprintf(line, "Accept-Language: %s%c%c", language, CR, LF);
+ sprintf(line, "Accept-Language: %s%c%c", language, CR, LF);
StrAllocCat(command, line);
}
@@ -329,10 +329,10 @@ try_again:
** over 406 (Not Acceptable) replies. - FM
*/
if (!do_post) {
- sprintf(line, "Negotiate: trans%c%c", CR, LF);
- StrAllocCat(command, line);
+ sprintf(line, "Negotiate: trans%c%c", CR, LF);
+ StrAllocCat(command, line);
}
-
+
/*
** When reloading give no-cache pragma to proxy server to make
** it refresh its cache. -- Ari L. <luotonen@dxcern.cern.ch>
@@ -340,33 +340,32 @@ try_again:
** Also send it as a Cache-Control header for HTTP/1.1. - FM
*/
if (reloading) {
- sprintf(line, "Pragma: no-cache%c%c", CR, LF);
- StrAllocCat(command, line);
- sprintf(line, "Cache-Control: no-cache%c%c", CR, LF);
- StrAllocCat(command, line);
+ sprintf(line, "Pragma: no-cache%c%c", CR, LF);
+ StrAllocCat(command, line);
+ sprintf(line, "Cache-Control: no-cache%c%c", CR, LF);
+ StrAllocCat(command, line);
}
- reloading = FALSE; /* Now turn it off again if on */
if (LYUserAgent && *LYUserAgent) {
- sprintf(line, "User-Agent: %s%c%c", LYUserAgent, CR, LF);
+ sprintf(line, "User-Agent: %s%c%c", LYUserAgent, CR, LF);
} else {
- sprintf(line, "User-Agent: %s/%s libwww-FM/%s%c%c",
- HTAppName ? HTAppName : "unknown",
+ sprintf(line, "User-Agent: %s/%s libwww-FM/%s%c%c",
+ HTAppName ? HTAppName : "unknown",
HTAppVersion ? HTAppVersion : "0.0",
HTLibraryVersion, CR, LF);
}
StrAllocCat(command, line);
if (personal_mail_address && !LYNoFromHeader) {
- sprintf(line, "From: %s%c%c", personal_mail_address, CR,LF);
- StrAllocCat(command, line);
+ sprintf(line, "From: %s%c%c", personal_mail_address, CR,LF);
+ StrAllocCat(command, line);
}
if (!(LYUserSpecifiedURL ||
LYNoRefererHeader || LYNoRefererForThis) &&
strcmp(HTLoadedDocumentURL(), "")) {
char *cp = HTLoadedDocumentURL();
- StrAllocCat(command, "Referer: ");
+ StrAllocCat(command, "Referer: ");
if (!strncasecomp(cp, "LYNXIMGMAP:", 11)) {
char *cp1 = strchr(cp, '#');
if (cp1)
@@ -377,30 +376,30 @@ try_again:
} else {
StrAllocCat(command, cp);
}
- sprintf(line, "%c%c", CR, LF);
- StrAllocCat(command, line);
+ sprintf(line, "%c%c", CR, LF);
+ StrAllocCat(command, line);
}
{
- char *abspath;
+ char *abspath;
char *docname;
- char *hostname;
- char *colon;
- int portnumber;
- char *auth, *cookie = NULL;
+ char *hostname;
+ char *colon;
+ int portnumber;
+ char *auth, *cookie = NULL;
BOOL secure = (strncmp(anAnchor->address, "https", 5) ?
FALSE : TRUE);
- abspath = HTParse(url, "", PARSE_PATH|PARSE_PUNCTUATION);
- docname = HTParse(url, "", PARSE_PATH);
- hostname = HTParse(url, "", PARSE_HOST);
- if (hostname &&
- NULL != (colon = strchr(hostname, ':'))) {
- *(colon++) = '\0'; /* Chop off port number */
- portnumber = atoi(colon);
- } else if (!strncmp(url, "https", 5)) {
+ abspath = HTParse(arg, "", PARSE_PATH|PARSE_PUNCTUATION);
+ docname = HTParse(arg, "", PARSE_PATH);
+ hostname = HTParse(arg, "", PARSE_HOST);
+ if (hostname &&
+ NULL != (colon = strchr(hostname, ':'))) {
+ *(colon++) = '\0'; /* Chop off port number */
+ portnumber = atoi(colon);
+ } else if (!strncmp(arg, "https", 5)) {
portnumber = HTTPS_PORT;
- } else {
+ } else {
portnumber = HTTP_PORT;
}
@@ -410,10 +409,10 @@ try_again:
*/
if (using_proxy) {
/*
- ** If we are using a proxy, first determine if
- ** we should include an Authorization header
- ** and/or Cookie header for the ultimate target
- ** of this request. - FM & AJL
+ ** If we are using a proxy, first determine if
+ ** we should include an Authorization header
+ ** and/or Cookie header for the ultimate target
+ ** of this request. - FM & AJL
*/
char *host2 = NULL, *path2 = NULL;
int port2 = (strncmp(docname, "https", 5) ?
@@ -429,8 +428,8 @@ try_again:
}
}
/*
- ** This composeAuth() does file access, i.e., for
- ** the ultimate target of the request. - AJL
+ ** This composeAuth() does file access, i.e., for
+ ** the ultimate target of the request. - AJL
*/
auth_proxy = NO;
if ((auth = HTAA_composeAuth(host2, port2, path2,
@@ -439,7 +438,7 @@ try_again:
/*
** If auth is not NULL nor zero-length, it's
** an Authorization header to be included. - FM
- */
+ */
sprintf(line, "%s%c%c", auth, CR, LF);
StrAllocCat(command, line);
if (TRACE)
@@ -472,8 +471,8 @@ try_again:
"HTTP: Not sending authorization (yet).\n");
}
/*
- ** Add 'Cookie:' header, if it's HTTP or HTTPS
- ** document being proxied.
+ ** Add 'Cookie:' header, if it's HTTP or HTTPS
+ ** document being proxied.
*/
if (!strncmp(docname, "http", 4)) {
cookie = LYCookie(host2, path2, port2, secure);
@@ -481,12 +480,12 @@ try_again:
FREE(host2);
FREE(path2);
/*
- ** The next composeAuth() will be for the proxy. - AJL
+ ** The next composeAuth() will be for the proxy. - AJL
*/
auth_proxy = YES;
} else {
/*
- ** Add cookie for a non-proxied request. - FM
+ ** Add cookie for a non-proxied request. - FM
*/
cookie = LYCookie(hostname, abspath, portnumber, secure);
auth_proxy = NO;
@@ -496,27 +495,27 @@ try_again:
*/
if (cookie != NULL) {
if (*cookie != '$') {
- /*
+ /*
** It's a historical cookie, so signal to the
** server that we support modern cookies. - FM
*/
StrAllocCat(command, "Cookie2: $Version=\"1\"");
StrAllocCat(command, crlf);
- if (TRACE)
- fprintf(stderr,
+ if (TRACE)
+ fprintf(stderr,
"HTTP: Sending Cookie2: $Version =\"1\"\n");
}
if (*cookie != '\0') {
- /*
+ /*
** It's not a zero-length string, so add the header.
** Note that any folding of long strings has been
** done already in LYCookie.c. - FM
*/
- StrAllocCat(command, "Cookie: ");
- StrAllocCat(command, cookie);
+ StrAllocCat(command, "Cookie: ");
+ StrAllocCat(command, cookie);
StrAllocCat(command, crlf);
- if (TRACE)
- fprintf(stderr, "HTTP: Sending Cookie: %s\n", cookie);
+ if (TRACE)
+ fprintf(stderr, "HTTP: Sending Cookie: %s\n", cookie);
}
FREE(cookie);
}
@@ -529,39 +528,39 @@ try_again:
** still be NO, and we check here for whether we want an
** Authorization header. - FM & AJL
*/
- if ((auth = HTAA_composeAuth(hostname,
+ if ((auth = HTAA_composeAuth(hostname,
portnumber,
docname,
auth_proxy)) != NULL &&
*auth != '\0') {
/*
- ** If auth is not NULL nor zero-length, it's
- ** an Authorization or Proxy-Authorization
- ** header to be included. - FM
- */
- sprintf(line, "%s%c%c", auth, CR, LF);
- StrAllocCat(command, line);
+ ** If auth is not NULL nor zero-length, it's
+ ** an Authorization or Proxy-Authorization
+ ** header to be included. - FM
+ */
+ sprintf(line, "%s%c%c", auth, CR, LF);
+ StrAllocCat(command, line);
if (TRACE)
- fprintf(stderr,
+ fprintf(stderr,
(auth_proxy ?
"HTTP: Sending proxy authorization: %s\n" :
"HTTP: Sending authorization: %s\n"),
auth);
} else if (auth && *auth == '\0') {
/*
- ** If auth is a zero-length string, the user either
- ** cancelled or goofed at the username and password
- ** prompt. - FM
+ ** If auth is a zero-length string, the user either
+ ** cancelled or goofed at the username and password
+ ** prompt. - FM
*/
if (!(traversal || dump_output_immediately) &&
- HTConfirm("Proceed without a username and password?")) {
+ HTConfirm("Proceed without a username and password?")) {
if (auth_proxy == TRUE) {
show_407 = TRUE;
} else {
show_401 = TRUE;
}
} else {
- if (traversal || dump_output_immediately)
+ if (traversal || dump_output_immediately)
HTAlert("Can't proceed without a username and password.");
FREE(command);
FREE(hostname);
@@ -569,15 +568,15 @@ try_again:
status = HT_NOT_LOADED;
goto done;
}
- } else {
+ } else {
if (TRACE)
- fprintf(stderr,
+ fprintf(stderr,
(auth_proxy ?
"HTTP: Not sending proxy authorization (yet).\n" :
"HTTP: Not sending authorization (yet).\n"));
- }
- FREE(hostname);
- FREE(docname);
+ }
+ FREE(hostname);
+ FREE(docname);
}
auth_proxy = NO;
}
@@ -585,22 +584,22 @@ try_again:
if (do_post)
{
if (TRACE)
- fprintf (stderr, "HTTP: Doing post, content-type '%s'\n",
- anAnchor->post_content_type ? anAnchor->post_content_type
- : "lose");
+ fprintf (stderr, "HTTP: Doing post, content-type '%s'\n",
+ anAnchor->post_content_type ? anAnchor->post_content_type
+ : "lose");
sprintf (line, "Content-type: %s%c%c",
- anAnchor->post_content_type ? anAnchor->post_content_type
+ anAnchor->post_content_type ? anAnchor->post_content_type
: "lose", CR, LF);
StrAllocCat(command, line);
{
- int content_length;
- if (!anAnchor->post_data)
- content_length = 0;
- else
- content_length = strlen (anAnchor->post_data);
- sprintf (line, "Content-length: %d%c%c",
- content_length, CR, LF);
- StrAllocCat(command, line);
+ int content_length;
+ if (!anAnchor->post_data)
+ content_length = 0;
+ else
+ content_length = strlen (anAnchor->post_data);
+ sprintf (line, "Content-length: %d%c%c",
+ content_length, CR, LF);
+ StrAllocCat(command, line);
}
StrAllocCat(command, crlf); /* Blank line means "end" of headers */
@@ -610,9 +609,12 @@ try_again:
else
StrAllocCat(command, crlf); /* Blank line means "end" of headers */
- if (TRACE)
- fprintf (stderr, "Writing:\n%s----------------------------------\n",
- command);
+ if (TRACE) {
+ fprintf (stderr,
+ "Writing:\n%s%s----------------------------------\n",
+ command,
+ (anAnchor->post_data ? crlf : ""));
+ }
_HTProgress ("Sending HTTP request.");
@@ -620,33 +622,33 @@ try_again:
FREE(command);
if (status <= 0) {
if (status == 0) {
- if (TRACE)
- fprintf (stderr, "HTTP: Got status 0 in initial write\n");
- /* Do nothing. */
+ if (TRACE)
+ fprintf (stderr, "HTTP: Got status 0 in initial write\n");
+ /* Do nothing. */
} else if ((SOCKET_ERRNO == ENOTCONN ||
- SOCKET_ERRNO == ECONNRESET ||
+ SOCKET_ERRNO == ECONNRESET ||
SOCKET_ERRNO == EPIPE) &&
!already_retrying &&
/* Don't retry if we're posting. */ !do_post) {
- /*
- ** Arrrrgh, HTTP 0/1 compability problem, maybe.
+ /*
+ ** Arrrrgh, HTTP 0/1 compability problem, maybe.
*/
- if (TRACE)
- fprintf (stderr,
- "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n");
- _HTProgress ("Retrying as HTTP0 request.");
- HTTP_NETCLOSE(s, handle);
- extensions = NO;
- already_retrying = TRUE;
- goto try_again;
+ if (TRACE)
+ fprintf (stderr,
+ "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n");
+ _HTProgress ("Retrying as HTTP0 request.");
+ HTTP_NETCLOSE(s, handle);
+ extensions = NO;
+ already_retrying = TRUE;
+ goto try_again;
} else {
- if (TRACE)
- fprintf (stderr,
+ if (TRACE)
+ fprintf (stderr,
"HTTP: Hit unexpected network WRITE error; aborting connection.\n");
- HTTP_NETCLOSE(s, handle);
- status = -1;
- HTAlert("Unexpected network write error; connection aborted.");
- goto done;
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ HTAlert("Unexpected network write error; connection aborted.");
+ goto done;
}
}
@@ -665,102 +667,102 @@ try_again:
line_buffer = (char *)calloc(1, (buffer_length * sizeof(char)));
do {/* Loop to read in the first line */
- /*
+ /*
** Extend line buffer if necessary for those crazy WAIS URLs ;-)
*/
- if (buffer_length - length < LINE_EXTEND_THRESH) {
- buffer_length = buffer_length + buffer_length;
- line_buffer =
- (char *)realloc(line_buffer, (buffer_length * sizeof(char)));
- }
- if (TRACE)
- fprintf (stderr, "HTTP: Trying to read %d\n",
- buffer_length - length - 1);
- status = HTTP_NETREAD(s, line_buffer + length,
- buffer_length - length - 1, handle);
- if (TRACE)
- fprintf (stderr, "HTTP: Read %d\n", status);
- if (status <= 0) {
- /*
- * Retry if we get nothing back too.
- * Bomb out if we get nothing twice.
+ if (buffer_length - length < LINE_EXTEND_THRESH) {
+ buffer_length = buffer_length + buffer_length;
+ line_buffer =
+ (char *)realloc(line_buffer, (buffer_length * sizeof(char)));
+ }
+ if (TRACE)
+ fprintf (stderr, "HTTP: Trying to read %d\n",
+ buffer_length - length - 1);
+ status = HTTP_NETREAD(s, line_buffer + length,
+ buffer_length - length - 1, handle);
+ if (TRACE)
+ fprintf (stderr, "HTTP: Read %d\n", status);
+ if (status <= 0) {
+ /*
+ * Retry if we get nothing back too.
+ * Bomb out if we get nothing twice.
*/
- if (status == HT_INTERRUPTED) {
- if (TRACE)
- fprintf (stderr, "HTTP: Interrupted initial read.\n");
- _HTProgress ("Connection interrupted.");
- HTTP_NETCLOSE(s, handle);
+ if (status == HT_INTERRUPTED) {
+ if (TRACE)
+ fprintf (stderr, "HTTP: Interrupted initial read.\n");
+ _HTProgress ("Connection interrupted.");
+ HTTP_NETCLOSE(s, handle);
status = HT_NO_DATA;
- goto clean_up;
- } else if (status < 0 &&
+ goto clean_up;
+ } else if (status < 0 &&
(SOCKET_ERRNO == ENOTCONN ||
- SOCKET_ERRNO == ECONNRESET ||
+ SOCKET_ERRNO == ECONNRESET ||
SOCKET_ERRNO == EPIPE) &&
!already_retrying && !do_post) {
- /*
+ /*
** Arrrrgh, HTTP 0/1 compability problem, maybe.
*/
- if (TRACE)
- fprintf (stderr,
- "HTTP: BONZO Trying again with HTTP0 request.\n");
- HTTP_NETCLOSE(s, handle);
- FREE(line_buffer);
- FREE(line_kept_clean);
-
- extensions = NO;
- already_retrying = TRUE;
- _HTProgress ("Retrying as HTTP0 request.");
- goto try_again;
- } else {
- if (TRACE)
- fprintf (stderr,
+ if (TRACE)
+ fprintf (stderr,
+ "HTTP: BONZO Trying again with HTTP0 request.\n");
+ HTTP_NETCLOSE(s, handle);
+ FREE(line_buffer);
+ FREE(line_kept_clean);
+
+ extensions = NO;
+ already_retrying = TRUE;
+ _HTProgress ("Retrying as HTTP0 request.");
+ goto try_again;
+ } else {
+ if (TRACE)
+ fprintf (stderr,
"HTTP: Hit unexpected network read error; aborting connection; status %d.\n",
status);
- HTAlert("Unexpected network read error; connection aborted.");
- HTTP_NETCLOSE(s, handle);
- status = -1;
- goto clean_up;
- }
- }
+ HTAlert("Unexpected network read error; connection aborted.");
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ goto clean_up;
+ }
+ }
- bytes_already_read += status;
- sprintf (line, "Read %d bytes of data.", bytes_already_read);
- HTProgress (line);
+ bytes_already_read += status;
+ sprintf (line, "Read %d bytes of data.", bytes_already_read);
+ HTProgress (line);
#ifdef UCX /* UCX returns -1 on EOF */
- if (status == 0 || status == -1)
+ if (status == 0 || status == -1)
#else
- if (status == 0)
+ if (status == 0)
#endif
- {
- end_of_file = YES;
- break;
- }
- line_buffer[length+status] = 0;
-
- if (line_buffer) {
- FREE(line_kept_clean);
- line_kept_clean = (char *)malloc(buffer_length * sizeof(char));
- memcpy(line_kept_clean, line_buffer, buffer_length);
- }
-
- eol = strchr(line_buffer + length, LF);
- /* Do we *really* want to do this? */
- if (eol && eol != line_buffer && *(eol-1) == CR)
- *(eol-1) = ' ';
-
- length = length + status;
-
- /* Do we really want to do *this*? */
- if (eol)
- *eol = 0; /* Terminate the line */
+ {
+ end_of_file = YES;
+ break;
+ }
+ line_buffer[length+status] = 0;
+
+ if (line_buffer) {
+ FREE(line_kept_clean);
+ line_kept_clean = (char *)malloc(buffer_length * sizeof(char));
+ memcpy(line_kept_clean, line_buffer, buffer_length);
+ }
+
+ eol = strchr(line_buffer + length, LF);
+ /* Do we *really* want to do this? */
+ if (eol && eol != line_buffer && *(eol-1) == CR)
+ *(eol-1) = ' ';
+
+ length = length + status;
+
+ /* Do we really want to do *this*? */
+ if (eol)
+ *eol = 0; /* Terminate the line */
}
- /* All we need is the first line of the response. If it's a HTTP/1.0
- ** response, then the first line will be absurdly short and therefore
- ** we can safely gate the number of bytes read through this code
- ** (as opposed to below) to ~1000.
+ /* All we need is the first line of the response. If it's a HTTP/1.0
+ ** response, then the first line will be absurdly short and therefore
+ ** we can safely gate the number of bytes read through this code
+ ** (as opposed to below) to ~1000.
**
- ** Well, let's try 100.
+ ** Well, let's try 100.
*/
while (!eol && !end_of_file && bytes_already_read < 100);
} /* Scope of loop variables */
@@ -776,18 +778,18 @@ try_again:
** Kludge to work with old buggy servers and the VMS Help gateway.
** They can't handle the third word, so we try again without it.
*/
- if (extensions && /* Old buggy server or Help gateway? */
+ if (extensions && /* Old buggy server or Help gateway? */
(0==strncmp(line_buffer,"<TITLE>Bad File Request</TITLE>",31) ||
0==strncmp(line_buffer,"Address should begin with",25) ||
0==strncmp(line_buffer,"<TITLE>Help ",12) ||
0==strcmp(line_buffer,
- "Document address invalid or access not authorised"))) {
+ "Document address invalid or access not authorised"))) {
FREE(line_buffer);
FREE(line_kept_clean);
extensions = NO;
already_retrying = TRUE;
if (TRACE)
- fprintf(stderr, "HTTP: close socket %d to retry with HTTP0\n", s);
+ fprintf(stderr, "HTTP: close socket %d to retry with HTTP0\n", s);
HTTP_NETCLOSE(s, handle);
/* print a progress message */
_HTProgress ("Retrying as HTTP0 request.");
@@ -803,11 +805,11 @@ try_again:
server_version[0] = 0;
fields = sscanf(line_buffer, "%20s %d",
- server_version,
- &server_status);
+ server_version,
+ &server_status);
if (TRACE)
- fprintf (stderr, "HTTP: Scanned %d fields from line_buffer\n", fields);
+ fprintf (stderr, "HTTP: Scanned %d fields from line_buffer\n", fields);
if (http_error_file) { /* Make the status code externally available */
FILE *error_file;
@@ -828,35 +830,35 @@ try_again:
}
/*
- ** Rule out a non-HTTP/1.n reply as best we can.
+ ** Rule out a non-HTTP/1.n reply as best we can.
*/
if (fields < 2 || !server_version[0] || server_version[0] != 'H' ||
- server_version[1] != 'T' || server_version[2] != 'T' ||
- server_version[3] != 'P' || server_version[4] != '/' ||
- server_version[6] != '.') {
+ server_version[1] != 'T' || server_version[2] != 'T' ||
+ server_version[3] != 'P' || server_version[4] != '/' ||
+ server_version[6] != '.') {
/*
* Ugh! An HTTP0 reply,
*/
- HTAtom * encoding;
+ HTAtom * encoding;
- if (TRACE)
- fprintf (stderr, "--- Talking HTTP0.\n");
+ if (TRACE)
+ fprintf (stderr, "--- Talking HTTP0.\n");
- format_in = HTFileFormat(url, &encoding, NULL);
+ format_in = HTFileFormat(url, &encoding, NULL);
/*
** Treat all plain text as HTML.
- ** This sucks but its the only solution without
- ** without looking at content.
- */
- if (!strncmp(HTAtom_name(format_in), "text/plain",10)) {
- if (TRACE)
- fprintf(stderr,
- "HTTP: format_in being changed to text/HTML\n");
- format_in = WWW_HTML;
- }
+ ** This sucks but its the only solution without
+ ** without looking at content.
+ */
+ if (!strncmp(HTAtom_name(format_in), "text/plain",10)) {
+ if (TRACE)
+ fprintf(stderr,
+ "HTTP: format_in being changed to text/HTML\n");
+ format_in = WWW_HTML;
+ }
if (!IsUnityEnc(encoding)) {
/*
- ** Change the format to that for "www/compressed".
+ ** Change the format to that for "www/compressed".
*/
if (TRACE) {
fprintf(stderr,
@@ -872,25 +874,25 @@ try_again:
}
}
- start_of_data = line_kept_clean;
+ start_of_data = line_kept_clean;
} else {
- /*
+ /*
** Set up to decode full HTTP/1.n response. - FM
*/
- format_in = HTAtom_for("www/mime");
- if (TRACE)
- fprintf (stderr, "--- Talking HTTP1.\n");
+ format_in = HTAtom_for("www/mime");
+ if (TRACE)
+ fprintf (stderr, "--- Talking HTTP1.\n");
- /*
+ /*
** We set start_of_data to "" when !eol here because there
- ** will be a put_block done below; we do *not* use the value
- ** of start_of_data (as a pointer) in the computation of
- ** length (or anything else) when !eol. Otherwise, set the
+ ** will be a put_block done below; we do *not* use the value
+ ** of start_of_data (as a pointer) in the computation of
+ ** length (or anything else) when !eol. Otherwise, set the
** value of length to what we have beyond eol (i.e., beyond
** the status line). - FM
*/
- start_of_data = eol ? eol + 1 : "";
- length = eol ? length - (start_of_data - line_buffer) : 0;
+ start_of_data = eol ? eol + 1 : "";
+ length = eol ? length - (start_of_data - line_buffer) : 0;
/*
** Trim trailing spaces in line_buffer so that we can use
@@ -902,74 +904,74 @@ try_again:
/*
** Take appropriate actions based on the status. - FM
*/
- switch (server_status/100) {
+ switch (server_status/100) {
case 1:
/*
- ** HTTP/1.1 Informational statuses.
- ** 100 Continue.
- ** 101 Switching Protocols.
- ** > 101 is unknown.
- ** We should never get these, and they have only
- ** the status line and possibly other headers,
- ** so we'll deal with them by showing the full
- ** header to the user as text/plain. - FM
+ ** HTTP/1.1 Informational statuses.
+ ** 100 Continue.
+ ** 101 Switching Protocols.
+ ** > 101 is unknown.
+ ** We should never get these, and they have only
+ ** the status line and possibly other headers,
+ ** so we'll deal with them by showing the full
+ ** header to the user as text/plain. - FM
*/
HTAlert("Got unexpected Informational Status.");
do_head = TRUE;
break;
- case 2:
+ case 2:
/*
- ** Good: Got MIME object! (Successful) - FM
+ ** Good: Got MIME object! (Successful) - FM
*/
if (do_head) {
- /*
+ /*
* If HEAD was requested, show headers (and possibly
* bogus body) for all 2xx status codes as text/plain - KW
*/
HTProgress(line_buffer);
- break;
+ break;
}
switch (server_status) {
case 204:
- /*
+ /*
* No Content.
*/
- HTAlert(line_buffer);
- HTTP_NETCLOSE(s, handle);
- status = HT_NO_DATA;
- goto clean_up;
+ HTAlert(line_buffer);
+ HTTP_NETCLOSE(s, handle);
+ status = HT_NO_DATA;
+ goto clean_up;
break;
case 205:
- /*
+ /*
* Reset Content. The server has fulfilled the
* request but nothing is returned and we should
* reset any form content. We'll instruct the
* user to do that, and restore the current
* document. - FM
*/
- HTAlert("Request fulfilled. Reset Content.");
- HTTP_NETCLOSE(s, handle);
- status = HT_NO_DATA;
- goto clean_up;
+ HTAlert("Request fulfilled. Reset Content.");
+ HTTP_NETCLOSE(s, handle);
+ status = HT_NO_DATA;
+ goto clean_up;
break;
case 206:
- /*
+ /*
* Partial Content. We didn't send a Range
- * so something went wrong somewhere. Show
+ * so something went wrong somewhere. Show
* the status message and restore the current
* document. - FM
*/
- HTAlert(line_buffer);
- HTTP_NETCLOSE(s, handle);
- status = HT_NO_DATA;
- goto clean_up;
+ HTAlert(line_buffer);
+ HTTP_NETCLOSE(s, handle);
+ status = HT_NO_DATA;
+ goto clean_up;
break;
default:
- /*
+ /*
* 200 OK.
* 201 Created.
* 202 Accepted.
@@ -979,33 +981,33 @@ try_again:
*/
HTProgress(line_buffer);
} /* case 2 switch */
- break;
+ break;
- case 3:
+ case 3:
/*
- ** Various forms of Redirection. - FM
- ** 300 Multiple Choices.
- ** 301 Moved Permanently.
- ** 302 Found (temporary; we can, and do, use GET).
- ** 303 See Other (temporary; always use GET).
- ** 304 Not Modified.
- ** 305 Use Proxy.
- ** 306 Set Proxy.
- ** 307 Temporary Redirect with method retained.
- ** > 308 is unknown.
+ ** Various forms of Redirection. - FM
+ ** 300 Multiple Choices.
+ ** 301 Moved Permanently.
+ ** 302 Found (temporary; we can, and do, use GET).
+ ** 303 See Other (temporary; always use GET).
+ ** 304 Not Modified.
+ ** 305 Use Proxy.
+ ** 306 Set Proxy.
+ ** 307 Temporary Redirect with method retained.
+ ** > 308 is unknown.
*/
if (no_url_redirection || do_head || keep_mime_headers) {
- /*
+ /*
* If any of these flags are set, we do not redirect,
* but instead show what was returned to the user as
* text/plain. - FM
*/
HTProgress(line_buffer);
- break;
+ break;
}
if (server_status == 300) { /* Multiple Choices */
- /*
+ /*
* For client driven content negotiation. The server
* should be sending some way for the user-agent to
* make a selection, so we'll show the user whatever
@@ -1025,9 +1027,9 @@ try_again:
if (!dump_output_immediately &&
format_out == HTAtom_for("www/download")) {
/*
- * Convert a download request to
- * a presentation request for
- * interactive users. - FM
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
*/
format_out = WWW_PRESENT;
}
@@ -1035,21 +1037,21 @@ try_again:
}
if (server_status == 304) { /* Not Modified */
- /*
+ /*
* We didn't send an "If-Modified-Since" header,
* so this status is inappropriate. We'll deal
* with it by showing the full header to the user
* as text/plain. - FM
*/
HTAlert("Got unexpected 304 Not Modified status.");
- do_head = TRUE;
+ do_head = TRUE;
break;
}
if (server_status == 305 ||
server_status == 306 ||
server_status > 307) {
- /*
+ /*
* Show user the content, if any, for 305, 306,
* or unknown status. - FM
*/
@@ -1062,44 +1064,44 @@ try_again:
if (!dump_output_immediately &&
format_out == HTAtom_for("www/download")) {
/*
- * Convert a download request to
- * a presentation request for
- * interactive users. - FM
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
*/
format_out = WWW_PRESENT;
}
break;
}
- /*
- * We do not load the file, but read the headers for
- * the "Location:", check out that redirecting_url
- * and if it's acceptible (e.g., not a telnet URL
- * when we have that disabled), initiate a new fetch.
- * If that's another redirecting_url, we'll repeat the
- * checks, and fetch initiations if acceptible, until
- * we reach the actual URL, or the redirection limit
- * set in HTAccess.c is exceeded. If the status was 301
- * indicating that the relocation is permanent, we set
- * the permanent_redirection flag to make it permanent
- * for the current anchor tree (i.e., will persist until
- * the tree is freed or the client exits). If the
- * redirection would include POST content, we seek
- * confirmation from an interactive user, with option to
- * use 303 for 301 (but not for 307), and otherwise refuse
- * the redirection. We also don't allow permanent
- * redirection if we keep POST content. If we don't find
- * the Location header or it's value is zero-length, we
- * display whatever the server returned, and the user
- * should RELOAD that to try again, or make a selection
- * from it if it contains links, or Left-Arrow to the
- * previous document. - FM
+ /*
+ * We do not load the file, but read the headers for
+ * the "Location:", check out that redirecting_url
+ * and if it's acceptible (e.g., not a telnet URL
+ * when we have that disabled), initiate a new fetch.
+ * If that's another redirecting_url, we'll repeat the
+ * checks, and fetch initiations if acceptible, until
+ * we reach the actual URL, or the redirection limit
+ * set in HTAccess.c is exceeded. If the status was 301
+ * indicating that the relocation is permanent, we set
+ * the permanent_redirection flag to make it permanent
+ * for the current anchor tree (i.e., will persist until
+ * the tree is freed or the client exits). If the
+ * redirection would include POST content, we seek
+ * confirmation from an interactive user, with option to
+ * use 303 for 301 (but not for 307), and otherwise refuse
+ * the redirection. We also don't allow permanent
+ * redirection if we keep POST content. If we don't find
+ * the Location header or it's value is zero-length, we
+ * display whatever the server returned, and the user
+ * should RELOAD that to try again, or make a selection
+ * from it if it contains links, or Left-Arrow to the
+ * previous document. - FM
*/
{
char *cp;
if ((dump_output_immediately || traversal) &&
- do_post &&
+ do_post &&
server_status != 303 &&
server_status != 302 &&
server_status != 301) {
@@ -1123,35 +1125,35 @@ try_again:
while ((status = HTTP_NETREAD(s, line_buffer,
(INIT_LINE_SIZE - 1),
handle)) > 0) {
- line_buffer[status] = '\0';
+ line_buffer[status] = '\0';
StrAllocCat(line_kept_clean, line_buffer);
}
HTTP_NETCLOSE(s, handle);
- if (status == HT_INTERRUPTED) {
+ if (status == HT_INTERRUPTED) {
/*
* Impatient user. - FM
*/
- if (TRACE)
- fprintf (stderr, "HTTP: Interrupted followup read.\n");
- _HTProgress ("Connection interrupted.");
- status = HT_INTERRUPTED;
- goto clean_up;
- }
+ if (TRACE)
+ fprintf (stderr, "HTTP: Interrupted followup read.\n");
+ _HTProgress ("Connection interrupted.");
+ status = HT_INTERRUPTED;
+ goto clean_up;
+ }
doing_redirect = TRUE;
if (server_status == 301) { /* Moved Permanently */
- HTProgress(line_buffer);
+ HTProgress(line_buffer);
if (do_post) {
- /*
+ /*
* Don't make the redirection permanent
* if we have POST content. - FM
*/
if (TRACE)
- fprintf(stderr,
+ fprintf(stderr,
"HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n");
HTAlert(
"Have POST content. Treating Permanent Redirection as Temporary.\n");
} else {
- permanent_redirection = TRUE;
+ permanent_redirection = TRUE;
}
}
@@ -1159,25 +1161,25 @@ try_again:
** Look for "Set-Cookie:" and "Set-Cookie2:" headers. - FM
*/
if (LYSetCookies == TRUE) {
- char *value = NULL;
+ char *value = NULL;
char *SetCookie = NULL;
char *SetCookie2 = NULL;
- cp = line_kept_clean;
+ cp = line_kept_clean;
while (*cp) {
/*
** Assume a CRLF pair terminates
** the header section. - FM
*/
if (*cp == CR) {
- if (*(cp+1) == LF &&
+ if (*(cp+1) == LF &&
*(cp+2) == CR && *(cp+3) == LF) {
break;
- }
+ }
}
if (TOUPPER(*cp) != 'S') {
- cp++;
- } else if (!strncasecomp(cp, "Set-Cookie:", 11)) {
- char *cp1 = NULL, *cp2 = NULL;
+ cp++;
+ } else if (!strncasecomp(cp, "Set-Cookie:", 11)) {
+ char *cp1 = NULL, *cp2 = NULL;
cp += 11;
Cookie_continuation:
/*
@@ -1191,11 +1193,11 @@ Cookie_continuation:
if (((cp1 = strchr(cp, LF)) != NULL) ||
(cp2 = strchr(cp, CR)) != NULL) {
if (*cp1) {
- *cp1 = '\0';
+ *cp1 = '\0';
if ((cp2 = strchr(cp, CR)) != NULL)
*cp2 = '\0';
} else {
- *cp2 = '\0';
+ *cp2 = '\0';
}
}
if (*cp == '\0') {
@@ -1246,7 +1248,7 @@ Cookie_continuation:
}
FREE(value);
} else if (!strncasecomp(cp, "Set-Cookie2:", 12)) {
- char *cp1 = NULL, *cp2 = NULL;
+ char *cp1 = NULL, *cp2 = NULL;
cp += 12;
Cookie2_continuation:
/*
@@ -1260,11 +1262,11 @@ Cookie2_continuation:
if (((cp1 = strchr(cp, LF)) != NULL) ||
(cp2 = strchr(cp, CR)) != NULL) {
if (*cp1) {
- *cp1 = '\0';
+ *cp1 = '\0';
if ((cp2 = strchr(cp, CR)) != NULL)
*cp2 = '\0';
} else {
- *cp2 = '\0';
+ *cp2 = '\0';
}
}
if (*cp == '\0') {
@@ -1273,7 +1275,7 @@ Cookie2_continuation:
if (cp2)
*cp2 = CR;
if (value != NULL) {
- HTMIME_TrimDoubleQuotes(value);
+ HTMIME_TrimDoubleQuotes(value);
if (SetCookie2 == NULL) {
StrAllocCopy(SetCookie2, value);
} else {
@@ -1315,7 +1317,7 @@ Cookie2_continuation:
}
FREE(value);
} else {
- cp++;
+ cp++;
}
}
FREE(value);
@@ -1331,25 +1333,25 @@ Cookie2_continuation:
*/
cp = line_kept_clean;
while (*cp) {
- if (TOUPPER(*cp) != 'L') {
+ if (TOUPPER(*cp) != 'L') {
cp++;
- } else if (!strncasecomp(cp, "Location:", 9)) {
- char *cp1 = NULL, *cp2 = NULL;
- cp += 9;
+ } else if (!strncasecomp(cp, "Location:", 9)) {
+ char *cp1 = NULL, *cp2 = NULL;
+ cp += 9;
/*
- * Trim leading spaces. - FM
+ * Trim leading spaces. - FM
*/
while (isspace((unsigned char)*cp))
- cp++;
+ cp++;
/*
- * Accept CRLF, LF, or CR as end of header. - FM
+ * Accept CRLF, LF, or CR as end of header. - FM
*/
if (((cp1 = strchr(cp, LF)) != NULL) ||
- (cp2 = strchr(cp, CR)) != NULL) {
+ (cp2 = strchr(cp, CR)) != NULL) {
if (*cp1) {
*cp1 = '\0';
if ((cp2 = strchr(cp, CR)) != NULL)
- *cp2 = '\0';
+ *cp2 = '\0';
} else {
*cp2 = '\0';
}
@@ -1361,17 +1363,17 @@ Cookie2_continuation:
HTMIME_TrimDoubleQuotes(redirecting_url);
if (*redirecting_url == '\0') {
/*
- * The "Location:" value is zero-length, and
- * thus is probably something in the body, so
- * we'll show the user what was returned. - FM
+ * The "Location:" value is zero-length, and
+ * thus is probably something in the body, so
+ * we'll show the user what was returned. - FM
*/
if (TRACE)
- fprintf(stderr,
+ fprintf(stderr,
"HTTP: 'Location:' is zero-length!\n");
if (cp1)
- *cp1 = LF;
+ *cp1 = LF;
if (cp2)
- *cp2 = CR;
+ *cp2 = CR;
bad_location = TRUE;
FREE(redirecting_url);
HTAlert(
@@ -1386,28 +1388,28 @@ Cookie2_continuation:
* seek the document at that Location. - FM
*/
HTProgress(line_buffer);
- if (TRACE)
- fprintf(stderr,
- "HTTP: Picked up location '%s'\n",
+ if (TRACE)
+ fprintf(stderr,
+ "HTTP: Picked up location '%s'\n",
redirecting_url);
if (cp1)
- *cp1 = LF;
- if (cp2)
- *cp2 = CR;
+ *cp1 = LF;
+ if (cp2)
+ *cp2 = CR;
if (server_status == 305) { /* Use Proxy */
/*
- * Make sure the proxy field ends with
- * a slash. - FM
+ * Make sure the proxy field ends with
+ * a slash. - FM
*/
if (redirecting_url[strlen(redirecting_url)-1]
- != '/')
+ != '/')
StrAllocCat(redirecting_url, "/");
/*
- * Append our URL. - FM
+ * Append our URL. - FM
*/
StrAllocCat(redirecting_url, anAnchor->address);
if (TRACE)
- fprintf(stderr,
+ fprintf(stderr,
"HTTP: Proxy URL is '%s'\n",
redirecting_url);
}
@@ -1415,13 +1417,13 @@ Cookie2_continuation:
server_status == 303 ||
server_status == 302) {
/*
- * We don't have POST content (nor support PUT
- * or DELETE), or the status is "See Other" or
- * "General Redirection" and we can convert to
- * GET, so go back and check out the new URL. - FM
+ * We don't have POST content (nor support PUT
+ * or DELETE), or the status is "See Other" or
+ * "General Redirection" and we can convert to
+ * GET, so go back and check out the new URL. - FM
*/
- status = HT_REDIRECTING;
- goto clean_up;
+ status = HT_REDIRECTING;
+ goto clean_up;
}
/*
* Make sure the user wants to redirect
@@ -1430,41 +1432,41 @@ Cookie2_continuation:
switch (HTConfirmPostRedirect(redirecting_url,
server_status)) {
/*
- * User failed to confirm.
- * Abort the fetch.
+ * User failed to confirm.
+ * Abort the fetch.
*/
case 0:
- doing_redirect = FALSE;
+ doing_redirect = FALSE;
FREE(redirecting_url);
status = HT_NO_DATA;
goto clean_up;
-
+
/*
- * User wants to treat as GET with no content.
- * Go back to check out the URL.
+ * User wants to treat as GET with no content.
+ * Go back to check out the URL.
*/
case 303:
status = HT_REDIRECTING;
goto clean_up;
/*
- * Set the flag to retain the POST
- * content and go back to check out
- * the URL. - FM
+ * Set the flag to retain the POST
+ * content and go back to check out
+ * the URL. - FM
*/
default:
status = HT_REDIRECTING;
redirect_post_content = TRUE;
goto clean_up;
- }
+ }
}
- break;
- } else {
+ break;
+ } else {
/*
- * Keep looking for the Location header. - FM
+ * Keep looking for the Location header. - FM
*/
- cp++;
- }
+ cp++;
+ }
}
/*
@@ -1472,8 +1474,8 @@ Cookie2_continuation:
* header, so we'll show the user what we got, if
* anything. - FM
*/
- if (TRACE)
- fprintf (stderr, "HTTP: Failed to pick up location.\n");
+ if (TRACE)
+ fprintf (stderr, "HTTP: Failed to pick up location.\n");
doing_redirect = FALSE;
permanent_redirection = FALSE;
start_of_data = line_kept_clean;
@@ -1499,13 +1501,13 @@ Cookie2_continuation:
break;
}
- case 4:
+ case 4:
/*
- ** "I think I goofed!" (Client Error) - FM
+ ** "I think I goofed!" (Client Error) - FM
*/
- switch (server_status) {
- case 401: /* Unauthorized */
- /*
+ switch (server_status) {
+ case 401: /* Unauthorized */
+ /*
* Authorization for orgin server required.
* If show_401 is set, proceed to showing the
* 401 body. Otherwise, if we can set up
@@ -1520,42 +1522,42 @@ Cookie2_continuation:
if (HTAA_shouldRetryWithAuth(start_of_data, length,
(void *)handle, s, NO)) {
- HTTP_NETCLOSE(s, handle);
- if (dump_output_immediately && !authentication_info[0]) {
- fprintf(stderr,
- "HTTP: Access authorization required.\n");
- fprintf(stderr,
- " Use the -auth=id:pw parameter.\n");
- status = HT_NO_DATA;
- goto clean_up;
- }
-
- if (TRACE)
- fprintf(stderr, "%s %d %s\n",
- "HTTP: close socket", s,
- "to retry with Access Authorization");
-
- _HTProgress (
- "Retrying with access authorization information.");
+ HTTP_NETCLOSE(s, handle);
+ if (dump_output_immediately && !authentication_info[0]) {
+ fprintf(stderr,
+ "HTTP: Access authorization required.\n");
+ fprintf(stderr,
+ " Use the -auth=id:pw parameter.\n");
+ status = HT_NO_DATA;
+ goto clean_up;
+ }
+
+ if (TRACE)
+ fprintf(stderr, "%s %d %s\n",
+ "HTTP: close socket", s,
+ "to retry with Access Authorization");
+
+ _HTProgress (
+ "Retrying with access authorization information.");
FREE(line_buffer);
FREE(line_kept_clean);
- goto try_again;
- break;
+ goto try_again;
+ break;
} else if (!(traversal || dump_output_immediately) &&
- HTConfirm("Show the 401 message body?")) {
+ HTConfirm("Show the 401 message body?")) {
break;
- } else {
+ } else {
if (traversal || dump_output_immediately)
- HTAlert(
+ HTAlert(
"Can't retry with authorization! Contact the server's WebMaster.");
HTTP_NETCLOSE(s, handle);
- status = -1;
- goto clean_up;
+ status = -1;
+ goto clean_up;
}
break;
case 407:
- /*
+ /*
* Authorization for proxy server required.
* If we are not in fact using a proxy, or
* show_407 is set, proceed to showing the
@@ -1571,29 +1573,29 @@ Cookie2_continuation:
if (HTAA_shouldRetryWithAuth(start_of_data, length,
(void *)handle, s, YES)) {
- HTTP_NETCLOSE(s, handle);
- if (dump_output_immediately && !proxyauth_info[0]) {
- fprintf(stderr,
- "HTTP: Proxy authorization required.\n");
- fprintf(stderr,
- " Use the -pauth=id:pw parameter.\n");
- status = HT_NO_DATA;
- goto clean_up;
- }
-
- if (TRACE)
- fprintf(stderr, "%s %d %s\n",
- "HTTP: close socket", s,
- "to retry with Proxy Authorization");
-
- _HTProgress (
- "Retrying with proxy authorization information.");
+ HTTP_NETCLOSE(s, handle);
+ if (dump_output_immediately && !proxyauth_info[0]) {
+ fprintf(stderr,
+ "HTTP: Proxy authorization required.\n");
+ fprintf(stderr,
+ " Use the -pauth=id:pw parameter.\n");
+ status = HT_NO_DATA;
+ goto clean_up;
+ }
+
+ if (TRACE)
+ fprintf(stderr, "%s %d %s\n",
+ "HTTP: close socket", s,
+ "to retry with Proxy Authorization");
+
+ _HTProgress (
+ "Retrying with proxy authorization information.");
FREE(line_buffer);
FREE(line_kept_clean);
- goto try_again;
- break;
+ goto try_again;
+ break;
} else if (!(traversal || dump_output_immediately) &&
- HTConfirm("Show the 407 message body?")) {
+ HTConfirm("Show the 407 message body?")) {
if (!dump_output_immediately &&
format_out == HTAtom_for("www/download")) {
/*
@@ -1604,29 +1606,29 @@ Cookie2_continuation:
format_out = WWW_PRESENT;
}
break;
- } else {
+ } else {
if (traversal || dump_output_immediately)
- HTAlert(
+ HTAlert(
"Can't retry with proxy authorization! Contact the server's WebMaster.");
HTTP_NETCLOSE(s, handle);
- status = -1;
- goto clean_up;
+ status = -1;
+ goto clean_up;
}
break;
case 408:
- /*
+ /*
* Request Timeout. Show the status message
* and restore the current document. - FM
*/
- HTAlert(line_buffer);
- HTTP_NETCLOSE(s, handle);
- status = HT_NO_DATA;
- goto done;
+ HTAlert(line_buffer);
+ HTTP_NETCLOSE(s, handle);
+ status = HT_NO_DATA;
+ goto done;
break;
- default:
- /*
+ default:
+ /*
* 400 Bad Request.
* 402 Payment Required.
* 403 Forbidden.
@@ -1655,28 +1657,28 @@ Cookie2_continuation:
if (!dump_output_immediately &&
format_out == HTAtom_for("www/download")) {
/*
- * Convert a download request to
- * a presentation request for
- * interactive users. - FM
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
*/
format_out = WWW_PRESENT;
}
- break;
- } /* case 4 switch */
- break;
+ break;
+ } /* case 4 switch */
+ break;
- case 5:
+ case 5:
/*
- ** "I think YOU goofed!" (server error)
- ** 500 Internal Server Error
- ** 501 Not Implemented
- ** 502 Bad Gateway
- ** 503 Service Unavailable
- ** 504 Gateway Timeout
- ** 505 HTTP Version Not Supported
- ** > 505 is unknown.
- ** Should always include a message, which
- ** we always should display. - FM
+ ** "I think YOU goofed!" (server error)
+ ** 500 Internal Server Error
+ ** 501 Not Implemented
+ ** 502 Bad Gateway
+ ** 503 Service Unavailable
+ ** 504 Gateway Timeout
+ ** 505 HTTP Version Not Supported
+ ** > 505 is unknown.
+ ** Should always include a message, which
+ ** we always should display. - FM
*/
HTAlert(line_buffer);
if (traversal) {
@@ -1693,15 +1695,15 @@ Cookie2_continuation:
*/
format_out = WWW_PRESENT;
}
- break;
+ break;
- default:
+ default:
/*
- ** Bad or unknown server_status number.
- ** Take a chance and hope there is
- ** something to display. - FM
+ ** Bad or unknown server_status number.
+ ** Take a chance and hope there is
+ ** something to display. - FM
*/
- HTAlert("Unknown status reply from server!");
+ HTAlert("Unknown status reply from server!");
HTAlert(line_buffer);
if (traversal) {
HTTP_NETCLOSE(s, handle);
@@ -1717,10 +1719,10 @@ Cookie2_continuation:
*/
format_out = WWW_PRESENT;
}
- break;
- } /* Switch on server_status/100 */
+ break;
+ } /* Switch on server_status/100 */
- } /* Full HTTP reply */
+ } /* Full HTTP reply */
} /* scope of fields */
/*
@@ -1736,15 +1738,15 @@ Cookie2_continuation:
}
target = HTStreamStack(format_in,
- format_out,
- sink, anAnchor);
+ format_out,
+ sink, anAnchor);
if (!target || target == NULL) {
char buffer[1024]; /* @@@@@@@@ */
HTTP_NETCLOSE(s, handle);
sprintf(buffer, "Sorry, no known way of converting %s to %s.",
- HTAtom_name(format_in), HTAtom_name(format_out));
+ HTAtom_name(format_in), HTAtom_name(format_out));
_HTProgress (buffer);
status = -1;
goto clean_up;
@@ -1770,31 +1772,31 @@ Cookie2_continuation:
goto clean_up;
}
- if (rv == -2) {
+ if (rv == -2) {
/*
** Aw hell, a REAL error, maybe cuz it's a dumb HTTP0 server
*/
(*target->isa->_abort)(target, NULL);
HTTP_NETCLOSE(s, handle);
if (!already_retrying && !do_post) {
- if (TRACE)
- fprintf (stderr, "HTTP: Trying again with HTTP0 request.\n");
- /*
- ** May as well consider it an interrupt -- right?
- */
- FREE(line_buffer);
- FREE(line_kept_clean);
- extensions = NO;
- already_retrying = TRUE;
- _HTProgress ("Retrying as HTTP0 request.");
- goto try_again;
+ if (TRACE)
+ fprintf (stderr, "HTTP: Trying again with HTTP0 request.\n");
+ /*
+ ** May as well consider it an interrupt -- right?
+ */
+ FREE(line_buffer);
+ FREE(line_kept_clean);
+ extensions = NO;
+ already_retrying = TRUE;
+ _HTProgress ("Retrying as HTTP0 request.");
+ goto try_again;
} else {
- status = HT_NOT_LOADED;
+ status = HT_NOT_LOADED;
goto clean_up;
}
}
- /*
+ /*
** Free if complete transmission (socket was closed before return).
** Close socket if partial transmission (was freed on abort).
*/
@@ -1811,9 +1813,9 @@ Cookie2_continuation:
*/
/* Lou's old comment: - FM */
/* OK, now we've got the redirection URL temporarily stored
- in external variable redirecting_url, exported from HTMIME.c,
- since there's no straightforward way to do this in the library
- currently. Do the right thing. */
+ in external variable redirecting_url, exported from HTMIME.c,
+ since there's no straightforward way to do this in the library
+ currently. Do the right thing. */
status = HT_REDIRECTING;
} else {
/*
@@ -1835,6 +1837,7 @@ done:
*/
do_head = FALSE;
do_post = FALSE;
+ reloading = FALSE;
return status;
}
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index fedd0f40..61f01f1c 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -5,7 +5,7 @@
** SGML file, create this object which is a parser. The object
** is (currently) created by being passed a DTD structure,
** and a target HTStructured oject at which to throw the parsed stuff.
-**
+**
** 6 Feb 93 Binary seraches used. Intreface modified.
*/
@@ -37,7 +37,7 @@
#define FREE(x) if (x) {free(x); x = NULL;}
PUBLIC HTCJKlang HTCJK = NOCJK; /* CJK enum value. */
-PUBLIC BOOL HTPassEightBitRaw = FALSE; /* Pass 161-172,174-255 raw. */
+PUBLIC BOOL HTPassEightBitRaw = FALSE; /* Pass 161-172,174-255 raw. */
PUBLIC BOOL HTPassEightBitNum = FALSE; /* Pass ^ numeric entities raw. */
PUBLIC BOOL HTPassHighCtrlRaw = FALSE; /* Pass 127-160,173,&#127; raw. */
PUBLIC BOOL HTPassHighCtrlNum = FALSE; /* Pass &#128;-&#159; raw. */
@@ -52,7 +52,7 @@ extern int LYlowest_eightbit[];
#define MAX_ATTRIBUTES 36 /* Max number of attributes per element */
-
+
/* Element Stack
** -------------
** This allows us to return down the stack reselcting styles.
@@ -71,7 +71,7 @@ struct _HTElement {
struct _HTStream {
CONST HTStreamClass * isa; /* inherited from HTStream */
-
+
CONST SGML_dtd *dtd;
HTStructuredClass *actions; /* target class */
HTStructured *target; /* target object */
@@ -112,8 +112,8 @@ struct _HTStream {
HTParentAnchor * node_anchor;
LYUCcharset * inUCI; /* pointer to anchor UCInfo */
int inUCLYhndl; /* charset we are fed */
- LYUCcharset * outUCI; /* anchor UCInfo for target */
- int outUCLYhndl; /* charset for target */
+ LYUCcharset * outUCI; /* anchor UCInfo for target */
+ int outUCLYhndl; /* charset for target */
char utf_count;
UCode_t utf_char;
char utf_buf[8];
@@ -144,13 +144,13 @@ PRIVATE void set_chartrans_handling ARGS3(
chndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_STRUCTURED);
if (chndl < 0)
/*
- ** That wasn't set either, so seek the HText default. - FM
+ ** That wasn't set either, so seek the HText default. - FM
*/
chndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT);
if (chndl < 0)
/*
- ** That wasn't set either, so assume the current display
- ** character set. - FM
+ ** That wasn't set either, so assume the current display
+ ** character set. - FM
*/
chndl = current_char_set;
/*
@@ -173,18 +173,18 @@ PRIVATE void set_chartrans_handling ARGS3(
UCT_STAGE_STRUCTURED);
}
/*
- ** Set the in->out transformation parameters. - FM
+ ** Set the in->out transformation parameters. - FM
*/
UCSetTransParams(&context->T,
context->inUCLYhndl, context->inUCI,
context->outUCLYhndl, context->outUCI);
/*
- ** This is intended for passing the SGML parser's input
- ** charset as an argument in each call to the HTML
- ** parser's start tag function, but it would be better
- ** to call a Lynx_HTML_parser function to set an element
- ** in its HTStructured object, itself, if this were
- ** needed. - FM
+ ** This is intended for passing the SGML parser's input
+ ** charset as an argument in each call to the HTML
+ ** parser's start tag function, but it would be better
+ ** to call a Lynx_HTML_parser function to set an element
+ ** in its HTStructured object, itself, if this were
+ ** needed. - FM
*/
if (HTCJK != NOCJK) {
context->current_tag_charset = -1;
@@ -200,7 +200,7 @@ PRIVATE void set_chartrans_handling ARGS3(
context->current_tag_charset = UCGetLYhndl_byMIME("unicode-1-1-utf-8");
} else {
context->current_tag_charset = 0;
- }
+ }
}
PRIVATE void change_chartrans_handling ARGS1(
@@ -261,14 +261,14 @@ PRIVATE void handle_attribute_name ARGS2(
int high, low, i, diff;
/*
- ** Ignore unknown tag. - KW
+ ** Ignore unknown tag. - KW
*/
if (tag == context->unknown_tag) {
return;
}
/*
- ** Binary search for attribute name.
+ ** Binary search for attribute name.
*/
for (low = 0, high = tag->number_of_attributes;
high > low;
@@ -286,9 +286,9 @@ PRIVATE void handle_attribute_name ARGS2(
#endif
return;
} /* if */
-
+
} /* for */
-
+
if (TRACE)
fprintf(stderr, "SGML: Unknown attribute %s for tag %s\n",
s, context->current_tag->name);
@@ -327,7 +327,13 @@ PRIVATE void handle_attribute_value ARGS2(
/*
-** translate some Unicodes to Lynx special codes and output them.
+** Translate some Unicodes to Lynx special codes and output them.
+** Special codes - ones those output depend on parsing.
+**
+** Additional issue, like handling bidirectional text if nesseccery
+** may be called from here: zwnj (8204), zwj (8205), lrm (8206), rlm (8207)
+** - currently they are passed to def7_uni.tbl as regular characters.
+**
*/
PRIVATE BOOL put_special_unicodes ARGS2(
HTStream *, context,
@@ -346,13 +352,20 @@ PRIVATE BOOL put_special_unicodes ARGS2(
} else if (code == 8194 || code == 8195 || code == 8201) {
/*
** Use Lynx special character for ensp, emsp or thinsp.
+ **
+ ** Originally, Lynx use space '32' as word delimiter and omits this
+ ** space at end of line if word is wrapped to the next line. There
+ ** are several other spaces in the Unicode repertoire and we should
+ ** teach Lynx to understand them, not only as regular characters but
+ ** in the context of line wrapping. Unfortunately, if we use
+ ** HT_EM_SPACE we override the chartrans tables for those spaces
+ ** (e.g., emsp= double space) with a single '32' for all (but do line
+ ** wrapping more fancy). In the future we need HT_SPACE with a
+ ** transferred parameter (Unicode number) which falls back to
+ ** chartrans if line wrapping is not the case.
+ **
*/
PUTC(HT_EM_SPACE);
- } else if (code == 8211 || code == 8212) {
- /*
- ** Use ASCII hyphen for ndash/endash or mdash/emdash.
- */
- PUTC('-');
} else {
/*
** Return NO if nothing done.
@@ -391,49 +404,14 @@ PRIVATE void handle_entity ARGS2(
HTStream *, context,
char, term)
{
- CONST char ** entities = context->dtd->entity_names;
UCode_t code;
long uck;
CONST char *s = context->string->data;
int high, low, i, diff;
- /*
- ** Use Lynx special characters for nbsp (160), ensp (8194),
- ** emsp (8195), thinsp (8201), and shy (173). - FM
- */
- if (!strcmp(s, "nbsp")) {
- PUTC(HT_NON_BREAK_SPACE);
- FoundEntity = TRUE;
- return;
- }
- if (!strcmp(s, "ensp") || !strcmp(s, "emsp") || !strcmp(s, "thinsp")) {
- PUTC(HT_EM_SPACE);
- FoundEntity = TRUE;
- return;
- }
- if (!strcmp(s, "shy")) {
- PUTC(LY_SOFT_HYPHEN);
- FoundEntity = TRUE;
- return;
- }
-
-#ifdef NOTUSED_FOTEMODS
- /*
- ** For ndash or endash (8211), and mdash or emdash (8212),
- ** use an ASCII hyphen (32). - FM
- */
- if (!strcmp(s, "ndash") ||
- !strcmp(s, "endash") ||
- !strcmp(s, "mdash") ||
- !strcmp(s, "endash")) {
- PUTC('-');
- FoundEntity = TRUE;
- return;
- }
-#endif /* NOTUSED_FOTEMODS */
/*
- ** Handle all other entities normally. - FM
+ ** Handle named entities.
*/
FoundEntity = FALSE;
if ((code = HTMLGetEntityUCValue(s)) != 0) {
@@ -441,12 +419,13 @@ PRIVATE void handle_entity ARGS2(
** We got a Unicode value for the entity name.
** Check for special Unicodes. - FM
*/
- if (put_special_unicodes(context, code)) {
+ if (put_special_unicodes(context, code)) {
FoundEntity = TRUE;
return;
}
/*
- ** Seek a translation from the chartrans tables.
+ ** No special unicodes -
+ ** seek a translation from the chartrans tables.
*/
if ((uck = UCTransUniChar(code, context->outUCLYhndl)) >= 32 &&
uck < 256 &&
@@ -499,55 +478,12 @@ PRIVATE void handle_entity ARGS2(
return;
}
}
-#ifdef NOTUSED_FOTEMODS
- /*
- ** Ignore zwnj (8204) and zwj (8205), if we get to here.
- ** Note that zwnj may have been handled as <WBR>
- ** by the calling function. - FM
- */
- if (!strcmp(s, "zwnj") ||
- !strcmp(s, "zwj")) {
- if (TRACE) {
- fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s);
- }
- FoundEntity = TRUE;
- return;
- }
-
- /*
- ** Ignore lrm (8206), and rln (8207), if we get to here. - FM
- */
- if (!strcmp(s, "lrm") ||
- !strcmp(s, "rlm")) {
- if (TRACE) {
- fprintf(stderr, "handle_entity: Ignoring '%s'.\n", s);
- }
- FoundEntity = TRUE;
- return;
- }
-#endif /* NOTUSED_FOTEMODS */
-
- /*
- ** We haven't succeeded yet, so try the old LYCharSets
- ** arrays for translation strings. - FM
- */
- for (low = 0, high = context->dtd->number_of_entities;
- high > low;
- diff < 0 ? (low = i+1) : (high = i)) { /* Binary search */
- i = (low + (high-low)/2);
- diff = strcmp(entities[i], s); /* Case sensitive! */
- if (diff == 0) { /* success: found it */
- (*context->actions->put_entity)(context->target, i);
- FoundEntity = TRUE;
- return;
- }
- }
/*
** If entity string not found, display as text.
*/
if (TRACE)
- fprintf(stderr, "SGML: Unknown entity '%s'\n", s);
+ fprintf(stderr, "SGML: Unknown entity '%s'\n", s);
PUTC('&');
{
CONST char *p;
@@ -732,7 +668,7 @@ PRIVATE void do_close_stacked ARGS1(
PRIVATE int is_on_stack ARGS2(
HTStream *, context,
HTTag *, old_tag)
-{
+{
HTElement * stacked = context->element_stack;
int i = 1;
for (; stacked; stacked = stacked->next, i++) {
@@ -837,11 +773,11 @@ PRIVATE void end_element ARGS2(
#ifdef WIND_DOWN_STACK
while (context->element_stack) { /* Loop is error path only */
#else
- if (context->element_stack) { /* Substitute and remove one stack element */
+ if (context->element_stack) { /* Substitute and remove one stack element */
#endif /* WIND_DOWN_STACK */
HTElement * N = context->element_stack;
HTTag * t = N->tag;
-
+
if (old_tag != t) { /* Mismatch: syntax error */
if (context->element_stack->next) { /* This is not the last level */
if (TRACE) fprintf(stderr,
@@ -854,7 +790,7 @@ PRIVATE void end_element ARGS2(
return; /* Ignore */
}
}
-
+
context->element_stack = N->next; /* Remove from stack */
FREE(N);
(*context->actions->end_element)(context->target,
@@ -865,9 +801,9 @@ PRIVATE void end_element ARGS2(
#else
return;
#endif /* WIND_DOWN_STACK */
-
+
/* Syntax error path only */
-
+
}
if (TRACE)
fprintf(stderr, "SGML: Extra end tag </%s> found and ignored.\n",
@@ -941,7 +877,7 @@ PRIVATE void start_element ARGS1(
return;
}
}
-
+
if (context->element_stack &&
canclose_check == close_error && !(valid =
element_valid_within(
@@ -1120,7 +1056,7 @@ PRIVATE void SGML_free ARGS1(
** Free the strings and context structure. - FM
*/
HTChunkFree(context->string);
- for (i = 0; i < MAX_ATTRIBUTES; i++)
+ for (i = 0; i < MAX_ATTRIBUTES; i++)
FREE(context->value[i]);
FREE(context);
}
@@ -1158,7 +1094,7 @@ PRIVATE void SGML_abort ARGS2(
** Free the strings and context structure. - FM
*/
HTChunkFree(context->string);
- for (i = 0; i < MAX_ATTRIBUTES; i++)
+ for (i = 0; i < MAX_ATTRIBUTES; i++)
FREE(context->value[i]);
FREE(context);
}
@@ -1172,7 +1108,7 @@ PRIVATE void SGML_abort ARGS2(
** particular SGML context.
*/
-#ifdef CALLERDATA
+#ifdef CALLERDATA
PUBLIC void* SGML_callerData ARGS1(
HTStream *, context)
{
@@ -1218,7 +1154,7 @@ PRIVATE void SGML_character ARGS2(
*/
if ((unsigned char)c > 127) {
/*
- ** We have an octet from a multibyte character. - FM
+ ** We have an octet from a multibyte character. - FM
*/
if (context->utf_count > 0 && (c & 0xc0) == 0x80) {
context->utf_char = (context->utf_char << 6) | (c & 0x3f);
@@ -1227,9 +1163,9 @@ PRIVATE void SGML_character ARGS2(
(context->utf_buf_p)++;
if (context->utf_count == 0) {
/*
- ** We have all of the bytes, so terminate
- ** the buffer and set 'clong' to the UCode_t
- ** value. - FM
+ ** We have all of the bytes, so terminate
+ ** the buffer and set 'clong' to the UCode_t
+ ** value. - FM
*/
*(context->utf_buf_p) = '\0';
clong = context->utf_char;
@@ -1289,20 +1225,10 @@ PRIVATE void SGML_character ARGS2(
}
}
-#ifdef NOTDEFINED
- /*
- ** If we have a koi8-r input and do not have
- ** koi8-r as the output, save the raw input
- ** in saved_char_in before we potentially
- ** convert it to Unicode. - FM
- */
- if (context->T.strip_raw_char_in)
- saved_char_in = c;
-#endif /* NOTDEFINED */
/*
- ** If we want the raw input converted
- ** to Unicode, try that now. - FM
+ ** If we want the raw input converted
+ ** to Unicode, try that now. - FM
*/
if (context->T.trans_to_uni &&
((unsign_c >= 127) ||
@@ -1418,7 +1344,7 @@ top1:
** or HTCJK set. - FM
*/
#define PASSHICTRL (context->T.transp || \
- unsign_c >= LYlowest_eightbit[context->inUCLYhndl])
+ unsign_c >= LYlowest_eightbit[context->inUCLYhndl])
if (c == 127 &&
!(PASSHICTRL || HTCJK != NOCJK))
return;
@@ -1437,7 +1363,7 @@ top1:
switch(context->state) {
case S_in_kanji:
- /*
+ /*
** Note that if we don't have a CJK input, then this
** is not the second byte of a CJK di-byte, and we're
** trashing the input. That's why 8-bit characters
@@ -1455,13 +1381,13 @@ top1:
if (HTCJK != NOCJK && (c & 0200) != 0) {
/*
** Setting up for Kanji multibyte handling (based on
- ** Takuya ASADA's (asada@three-a.co.jp) CJK Lynx).
- ** Note that if the input is not in fact CJK, the
- ** next byte also will be mishandled, as explained
- ** above. Toggle raw mode off in such cases, or
- ** select the "7 bit approximations" display
- ** character set, which is largely equivalent
- ** to having raw mode off with CJK. - FM
+ ** Takuya ASADA's (asada@three-a.co.jp) CJK Lynx).
+ ** Note that if the input is not in fact CJK, the
+ ** next byte also will be mishandled, as explained
+ ** above. Toggle raw mode off in such cases, or
+ ** select the "7 bit approximations" display
+ ** character set, which is largely equivalent
+ ** to having raw mode off with CJK. - FM
*/
context->state = S_in_kanji;
PUTC(c);
@@ -1525,7 +1451,7 @@ top1:
saved_char_in = '\0';
/******************************************************************
* I. LATIN-1 OR UCS2 TO DISPLAY CHARSET
- ******************************************************************/
+ ******************************************************************/
} else if ((chk = (context->T.trans_from_uni && unsign_c >= 160)) &&
(uck = UCTransUniChar(unsign_c,
context->outUCLYhndl)) >= 32 &&
@@ -1536,7 +1462,7 @@ top1:
uck, FROMASCII((char)uck));
}
/*
- ** We got one octet from the conversions, so use it. - FM
+ ** We got one octet from the conversions, so use it. - FM
*/
PUTC(FROMASCII((char)uck));
} else if (chk &&
@@ -1548,9 +1474,9 @@ top1:
*/
(uck = UCTransUniCharStr(replace_buf, 60, clong,
context->outUCLYhndl,
- 0) >= 0)) {
+ 0) >= 0)) {
/*
- ** Got a replacement string.
+ ** Got a replacement string.
** No further tests for valididy - assume that whoever
** defined replacement strings knew what she was doing. - KW
*/
@@ -1636,7 +1562,7 @@ top1:
}
break;
- /*
+ /*
** In litteral mode, waits only for specific end tag (for
** compatibility with old servers, and for Lynx). - FM
*/
@@ -1646,7 +1572,7 @@ top1:
'/' :
context->element_stack->tag->name[string->size-2])) {
int i;
-
+
/*
** If complete match, end litteral.
*/
@@ -1665,7 +1591,7 @@ top1:
for (i = 0; i < string->size; i++) /* recover */
PUTC(string->data[i]);
string->size = 0;
- context->state = S_text;
+ context->state = S_text;
}
break;
@@ -1677,11 +1603,11 @@ top1:
/*
** Setting up for possible numeric entity.
*/
- context->state = S_cro; /* &# is Char Ref Open */
+ context->state = S_cro; /* &# is Char Ref Open */
break;
}
context->state = S_entity; /* Fall through! */
-
+
/*
** Handle possible named entity.
*/
@@ -1719,9 +1645,9 @@ top1:
"SGML_character: Handling 'zwnj' entity as 'WBR' element.\n");
}
if (c != ';') {
- sprintf(temp, "<WBR>%c", c);
+ sprintf(temp, "<WBR>%c", c);
} else {
- sprintf(temp, "<WBR>");
+ sprintf(temp, "<WBR>");
}
if (context->recover == NULL) {
StrAllocCopy(context->recover, temp);
@@ -1953,9 +1879,9 @@ top1:
** the standard semi-colon. - FM
*/
if (c != ';') {
- sprintf(temp, "<WBR>%c", c);
+ sprintf(temp, "<WBR>%c", c);
} else {
- sprintf(temp, "<WBR>");
+ sprintf(temp, "<WBR>");
}
/*
** Add the replacement string to the
@@ -1972,17 +1898,12 @@ top1:
context->state = S_text;
break;
}
- if (code == 160 || code == 173) {
+
/*
- ** We *always* should interpret these as Latin1 here!
- ** Output the Lynx special character for nbsp and
- ** then recycle the terminator or break. - FM
+ ** Check for special Unicodes.
*/
- if (code == 160) {
- PUTC(HT_NON_BREAK_SPACE);
- } else {
- PUTC(LY_SOFT_HYPHEN);
- }
+ if (put_special_unicodes(context, code)) {
+
string->size = 0;
context->isHex = FALSE;
context->state = S_text;
@@ -1991,7 +1912,8 @@ top1:
break;
}
/*
- ** Seek a translation from the chartrans tables.
+ ** No special unicodes -
+ ** seek a translation from the chartrans tables.
*/
if ((uck = UCTransUniChar(code,
context->outUCLYhndl)) >= 32 &&
@@ -2023,7 +1945,7 @@ top1:
*/
(uck = UCTransUniCharStr(replace_buf, 60, code,
context->outUCLYhndl,
- 0) >= 0)) {
+ 0) >= 0)) {
for (p = replace_buf; *p; p++) {
PUTC(*p);
}
@@ -2114,11 +2036,6 @@ top1:
** ensp, emsp or thinsp. - FM
*/
PUTC(HT_EM_SPACE);
- } else if (code == 8211 || code == 8212) {
- /*
- ** ndash or mdash. - FM
- */
- PUTC('-');
} else {
/*
** Unhandled or illegal value. Recover the
@@ -2148,7 +2065,7 @@ top1:
PUTC(FROMASCII((char)code));
} else {
/*
- ** Handle as named entity. - FM
+ ** Handle as named entity. - FM
*/
code -= 160;
EntityName = HTMLGetEntityName(code);
@@ -2230,7 +2147,7 @@ top1:
/*
** Tag
- */
+ */
case S_tag: /* new tag */
if (unsign_c < 127 && (string->size ?
isalnum((unsigned char)c) : isalpha((unsigned char)c))) {
@@ -2311,8 +2228,8 @@ top1:
*/
}
context->current_tag = t;
-
- /*
+
+ /*
** Clear out attributes.
*/
{
@@ -2322,7 +2239,7 @@ top1:
}
string->size = 0;
context->current_attribute_number = INVALID;
-
+
if (c == '>') {
if (context->current_tag->name)
start_element(context);
@@ -2619,7 +2536,7 @@ top1:
HTChunkPutc(string, c);
context->state = S_attr; /* Get attribute */
break;
-
+
/* accumulating value */
case S_attr:
if (WHITE(c) || (c == '>') || (c == '=')) { /* End of word */
@@ -2637,7 +2554,7 @@ top1:
HTChunkPutc(string, c);
}
break;
-
+
case S_attr_gap: /* Expecting attribute or '=' or '>' */
if (WHITE(c))
break; /* Gap after attribute */
@@ -2653,8 +2570,8 @@ top1:
HTChunkPutc(string, c);
context->state = S_attr; /* Get next attribute */
break;
-
- case S_equals: /* After attr = */
+
+ case S_equals: /* After attr = */
if (WHITE(c))
break; /* Before attribute value */
if (c == '>') { /* End of tag */
@@ -2664,7 +2581,7 @@ top1:
start_element(context);
context->state = S_text;
break;
-
+
} else if (c == '\'') {
context->state = S_squoted;
break;
@@ -2676,7 +2593,7 @@ top1:
HTChunkPutc(string, c);
context->state = S_value;
break;
-
+
case S_value:
if (WHITE(c) || (c == '>')) { /* End of word */
HTChunkTerminate(string) ;
@@ -2712,7 +2629,7 @@ top1:
HTChunkPutc(string, c);
}
break;
-
+
case S_squoted: /* Quoted attribute value */
if (c == '\'') { /* End of attribute value */
HTChunkTerminate(string) ;
@@ -2749,7 +2666,7 @@ top1:
HTChunkPutc(string, c);
}
break;
-
+
case S_dquoted: /* Quoted attribute value */
if (c == '"' || /* Valid end of attribute value */
(soft_dquotes && /* If emulating old Netscape bug, treat '>' */
@@ -2790,7 +2707,7 @@ top1:
HTChunkPutc(string, c);
}
break;
-
+
case S_end: /* </ */
if (unsign_c < 127 && isalnum((unsigned char)c)) {
HTChunkPutc(string, c);
@@ -2806,7 +2723,7 @@ top1:
}
if (!t || t == context->unknown_tag) {
if (TRACE)
- fprintf(stderr, "Unknown end tag </%s>\n", string->data);
+ fprintf(stderr, "Unknown end tag </%s>\n", string->data);
} else {
BOOL tag_OK = (c == '>' || WHITE(c));
context->current_tag = t;
@@ -3178,15 +3095,15 @@ PRIVATE void SGML_write ARGS3(
/* Structured Object Class
** -----------------------
*/
-PUBLIC CONST HTStreamClass SGMLParser =
-{
+PUBLIC CONST HTStreamClass SGMLParser =
+{
"SGMLParser",
SGML_free,
SGML_abort,
- SGML_character,
+ SGML_character,
SGML_string,
SGML_write,
-};
+};
/* Create SGML Engine
** ------------------
@@ -3217,7 +3134,7 @@ PUBLIC HTStream* SGML_new ARGS3(
context->state = S_text;
context->element_stack = 0; /* empty */
context->inSELECT = FALSE;
-#ifdef CALLERDATA
+#ifdef CALLERDATA
context->callerData = (void*) callerData;
#endif /* CALLERDATA */
for (i = 0; i < MAX_ATTRIBUTES; i++)
@@ -3270,15 +3187,15 @@ PUBLIC HTStream* SGML_new ARGS3(
////////////////////////////////////////////////////////////////////////
Copyright (c) 1993 Electrotechnical Laboratry (ETL)
-Permission to use, copy, modify, and distribute this material
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice and this permission notice
-appear in all copies, and that the name of ETL not be
-used in advertising or publicity pertaining to this
-material without the specific, prior written permission
+Permission to use, copy, modify, and distribute this material
+for any purpose and without fee is hereby granted, provided
+that the above copyright notice and this permission notice
+appear in all copies, and that the name of ETL not be
+used in advertising or publicity pertaining to this
+material without the specific, prior written permission
of an authorized representative of ETL.
-ETL MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
-OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
+ETL MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
+OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
/////////////////////////////////////////////////////////////////////////
Content-Type: program/C; charset=US-ASCII
@@ -3298,7 +3215,7 @@ PUBLIC void JISx0201TO0208_EUC ARGS4(
register unsigned char *, OHI,
register unsigned char *, OLO)
{
- static char *table[] = {
+ static char *table[] = {
"\xA1\xA3", "\xA1\xD6", "\xA1\xD7", "\xA1\xA2", "\xA1\xA6", "\xA5\xF2",
"\xA5\xA1", "\xA5\xA3", "\xA5\xA5", "\xA5\xA7", "\xA5\xA9",
"\xA5\xE3", "\xA5\xE5", "\xA5\xE7", "\xA5\xC3", "\xA1\xBC",
diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h
index 30f0d170..5daafc73 100644
--- a/WWW/Library/Implementation/SGML.h
+++ b/WWW/Library/Implementation/SGML.h
@@ -141,9 +141,9 @@ typedef struct {
HTTag * tags; /* Must be in strcmp order by name */
int number_of_tags;
CONST char ** entity_names; /* Must be in strcmp order by name */
- int number_of_entities;
+ size_t number_of_entities;
CONST UC_entity_info * extra_entity_info; /* strcmp order by name */
- int number_of_extra_entities;
+ size_t number_of_extra_entities;
} SGML_dtd;
diff --git a/WWW/Library/Implementation/UCAux.h b/WWW/Library/Implementation/UCAux.h
index 5b2d52ce..b350e617 100644
--- a/WWW/Library/Implementation/UCAux.h
+++ b/WWW/Library/Implementation/UCAux.h
@@ -1,25 +1,9 @@
#ifndef UCAUX_H
#define UCAUX_H
-/*
- * A type for a "Translation Quality" (actually, Transcoding Quality).
- * This is a fuzzy concept since we are just looking at the charset
- * not what characters are actually there, so it's just a guess for
- * "common" cases. TQ_NO must be 0 since callers of functions that
- * return this type may treat result as a boolean flag.
- * The functions returning this type could be improved to use more
- * knowledge from the translation tables.
- */
-typedef enum {
- TQ_NO = 0, /* must be 0 */
- TQ_POOR = 1,
- TQ_GOOD = 2,
- TQ_EXCELLENT = 3
-} UCTQ_t;
-
-extern UCTQ_t UCCanUniTranslateFrom PARAMS((int from));
-extern UCTQ_t UCCanTranslateUniTo PARAMS((int to));
-extern UCTQ_t UCCanTranslateFromTo PARAMS((int from, int to));
+extern BOOL UCCanUniTranslateFrom PARAMS((int from));
+extern BOOL UCCanTranslateUniTo PARAMS((int to));
+extern BOOL UCCanTranslateFromTo PARAMS((int from, int to));
extern BOOL UCNeedNotTranslate PARAMS((
int from,
int to));