about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTFile.c47
-rw-r--r--WWW/Library/Implementation/HTTP.c35
-rw-r--r--WWW/Library/Implementation/UCMap.h14
3 files changed, 68 insertions, 28 deletions
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 2ab38a3c..680cc3a2 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.110 2008/12/07 18:49:34 tom Exp $
+ * $LynxId: HTFile.c,v 1.114 2008/12/24 13:18:35 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -147,14 +147,23 @@ static const char *HTCacheRoot = "/WWW$SCRATCH";	/* Where to cache things */
 static const char *HTCacheRoot = "/tmp/W3_Cache_";	/* Where to cache things */
 #endif /* VMS */
 
+#define NO_SUFFIX      "*"
+#define UNKNOWN_SUFFIX "*.*"
+
 /*
  *  Suffix registration.
  */
 static HTList *HTSuffixes = 0;
+
 static HTSuffix no_suffix =
-{"*", NULL, NULL, NULL, 1.0};
+{
+    NO_SUFFIX, NULL, NULL, NULL, 1.0
+};
+
 static HTSuffix unknown_suffix =
-{"*.*", NULL, NULL, NULL, 1.0};
+{
+    UNKNOWN_SUFFIX, NULL, NULL, NULL, 1.0
+};
 
 /*	To free up the suffixes at program exit.
  *	----------------------------------------
@@ -499,9 +508,9 @@ void HTSetSuffix5(const char *suffix,
     HTSuffix *suff;
     BOOL trivial_enc = (BOOL) IsUnityEncStr(encoding);
 
-    if (strcmp(suffix, "*") == 0)
+    if (strcmp(suffix, NO_SUFFIX) == 0)
 	suff = &no_suffix;
-    else if (strcmp(suffix, "*.*") == 0)
+    else if (strcmp(suffix, UNKNOWN_SUFFIX) == 0)
 	suff = &unknown_suffix;
     else {
 	HTList *cur = HTSuffixes;
@@ -697,7 +706,7 @@ char *HTnameOfFile_WWW(const char *name,
 	}
     } else if (WWW_prefix) {	/* other access */
 #ifdef VMS
-	if ((home = LYGetEnv("HOME")) == 0)
+	if ((home = LYGetEnv("HOME")) == NULL)
 	    home = HTCacheRoot;
 	else
 	    home = HTVMS_wwwName(home);
@@ -707,7 +716,7 @@ char *HTnameOfFile_WWW(const char *name,
 #else
 	home = LYGetEnv("HOME");
 #endif
-	if (home == 0)
+	if (home == NULL)
 	    home = "/tmp";
 #endif /* VMS */
 	HTSprintf0(&result, "%s/WWW/%s/%s%s", home, acc_method, host, path);
@@ -1314,7 +1323,7 @@ CompressFileType HTEncodingToCompressType(const char *coding)
 {
     CompressFileType result = cftNone;
 
-    if (coding == 0) {
+    if (coding == NULL) {
 	result = cftNone;
     } else if (!strcasecomp(coding, "gzip") ||
 	       !strcasecomp(coding, "x-gzip")) {
@@ -1336,8 +1345,10 @@ CompressFileType HTContentTypeToCompressType(const char *ct)
 {
     CompressFileType method = cftNone;
 
-    if (!strncasecomp(ct, "application/gzip", 16) ||
-	!strncasecomp(ct, "application/x-gzip", 18)) {
+    if (ct == NULL) {
+	method = cftNone;
+    } else if (!strncasecomp(ct, "application/gzip", 16) ||
+	       !strncasecomp(ct, "application/x-gzip", 18)) {
 	method = cftGzip;
     } else if (!strncasecomp(ct, "application/compress", 20) ||
 	       !strncasecomp(ct, "application/x-compress", 22)) {
@@ -1889,7 +1900,7 @@ static int print_local_dir(DIR *dp, char *localname,
     pathname = HTParse(anchor->address, "",
 		       PARSE_PATH + PARSE_PUNCTUATION);
 
-    if ((p = strrchr(pathname, '/')) == 0)
+    if ((p = strrchr(pathname, '/')) == NULL)
 	p = "/";
     StrAllocCopy(tail, (p + 1));
     FREE(pathname);
@@ -2019,8 +2030,7 @@ static int print_local_dir(DIR *dp, char *localname,
 #ifdef DISP_PARTIAL
 	/* optimize for expensive operation: */
 	if (num_of_entries % (partial_threshold > 0 ?
-			      partial_threshold : display_lines)
-	    == 0) {
+			      partial_threshold : display_lines) == 0) {
 	    if (HTCheckForInterrupt()) {
 		status = HT_PARTIAL_CONTENT;
 		break;
@@ -2179,8 +2189,9 @@ static int print_local_dir(DIR *dp, char *localname,
 	    /* optimize for expensive operation: */
 #ifdef DISP_PARTIAL
 	    if (num_of_entries_output %
-		(partial_threshold > 0 ? partial_threshold : display_lines)
-		== 0) {
+		((partial_threshold > 0)
+		 ? partial_threshold
+		 : display_lines) == 0) {
 		/* num_of_entries, num_of_entries_output... */
 		/* HTReadProgress...(bytes, 0); */
 		HTDisplayPartial();
@@ -2455,16 +2466,16 @@ static int decompressAndParse(HTParentAnchor *anchor,
 	    switch (internal_decompress) {
 #ifdef USE_ZLIB
 	    case cftDeflate:
-		failed_decompress = (zzfp == 0);
+		failed_decompress = (zzfp == NULL);
 		break;
 	    case cftCompress:
 	    case cftGzip:
-		failed_decompress = (gzfp == 0);
+		failed_decompress = (gzfp == NULL);
 		break;
 #endif
 #ifdef USE_BZLIB
 	    case cftBzip2:
-		failed_decompress = (bzfp == 0);
+		failed_decompress = (bzfp == NULL);
 		break;
 #endif
 	    default:
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 2aa7e850..99d4a9f3 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTP.c,v 1.99 2008/12/14 18:05:36 tom Exp $
+ * $LynxId: HTTP.c,v 1.100 2008/12/25 14:15:28 tom Exp $
  *
  * HyperText Tranfer Protocol	- Client implementation		HTTP.c
  * ==========================
@@ -466,6 +466,27 @@ static void show_cert_issuer(X509 * peer_cert GCC_UNUSED)
 }
 #endif
 
+/*
+ * Remove IPv6 brackets (and any port-number) from the given host-string.
+ */
+static char *StripIpv6Brackets(char *host)
+{
+    int port_number;
+    char *p;
+
+    if ((p = HTParsePort(host, &port_number)) != 0)
+	*p = '\0';
+
+    if (*host == '[') {
+	p = host + strlen(host) - 1;
+	if (*p == ']') {
+	    *p = '\0';
+	    ++host;
+	}
+    }
+    return host;
+}
+
 /*		Load Document from HTTP Server			HTLoadHTTP()
  *		==============================
  *
@@ -530,7 +551,6 @@ static int HTLoadHTTP(const char *arg,
     char ssl_dn[1024];
     char *cert_host;
     char *ssl_host;
-    int port_number;
     char *p;
     char *msg = NULL;
     int status_sslcertcheck;
@@ -775,9 +795,7 @@ static int HTLoadHTTP(const char *arg,
 	ssl_dn_start = ssl_dn;
 	/* get host we're connecting to */
 	ssl_host = HTParse(url, "", PARSE_HOST);
-	/* strip port number or extract hostname component */
-	if ((p = HTParsePort(ssl_host, &port_number)) != 0)
-	    *p = '\0';
+	ssl_host = StripIpv6Brackets(ssl_host);
 
 	/* validate all CNs found in DN */
 	CTRACE((tfp, "Validating CNs in '%s'\n", ssl_dn_start));
@@ -791,9 +809,7 @@ static int HTLoadHTTP(const char *arg,
 		ssl_dn_start = p;	/* yes this points to the NUL byte */
 	    } else
 		ssl_dn_start = NULL;
-	    /* strip port number (XXX [ip]:port encap here too? -TG) */
-	    if ((p = HTParsePort(cert_host, &port_number)) != 0)
-		*p = '\0';
+	    cert_host = StripIpv6Brackets(cert_host);
 
 	    /* verify this CN */
 	    CTRACE((tfp, "Matching\n\tssl_host  '%s'\n\tcert_host '%s'\n",
@@ -887,8 +903,7 @@ static int HTLoadHTTP(const char *arg,
 			continue;
 		    status_sslcertcheck = 1;	/* got at least one */
 		    /* verify this SubjectAltName (see above) */
-		    if ((p = HTParsePort(cert_host, &port_number)) != 0)
-			*p = '\0';
+		    cert_host = StripIpv6Brackets(cert_host);
 		    if (!(gn->type == GEN_IPADD ? strcasecomp :
 			  strcasecomp_asterisk) (ssl_host, cert_host)) {
 			status_sslcertcheck = 2;
diff --git a/WWW/Library/Implementation/UCMap.h b/WWW/Library/Implementation/UCMap.h
index 616c1057..fc10788d 100644
--- a/WWW/Library/Implementation/UCMap.h
+++ b/WWW/Library/Implementation/UCMap.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: UCMap.h,v 1.21 2008/12/25 22:36:50 tom Exp $
+ */
 #ifndef UCMAP_H
 #define UCMAP_H
 
@@ -8,6 +11,17 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+    typedef enum {
+	ucError = -1,
+	ucZeroWidth = -2,
+	ucInvalidHash = -3,
+	ucNotFound = -4,
+	ucNeedMore = -10,
+	ucCannotConvert = -11,
+	ucCannotOutput = -12,
+	ucBufferTooSmall = -13,
+    } UCStatus;
+
     typedef long UCode_t;
 
     extern int UCTransUniChar(UCode_t unicode,