server.h (850B)
1 #ifndef UDPHOLE_API_SERVER_H 2 #define UDPHOLE_API_SERVER_H 3 4 #include <stdint.h> 5 #include <stdbool.h> 6 7 #include "domain/scheduler.h" 8 #include "common/resp.h" 9 10 struct api_client_state; 11 typedef struct api_client_state api_client_t; 12 13 typedef resp_object *(*domain_cmd_fn)(const char *cmd, resp_object *args); 14 15 PT_THREAD(api_server_pt(struct pt *pt, int64_t timestamp, struct pt_task *task)); 16 17 void api_register_cmd(const char *name, char (*func)(api_client_t *, char **, int)); 18 19 void api_register_domain_cmd(const char *name, domain_cmd_fn func); 20 21 bool api_write_ok(api_client_t *c); 22 bool api_write_err(api_client_t *c, const char *msg); 23 bool api_write_array(api_client_t *c, size_t nitems); 24 bool api_write_bulk_cstr(api_client_t *c, const char *s); 25 bool api_write_bulk_int(api_client_t *c, int val); 26 bool api_write_int(api_client_t *c, int val); 27 28 #endif