about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTWAIS.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2010-06-19 18:23:03 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2010-06-19 18:23:03 -0400
commitcf8dea28bede9af20f1b6b3435a793e91924f4d6 (patch)
treee6e9d5b563137861d3f9faee0775103c892fba7f /WWW/Library/Implementation/HTWAIS.c
parent8c48e8845381e727bc11c8c0c44a6a5156d83c29 (diff)
downloadlynx-snapshots-cf8dea28bede9af20f1b6b3435a793e91924f4d6.tar.gz
snapshot of project "lynx", label v2-8-8dev_3h
Diffstat (limited to 'WWW/Library/Implementation/HTWAIS.c')
-rw-r--r--WWW/Library/Implementation/HTWAIS.c85
1 files changed, 45 insertions, 40 deletions
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index 0e09f761..b04d380f 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTWAIS.c,v 1.31 2008/09/06 15:47:08 tom Exp $
+ * $LynxId: HTWAIS.c,v 1.34 2010/06/19 17:43:32 tom Exp $
  *
  *	WorldWideWeb - Wide Area Informaion Server Access	HTWAIS.c
  *	==================================================
@@ -59,6 +59,10 @@
 #include <HTTCP.h>
 #include <HTCJK.h>
 #include <HTAlert.h>
+#include <LYStrings.h>
+
+#undef lines			/* term.h conflict with wais.h */
+#undef alloca			/* alloca.h conflict with wais.h */
 
 /*			From WAIS
  *			---------
@@ -66,6 +70,8 @@
 #ifdef VMS
 #include <HTVMS_WaisUI.h>
 #include <HTVMS_WaisProt.h>
+#elif defined(HAVE_WAIS_H)
+#include <wais.h>
 #else
 #include <ui.h>
 #endif /* VMS */
@@ -126,7 +132,7 @@ static int fd_mosaic_connect_to_server(char *host_name,
     int status;
     int result;
 
-    HTSprintf0(&dummy, "%s//%s:%d/", STR_WAIS_URL, host_name, port);
+    HTSprintf0(&dummy, "%s//%s:%ld/", STR_WAIS_URL, host_name, port);
 
     status = HTDoConnect(dummy, "WAIS", 210, (int *) fd);
     if (status == HT_INTERRUPTED) {
@@ -266,14 +272,14 @@ static char *WWW_from_WAIS(any *docid)
     int i, l;
 
     if (TRACE) {
-	char *p;
+	char *p2;
 
 	fprintf(tfp, "WAIS id (%d bytes) is ", (int) docid->size);
-	for (p = docid->bytes; p < docid->bytes + docid->size; p++) {
-	    if ((*p >= ' ') && (*p <= '~'))	/* Assume ASCII! */
-		fprintf(tfp, "%c", *p);
+	for (p2 = docid->bytes; p2 < docid->bytes + docid->size; p2++) {
+	    if ((*p2 >= ' ') && (*p2 <= '~'))	/* Assume ASCII! */
+		fprintf(tfp, "%c", *p2);
 	    else
-		fprintf(tfp, "<%x>", (unsigned) *p);
+		fprintf(tfp, "<%x>", (unsigned) *p2);
 	}
 	fprintf(tfp, "\n");
     }
@@ -284,22 +290,22 @@ static char *WWW_from_WAIS(any *docid)
 	    CTRACE((tfp, "Eh?  DOCID record type of %d!\n", *p));
 	    return 0;
 	} {			/* Bug fix -- allow any byte value 15 Apr 93 */
-	    unsigned int i = (unsigned) *p++;
+	    unsigned int i2 = (unsigned) *p++;
 
-	    if (i > 99) {
-		*q++ = (i / 100) + '0';
-		i = i % 100;
+	    if (i2 > 99) {
+		*q++ = (i2 / 100) + '0';
+		i2 = i2 % 100;
 	    }
-	    if (i > 9) {
-		*q++ = (i / 10) + '0';
-		i = i % 10;
+	    if (i2 > 9) {
+		*q++ = (i2 / 10) + '0';
+		i2 = i2 % 10;
 	    }
-	    *q++ = i + '0';	/* Record type */
+	    *q++ = i2 + '0';	/* Record type */
 	}
 	*q++ = '=';		/* Separate */
 	l = *p++;		/* Length */
 	for (i = 0; i < l; i++, p++) {
-	    if (!acceptable[*p]) {
+	    if (!acceptable[UCH(*p)]) {
 		*q++ = HEX_ESCAPE;	/* Means hex coming */
 		*q++ = hex[(*p) >> 4];
 		*q++ = hex[(*p) & 15];
@@ -389,14 +395,14 @@ static any *WAIS_from_WWW(any *docid, char *docname)
     }
 
     if (TRACE) {
-	char *p;
+	char *p2;
 
 	fprintf(tfp, "WAIS id (%d bytes) is ", (int) docid->size);
-	for (p = docid->bytes; p < docid->bytes + docid->size; p++) {
-	    if ((*p >= ' ') && (*p <= '~'))	/* Assume ASCII! */
-		fprintf(tfp, "%c", *p);
+	for (p2 = docid->bytes; p2 < docid->bytes + docid->size; p2++) {
+	    if ((*p2 >= ' ') && (*p2 <= '~'))	/* Assume ASCII! */
+		fprintf(tfp, "%c", *p2);
 	    else
-		fprintf(tfp, "<%x>", (unsigned) *p);
+		fprintf(tfp, "<%x>", (unsigned) *p2);
 	}
 	fprintf(tfp, "\n");
     }
@@ -409,10 +415,9 @@ static any *WAIS_from_WWW(any *docid, char *docname)
  */
 static void output_text_record(HTStream *target,
 			       WAISDocumentText *record,
-			       boolean quote_string_quotes,
 			       boolean binary)
 {
-    long count;
+    unsigned long count;
 
     /* printf(" Text\n");
        print_any("     DocumentID:  ", record->DocumentID);
@@ -452,18 +457,18 @@ static void output_text_record(HTStream *target,
  * displays either a text record or a set of headlines.
  */
 static void display_search_response(HTStructured * target, SearchResponseAPDU *response,
-				    char *database,
+				    char *the_database,
 				    char *keywords)
 {
     WAISSearchResponse *info;
     long i, k;
 
-    BOOL archie = strstr(database, "archie") != 0;	/* Special handling */
+    BOOL archie = strstr(the_database, "archie") != 0;	/* Special handling */
 
     CTRACE((tfp, "HTWAIS: Displaying search response\n"));
     PUTS(gettext("Index "));
     START(HTML_EM);
-    PUTS(database);
+    PUTS(the_database);
     END(HTML_EM);
     sprintf(line, gettext(" contains the following %d item%s relevant to \""),
 	    (int) (response->NumberOfRecordsReturned),
@@ -525,7 +530,7 @@ static void display_search_response(HTStructured * target, SearchResponseAPDU *r
 			    (!strcmp(head->Types[0], "URL"))) {
 			    HTStartAnchor(target, NULL, headline);
 			} else {
-			    char *dbname = HTEscape(database, URL_XPALPHAS);
+			    char *dbname = HTEscape(the_database, URL_XPALPHAS);
 			    char *w3_address = NULL;
 
 			    HTSprintf0(&w3_address,
@@ -574,7 +579,7 @@ static void display_search_response(HTStructured * target, SearchResponseAPDU *r
 		i++;
 		PUTS(gettext("\nText record\n"));
 		output_text_record((HTStream *) target,
-				   info->Text[k++], false, false);
+				   info->Text[k++], false);
 	    }
 	}
 	if (info->Headlines != 0) {
@@ -620,14 +625,14 @@ int HTLoadWAIS(const char *arg,
     long request_buffer_length;	/* how of the request is left */
     SearchResponseAPDU *retrieval_response = 0;
     char keywords[MAX_KEYWORDS_LENGTH + 1];
-    char *server_name;
+    char *the_server_name;
     char *wais_database = NULL;	/* name of current database */
     char *www_database;		/* Same name escaped */
     char *service;
     char *doctype;
     char *doclength;
-    long document_length;
-    char *docname;
+    long document_length = 0;
+    char *docname = 0;
 
 #ifdef VMS
     long connection = 0;
@@ -661,10 +666,10 @@ int HTLoadWAIS(const char *arg,
 	HTUnEscape(key);
     }
     if (names[0] == '/') {
-	server_name = names + 1;
-	if ((as_gate = (*server_name == '/')) != 0)
-	    server_name++;	/* Accept one or two */
-	www_database = strchr(server_name, '/');
+	the_server_name = names + 1;
+	if ((as_gate = (*the_server_name == '/')) != 0)
+	    the_server_name++;	/* Accept one or two */
+	www_database = strchr(the_server_name, '/');
 	if (www_database) {
 	    *www_database++ = 0;	/* Separate database name */
 	    doctype = strchr(www_database, '/');
@@ -703,7 +708,7 @@ int HTLoadWAIS(const char *arg,
     else
 	service = "210";
 
-    if (server_name[0] == 0) {
+    if (the_server_name[0] == 0) {
 #ifdef VMS
 	connection = 0;
 #else
@@ -714,7 +719,7 @@ int HTLoadWAIS(const char *arg,
 	int status;
 
 	CTRACE((tfp, "===WAIS=== calling mosaic_connect_to_server\n"));
-	status = mosaic_connect_to_server(server_name,
+	status = mosaic_connect_to_server(the_server_name,
 					  atoi(service),
 					  &connection);
 	if (status == 0) {
@@ -791,7 +796,7 @@ int HTLoadWAIS(const char *arg,
 #ifdef CACHE_FILE_PREFIX
 	HTSprintf0(&filename, "%sWSRC-%s:%s:%.100s.txt",
 		   CACHE_FILE_PREFIX,
-		   server_name, service, www_database);
+		   the_server_name, service, www_database);
 
 	fp = fopen(filename, "r");	/* Have we found this already? */
 	CTRACE((tfp, "HTWAIS: Description of server %s %s.\n",
@@ -915,7 +920,7 @@ int HTLoadWAIS(const char *arg,
 
 	CTRACE((tfp,
 		"HTWAIS: Retrieve document id `%s' type `%s' length %ld\n",
-		docname, doctype, document_length));
+		NonNull(docname), doctype, document_length));
 
 	format_in =
 	    !strcmp(doctype, "WSRC") ? HTAtom_for("application/x-wais-source") :
@@ -1034,7 +1039,7 @@ int HTLoadWAIS(const char *arg,
 		output_text_record(target,
 				   ((WAISSearchResponse *)
 				    retrieval_response->DatabaseDiagnosticRecords)->Text[0],
-				   false, binary);
+				   binary);
 	    }			/* If text existed */
 
 #ifdef VMS