55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
#ifndef COMMON_REQUEST_H
|
|
#define COMMON_REQUEST_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "error.h"
|
|
#include "world.h"
|
|
|
|
// ### REQUEST TYPES ### //
|
|
|
|
enum request_type_t {
|
|
REQUEST_NONE,
|
|
REQUEST_GET_WORLD_DATA,
|
|
};
|
|
|
|
|
|
struct request_body_get_world_data_t {
|
|
size_t world_id;
|
|
};
|
|
|
|
|
|
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);
|
|
|
|
|
|
// ### RESPONSE TYPES ### //
|
|
|
|
struct response_body_get_world_data_t {
|
|
struct world_t world;
|
|
};
|
|
|
|
|
|
struct response_t {
|
|
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
|