diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-07-26 17:17:09 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-07-26 17:17:09 -0700 |
commit | 8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2 (patch) | |
tree | fa39391ea1eef6e87a563ee417ba709a33dae596 /client/libacron/apps/acronc/handler.h | |
parent | 219e4bb54375995fa377a1bcf9601a77cf6f1fee (diff) | |
download | acron-8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2.tar acron-8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2.tar.gz acron-8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2.tar.bz2 acron-8b07bf593e54dd876e30d0cb1c7c7226d0d1b1e2.zip |
feat(acronc): add acronc(1), the Acron cli
Still in early development, Windows support is incomplete.
Signed-off-by: Trumeet <yuuta@yuuta.moe>
Diffstat (limited to 'client/libacron/apps/acronc/handler.h')
-rw-r--r-- | client/libacron/apps/acronc/handler.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/client/libacron/apps/acronc/handler.h b/client/libacron/apps/acronc/handler.h new file mode 100644 index 0000000..1a2ccfe --- /dev/null +++ b/client/libacron/apps/acronc/handler.h @@ -0,0 +1,55 @@ +/* + * Created by yuuta on 7/24/22. + */ + +#ifndef ACRONC_HANDLER_H +#define ACRONC_HANDLER_H + +#include <uv.h> +#include <libac.h> + +enum exit_reason { + /* Exit due to a signal. Socket is working. */ + EXIT_SIGNAL, + /* Exit due to an EOF from stdin. Socket is working. */ + EXIT_STDIN_EOF, + /* Exit due to an EOF from socket. Socket is closed. */ + EXIT_SOCKET_EOF, + /* Exit due to a socket failure. Socket is closed. */ + EXIT_FAILURE_SOCKET, + /* Exit due to a failure. Socket is working. */ + EXIT_FAILURE +}; + +struct uv_obj { + void *obj; + bool running; +}; + +extern uv_loop_t *loop; + +extern void (*on_exit)(enum exit_reason reason); + +int h_signal(void); + +int h_stdin(int (*on_input)(ac_request_t *req), + void (*on_close)(void)); + +int h_socket(ac_connection_parameters_t *p, + const struct addrinfo *ai, + void (*on_connect_result)(bool), + int (*on_ready)(void), + int (*on_received)(ac_obj_t *obj), + void (*on_closed)(void)); + +int sock_request(ac_request_t *req); + +int sock_ext(bool trigger_callback); + +int a_dns(const char *host, + uint16_t port, + void (*on_resolv)(int status, + const struct addrinfo *, + void (*on_connect_result)(bool))); + +#endif /* ACRONC_HANDLER_H */ |