duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

rc_api_request.h (1743B)


      1 #ifndef RC_API_REQUEST_H
      2 #define RC_API_REQUEST_H
      3 
      4 #include "rc_error.h"
      5 #include "rc_util.h"
      6 
      7 #include <stddef.h>
      8 
      9 RC_BEGIN_C_DECLS
     10 
     11 /**
     12  * A constructed request to send to the retroachievements server.
     13  */
     14 typedef struct rc_api_request_t {
     15   /* The URL to send the request to (contains protocol, host, path, and query args) */
     16   const char* url;
     17   /* Additional query args that should be sent via a POST command. If null, GET may be used */
     18   const char* post_data;
     19   /* The HTTP Content-Type of the POST data. */
     20   const char* content_type;
     21 
     22   /* Storage for the url and post_data */
     23   rc_buffer_t buffer;
     24 }
     25 rc_api_request_t;
     26 
     27 /**
     28  * Common attributes for all server responses.
     29  */
     30 typedef struct rc_api_response_t {
     31   /* Server-provided success indicator (non-zero on success, zero on failure) */
     32   int succeeded;
     33   /* Server-provided message associated to the failure */
     34   const char* error_message;
     35   /* Server-provided error code associated to the failure */
     36   const char* error_code;
     37 
     38   /* Storage for the response data */
     39   rc_buffer_t buffer;
     40 }
     41 rc_api_response_t;
     42 
     43 RC_EXPORT void RC_CCONV rc_api_destroy_request(rc_api_request_t* request);
     44 
     45 RC_EXPORT void RC_CCONV rc_api_set_host(const char* hostname);
     46 RC_EXPORT void RC_CCONV rc_api_set_image_host(const char* hostname);
     47 
     48 typedef struct rc_api_server_response_t {
     49   /* Pointer to the data returned from the server */
     50   const char* body;
     51   /* Length of data returned from the server (Content-Length) */
     52   size_t body_length;
     53   /* HTTP status code returned from the server */
     54   int http_status_code;
     55 } rc_api_server_response_t;
     56 
     57 enum {
     58   RC_API_SERVER_RESPONSE_CLIENT_ERROR = -1,
     59   RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR = -2
     60 };
     61 
     62 RC_END_C_DECLS
     63 
     64 #endif /* RC_API_REQUEST_H */