Path: blob/master/dep/rcheevos/include/rc_api_request.h
4246 views
#ifndef RC_API_REQUEST_H1#define RC_API_REQUEST_H23#include "rc_error.h"4#include "rc_util.h"56#include <stddef.h>78RC_BEGIN_C_DECLS910/**11* Information about the server being connected to.12*/13typedef struct rc_api_host_t {14/* The host name for the API calls (retroachievements.org) */15const char* host;16/* The host name for media URLs (media.retroachievements.org) */17const char* media_host;18}19rc_api_host_t;2021/**22* A constructed request to send to the retroachievements server.23*/24typedef struct rc_api_request_t {25/* The URL to send the request to (contains protocol, host, path, and query args) */26const char* url;27/* Additional query args that should be sent via a POST command. If null, GET may be used */28const char* post_data;29/* The HTTP Content-Type of the POST data. */30const char* content_type;3132/* Storage for the url and post_data */33rc_buffer_t buffer;34}35rc_api_request_t;3637/**38* Common attributes for all server responses.39*/40typedef struct rc_api_response_t {41/* Server-provided success indicator (non-zero on success, zero on failure) */42int succeeded;43/* Server-provided message associated to the failure */44const char* error_message;45/* Server-provided error code associated to the failure */46const char* error_code;4748/* Storage for the response data */49rc_buffer_t buffer;50}51rc_api_response_t;5253RC_EXPORT void RC_CCONV rc_api_destroy_request(rc_api_request_t* request);5455/* [deprecated] use rc_api_init_*_hosted instead */56RC_EXPORT void RC_CCONV rc_api_set_host(const char* hostname);57/* [deprecated] use rc_api_init_*_hosted instead */58RC_EXPORT void RC_CCONV rc_api_set_image_host(const char* hostname);5960typedef struct rc_api_server_response_t {61/* Pointer to the data returned from the server */62const char* body;63/* Length of data returned from the server (Content-Length) */64size_t body_length;65/* HTTP status code returned from the server */66int http_status_code;67} rc_api_server_response_t;6869enum {70RC_API_SERVER_RESPONSE_CLIENT_ERROR = -1,71RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR = -272};7374RC_END_C_DECLS7576#endif /* RC_API_REQUEST_H */777879