summaryrefslogtreecommitdiffstats
path: root/src/h.c
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2021-09-10 23:12:04 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2021-09-10 23:12:04 +0200
commit900e4b546e56a11cbc75f1af7195ebbaca9c95ac (patch)
treeb278966fab02fb724285760da54cde66211a7dd4 /src/h.c
parentsome fixing work (diff)
downloaddiscord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar.gz
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar.bz2
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar.lz
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar.xz
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.tar.zst
discord.c-900e4b546e56a11cbc75f1af7195ebbaca9c95ac.zip
Diffstat (limited to 'src/h.c')
-rw-r--r--src/h.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/h.c b/src/h.c
index 07852a3..19e52fb 100644
--- a/src/h.c
+++ b/src/h.c
@@ -19,7 +19,7 @@ enum dc_status { /* theese are flags and should be and-checked */
DC_UNSET = 0, /* default value when enum is calloced */
DC_INCOMPLETE = 1 << 0, /* struct SHALL NOT be used by the ui, it is yet to be filled by api */
DC_OK = 1 << 1, /* success status, api usually sets this after completion/filling of the strct */
- DC_BAD_LOGIN = 1 << 2, /* login failed */
+ DC_BAD_LOGIN = 1 << 2, /* login failed because of wrong credentials */
DC_VERIFICATION_NEEDED = 1 << 3, /* login: check email, click link/reg: tough luck ur IP flagd */
DC_CAPTCHA_NEEDED = 1 << 4, /* must solve captcha, tough luck, not impl, use browser login */
DC_BAD_USERNAME = 1 << 5, /* provided username can't be registered */
@@ -28,7 +28,9 @@ enum dc_status { /* theese are flags and should be and-checked */
DC_CONTINUE = 1 << 8, /* attached handlers return this to continue processing this output, N/I */
DC_BREAK = 1 << 9, /* attached handlers return this to stop processing this output */
DC_FROM_LWS = 1 << 10, /* LWS cb is the caller, so do not attempt to do lws_service (loop) */
- DC_MUST_FREE = 1 << 11 /* cb pass: body must be freed when request is done with user_data */
+ DC_MUST_FREE = 1 << 11, /* cb pass: body must be freed when request is done with user_data */
+ DC_REQUEST_FAILED = 1 << 12, /* http request failed, reported to ui */
+ DC_ERROR = 1 << 13 /* unknown error, non implemented non expected response */
};
enum dc_permissions { /* other permissions exist, but are not implemented/understood */
DC_ALL_PERMISSIONS = 1 << 3, /* this is incredibly retarded, why is this SEPARATE?!? - admins */
@@ -59,9 +61,9 @@ enum dc_api_io_type {
DC_API_GUILD, /* i: TODO: create a guild-tr0 */
/* o: TODO: new guild created, GUI spawn it */
DC_API_LOGIN, /* i: pass a dc_client-tr1, to relogin FIX prev retd cl not create new */
- /* o: the previously passed dc_client with set status */
+ /* o: the previously passed dc_client with set status, do not use yet! \/ */
DC_API_LOGIN_CB,/* i: used internally for passing response from http client to api, see source */
- /* o: n/a */
+ /* o: to tell user that client is now fully filled and ready for use */
DC_API_REGISTER,/* i: pass a dc_client, to relogin FIX pr rt cl&cl->user not creat new */
/* o: the previously passed dc_client with set status */
DC_API_STATUS, /* i: N/A */
@@ -99,14 +101,16 @@ void dc_api_io_free (struct dc_api_io * s) {
void dc_api_i (struct dc_api_io);
enum dc_lws_headers {
DC_LWS_AUTHORIZATION,
+ DC_LWS_CONTENT_TYPE,
DC_LWS_HEADERS_LENGTH
};
char * dc_lws_headers[] = {
"Authorization:",
+ "Content-Type:"
};
struct dc_lws_pass { /* struct that is allocated for in dc_lws_cb unique per connection in void * us */
char * body; /* this contains post body and when _CB is called, it contains response */
- size_t body_length; /* body is NULL terminated - note0 in src/api.c */
+ size_t body_length; /* body is NULL terminated or NULL in case of failure */
char headers[DC_LWS_HEADERS_LENGTH][DC_LWS_MAX_HEADER_LENGTH]; /* nofree, a static 2d array */
int status; /* HTTP response code /\ headers contain request headers, then resp. */
struct dc_api_io api_io; /* so dc_api_io can decide what shall be passed into _CB */