diff options
author | Julien Dessaux | 2019-08-01 17:52:46 +0200 |
---|---|---|
committer | Julien Dessaux | 2019-08-01 17:52:46 +0200 |
commit | c151f2d4c85350b51fcf24ba83b426bf699269d6 (patch) | |
tree | 2b5fefac0f30504cc4c55ee09ac531e000b3fa95 /close_im | |
download | rocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.tar.gz rocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.tar.bz2 rocket-cli-client-c151f2d4c85350b51fcf24ba83b426bf699269d6.zip |
Initial import
Diffstat (limited to 'close_im')
-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; +} |