CTRACE(tfp, "HTAA_composeAuth: %s\n", "Forwarding received authorization");
CTRACE((tfp, "HTAA_composeAuth: %s\n", "Forwarding received authorization"));
PUBLIC char *HTAA_composeAuth ARGS4(	CONST char *,	hostname,	CONST int,	portnumber,	CONST char *,	docname,	BOOL,		IsProxy){    char *auth_string;    BOOL retry;    HTAAScheme scheme;    int len;    /*    **  Setup atexit() freeing if not done already. - FM    */    if (!free_HTAAGlobalsSet) {#ifdef LY_FIND_LEAKS        atexit(free_HTAAGlobals);#endif	free_HTAAGlobalsSet = TRUE;    }    /*    ** Make gateway httpds pass authorization field as it was received.    ** (This still doesn't really work because Authenticate: headers    **  from remote server are not forwarded to client yet so it cannot    **  really know that it should send authorization;  I will not    **  implement it yet because I feel we will soon change radically    **  the way requests are represented to allow multithreading    **  on server-side.  Life is hard.)    */    if (HTAAForwardAuth) {	CTRACE(tfp, "HTAA_composeAuth: %s\n",		    "Forwarding received authorization");	StrAllocCopy(HTAA_composeAuthResult, HTAAForwardAuth);	HTAAForwardAuth_reset();	/* Just a precaution */	return HTAA_composeAuthResult;    }    FREE(HTAA_composeAuthResult);	/* From previous call */    if (IsProxy) {        /*	**  Proxy Authorization required. - AJL	*/	CTRACE(tfp, "Composing Proxy Authorization for %s:%d/%s\n",		    hostname, portnumber, docname);	if (proxy_portnumber != portnumber ||	    !proxy_hostname || !proxy_docname ||	    !hostname         || !docname         ||	    0 != strcmp(proxy_hostname, hostname) ||	    0 != strcmp(proxy_docname, docname)) {	    retry = NO;	    proxy_portnumber = portnumber;	    if (hostname)		StrAllocCopy(proxy_hostname, hostname);	    else		FREE(proxy_hostname);	    if (docname)		StrAllocCopy(proxy_docname, docname);	    else		FREE(proxy_docname);	} else {	    retry = YES;	}	if (!proxy_setup || !retry)	    proxy_setup = HTAASetup_lookup(hostname, portnumber,					   docname, IsProxy);	if (!proxy_setup)	    return NULL;    	switch (scheme = HTAA_selectScheme(proxy_setup)) {	  case HTAA_BASIC:	  case HTAA_PUBKEY:	    auth_string = compose_auth_string(scheme, proxy_setup, IsProxy);	    break;	  case HTAA_KERBEROS_V4:	    /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */	  default:	    {		char *msg = NULL;		HTSprintf0(&msg, "%s `%s'",			gettext("This client doesn't know how to compose proxy authorization information for scheme"),			HTAAScheme_name(scheme));		HTAlert(msg);		FREE(msg);		auth_string = NULL;	    }	} /* switch scheme */	proxy_setup->retry = NO;	if (!auth_string)	    /*	    **  Signal a failure. - FM	    */	    return NULL;  /* Added by marca. */	if (*auth_string == '\0') {	    /*	    **  Signal an abort. - FM	    */	    StrAllocCopy(HTAA_composeAuthResult, "");	    return(HTAA_composeAuthResult);	}	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 26;	if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))	    outofmem(__FILE__, "HTAA_composeAuth");	strcpy(HTAA_composeAuthResult, "Proxy-Authorization: ");    } else {	/*	**  Normal WWW authorization.	*/	CTRACE(tfp, "Composing Authorization for %s:%d/%s\n",		    hostname, portnumber, docname);	if (current_portnumber != portnumber ||	    !current_hostname || !current_docname ||	    !hostname         || !docname         ||	    0 != strcmp(current_hostname, hostname) ||	    0 != strcmp(current_docname, docname)) {	    retry = NO;	    current_portnumber = portnumber;	    if (hostname)		StrAllocCopy(current_hostname, hostname);	    else		FREE(current_hostname);	    if (docname)		StrAllocCopy(current_docname, docname);	    else		FREE(current_docname);	} else {	    retry = YES;	}	if (!current_setup || !retry)	    current_setup = HTAASetup_lookup(hostname, portnumber,					     docname, IsProxy);	if (!current_setup)	    return NULL;	switch (scheme = HTAA_selectScheme(current_setup)) {	  case HTAA_BASIC:	  case HTAA_PUBKEY:	    auth_string = compose_auth_string(scheme, current_setup, IsProxy);	    break;	  case HTAA_KERBEROS_V4:	    /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */	  default:	    {		char *msg = 0;		HTSprintf0(&msg, "%s `%s'",			gettext("This client doesn't know how to compose authorization information for scheme"),			HTAAScheme_name(scheme));		HTAlert(msg);		FREE(msg);		auth_string = NULL;	    }	} /* switch scheme */	current_setup->retry = NO;	if (!auth_string)	    /*	    **  Signal a failure. - FM	    */	    return NULL;  /* Added by marca. */	if (*auth_string == '\0') {	    /*	    **  Signal an abort. - FM	    */	    StrAllocCopy(HTAA_composeAuthResult, "");	    return(HTAA_composeAuthResult);	}	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 20;	if (!(HTAA_composeAuthResult = (char*)calloc(1, sizeof(char) * len)))	    outofmem(__FILE__, "HTAA_composeAuth");	strcpy(HTAA_composeAuthResult, "Authorization: ");    }    strcat(HTAA_composeAuthResult, HTAAScheme_name(scheme));    strcat(HTAA_composeAuthResult, " ");    strcat(HTAA_composeAuthResult, auth_string);    return HTAA_composeAuthResult;}