From 8576aa5186a2cdd4f4bf44ec34c80e90d04de969 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 2 Dec 2016 15:03:10 +0100 Subject: Exit when no email/password was entered or ^C was pressed Fixes #600. # Conflicts: # src/main.c --- src/main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 6e99ada..3e6e85f 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,8 @@ static bool BarMainGetLoginCredentials(BarSettings_t *settings, char nameBuf[100]; BarUiMsg(settings, MSG_QUESTION, "Email: "); - BarReadlineStr(nameBuf, sizeof(nameBuf), rl, BAR_RL_DEFAULT); + if (BarReadlineStr(nameBuf, sizeof(nameBuf), rl, BAR_RL_DEFAULT) == 0) + return false; settings->username = strdup(nameBuf); usernameFromConfig = false; } @@ -78,18 +79,20 @@ static bool BarMainGetLoginCredentials(BarSettings_t *settings, BarUiMsg(settings, MSG_QUESTION, "Email: %s\n", settings->username); } - if (settings->passwordCmd == NULL) - { - BarUiMsg(settings, MSG_QUESTION, "Password: "); - BarReadlineStr(passBuf, sizeof(passBuf), rl, BAR_RL_NOECHO); + if (settings->passwordCmd == NULL) { + BarUiMsg (settings, MSG_QUESTION, "Password: "); + if (BarReadlineStr (passBuf, sizeof (passBuf), rl, BAR_RL_NOECHO) == 0) { + BarConsolePutc('\n'); + return false; + } /* write missing newline */ BarConsolePutc('\n'); - settings->password = strdup(passBuf); - } + settings->password = strdup (passBuf); + } else { - //pid_t chld; - //int pipeFd[2]; + //pid_t chld; + //int pipeFd[2]; //BarUiMsg (settings, MSG_INFO, "Requesting password from external helper... "); -- cgit v1.2.3