diff options
Diffstat (limited to 'clients/client.h')
| -rw-r--r-- | clients/client.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/clients/client.h b/clients/client.h new file mode 100644 index 0000000..7e18a23 --- /dev/null +++ b/clients/client.h @@ -0,0 +1,32 @@ +#ifndef BOKF_CLIENT_H +#define BOKF_CLIENT_H + +#include <stdint.h> + +/* Thin protocol client shared by bokfctl and bokftui. Connects to a unix + socket path or "tcp:host:port". */ + +int client_connect(const char *target); +int client_send_line(int fd, const char *line); +char *client_read_line(int fd); + +char *client_make_request(const char *cmd, const char *session, int64_t org, + const char *args_json, const char *id); +char *client_make_login_args(const char *user, const char *password); + +/* Sends one command and returns the raw response line (malloc'd), or NULL + on a transport error. */ +char *client_rpc(int fd, const char *cmd, const char *session, int64_t org, + const char *args_json); + +/* Password login. Returns 0 and sets *session_out on success; on failure + returns -1 and sets *err_out to the response line or an error message. */ +int client_login(int fd, const char *user, const char *password, + char **session_out, char **err_out); + +/* Convenience: true when the response line has "ok":true. */ +int client_ok(const char *response); +/* Extract result.session into buf; returns 0 on success. */ +int client_session_from(const char *response, char *buf, unsigned long cap); + +#endif |
