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_user.h (5394B)


      1 #ifndef RC_API_USER_H
      2 #define RC_API_USER_H
      3 
      4 #include "rc_api_request.h"
      5 
      6 #include <stdint.h>
      7 #include <time.h>
      8 
      9 RC_BEGIN_C_DECLS
     10 
     11 /* --- Login --- */
     12 
     13 /**
     14  * API parameters for a login request.
     15  * If both password and api_token are provided, api_token will be ignored.
     16  */
     17 typedef struct rc_api_login_request_t {
     18   /* The username of the player being logged in */
     19   const char* username;
     20   /* The API token from a previous login */
     21   const char* api_token;
     22   /* The player's password */
     23   const char* password;
     24 }
     25 rc_api_login_request_t;
     26 
     27 /**
     28  * Response data for a login request.
     29  */
     30 typedef struct rc_api_login_response_t {
     31   /* The case-corrected username of the player */
     32   const char* username;
     33   /* The API token to use for all future requests */
     34   const char* api_token;
     35   /* The current score of the player */
     36   uint32_t score;
     37   /* The current softcore score of the player */
     38   uint32_t score_softcore;
     39   /* The number of unread messages waiting for the player on the web site */
     40   uint32_t num_unread_messages;
     41   /* The preferred name to display for the player */
     42   const char* display_name;
     43 
     44   /* Common server-provided response information */
     45   rc_api_response_t response;
     46 }
     47 rc_api_login_response_t;
     48 
     49 RC_EXPORT int RC_CCONV rc_api_init_login_request(rc_api_request_t* request, const rc_api_login_request_t* api_params);
     50 /* [deprecated] use rc_api_process_login_server_response instead */
     51 RC_EXPORT int RC_CCONV rc_api_process_login_response(rc_api_login_response_t* response, const char* server_response);
     52 RC_EXPORT int RC_CCONV rc_api_process_login_server_response(rc_api_login_response_t* response, const rc_api_server_response_t* server_response);
     53 RC_EXPORT void RC_CCONV rc_api_destroy_login_response(rc_api_login_response_t* response);
     54 
     55 /* --- Start Session --- */
     56 
     57 /**
     58  * API parameters for a start session request.
     59  */
     60 typedef struct rc_api_start_session_request_t {
     61   /* The username of the player */
     62   const char* username;
     63   /* The API token from the login request */
     64   const char* api_token;
     65   /* The unique identifier of the game */
     66   uint32_t game_id;
     67   /* (recommended) The hash associated to the game being played */
     68   const char* game_hash;
     69   /* Non-zero if hardcore is currently enabled (ignored if game_hash is null) */
     70   uint32_t hardcore;
     71 }
     72 rc_api_start_session_request_t;
     73 
     74 /**
     75  * Response data for an achievement unlock.
     76  */
     77 typedef struct rc_api_unlock_entry_t {
     78   /* The unique identifier of the unlocked achievement */
     79   uint32_t achievement_id;
     80   /* When the achievement was unlocked */
     81   time_t when;
     82 }
     83 rc_api_unlock_entry_t;
     84 
     85 /**
     86  * Response data for a start session request.
     87  */
     88 typedef struct rc_api_start_session_response_t {
     89   /* An array of hardcore user unlocks */
     90   rc_api_unlock_entry_t* hardcore_unlocks;
     91   /* An array of user unlocks */
     92   rc_api_unlock_entry_t* unlocks;
     93 
     94   /* The number of items in the hardcore_unlocks array */
     95   uint32_t num_hardcore_unlocks;
     96   /* The number of items in the unlocks array */
     97   uint32_t num_unlocks;
     98 
     99   /* The server timestamp when the response was generated */
    100   time_t server_now;
    101 
    102   /* Common server-provided response information */
    103   rc_api_response_t response;
    104 }
    105 rc_api_start_session_response_t;
    106 
    107 RC_EXPORT int RC_CCONV rc_api_init_start_session_request(rc_api_request_t* request, const rc_api_start_session_request_t* api_params);
    108 /* [deprecated] use rc_api_process_start_session_server_response instead */
    109 RC_EXPORT int RC_CCONV rc_api_process_start_session_response(rc_api_start_session_response_t* response, const char* server_response);
    110 RC_EXPORT int RC_CCONV rc_api_process_start_session_server_response(rc_api_start_session_response_t* response, const rc_api_server_response_t* server_response);
    111 RC_EXPORT void RC_CCONV rc_api_destroy_start_session_response(rc_api_start_session_response_t* response);
    112 
    113 /* --- Fetch User Unlocks --- */
    114 
    115 /**
    116  * API parameters for a fetch user unlocks request.
    117  */
    118 typedef struct rc_api_fetch_user_unlocks_request_t {
    119   /* The username of the player */
    120   const char* username;
    121   /* The API token from the login request */
    122   const char* api_token;
    123   /* The unique identifier of the game */
    124   uint32_t game_id;
    125   /* Non-zero to fetch hardcore unlocks, 0 to fetch non-hardcore unlocks */
    126   uint32_t hardcore;
    127 }
    128 rc_api_fetch_user_unlocks_request_t;
    129 
    130 /**
    131  * Response data for a fetch user unlocks request.
    132  */
    133 typedef struct rc_api_fetch_user_unlocks_response_t {
    134   /* An array of achievement IDs previously unlocked by the user */
    135   uint32_t* achievement_ids;
    136   /* The number of items in the achievement_ids array */
    137   uint32_t num_achievement_ids;
    138 
    139   /* Common server-provided response information */
    140   rc_api_response_t response;
    141 }
    142 rc_api_fetch_user_unlocks_response_t;
    143 
    144 RC_EXPORT int RC_CCONV rc_api_init_fetch_user_unlocks_request(rc_api_request_t* request, const rc_api_fetch_user_unlocks_request_t* api_params);
    145 /* [deprecated] use rc_api_process_fetch_user_unlocks_server_response instead */
    146 RC_EXPORT int RC_CCONV rc_api_process_fetch_user_unlocks_response(rc_api_fetch_user_unlocks_response_t* response, const char* server_response);
    147 RC_EXPORT int RC_CCONV rc_api_process_fetch_user_unlocks_server_response(rc_api_fetch_user_unlocks_response_t* response, const rc_api_server_response_t* server_response);
    148 RC_EXPORT void RC_CCONV rc_api_destroy_fetch_user_unlocks_response(rc_api_fetch_user_unlocks_response_t* response);
    149 
    150 RC_END_C_DECLS
    151 
    152 #endif /* RC_API_H */