aboutsummaryrefslogtreecommitdiff
path: root/client/libacron/apps/acronc/handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/libacron/apps/acronc/handler.h')
-rw-r--r--client/libacron/apps/acronc/handler.h55
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 */