From 8a2ffcd0ffe82296bd25d52288619c0497153581 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sat, 28 Sep 2013 01:20:43 -0400 Subject: [PATCH] fixed status bugs and made them case insensitive --- src/commands.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/commands.c b/src/commands.c index cf4b0dd..765ad8d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -421,19 +421,28 @@ void cmd_status(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv return; } + int len = strlen(status); + char l_status[len+1]; + int i; + + for (i = 0; i <= len; ++i) + l_status[i] = tolower(status[i]); + TOX_USERSTATUS status_kind; - if (!strncmp(status, "online", strlen("online"))) + if (!strcmp(l_status, "online")) status_kind = TOX_USERSTATUS_NONE; - else if (!strncmp(status, "away", strlen("away"))) + else if (!strcmp(l_status, "away")) status_kind = TOX_USERSTATUS_AWAY; - else if (!strncmp(status, "busy", strlen("busy"))) + else if (!strcmp(l_status, "busy")) status_kind = TOX_USERSTATUS_BUSY; - else - wprintw(window, "Invalid status.\n"); + else { + wprintw(window, "Invalid status. Valid statuses are: online, busy and away.\n"); + return; + } tox_set_userstatus(m, status_kind); prompt_update_status(prompt, status_kind);