diff options
Diffstat (limited to '')
-rw-r--r-- | close_im/CMakeLists.txt | 7 | ||||
-rw-r--r-- | close_im/main.cpp | 46 |
2 files changed, 53 insertions, 0 deletions
diff --git a/close_im/CMakeLists.txt b/close_im/CMakeLists.txt new file mode 100644 index 0000000..fd5ce8c --- /dev/null +++ b/close_im/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCES *.cpp) + +ADD_EXECUTABLE(rocket_close_im ${SOURCES}) +target_link_libraries(rocket_close_im common rest) +target_link_libraries(rocket_close_im curl) + +install(TARGETS rocket_close_im DESTINATION bin) diff --git a/close_im/main.cpp b/close_im/main.cpp new file mode 100644 index 0000000..c412d8b --- /dev/null +++ b/close_im/main.cpp @@ -0,0 +1,46 @@ +#include <cstdlib> +#include <string> +#include <unistd.h> + +#include "common/config.h" +#include "rest/rest.hpp" +#include "common/util.h" + +int main(void) +{ + char* login = NULL; + size_t len = 0; + printf("Login: "); + ssize_t read = getline(&login, &len, stdin); + if (read > 1) login[read-1] = 0; + + char* password = getpass("Password: "); + + rest_init(WEB_URL); + + if (rest_login(login, password)) { + 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; + } + rest_im_close(buff); + free(buff); + } + } else { + printf("Couldn't init rest api.\n"); + } + + rest_logout(); + rest_clear(); + + free(login); + + return 0; +} |