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>1998-11-10 19:47:00 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-11-10 19:47:00 -0500
commitd3f9d5478df478427c2aa5db4507ddd0a38f0eb6 (patch)
treee27eacd6bbda653dd77f11cc020b9e0a59f7f4fc /WWW/Library/Implementation/HTWAIS.c
parent18024037b515bfff83e0230b35151babe6005e18 (diff)
downloadlynx-snapshots-d3f9d5478df478427c2aa5db4507ddd0a38f0eb6.tar.gz
snapshot of project "lynx", label v2-8-2dev_2
Diffstat (limited to 'WWW/Library/Implementation/HTWAIS.c')
-rw-r--r--WWW/Library/Implementation/HTWAIS.c147
1 files changed, 65 insertions, 82 deletions
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index 627086ab..1440a5f8 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -49,7 +49,6 @@
 */
 
 #include <HTUtils.h>
-#include <tcp.h>
 #include <HTParse.h>
 #include <HTAccess.h>		/* We implement a protocol */
 #include <HTML.h>		/* The object we will generate */
@@ -78,10 +77,6 @@
 */
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
-extern int HTCheckForInterrupt NOPARAMS;
-
 #define DIRECTORY "/cnidr.org:210/directory-of-servers"
 /* #define DIRECTORY "/quake.think.com:210/directory-of-servers" */
 
@@ -166,16 +161,16 @@ PRIVATE int mosaic_connect_to_server ARGS3(
 
     rv = fd_mosaic_connect_to_server (host_name, port, &fd);
     if (rv == 0) {
-	HTAlert ("Could not connect to WAIS server.");
+	HTAlert (gettext("Could not connect to WAIS server."));
 	return 0;
     } else if (rv == -1) {
-	HTAlert ("Connection interrupted.");
+	HTAlert (gettext("Connection interrupted."));
 	return -1;
     }
 
 #ifndef VMS
     if ((file = fdopen(fd,"r+")) == NULL) {
-	HTAlert ("Could not open WAIS connection for reading.");
+	HTAlert (gettext("Could not open WAIS connection for reading."));
 	return 0;
     }
 
@@ -199,7 +194,7 @@ PRIVATE void showDiags ARGS2(
 
     for (i = 0; d[i] != NULL; i++) {
 	if (d[i]->ADDINFO != NULL) {
-	    PUTS("Diagnostic code is ");
+	    PUTS(gettext("Diagnostic code is "));
 	    PUTS(d[i]->DIAG);
 	    PUTC(' ');
 	    PUTS(d[i]->ADDINFO);
@@ -272,22 +267,20 @@ PRIVATE char * WWW_from_WAIS ARGS1(
     int i, l;
     if (TRACE) {
 	char *p;
-	fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size);
+	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(stderr, "%c", *p);
+		fprintf(tfp, "%c", *p);
 	    else
-		fprintf(stderr, "<%x>", (unsigned)*p);
+		fprintf(tfp, "<%x>", (unsigned)*p);
 	}
-	fprintf(stderr, "\n");
+	fprintf(tfp, "\n");
     }
     for (p = docid->bytes;
 	 (p < docid->bytes+docid->size) && (q < &buf[BIG]);) {
-	if (TRACE)
-	    fprintf(stderr, "    Record type %d, length %d\n", p[0], p[1]);
+	CTRACE(tfp, "    Record type %d, length %d\n", p[0], p[1]);
 	if (*p > 10) {
-	    if (TRACE)
-		fprintf(stderr, "Eh? DOCID record type of %d!\n", *p);
+	    CTRACE(tfp, "Eh? DOCID record type of %d!\n", *p);
 	    return 0;
 	}
 	{	/* Bug fix -- allow any byte value 15 Apr 93 */
@@ -316,8 +309,7 @@ PRIVATE char * WWW_from_WAIS ARGS1(
 	*q++= ';';		/* Terminate field */
     }
     *q++ = 0;			/* Terminate string */
-    if (TRACE)
-	fprintf(stderr, "WWW form of id: %s\n", buf);
+    CTRACE(tfp, "WWW form of id: %s\n", buf);
     {
 	char * result = (char *)malloc(strlen(buf)+1);
 	if (!result)
@@ -347,8 +339,8 @@ PRIVATE any * WAIS_from_WWW ARGS2(
     char *q;	/* Poisition of "=" */
     char *s;	/* Position of semicolon */
     int n;	/* size */
-    if (TRACE)
-	fprintf(stderr, "WWW id (to become WAIS id): %s\n", docname);
+
+    CTRACE(tfp, "WWW id (to become WAIS id): %s\n", docname);
     for (n = 0, p = docname; *p; p++) { /* Count sizes of strings */
 	n++;
 	if (*p == ';')
@@ -404,14 +396,14 @@ PRIVATE any * WAIS_from_WWW ARGS2(
 
     if (TRACE) {
 	char *p;
-	fprintf(stderr, "WAIS id (%d bytes) is ", (int)docid->size);
+	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(stderr, "%c", *p);
+		fprintf(tfp, "%c", *p);
 	    else
-		fprintf(stderr, "<%x>", (unsigned)*p);
+		fprintf(tfp, "<%x>", (unsigned)*p);
 	}
-	fprintf(stderr, "\n");
+	fprintf(tfp, "\n");
     }
     return docid;		/* Ok */
 
@@ -473,13 +465,12 @@ PRIVATE void display_search_response ARGS4(
 
     BOOL archie =  strstr(database, "archie")!=0;	/* Specical handling */
 
-    if (TRACE)
-	fprintf(stderr, "HTWAIS: Displaying search response\n");
-    PUTS("Index ");
+    CTRACE(tfp, "HTWAIS: Displaying search response\n");
+    PUTS(gettext("Index "));
     START(HTML_EM);
     PUTS(database);
     END(HTML_EM);
-    sprintf(line, " contains the following %d item%s relevant to \"",
+    sprintf(line, gettext(" contains the following %d item%s relevant to \""),
 	    (int)(response->NumberOfRecordsReturned),
 	    response->NumberOfRecordsReturned ==1 ? "" : "s");
     PUTS(line);
@@ -487,8 +478,8 @@ PRIVATE void display_search_response ARGS4(
     PUTS(keywords);
     END(HTML_EM);
     PUTS("\".\n");
-    PUTS("The first figure after each entry is its relative score, ");
-    PUTS("the second is the number of lines in the item.");
+    PUTS(gettext("The first figure after each entry is its relative score, "));
+    PUTS(gettext("the second is the number of lines in the item."));
     START(HTML_BR);
     START(HTML_BR);
     PUTS("\n");
@@ -512,9 +503,7 @@ PRIVATE void display_search_response ARGS4(
 		/*
 		**  Make a printable string out of the document id.
 		*/
-		if (TRACE)
-		    fprintf(stderr,
-			    "HTWAIS:  %2ld: Score: %4ld, lines:%4ld '%s'\n",
+		CTRACE(tfp, "HTWAIS:  %2ld: Score: %4ld, lines:%4ld '%s'\n",
 			    i,
 			    (long int)(info->DocHeaders[k]->Score),
 			    (long int)(info->DocHeaders[k]->Lines),
@@ -531,7 +520,7 @@ PRIVATE void display_search_response ARGS4(
 			FREE(www_name);
 		    } else {
 			PUTS(headline);
-			PUTS(" (bad file name)");
+			PUTS(gettext(" (bad file name)"));
 		    }
 		} else { /* Not archie */
 		    docname =  WWW_from_WAIS(docid);
@@ -553,7 +542,7 @@ PRIVATE void display_search_response ARGS4(
 			FREE(dbname);
 			FREE(docname);
 		    } else {
-			PUTS("(bad doc id)");
+			PUTS(gettext("(bad doc id)"));
 		    }
 		}
 
@@ -569,21 +558,21 @@ PRIVATE void display_search_response ARGS4(
 	    k = 0;
 	    while (info->ShortHeaders[k] != 0) {
 		i++;
-		PUTS( "(Short Header record, can't display)");
+		PUTS( gettext("(Short Header record, can't display)"));
 	    }
 	}
 	if (info->LongHeaders != 0) {
 	    k = 0;
 	    while (info->LongHeaders[k] != 0) {
 		i++;
-		PUTS( "\nLong Header record, can't display\n");
+		PUTS( gettext("\nLong Header record, can't display\n"));
 	    }
 	}
 	if (info->Text != 0) {
 	    k = 0;
 	    while (info->Text[k] != 0) {
 		i++;
-		PUTS( "\nText record\n");
+		PUTS( gettext("\nText record\n"));
 		output_text_record((HTStream*)target,
 				   info->Text[k++], false, false);
 	    }
@@ -592,7 +581,7 @@ PRIVATE void display_search_response ARGS4(
 	    k = 0;
 	    while (info->Headlines[k] != 0) {
 		i++;
-		PUTS( "\nHeadline record, can't display\n");
+		PUTS( gettext("\nHeadline record, can't display\n"));
 		/* dsply_headline_record( info->Headlines[k++]); */
 	    }
 	}
@@ -600,7 +589,7 @@ PRIVATE void display_search_response ARGS4(
 	    k = 0;
 	    while (info->Codes[k] != 0) {
 		i++;
-		PUTS( "\nCode record, can't display\n");
+		PUTS( gettext("\nCode record, can't display\n"));
 		/* dsply_code_record( info->Codes[k++]); */
 	    }
 	}
@@ -704,10 +693,9 @@ PUBLIC int HTLoadWAIS ARGS4(
     }
 
     if (!ok)
-	return HTLoadError(sink, 500, "Syntax error in WAIS URL");
+	return HTLoadError(sink, 500, gettext("Syntax error in WAIS URL"));
 
-    if (TRACE)
-	fprintf(stderr, "HTWAIS: Parsed OK\n");
+    CTRACE(tfp, "HTWAIS: Parsed OK\n");
 
     service = strchr(names, ':');
     if (service)
@@ -724,19 +712,16 @@ PUBLIC int HTLoadWAIS ARGS4(
 
     } else if (!(key && !*key)) {
 	int status;
-	if (TRACE)
-	fprintf (stderr, "===WAIS=== calling mosaic_connect_to_server\n");
+	CTRACE (tfp, "===WAIS=== calling mosaic_connect_to_server\n");
 	status = mosaic_connect_to_server(server_name,
 					  atoi(service),
 					  &connection);
 	if (status == 0) {
-	    if (TRACE)
-		fprintf (stderr, "===WAIS=== connection failed\n");
+	    CTRACE (tfp, "===WAIS=== connection failed\n");
 	    FREE(names);
 	    return HT_NOT_LOADED;
 	} else if (status == -1) {
-	    if (TRACE)
-		fprintf (stderr, "===WAIS=== connection interrupted\n");
+	    CTRACE (tfp, "===WAIS=== connection interrupted\n");
 	    FREE(names);
 	    return HT_NOT_LOADED;
 	}
@@ -774,30 +759,30 @@ PUBLIC int HTLoadWAIS ARGS4(
 
 	START(HTML_HEAD);
 	PUTS("\n");
-	HTStartIsIndex(target, "Enter WAIS query: ", NULL);
+	HTStartIsIndex(target, gettext("Enter WAIS query: "), NULL);
 	PUTS("\n");
 
 	{
 	    START(HTML_TITLE);
 	    PUTS(wais_database);
-	    PUTS(" (WAIS Index)");
+	    PUTS(gettext(" (WAIS Index)"));
 	    END(HTML_TITLE);
 	    PUTS("\n");
 	    END(HTML_HEAD);
 	    PUTS("\n");
 
 	    START(HTML_H1);
-	    PUTS("WAIS Index: ");
+	    PUTS(gettext("WAIS Index: "));
 	    START(HTML_EM);
 	    PUTS(wais_database);
 	    END(HTML_EM);
 	    END(HTML_H1);
 	    PUTS("\n");
-	    PUTS("This is a link for searching the ");
+	    PUTS(gettext("This is a link for searching the "));
 	    START(HTML_EM);
 	    PUTS(wais_database);
 	    END(HTML_EM);
-	    PUTS(" WAIS Index.\n");
+	    PUTS(gettext(" WAIS Index.\n"));
 
 	}
 	/*
@@ -809,10 +794,9 @@ PUBLIC int HTLoadWAIS ARGS4(
 		server_name, service, www_database);
 
 	fp = fopen(filename, "r");	/* Have we found this already? */
-	if (TRACE) fprintf(stderr,
-		"HTWAIS: Description of server %s %s.\n",
-		filename,
-		fp ? "exists already" : "does NOT exist!");
+	CTRACE(tfp, "HTWAIS: Description of server %s %s.\n",
+		    filename,
+		    fp ? "exists already" : "does NOT exist!");
 
 	if (fp) {
 	    char c;
@@ -821,9 +805,10 @@ PUBLIC int HTLoadWAIS ARGS4(
 	    while((c=getc(fp))!=EOF) PUTC(c);	/* Transfer file */
 	    END(HTML_PRE);
 	    fclose(fp);
+	}
 #endif
 	START(HTML_P);
-	PUTS("\nEnter the 's'earch command and then specify search words.\n");
+	PUTS(gettext("\nEnter the 's'earch command and then specify search words.\n"));
 
 	FREE_TARGET;
     } else if (key) {					/* S E A R C H */
@@ -840,11 +825,11 @@ PUBLIC int HTLoadWAIS ARGS4(
 
 	START(HTML_HEAD);
 	PUTS("\n");
-	HTStartIsIndex(target, "Enter WAIS query: ", NULL);
+	HTStartIsIndex(target, gettext("Enter WAIS query: "), NULL);
 	PUTS("\n");
 	START(HTML_TITLE);
 	PUTS(keywords);
-	PUTS(" (in ");
+	PUTS(gettext(" (in "));
 	PUTS(wais_database);
 	PUTS(")");
 	END(HTML_TITLE);
@@ -853,11 +838,11 @@ PUBLIC int HTLoadWAIS ARGS4(
 	PUTS("\n");
 
 	START(HTML_H1);
-	PUTS("WAIS Search of \"");
+	PUTS(gettext("WAIS Search of \""));
 	START(HTML_EM);
 	PUTS(keywords);
 	END(HTML_EM);
-	PUTS("\" in: ");
+	PUTS(gettext("\" in: "));
 	START(HTML_EM);
 	PUTS(wais_database);
 	END(HTML_EM);
@@ -865,14 +850,14 @@ PUBLIC int HTLoadWAIS ARGS4(
 	PUTS("\n");
 
 	request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */
-	if (TRACE) fprintf(stderr, "HTWAIS: Search for `%s' in `%s'\n",
-		keywords, wais_database);
+	CTRACE(tfp, "HTWAIS: Search for `%s' in `%s'\n",
+		    keywords, wais_database);
 	if(NULL ==
 	generate_search_apdu(request_message + HEADER_LENGTH,
 				&request_buffer_length,
 				keywords, wais_database, NULL, MAXDOCS)) {
 #ifdef VMS
-	    HTAlert ("HTWAIS: Request too large.");
+	    HTAlert (gettext("HTWAIS: Request too large."));
 	    return_status = HT_NOT_LOADED;
 	    FREE_TARGET;
 	    goto CleanUp;
@@ -881,7 +866,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 #endif /* VMS */
 	}
 
-	HTProgress("Searching WAIS database...");
+	HTProgress(gettext("Searching WAIS database..."));
 	rv = interpret_message (request_message,
 				MAX_MESSAGE_LEN - request_buffer_length,
 				response_message,
@@ -891,13 +876,13 @@ PUBLIC int HTLoadWAIS ARGS4(
 			       );
 
 	if (rv == HT_INTERRUPTED) {
-	    HTAlert ("Search interrupted.");
+	    HTAlert (gettext("Search interrupted."));
 	    return_status = HT_INTERRUPTED;
 	    FREE_TARGET;
 	    goto CleanUp;
 	} else if (!rv) {
 #ifdef VMS
-	    HTAlert ("HTWAIS: Return message too large.");
+	    HTAlert (gettext("HTWAIS: Return message too large."));
 	    return_status = HT_NOT_LOADED;
 	    FREE_TARGET;
 	    goto CleanUp;
@@ -924,9 +909,8 @@ PUBLIC int HTLoadWAIS ARGS4(
 	any   doc_chunk;
 	any * docid = &doc_chunk;
 
-	if (TRACE) fprintf(stderr,
-		"HTWAIS: Retrieve document id `%s' type `%s' length %ld\n",
-		docname, doctype, document_length);
+	CTRACE(tfp, "HTWAIS: Retrieve document id `%s' type `%s' length %ld\n",
+		    docname, doctype, document_length);
 
 	format_in =
 	  !strcmp(doctype, "WSRC") ? HTAtom_for("application/x-wais-source") :
@@ -942,7 +926,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 	target = HTStreamStack(format_in, format_out, sink, anAnchor);
 	if (!target)
 	    return HTLoadError(sink, 500,
-			       "Can't convert format of WAIS document");
+			       gettext("Can't convert format of WAIS document"));
 	/*
 	**  Decode hex or litteral format for document ID.
 	*/
@@ -962,11 +946,10 @@ PUBLIC int HTLoadWAIS ARGS4(
 	    char *type = s_strdup(doctype);	/* Gets freed I guess */
 #endif /* VMS */
 	    request_buffer_length = MAX_MESSAGE_LEN; /* Amount left */
-	    if (TRACE)
-		fprintf(stderr, "HTWAIS: Slice number %ld\n", count);
+	    CTRACE(tfp, "HTWAIS: Slice number %ld\n", count);
 
 	    if (HTCheckForInterrupt()) {
-		HTAlert ("Data transfer interrupted.");
+		HTAlert (gettext("Data transfer interrupted."));
 		(*target->isa->_abort)(target, NULL);
 #ifdef VMS
 		FREE(type);
@@ -987,7 +970,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 					type,
 					wais_database)) {
 #ifdef VMS
-		HTAlert ("HTWAIS: Request too long.");
+		HTAlert (gettext("HTWAIS: Request too long."));
 		return_status = HT_NOT_LOADED;
 		FREE_TARGET;
 		FREE(type);
@@ -1001,7 +984,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 	    /*
 	    **	Actually do the transaction given by request_message.
 	    */
-	    HTProgress("Fetching WAIS document...");
+	    HTProgress(gettext("Fetching WAIS document..."));
 	    rv = interpret_message(request_message,
 				   MAX_MESSAGE_LEN - request_buffer_length,
 				   response_message,
@@ -1010,7 +993,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 				   false /* true verbose */
 				  );
 	    if (rv == HT_INTERRUPTED) {
-		HTAlert ("Data transfer interrupted.");
+		HTAlert (gettext("Data transfer interrupted."));
 		return_status = HT_INTERRUPTED;
 		FREE_TARGET;
 		FREE(type);
@@ -1018,7 +1001,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 		goto CleanUp;
 	    } else if (!rv) {
 #ifdef VMS
-		HTAlert ("HTWAIS: Return message too large.");
+		HTAlert (gettext("HTWAIS: Return message too large."));
 		return_status = HT_NOT_LOADED;
 		FREE_TARGET;
 		FREE(type);
@@ -1040,7 +1023,7 @@ PUBLIC int HTLoadWAIS ARGS4(
 		 retrieval_response->DatabaseDiagnosticRecords)->Text) {
 		/* display_search_response(target, retrieval_response,
 					wais_database, keywords); */
-		PUTS("No text was returned!\n");
+		PUTS(gettext("No text was returned!\n"));
 		/* panic("No text was returned"); */
 	    } else {
 		output_text_record(target,