// main.c #include #include #include #include #include #include #include "render/render.h" #include "sock.h" int main(void) { enum error_t err = ERR_OK; int sock; err = sock_init(&sock); if (err) goto error; char input_buffer[8192] = { 0 }; char output_buffer[8192] = { 0 }; // Send request for world data to server struct request_body_get_world_data_t request_body = { 420 }; struct request_t request = { REQUEST_GET_WORLD_DATA, &request_body }; err = request_serialise_buf(&request, output_buffer, 8192); if (err != ERR_OK) goto error_socket; write(sock, output_buffer, 8192); // Get response from server read(sock, input_buffer, 8192); struct response_t response = { 0 }; err = response_deserialise_str(&response, input_buffer); if (err != ERR_OK) goto error_socket; // Render data if (response.success != true) { err = ERR_REQUEST_FAILED; goto error_socket; } struct response_body_get_world_data_t *response_body = response.body; render_world(&response_body->world); close(sock); return ERR_OK; error_socket: close(sock); error: printf("CLIENT ERROR: %s\n", ERROR_STRS[err]); return err; }