server.h (888B)
1 #ifndef UDPHOLE_API_SERVER_H 2 #define UDPHOLE_API_SERVER_H 3 4 #include <stdbool.h> 5 #include <stdint.h> 6 7 #include "common/resp.h" 8 #include "common/scheduler.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 int api_server_pt(int64_t timestamp, struct pt_task *task); 16 int api_client_pt(int64_t timestamp, struct pt_task *task); 17 18 void api_register_cmd(const char *name, char (*func)(api_client_t *, char **, int)); 19 20 void api_register_domain_cmd(const char *name, domain_cmd_fn func); 21 22 bool api_write_ok(api_client_t *c); 23 bool api_write_err(api_client_t *c, const char *msg); 24 bool api_write_array(api_client_t *c, size_t nitems); 25 bool api_write_bulk_cstr(api_client_t *c, const char *s); 26 bool api_write_bulk_int(api_client_t *c, int val); 27 bool api_write_int(api_client_t *c, int val); 28 29 #endif