(!PreviousSearch && QueryTotal >= 1)) ? RECALL : NORECALL);
(!PreviousSearch && QueryTotal >= 1)) ? RECALL_URL : NORECALL);
PUBLIC int do_www_search ARGS1(	document *,	doc){    char searchstring[256], temp[256], *cp, *tmpaddress = NULL;    int ch, recall;    int QueryTotal;    int QueryNum;    BOOLEAN PreviousSearch = FALSE;    /*     *  Load the default query buffer     */    if ((cp=strchr(doc->address, '?')) != NULL) {	/*	 *  This is an index from a previous search.	 *  Use its query as the default.	 */	PreviousSearch = TRUE;	strcpy(searchstring, ++cp);	for (cp=searchstring; *cp; cp++)	    if (*cp == '+')		*cp = ' ';	HTUnEscape(searchstring);	strcpy(temp, searchstring);	/*	 *  Make sure it's treated as the most recent query. - FM	 */	HTAddSearchQuery(searchstring);    } else {	/*	 *  New search; no default.	 */	searchstring[0] = '\0';	temp[0] = '\0';    }    /*     *  Prompt for a query string.     */    if (searchstring[0] == '\0') {	if (HTMainAnchor->isIndexPrompt)	    _statusline(HTMainAnchor->isIndexPrompt);	else	    _statusline(ENTER_DATABASE_QUERY);    } else	_statusline(EDIT_CURRENT_QUERY);    QueryTotal = (search_queries ? HTList_count(search_queries) : 0);    recall = (((PreviousSearch && QueryTotal >= 2) ||	       (!PreviousSearch && QueryTotal >= 1)) ? RECALL : NORECALL);    QueryNum = QueryTotal;get_query:    if ((ch=LYgetstr(searchstring, VISIBLE,		     sizeof(searchstring), recall)) < 0 ||	*searchstring == '\0' || ch == UPARROW || ch == DNARROW) {	if (recall && ch == UPARROW) {	    if (PreviousSearch) {		/*		 *  Use the second to last query in the list. - FM		 */		QueryNum = 1;		PreviousSearch = FALSE;	    } else {		/*		 *  Go back to the previous query in the list. - FM		 */		QueryNum++;	    }	    if (QueryNum >= QueryTotal)		/*		 *  Roll around to the last query in the list. - FM		 */		QueryNum = 0;	    if ((cp=(char *)HTList_objectAt(search_queries,					    QueryNum)) != NULL) {		strcpy(searchstring, cp);		if (*temp && !strcmp(temp, searchstring)) {		    _statusline(EDIT_CURRENT_QUERY);		} else if ((*temp && QueryTotal == 2) ||			   (!(*temp) && QueryTotal == 1)) {		    _statusline(EDIT_THE_PREV_QUERY);		} else {		    _statusline(EDIT_A_PREV_QUERY);		}		goto get_query;	    }	} else if (recall && ch == DNARROW) {	    if (PreviousSearch) {		/*		 *  Use the first query in the list. - FM		 */		QueryNum = QueryTotal - 1;		PreviousSearch = FALSE;	    } else {		/*		 *  Advance to the next query in the list. - FM		 */		QueryNum--;	    }	    if (QueryNum < 0)		/*		 *  Roll around to the first query in the list. - FM		 */		QueryNum = QueryTotal - 1;	    if ((cp=(char *)HTList_objectAt(search_queries,					    QueryNum)) != NULL) {		strcpy(searchstring, cp);		if (*temp && !strcmp(temp, searchstring)) {		    _statusline(EDIT_CURRENT_QUERY);		} else if ((*temp && QueryTotal == 2) ||			   (!(*temp) && QueryTotal == 1)) {		    _statusline(EDIT_THE_PREV_QUERY);		} else {		    _statusline(EDIT_A_PREV_QUERY);		}		goto get_query;	    }	}	/*	 *  Search cancelled.	 */	HTInfoMsg(CANCELLED);	return(NULLFILE);    }    /*     *  Strip leaders and trailers. - FM     */    LYTrimLeading(searchstring);    if (!(*searchstring)) {	HTInfoMsg(CANCELLED);	return(NULLFILE);    }    LYTrimTrailing(searchstring);    /*     *  Don't resubmit the same query unintentionally.     */    if (!LYforce_no_cache && 0 == strcmp(temp, searchstring)) {	HTUserMsg(USE_C_R_TO_RESUB_CUR_QUERY);	return(NULLFILE);    }    /*     *  Add searchstring to the query list,     *  or make it the most current. - FM     */    HTAddSearchQuery(searchstring);    /*     *  Show the URL with the new query.     */    if ((cp=strchr(doc->address, '?')) != NULL)	*cp = '\0';    StrAllocCopy(tmpaddress, doc->address);    StrAllocCat(tmpaddress, "?");    StrAllocCat(tmpaddress, searchstring);    user_message(WWW_WAIT_MESSAGE, tmpaddress);#ifndef VMS#ifdef SYSLOG_REQUESTED_URLS    syslog(LOG_INFO|LOG_LOCAL5, "%s", tmpaddress);#endif /* SYSLOG_REQUESTED_URLS */#endif /* !VMS */    FREE(tmpaddress);    if (cp)	*cp = '?';    /*     *  OK, now we do the search.     */    if (HTSearch(searchstring, HTMainAnchor)) {	/*	 *	Memory leak fixed.	 *	05-28-94 Lynx 2-3-1 Garrett Arch Blythe	 */	auto char *cp_freeme = NULL;	if (traversal)	    cp_freeme = stub_HTAnchor_address((HTAnchor *)HTMainAnchor);	else	    cp_freeme = HTAnchor_address((HTAnchor *)HTMainAnchor);	StrAllocCopy(doc->address, cp_freeme);	FREE(cp_freeme);	CTRACE(tfp,"\ndo_www_search: newfile: %s\n",doc->address);	/*	 *  Yah, the search succeeded.	 */	return(NORMAL);    }    /*     *  Either the search failed (Yuk), or we got redirection.     *  If it's redirection, use_this_url_instead is set, and     *  mainloop() will deal with it such that security features     *  and restrictions are checked before acting on the URL, or     *  rejecting it. - FM     */    return(NOT_FOUND);}