From fea924350b6ba50dc0cb0e5e133cbbd914137e61 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 6 Aug 2019 15:44:18 +0200 Subject: Added a proper subscriptions listing for the direct conversations closer --- close_im/main.c | 78 --------------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 close_im/main.c (limited to 'close_im/main.c') diff --git a/close_im/main.c b/close_im/main.c deleted file mode 100644 index c54ab25..0000000 --- a/close_im/main.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "common/util.h" -#include -#include -#include -#include - -#include "common/config.h" -#include "restapi/auth.h" -#include "restapi/im.h" - -int main(void) -{ - if (config_load(CONFIG_PATH) != 0) { - return 1; - } - - const char* login = config_get_login(); - char* termlogin = NULL; - if (login == NULL) { - size_t len = 0; - printf("Login: "); - ssize_t read = getline(&termlogin, &len, stdin); - if (read > 1) termlogin[read-1] = 0; - login = termlogin; - } - - const char* password = config_get_password(); - char* termpassword = NULL; - if (password == NULL) { - struct termios oflags, nflags; - tcgetattr(fileno(stdin), &oflags); - nflags = oflags; - nflags.c_lflag &= ~ECHO; - nflags.c_lflag |= ECHONL; - - if (tcsetattr(fileno(stdin), TCSADRAIN, &nflags) != 0) { - perror("tcsetattr"); - return -1; - } - - size_t len = 0; - printf("Password: "); - size_t read = getline(&termpassword, &len, stdin); - if (read > 1) termpassword[read-1] = 0; - - if (tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) { - perror("tcsetattr"); - return -1; - } - password = termpassword; - } - - if (restapi_login(login, password) == 0) { - while(1) { - char* buff = NULL; - size_t len2; - printf("IM to close: "); - ssize_t entry = getline(&buff, &len2, stdin); - if (entry > 1) { - buff[entry-1] = 0; - } else { - free(buff); - break; - } - restapi_im_close(buff); - free(buff); - } - } else { - printf("Couldn't init rest api.\n"); - } - - restapi_logout(); - config_clean(); - free(termlogin); - free(termpassword); - - return 0; -} -- cgit v1.2.3