summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2016-12-02 15:03:10 +0100
committerMichał Cichoń <michcic@gmail.com>2017-05-17 04:37:39 +0200
commit8576aa5186a2cdd4f4bf44ec34c80e90d04de969 (patch)
treee050bb66a6ce0042a797b6708abe1d2083aebf0a
parent926764b76434c0919759ecd5b26cc4d3bc92712b (diff)
downloadpianobar-windows-8576aa5186a2cdd4f4bf44ec34c80e90d04de969.tar.gz
pianobar-windows-8576aa5186a2cdd4f4bf44ec34c80e90d04de969.tar.bz2
pianobar-windows-8576aa5186a2cdd4f4bf44ec34c80e90d04de969.zip
Exit when no email/password was entered or ^C was pressed
Fixes #600. # Conflicts: # src/main.c
-rw-r--r--src/main.c21
1 files changed, 12 insertions, 9 deletions
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... ");