diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2016-12-02 15:03:10 +0100 |
---|---|---|
committer | Michał Cichoń <michcic@gmail.com> | 2017-05-17 04:37:39 +0200 |
commit | 8576aa5186a2cdd4f4bf44ec34c80e90d04de969 (patch) | |
tree | e050bb66a6ce0042a797b6708abe1d2083aebf0a /src | |
parent | 926764b76434c0919759ecd5b26cc4d3bc92712b (diff) | |
download | pianobar-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
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -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... "); |