if ((auth = (NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {
if ((auth = typecalloc(NNTPAuth)) != NULL) {
PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1(	char *, 	host){    HTList *cur = NULL;    NNTPAuth *auth = NULL;    char *UserName = NULL;    char *PassWord = NULL;    char *msg = NULL;    char buffer[512];    int status, tries;    /*    **	Make sure we have an interactive user and a host. - FM    */    if (dump_output_immediately || !(host && *host))	return NNTPAUTH_ERROR;    /*    **	Check for an existing authorization entry. - FM    */    if (NNTP_AuthInfo != NULL) {	cur = NNTP_AuthInfo;	while (NULL != (auth = (NNTPAuth *)HTList_nextObject(cur))) {	    if (!strcmp(auth->host, host)) {		UserName = auth->user;		PassWord = auth->pass;		break;	    }	}    } else {	NNTP_AuthInfo = HTList_new();#ifdef LY_FIND_LEAKS	atexit(free_NNTP_AuthInfo);#endif    }    /*    **	Handle the username. - FM    */    buffer[511] = '\0';    tries = 3;    while (tries) {	if (UserName == NULL) {	    if ((msg = (char *)calloc(1, (strlen(host) + 30))) == NULL) {		outofmem(__FILE__, "HTHandleAuthInfo");	    }	    sprintf(msg, gettext("Username for news host '%s':"), host);	    UserName = HTPrompt(msg, NULL);	    FREE(msg);	    if (!(UserName && *UserName)) {		FREE(UserName);		return NNTPAUTH_ERROR;	    }	}	sprintf(buffer, "AUTHINFO USER %.*s%c%c", 495, UserName, CR, LF);	if ((status = response(buffer)) < 0) {	    if (status == HT_INTERRUPTED)		_HTProgress(CONNECTION_INTERRUPTED);	    else		HTAlert(FAILED_CONNECTION_CLOSED);	    if (auth) {		if (auth->user != UserName) {		    FREE(auth->user);		    auth->user = UserName;		}	    } else {		FREE(UserName);	    }	    return NNTPAUTH_CLOSE;	}	if (status == 281) {	    /*	    **  Username is accepted and no password is required. - FM	    */	    if (auth) {		if (auth->user != UserName) {		    FREE(auth->user);		    auth->user = UserName;		}	    } else {		/*		**  Store the accepted username and no password. - FM		*/		if ((auth =		    (NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {		    StrAllocCopy(auth->host, host);		    auth->user = UserName;		    HTList_appendObject(NNTP_AuthInfo, auth);		}	    }	    return NNTPAUTH_OK;	}	if (status != 381) {	    /*	    **  Not success, nor a request for the password,	    **  so it must be an error. - FM	    */	    HTAlert(response_text);	    tries--;	    if ((tries > 0) && HTConfirm(gettext("Change username?"))) {		if (!auth || auth->user != UserName) {		    FREE(UserName);		}		if ((UserName = HTPrompt(gettext("Username:"), UserName)) != NULL &&		    *UserName) {		    continue;		}	    }	    if (auth) {		if (auth->user != UserName) {		    FREE(auth->user);		}		FREE(auth->pass);	    }	    FREE(UserName);	    return NNTPAUTH_ERROR;	}	break;    }    if (status == 381) {	/*	**  Handle the password. - FM	*/	tries = 3;	while (tries) {	    if (PassWord == NULL) {		if ((msg = (char *)calloc(1, (strlen(host) + 30))) == NULL) {		    outofmem(__FILE__, "HTHandleAuthInfo");		}		sprintf(msg, gettext("Password for news host '%s':"), host);		PassWord = HTPromptPassword(msg);		FREE(msg);		if (!(PassWord && *PassWord)) {		    FREE(PassWord);		    return NNTPAUTH_ERROR;		}	    }	    sprintf(buffer, "AUTHINFO PASS %.*s%c%c", 495, PassWord, CR, LF);	    if ((status = response(buffer)) < 0) {		if (status == HT_INTERRUPTED) {		    _HTProgress(CONNECTION_INTERRUPTED);		} else {		    HTAlert(FAILED_CONNECTION_CLOSED);		}		if (auth) {		    if (auth->user != UserName) {			FREE(auth->user);			auth->user = UserName;		    }		    if (auth->pass != PassWord) {			FREE(auth->pass);			auth->pass = PassWord;		    }		} else {		    FREE(UserName);		    FREE(PassWord);		}		return NNTPAUTH_CLOSE;	    }	    if (status == 502) {		/*		 *  That's what INN's nnrpd returns.		 *  It closes the connection after this. - kw		 */		HTAlert(response_text);		if (auth) {		    if (auth->user == UserName)			UserName = NULL;		    FREE(auth->user);		    if (auth->pass == PassWord)			PassWord = NULL;		    FREE(auth->pass);		}		FREE(UserName);		FREE(PassWord);		return NNTPAUTH_CLOSE;	    }	    if (status == 281) {	    /*	    **	Password also is accepted, and everything	    **	has been stored. - FM	    */		if (auth) {		    if (auth->user != UserName) {			FREE(auth->user);			auth->user = UserName;		    }		    if (auth->pass != PassWord) {			FREE(auth->pass);			auth->pass = PassWord;		    }		} else {		    if ((auth =			(NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {			StrAllocCopy(auth->host, host);			auth->user = UserName;			auth->pass = PassWord;			HTList_appendObject(NNTP_AuthInfo, auth);		    }		}		return NNTPAUTH_OK;	    }	    /*	    **	Not success, so it must be an error. - FM	    */	    HTAlert(response_text);	    if (!auth || auth->pass != PassWord) {		FREE(PassWord);	    } else {		PassWord = NULL;	    }	    tries--;	    if ((tries > 0) && HTConfirm(gettext("Change password?"))) {		continue;	    }	    if (auth) {		if (auth->user == UserName)		    UserName = NULL;		FREE(auth->user);		FREE(auth->pass);	    }	    FREE(UserName);	    break;	}    }    return NNTPAUTH_ERROR;}