diff options
author | Julien Dessaux | 2019-08-06 11:19:31 +0200 |
---|---|---|
committer | Julien Dessaux | 2019-08-06 11:19:31 +0200 |
commit | 2adde9fc42145c0ca5d7aada0bdac336debf5487 (patch) | |
tree | 6f61d923f7d3471636739c84c2af7fa0c2fcd7e5 | |
parent | Added the option to set login and password in config file (diff) | |
download | rocket-cli-client-2adde9fc42145c0ca5d7aada0bdac336debf5487.tar.gz rocket-cli-client-2adde9fc42145c0ca5d7aada0bdac336debf5487.tar.bz2 rocket-cli-client-2adde9fc42145c0ca5d7aada0bdac336debf5487.zip |
Cosmetics
Diffstat (limited to '')
-rw-r--r-- | restapi/im.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/restapi/im.c b/restapi/im.c index 0c49cb0..0d42597 100644 --- a/restapi/im.c +++ b/restapi/im.c @@ -7,23 +7,23 @@ #include "common/http.h" #include "im.h" -#define LOGIN_ARG_PRE "{ \"username\": \"" -#define LOGIN_ARG_POST "\" }" +#define USERNAME_ARG_PRE "{ \"username\": \"" +#define USERNAME_ARG_POST "\" }" char // returns 0 if ok, greater than 0 otherwise restapi_im_close(const char* username) { char ret = 0; - size_t pre_len = strlen(LOGIN_ARG_PRE); + size_t pre_len = strlen(USERNAME_ARG_PRE); size_t user_len = strlen(username); - size_t post_len = strlen(LOGIN_ARG_POST); - char* login_args = malloc(pre_len + user_len + post_len + 1); - strcpy(login_args, LOGIN_ARG_PRE); - strcpy(login_args + pre_len, username); - strcpy(login_args + pre_len + user_len, LOGIN_ARG_POST); - const char* buffer = http_post("/api/v1/im.close", login_args); - free(login_args); + size_t post_len = strlen(USERNAME_ARG_POST); + char* username_arg = malloc(pre_len + user_len + post_len + 1); + strcpy(username_arg, USERNAME_ARG_PRE); + strcpy(username_arg + pre_len, username); + strcpy(username_arg + pre_len + user_len, USERNAME_ARG_POST); + const char* buffer = http_post("/api/v1/im.close", username_arg); + free(username_arg); if (buffer == NULL) { fprintf(stderr, "Error while im_close, http post didn't return any data.\n"); |