about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTAnchor.c21
-rw-r--r--WWW/Library/Implementation/HTFTP.c38
-rw-r--r--WWW/Library/Implementation/HTFile.c6
-rw-r--r--WWW/Library/Implementation/HTMIME.c21
-rw-r--r--WWW/Library/Implementation/HTNews.c9
-rw-r--r--WWW/Library/Implementation/HTParse.c21
-rw-r--r--WWW/Library/Implementation/HTTP.c10
-rw-r--r--WWW/Library/Implementation/SGML.c11
-rw-r--r--WWW/Library/Implementation/www_tcp.h18
9 files changed, 98 insertions, 57 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 5b6fc7a2..6bb592c8 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -1,4 +1,7 @@
-/*	Hypertext "Anchor" Object				HTAnchor.c
+/*
+ * $LynxId: HTAnchor.c,v 1.59 2007/07/02 23:42:54 tom Exp $
+ *
+ *	Hypertext "Anchor" Object				HTAnchor.c
  *	==========================
  *
  * An anchor represents a region of a hypertext document which is linked to
@@ -27,21 +30,25 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
+#define HASH_TYPE unsigned short
+
 #ifdef NOT_DEFINED
 /*
  *	This is the hashing function used to determine which list in the
  *		adult_table a parent anchor should be put in.  This is a
  *		much simpler function than the original used.
  */
-#define HASH_FUNCTION(cp_address) ((unsigned short int)strlen(cp_address) *\
-	(unsigned short int)TOUPPER(*cp_address) % HASH_SIZE)
+#define HASH_FUNCTION(cp_address) \
+	( (HASH_TYPE)strlen(cp_address) *\
+	  (HASH_TYPE)TOUPPER(*cp_address) % HASH_SIZE )
 #endif /* NOT_DEFINED */
+
 /*
  *	This is the original function.	We'll use it again. - FM
  */
-static int HASH_FUNCTION(const char *cp_address)
+static HASH_TYPE HASH_FUNCTION(const char *cp_address)
 {
-    int hash;
+    HASH_TYPE hash;
     const unsigned char *p;
 
     for (p = (const unsigned char *) cp_address, hash = 0; *p; p++)
@@ -71,7 +78,7 @@ static HTList adult_table[HASH_SIZE] =
  *	anchor you are creating : use newWithParent or newWithAddress.
  */
 static HTParentAnchor0 *HTParentAnchor0_new(const char *address,
-					    short hash)
+					    HASH_TYPE hash)
 {
     HTParentAnchor0 *newAnchor = typecalloc(HTParentAnchor0);
 
@@ -416,7 +423,7 @@ static HTParentAnchor0 *HTAnchor_findAddress_in_adult_table(const DocAddress *ne
     /*
      * Check whether we have this node.
      */
-    int hash;
+    HASH_TYPE hash;
     HTList *adults;
     HTList *grownups;
     HTParentAnchor0 *foundAnchor;
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index d4b9d695..50720368 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFTP.c,v 1.78 2007/05/22 23:47:17 tom Exp $
+ * $LynxId: HTFTP.c,v 1.79 2007/07/02 23:05:12 tom Exp $
  *
  *			File Transfer Protocol (FTP) Client
  *			for a WorldWideWeb browser
@@ -226,10 +226,12 @@ static int interrupted_in_next_data_char = FALSE;
 static PortNumber port_number = FIRST_TCP_PORT;
 #endif /* POLL_PORTS */
 
-static int master_socket = -1;	/* Listening socket = invalid   */
+static BOOL have_socket = FALSE;	/* true if master_socket is valid */
+static unsigned master_socket;	/* Listening socket = invalid */
+
 static char port_command[255];	/* Command for setting the port */
 static fd_set open_sockets;	/* Mask of active channels */
-static int num_sockets;		/* Number of sockets to scan */
+static unsigned num_sockets;	/* Number of sockets to scan */
 static PortNumber passive_port;	/* Port server specified for data */
 
 #define NEXT_CHAR HTGetCharacter()	/* Use function in HTFormat.c */
@@ -1117,6 +1119,18 @@ static int get_connection(const char *arg,
     return con->socket;		/* Good return */
 }
 
+static void reset_master_socket(void)
+{
+    have_socket = FALSE;
+}
+
+static void set_master_socket(int value)
+{
+    have_socket = (value >= 0);
+    if (have_socket)
+	master_socket = value;
+}
+
 /*	Close Master (listening) socket
  *	-------------------------------
  *
@@ -1126,11 +1140,14 @@ static int close_master_socket(void)
 {
     int status;
 
-    if (master_socket != -1)
+    if (have_socket)
 	FD_CLR(master_socket, &open_sockets);
+
     status = NETCLOSE(master_socket);
     CTRACE((tfp, "HTFTP: Closed master socket %d\n", master_socket));
-    master_socket = -1;
+
+    reset_master_socket();
+
     if (status < 0)
 	return HTInetStatus(gettext("close master socket"));
     else
@@ -1144,6 +1161,7 @@ static int close_master_socket(void)
  *	connect with the data.
  *
  * On entry,
+ *	have_socket	Must be false, if master_socket is not setup already
  *	master_socket	Must be negative if not set up already.
  * On exit,
  *	Returns		socket number if good
@@ -1169,7 +1187,7 @@ static int get_listen_socket(void)
     num_sockets = 0;
 
 #ifndef REPEAT_LISTEN
-    if (master_socket >= 0)
+    if (have_socket)
 	return master_socket;	/* Done already */
 #endif /* !REPEAT_LISTEN */
 
@@ -1336,11 +1354,11 @@ static int get_listen_socket(void)
 #endif /* INET6 */
 
 #ifdef REPEAT_LISTEN
-    if (master_socket >= 0)
+    if (have_socket)
 	(void) close_master_socket();
 #endif /* REPEAT_LISTEN */
 
-    master_socket = new_socket;
+    set_master_socket(new_socket);
 
 /*	Now we must find out who we are to tell the other guy
 */
@@ -1392,7 +1410,7 @@ static int get_listen_socket(void)
 #endif /* SOCKS */
 	    status = listen(master_socket, 1);
 	if (status < 0) {
-	    master_socket = -1;
+	    reset_master_socket();
 	    return HTInetStatus("listen");
 	}
     }
@@ -3020,7 +3038,7 @@ static int setup_connection(const char *name,
 		NETCLOSE(control->socket);
 		control->socket = -1;
 #ifdef INET6
-		if (master_socket >= 0)
+		if (have_socket)
 		    (void) close_master_socket();
 #else
 		close_master_socket();
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index f0fcdbc3..7b190474 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.102 2007/05/13 17:29:41 tom Exp $
+ * $LynxId: HTFile.c,v 1.103 2007/07/22 22:31:01 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -2629,7 +2629,7 @@ int HTLoadFile(const char *addr,
 	    char *best_name = NULL;	/* Best dir entry so far */
 
 	    char *base = strrchr(localname, '/');
-	    int baselen = 0;
+	    unsigned baselen = 0;
 
 	    if (!base || base == localname) {
 		forget_multi = YES;
@@ -2654,7 +2654,7 @@ int HTLoadFile(const char *addr,
 		if (dirbuf->d_ino == 0)
 		    continue;	/* if the entry is not being used, skip it */
 #endif
-		if ((int) strlen(dirbuf->d_name) > baselen &&	/* Match? */
+		if (strlen(dirbuf->d_name) > baselen &&		/* Match? */
 		    !strncmp(dirbuf->d_name, base, baselen)) {
 		    HTAtom *enc;
 		    HTFormat rep = HTFileFormat(dirbuf->d_name, &enc, NULL);
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 28814c65..9e6c03fd 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -1,4 +1,7 @@
-/*			MIME Message Parse			HTMIME.c
+/*
+ * $LynxId: HTMIME.c,v 1.62 2007/07/03 00:16:30 tom Exp $
+ *
+ *			MIME Message Parse			HTMIME.c
  *			==================
  *
  *	This is RFC 1341-specific code.
@@ -2137,8 +2140,8 @@ static void HTmmdec_base64(char **t,
     int d, count, j, val;
     char *buf, *bp, nw[4], *p;
 
-    if ((buf = malloc(strlen(s) * 3 + 1)) == 0)
-	outofmem(__FILE__, "HTmmdec_base64");
+    if ((buf = typeMallocn(char, strlen(s) * 3 + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdec_base64");
 
     for (bp = buf; *s; s += 4) {
 	val = 0;
@@ -2178,8 +2181,8 @@ static void HTmmdec_quote(char **t,
 {
     char *buf, cval, *bp, *p;
 
-    if ((buf = malloc(strlen(s) + 1)) == 0)
-	outofmem(__FILE__, "HTmmdec_quote");
+    if ((buf = typeMallocn(char, strlen(s) + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdec_quote");
 
     for (bp = buf; *s;) {
 	if (*s == '=') {
@@ -2222,8 +2225,8 @@ void HTmmdecode(char **target,
     char *s, *t, *u;
     int base64, quote;
 
-    if ((buf = malloc(strlen(source) + 1)) == 0)
-	outofmem(__FILE__, "HTmmdecode");
+    if ((buf = typeMallocn(char, strlen(source) + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdecode");
 
     for (s = source, u = buf; *s;) {
 	if (!strncasecomp(s, "=?ISO-2022-JP?B?", 16)) {
@@ -2297,8 +2300,8 @@ int HTrjis(char **t,
 	return 1;
     }
 
-    if ((buf = malloc(strlen(s) * 2 + 1)) == 0)
-	outofmem(__FILE__, "HTrjis");
+    if ((buf = typeMallocn(char, strlen(s) * 2 + 1)) == 0)
+	  outofmem(__FILE__, "HTrjis");
 
     for (p = buf; *s;) {
 	if (!kanji && s[0] == '$' && (s[1] == '@' || s[1] == 'B')) {
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index 611d7f1e..bc16318d 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -1,4 +1,7 @@
-/*			NEWS ACCESS				HTNews.c
+/*
+ * $LynxId: HTNews.c,v 1.57 2007/07/03 00:13:21 tom Exp $
+ *
+ *			NEWS ACCESS				HTNews.c
  *			===========
  *
  * History:
@@ -1003,12 +1006,14 @@ void debug_print(unsigned char *p)
 
 static char *decode_mime(char **str)
 {
+    static char empty[] = "";
+
 #ifdef SH_EX
     if (HTCJK != JAPANESE)
 	return *str;
 #endif
     HTmmdecode(str, *str);
-    return HTrjis(str, *str) ? *str : "";
+    return HTrjis(str, *str) ? *str : empty;
 }
 
 /*	Read in an Article					read_article
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index 62f06736..37b1208e 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -1,4 +1,7 @@
-/*		Parse HyperText Document Address		HTParse.c
+/*
+ * $LynxId: HTParse.c,v 1.47 2007/07/22 22:24:37 tom Exp $
+ *
+ *		Parse HyperText Document Address		HTParse.c
  *		================================
  */
 
@@ -212,7 +215,7 @@ char *HTParse(const char *aName,
     char *result = NULL;
     char *tail = NULL;		/* a pointer to the end of the 'result' string */
     char *return_value = NULL;
-    int len, len1, len2;
+    unsigned len, len1, len2;
     char *name = NULL;
     char *rel = NULL;
     char *p, *q;
@@ -900,12 +903,12 @@ char *HTEscape(const char *str,
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (!ACCEPTABLE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
@@ -940,12 +943,12 @@ char *HTEscapeUnsafe(const char *str)
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (UNSAFE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscapeUnsafe");
@@ -980,12 +983,12 @@ char *HTEscapeSP(const char *str,
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (!(*p == ' ' || ACCEPTABLE(UCH(TOASCII(*p)))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
@@ -1131,7 +1134,7 @@ void HTMake822Word(char **str,
     char *q;
     char *result;
     unsigned char a;
-    int added = 0;
+    unsigned added = 0;
 
     if (isEmpty(*str)) {
 	StrAllocCopy(*str, quoted ? "\"\"" : "");
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 5f262bd5..ec14e1ce 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTP.c,v 1.86 2007/05/22 22:42:12 Thorsten.Glaser Exp $
+ * $LynxId: HTTP.c,v 1.87 2007/07/03 00:20:33 tom Exp $
  *
  * HyperText Tranfer Protocol	- Client implementation		HTTP.c
  * ==========================
@@ -813,8 +813,10 @@ static int HTLoadHTTP(const char *arg,
 	    int i, numalts;
 	    const GENERAL_NAME *gn;
 
-	    if ((gens = X509_get_ext_d2i(peer_cert, NID_subject_alt_name,
-					 NULL, NULL)) != NULL) {
+	    gens = (STACK_OF(GENERAL_NAME) *)
+		X509_get_ext_d2i(peer_cert, NID_subject_alt_name, NULL, NULL);
+
+	    if (gens != NULL) {
 		numalts = sk_GENERAL_NAME_num(gens);
 		for (i = 0; i < numalts; ++i) {
 		    gn = sk_GENERAL_NAME_value(gens, i);
@@ -824,7 +826,7 @@ static int HTLoadHTTP(const char *arg,
 			/* XXX untested -TG */
 			size_t j = ASN1_STRING_length(gn->d.ia5);
 
-			cert_host = malloc(j + 1);
+			cert_host = (char *) malloc(j + 1);
 			memcpy(cert_host, ASN1_STRING_data(gn->d.ia5), j);
 			cert_host[j] = '\0';
 		    } else
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 8412465f..37325689 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,4 +1,7 @@
-/*			General SGML Parser code		SGML.c
+/*
+ * $LynxId: SGML.c,v 1.92 2007/07/22 21:52:43 Rado.Smiljanic Exp $
+ *
+ *			General SGML Parser code		SGML.c
  *			========================
  *
  *	This module implements an HTStream object.  To parse an
@@ -2466,7 +2469,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    /*
 	     * Terminate the numeric entity and try to handle it.  - FM
 	     */
-	    UCode_t code;
+	    unsigned long code;
 	    int i;
 
 	    HTChunkTerminate(string);
@@ -2474,7 +2477,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    entity_string = string->data;
 #endif
 	    if ((context->isHex ? sscanf(string->data, "%lx", &code) :
-		 sscanf(string->data, "%ld", &code)) == 1) {
+		 sscanf(string->data, "%lu", &code)) == 1) {
 /* =============== work in ASCII below here ===============  S/390 -- gil -- 1092 */
 		if ((code == 1) ||
 		    (code > 127 && code < 156)) {
@@ -3525,7 +3528,7 @@ static void SGML_character(HTStream *context, char c_in)
 		PUTS(string->data);
 		if (c == '=' || WHITE(c))
 		    PUTC(c);
-		if (c == '=' || c == '>' || c == ' ') {
+		if (c == '=' || c == '>' || WHITE(c)) {
 		    if (context->current_attribute_number == INVALID)
 			PSRCSTOP(badattr);
 		    else
diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h
index 4f5927e1..ca0ab6d8 100644
--- a/WWW/Library/Implementation/www_tcp.h
+++ b/WWW/Library/Implementation/www_tcp.h
@@ -1,5 +1,5 @@
 /*                System dependencies in the W3 library
- * $LynxId: www_tcp.h,v 1.35 2007/07/01 17:38:38 tom Exp $
+ * $LynxId: www_tcp.h,v 1.36 2007/07/02 23:05:01 tom Exp $
  *
                                    SYSTEM DEPENDENCIES
 
@@ -392,8 +392,8 @@ extern int socket_ioctl();
 #undef NETWRITE
 #define NETWRITE(s,b,l) send((s),(char *)(b),(l))
 
-#define TYPE_FD_SET 1
-typedef int fd_set;
+#define TYPE_FD_SET int
+typedef TYPE_FD_SET fd_set;
 
 #endif /* TCPIP_SERVICES */
 
@@ -874,14 +874,14 @@ ROUGH ESTIMATE OF MAX PATH LENGTH
 #ifdef SELECT
 #ifndef FD_SET
 #ifndef TYPE_FD_SET
-#define TYPE_FD_SET 1
-typedef unsigned int fd_set;
+#define TYPE_FD_SET unsigned
+typedef TYPE_FD_SET fd_set;
 #endif /* !TYPE_FD_SET */
 
-#define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
-#define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
-#define FD_ZERO(pmask)   (*(pmask))=0
-#define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
+#define FD_SET(fd,pmask)   (*(pmask)) |=  (1 << (fd))
+#define FD_CLR(fd,pmask)   (*(pmask)) &= ~(1 << (fd))
+#define FD_ZERO(pmask)     (*(pmask)) = 0
+#define FD_ISSET(fd,pmask) (*(pmask) & (1 << (fd)))
 #endif /* !FD_SET */
 #endif /* SELECT */