From a1c765a2cb08f49d31c70e5e6fbfba4190eb126e Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 21 Apr 2011 00:10:40 -0500 Subject: [PATCH 02/18] Generalize get_password So that we can use it to get other passwords as well. --- src/core/xmpp-servers.c | 10 +++++----- src/core/xmpp-servers.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) --- a/src/core/xmpp-servers.c +++ b/src/core/xmpp-servers.c @@ -282,8 +282,8 @@ * Displays input prompt on command line and takes input data from user * From irssi-silc (silc-client/lib/silcutil/silcutil.c) */ -static char * -get_password() +char * +get_password(char *prompt) { char input[2048], *ret = NULL; int fd; @@ -310,7 +310,7 @@ to.c_cc[VMIN] = 255; tcsetattr(fd, TCSANOW, &to); - printf("\tXMPP Password: "); + printf("\n\n%s", prompt); fflush(stdout); memset(input, 0, sizeof(input)); @@ -334,6 +334,7 @@ ret = g_strdup(input); memset(input, 0, sizeof(input)); #endif /* DISABLE_TERMIOS */ + signal_emit("send command", 1, "redraw"); return ret; } @@ -373,8 +374,7 @@ || *(server->connrec->password) == '\0' || *(server->connrec->password) == '\r') { g_free_not_null(server->connrec->password); - server->connrec->prompted_password = get_password(); - signal_emit("send command", 1, "redraw"); + server->connrec->prompted_password = get_password("XMPP Password: "); if (server->connrec->prompted_password != NULL) server->connrec->password = g_strdup(server->connrec->prompted_password); --- a/src/core/xmpp-servers.h +++ b/src/core/xmpp-servers.h @@ -58,8 +58,9 @@ SERVER_REC *xmpp_server_init_connect(SERVER_CONNECT_REC *); void xmpp_server_connect(XMPP_SERVER_REC *); -void xmpp_servers_init(void); -void xmpp_servers_deinit(void); +void xmpp_servers_init(void); +void xmpp_servers_deinit(void); +char *get_password(char *prompt); __END_DECLS #endif