src/bin/psql/command.c
static char *
prompt_for_password(const char *username, bool *canceled)
{
	char	   *result;
	PromptInterruptContext prompt_ctx;

	/* Set up to let SIGINT cancel simple_prompt_extended() */
	prompt_ctx.jmpbuf = sigint_interrupt_jmp;
	prompt_ctx.enabled = &sigint_interrupt_enabled;
	prompt_ctx.canceled = false;

	if (username == NULL || username[0] == '\0')
		result = simple_prompt_extended("Password: ", false, &prompt_ctx);
	else
	{
		char	   *prompt_text;

		prompt_text = psprintf(_("Password for user %s: "), username);
		result = simple_prompt_extended(prompt_text, false, &prompt_ctx);
		free(prompt_text);
	}

	if (canceled)
		*canceled = prompt_ctx.canceled;

	return result;
}
/*
 * Ask the user for a password; 'username' is the username the
 * password is for, if one has been explicitly specified.
 * Returns a malloc'd string.
 * If 'canceled' is provided, *canceled will be set to true if the prompt
 * is canceled via SIGINT, and to false otherwise.
 */
Ask the user for a password; 'username' is the username the
password is for, if one has been explicitly specified.
Returns a malloc'd string.
If 'canceled' is provided, *canceled will be set to true if the prompt
is canceled via SIGINT, and to false otherwise.
Ask the user for a password ; ' username ' is the username the password is for if one has been explicitly specified . Returns a malloc ' d string . If ' canceled ' is provided * canceled will be set to true if the prompt is canceled via SIGINT and to false otherwise .
static char *
prompt_for_password(const char *username, bool *canceled)
{
	char	   *result;
	PromptInterruptContext prompt_ctx;
	prompt_ctx.jmpbuf = sigint_interrupt_jmp;
	prompt_ctx.enabled = &sigint_interrupt_enabled;
	prompt_ctx.canceled = false;
	if (username == NULL || username[0] == '\0')
		result = simple_prompt_extended("Password: ", false, &prompt_ctx);
	else
	{
		char	   *prompt_text;
		prompt_text = psprintf(_("Password for user %s: "), username);
		result = simple_prompt_extended(prompt_text, false, &prompt_ctx);
		free(prompt_text);
	}
	if (canceled)
		*canceled = prompt_ctx.canceled;
	return result;
}
static char * prompt_for_password ( const char * username , bool * canceled ) { char * result ; PromptInterruptContext prompt_ctx ; prompt_ctx . jmpbuf = sigint_interrupt_jmp ; prompt_ctx . enabled = & sigint_interrupt_enabled ; prompt_ctx . canceled = false ; if ( username == NULL || username [ 0 ] == ' \0 ' ) result = simple_prompt_extended ( " " , false , & prompt_ctx ) ; else { char * prompt_text ; prompt_text = psprintf ( _ ( " " ) , username ) ; result = simple_prompt_extended ( prompt_text , false , & prompt_ctx ) ; free ( prompt_text ) ; } if ( canceled ) * canceled = prompt_ctx . canceled ; return result ; }
Ask the user for a password; 'username' is the username the
 password is for, if one has been explicitly specified.
Ask the user for a password ; ' username ' is the username the password is for if one has been explicitly specified .
/* Set up to let SIGINT cancel simple_prompt_extended() */