2024-10-18 02:26:25 +00:00
|
|
|
#ifndef COMMON_REQUEST_H
|
|
|
|
#define COMMON_REQUEST_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2024-10-29 18:14:08 +00:00
|
|
|
#include <stdlib.h>
|
2024-10-18 02:26:25 +00:00
|
|
|
|
|
|
|
#include "error.h"
|
2024-10-29 18:14:08 +00:00
|
|
|
#include "request/get_world_data.h"
|
2024-10-18 02:26:25 +00:00
|
|
|
|
|
|
|
enum request_type_t {
|
|
|
|
REQUEST_NONE,
|
|
|
|
REQUEST_GET_WORLD_DATA,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct request_t {
|
|
|
|
enum request_type_t type;
|
|
|
|
void *body;
|
|
|
|
// The body's type depends on the request's type
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum error_t request_serialise_str(struct request_t const *, char const **);
|
|
|
|
enum error_t request_deserialise_str(struct request_t *, char const *);
|
|
|
|
|
|
|
|
enum error_t request_serialise_buf(struct request_t const *, char *, size_t);
|
|
|
|
|
|
|
|
|
|
|
|
struct response_t {
|
2024-10-23 01:25:27 +00:00
|
|
|
enum request_type_t type;
|
2024-10-18 02:26:25 +00:00
|
|
|
bool success;
|
|
|
|
void *body;
|
|
|
|
// The body's type depends on the request's type
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum error_t response_serialise_str(struct response_t const *, char const **);
|
|
|
|
enum error_t response_deserialise_str(struct response_t *, char const *);
|
|
|
|
|
|
|
|
enum error_t response_serialise_buf(struct response_t const *, char *, size_t);
|
|
|
|
|
|
|
|
#endif
|