headline);
headline));
PRIVATE void display_search_response ARGS4(    HTStructured *,		target,    SearchResponseAPDU *,	response,    char *,			database,    char *,			keywords){    WAISSearchResponse	*info;    long i, k;    BOOL archie =  strstr(database, "archie")!=0;	/* Specical handling */    CTRACE(tfp, "HTWAIS: Displaying search response\n");    PUTS(gettext("Index "));    START(HTML_EM);    PUTS(database);    END(HTML_EM);    sprintf(line, gettext(" contains the following %d item%s relevant to \""),	    (int)(response->NumberOfRecordsReturned),	    response->NumberOfRecordsReturned ==1 ? "" : "s");    PUTS(line);    START(HTML_EM);    PUTS(keywords);    END(HTML_EM);    PUTS("\".\n");    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);    PUTC('\n');    START(HTML_OL);    if (response->DatabaseDiagnosticRecords != 0) {	info = (WAISSearchResponse *)response->DatabaseDiagnosticRecords;	i =0;	if (info->Diagnostics != NULL)	    showDiags((HTStream*)target, info->Diagnostics);	if (info->DocHeaders != 0) {	    for (k = 0; info->DocHeaders[k] != 0; k++ ) {		WAISDocumentHeader* head = info->DocHeaders[k];		char * headline = trim_junk(head->Headline);		any * docid = head->DocumentID;		char * docname; 	/* printable version of docid */		i++;		/*		**  Make a printable string out of the document id.		*/		CTRACE(tfp, "HTWAIS:  %2ld: Score: %4ld, lines:%4ld '%s'\n",			    i,			    (long int)(info->DocHeaders[k]->Score),			    (long int)(info->DocHeaders[k]->Lines),			    headline);		START(HTML_LI);		if (archie) {		    char * www_name = WWW_from_archie(headline);		    if (www_name) {			HTStartAnchor(target, NULL, www_name);			PUTS(headline);			END(HTML_A);			FREE(www_name);		    } else {			PUTS(headline);			PUTS(gettext(" (bad file name)"));		    }		} else { /* Not archie */		    docname =  WWW_from_WAIS(docid);		    if (docname) {			char * dbname = HTEscape(database, URL_XPALPHAS);			sprintf(line,				"/%s/%s/%d/%s", 	/* W3 address */				dbname,				head->Types ? head->Types[0] : "TEXT",				(int)(head->DocumentLength),				docname);			HTStartAnchor(target, NULL,				      ((head->Types) &&				       (!strcmp(head->Types[0], "URL")))						?				       headline : line); /* NT, Sep 93 */			PUTS(headline);			END(HTML_A);			FREE(dbname);			FREE(docname);		    } else {			PUTS(gettext("(bad doc id)"));		    }		}		sprintf(line, "%5ld  %5ld  ",			head->Score,			head->Lines);		PUTS( line);		MAYBE_END(HTML_LI);	    } /* next document header */	} /* if there were any document headers */	if (info->ShortHeaders != 0) {	    k = 0;	    while (info->ShortHeaders[k] != 0) {		i++;		PUTS( gettext("(Short Header record, can't display)"));	    }	}	if (info->LongHeaders != 0) {	    k = 0;	    while (info->LongHeaders[k] != 0) {		i++;		PUTS( gettext("\nLong Header record, can't display\n"));	    }	}	if (info->Text != 0) {	    k = 0;	    while (info->Text[k] != 0) {		i++;		PUTS( gettext("\nText record\n"));		output_text_record((HTStream*)target,				   info->Text[k++], false, false);	    }	}	if (info->Headlines != 0) {	    k = 0;	    while (info->Headlines[k] != 0) {		i++;		PUTS( gettext("\nHeadline record, can't display\n"));		/* dsply_headline_record( info->Headlines[k++]); */	    }	}	if (info->Codes != 0) {	    k = 0;	    while (info->Codes[k] != 0) {		i++;		PUTS( gettext("\nCode record, can't display\n"));		/* dsply_code_record( info->Codes[k++]); */	    }	}    }	/* Loop: display user info */    END(HTML_OL);    PUTC('\n');}