diff options
Diffstat (limited to 'client/libacron/include/requests.h')
-rw-r--r-- | client/libacron/include/requests.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/client/libacron/include/requests.h b/client/libacron/include/requests.h new file mode 100644 index 0000000..40742e0 --- /dev/null +++ b/client/libacron/include/requests.h @@ -0,0 +1,71 @@ +/* + * Created by yuuta on 7/13/22. + */ + +#ifndef LIBAC_REQUESTS_H +#define LIBAC_REQUESTS_H + +#include "common.h" +#include "ids.h" +#include <stdbool.h> + +/* Responses */ +typedef struct ac_response { + uint8_t type; + int id; +} ac_response_t; + +#define AC_RESPONSE_ERROR AC_ID(AC_TYPE_RESPONSE, 1 /* 0b00000001 */) /* 0b10000001 */ +typedef struct ac_response_error { + uint8_t type; + int id; + int code; + char *message; +} ac_response_error_t; + +#define AC_RESPONSE_OK AC_ID(AC_TYPE_RESPONSE, 2 /* 0b00000010 */) /* 0b10000010 */ +typedef struct ac_response_ok { + uint8_t type; + int id; +} ac_response_ok_t; + +#define AC_RESPONSE_CMD_OUT AC_ID(AC_TYPE_RESPONSE, 3 /* 0b00000011 */) /* 0b10000011 */ +typedef struct ac_response_cmd_out { + uint8_t type; + int id; + char *sender; + char *out; +} ac_response_cmd_out_t; + +#define AC_RESPONSE_CMD_RESULT AC_ID(AC_TYPE_RESPONSE, 4 /* 0b00000100 */) /* 0b10000100 */ +typedef struct ac_response_cmd_result { + uint8_t type; + int id; + int result; + bool success; +} ac_response_cmd_result_t; + +/* Requests */ +typedef struct ac_request { + uint8_t type; + int id; +} ac_request_t; + +#define AC_REQUEST_CMD AC_ID(AC_TYPE_REQUEST, 1 /* 0b00000001 */) /* 0b01000001 */ +typedef struct ac_request_cmd { + uint8_t type; + int id; + ac_config_t *config; + char *cmd; +} ac_request_cmd_t; + +#define AC_REQUEST_SET_CONFIG AC_ID(AC_TYPE_REQUEST, 2 /* 0b00000010 */) /* 0b01000010 */ +typedef struct ac_request_set_config { + uint8_t type; + int id; + ac_config_t config; +} ac_request_set_config_t; + +int ac_request(void *connection, const ac_request_t *request); + +#endif /* LIBAC_REQUESTS_H */ |