CTRACE(tfp, "Protection template set to `%s'\n", arg1);
CTRACE((tfp, "Protection template set to `%s'\n", arg1));
PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(	char *,		start_of_headers,	int,		length,	int,		soc,	BOOL,		IsProxy){    HTAAScheme scheme;    char *line = NULL;    int num_schemes = 0;    HTList *valid_schemes = HTList_new();    HTAssocList **scheme_specifics = NULL;    char *template = NULL;    char *temp = NULL;    /*    **  Setup atexit() freeing if not done already. - FM    */    if (!free_HTAAGlobalsSet) {#ifdef LY_FIND_LEAKS        atexit(free_HTAAGlobals);#endif	free_HTAAGlobalsSet = TRUE;    }    /*    **  Read server reply header lines    */    CTRACE(tfp, "Server reply header lines:\n");    HTAA_setupReader(start_of_headers, length, soc);    while (NULL != (line = HTAA_getUnfoldedLine())  &&  *line != '\0') {	CTRACE(tfp, "%s\n", line);	if (strchr(line, ':')) {	/* Valid header line */	    char *p = line;	    char *fieldname = HTNextField(&p);	    char *arg1 = HTNextField(&p);	    char *args = p;	    if ((IsProxy &&		 0==strcasecomp(fieldname, "Proxy-Authenticate:")) ||	        (!IsProxy &&		 0==strcasecomp(fieldname, "WWW-Authenticate:"))) {	        if (!(arg1 && *arg1 && args && *args)) {		    HTSprintf0(&temp, gettext("Invalid header '%s%s%s%s%s'"), line,				  ((arg1 && *arg1) ? " "  : ""),				  ((arg1 && *arg1) ? arg1 : ""),				  ((args && *args) ? " "  : ""),				  ((args && *args) ? args : ""));		    HTAlert(temp);		    FREE(temp);		}		else if (HTAA_UNKNOWN != (scheme = HTAAScheme_enum(arg1))) {		    HTList_addObject(valid_schemes, (void*)scheme);		    if (!scheme_specifics) {			int i;			scheme_specifics = (HTAssocList**)			    calloc(1, HTAA_MAX_SCHEMES * sizeof(HTAssocList*));			if (!scheme_specifics)			    outofmem(__FILE__, "HTAA_shouldRetryWithAuth");			for (i=0; i < HTAA_MAX_SCHEMES; i++)			    scheme_specifics[i] = NULL;		    }		    scheme_specifics[scheme] = HTAA_parseArgList(args);		    num_schemes++;		} else {		    CTRACE(tfp, "Unknown scheme `%s' %s\n",			    (arg1 ? arg1 : "(null)"),			    (IsProxy ?			     "in Proxy-Authenticate: field" :			     "in WWW-Authenticate: field"));		}	    }	    else if (!IsProxy &&		     0==strcasecomp(fieldname, "WWW-Protection-Template:")) {		CTRACE(tfp, "Protection template set to `%s'\n", arg1);		StrAllocCopy(template, arg1);	    }	} /* if a valid header line */	else {	    CTRACE(tfp, "Invalid header line `%s' ignored\n", line);	} /* else invalid header line */	FREE(line);    } /* while header lines remain */    FREE(line);    /*    **  So should we retry with authorization?    */    if (IsProxy) {	if (num_schemes == 0) {	    /*	    **  No proxy authorization valid	    */	    proxy_setup = NULL;	    return NO;	}        /*	**  Doing it for proxy.  -AJL	*/	if (proxy_setup && proxy_setup->server) {	    /*	    **  We have already tried with proxy authorization.	    **  Either we don't have access or username or	    **  password was misspelled.	    **	    **  Update scheme-specific parameters	    **  (in case they have expired by chance).	    */	    HTAASetup_updateSpecifics(proxy_setup, scheme_specifics);	    if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {		proxy_setup = NULL;		return NO;	    } else {	        /*		**  Re-ask username+password (if misspelled).		*/		proxy_setup->retry = YES;		return YES;	    }	} else {	    /*	    **  proxy_setup == NULL, i.e., we have a	    **  first connection to a protected server or	    **  the server serves a wider set of documents	    **  than we expected so far.	    */	    HTAAServer *server = HTAAServer_lookup(proxy_hostname,						   proxy_portnumber,						   IsProxy);	    if (!server) {		server = HTAAServer_new(proxy_hostname,					proxy_portnumber,					IsProxy);	    }	    if (!template)	/* Proxy matches everything  -AJL */		StrAllocCopy(template, "*");	    proxy_setup = HTAASetup_new(server,					  template,					  valid_schemes,					  scheme_specifics);	    FREE(template);	    HTAlert(gettext("Proxy authorization required -- retrying"));	    return YES;	}	/* Never reached */    }    /*    **  Normal WWW authorization.    */    if (num_schemes == 0) {	/*	**  No authorization valid.	*/	current_setup = NULL;	return NO;    }    if (current_setup && current_setup->server) {	/*	**  So we have already tried with WWW authorization.	**  Either we don't have access or username or	**  password was misspelled.	**	**  Update scheme-specific parameters	**  (in case they have expired by chance).	*/	HTAASetup_updateSpecifics(current_setup, scheme_specifics);	if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {	    current_setup = NULL;	    return NO;	} else {	    /*	    **  Re-ask username+password (if misspelled).	    */	    current_setup->retry = YES;	    return YES;	}    } else {        /*	**  current_setup == NULL, i.e., we have a	**  first connection to a protected server or	**  the server serves a wider set of documents	**  than we expected so far.	*/	HTAAServer *server = HTAAServer_lookup(current_hostname,					       current_portnumber,					       IsProxy);	if (!server) {	    server = HTAAServer_new(current_hostname,				    current_portnumber,				    IsProxy);	}	if (!template)	    template = HTAA_makeProtectionTemplate(current_docname);	current_setup = HTAASetup_new(server,				      template,				      valid_schemes,				      scheme_specifics);	FREE(template);        HTAlert(gettext("Access without authorization denied -- retrying"));	return YES;    }    /* Never reached */}