From 12cde42c929b63a1ef1b2ad7f3482336419980b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Wed, 2 Feb 2022 09:29:10 +0800 Subject: Asynchronous connection Important updates: 1. Emscripten port. 2. HTTP request code copied from libicclient & slightly fixed. 3. Cookies, for maintaining authorisation between different async handles. --- rtclient/search.h | 12 +++--------- rtclient/ticket.h | 14 +++----------- rtclient/typedefs.h | 18 ++++++++++++++++++ rtclient/user.h | 8 +++++--- 4 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 rtclient/typedefs.h (limited to 'rtclient') diff --git a/rtclient/search.h b/rtclient/search.h index e0e386a..25b7258 100644 --- a/rtclient/search.h +++ b/rtclient/search.h @@ -1,21 +1,15 @@ #ifndef RTCLIENT_SEARCH_H #define RTCLIENT_SEARCH_H -struct rtclient_search_ticket_list { - size_t length; - struct rtclient_ticket *tickets[]; -}; - #ifdef __cplusplus extern "C" { #endif - void rtclient_search_ticket(struct rtclient_search_ticket_list **listptr - , const char *query); - void rtclient_search_ticket_free(struct rtclient_search_ticket_list *list); +void rtclient_search_ticket(const char *query, + void (*callback)(struct rtclient_ticket **)); #ifdef __cplusplus } #endif -#endif // RTCLIENT_SEARCH_H +#endif diff --git a/rtclient/ticket.h b/rtclient/ticket.h index 9fdd9a0..0600c34 100644 --- a/rtclient/ticket.h +++ b/rtclient/ticket.h @@ -56,11 +56,6 @@ struct rtclient_ticket_history { struct rtclient_ticket_history_attachment_list *attachments; }; -struct rtclient_ticket_history_list { - size_t length; - struct rtclient_ticket_history *histories[]; -}; - #ifdef __cplusplus extern "C" { #endif @@ -79,12 +74,9 @@ void rtclient_ticket_new(const char *queue, const char *starts, const char *due, const char *text); - void rtclient_ticket_history(struct rtclient_ticket_history_list **listptr - , unsigned int id, bool long_format); - void rtclient_ticket_history_free - (struct rtclient_ticket_history *history); - void rtclient_ticket_history_list_free - (struct rtclient_ticket_history_list *list); +void rtclient_ticket_history_list(unsigned int id, bool long_format, + void (*callback)(struct rtclient_ticket_history **)); +void rtclient_ticket_history_free(struct rtclient_ticket_history *history); #ifdef __cplusplus } diff --git a/rtclient/typedefs.h b/rtclient/typedefs.h new file mode 100644 index 0000000..e15b1df --- /dev/null +++ b/rtclient/typedefs.h @@ -0,0 +1,18 @@ +#ifndef RTCLIENT_TYPEDEFS_H +#define RTCLIENT_TYPEDEFS_H + +#include +#ifdef __EMSCRIPTEN__ +#include +typedef emscripten_fetch_t rtclient_response; +#else +#include +typedef struct { + void *userData; + char *data; + size_t numBytes; + CURL *curl; +} rtclient_response; +#endif + +#endif diff --git a/rtclient/user.h b/rtclient/user.h index 5f62d17..02b2daa 100644 --- a/rtclient/user.h +++ b/rtclient/user.h @@ -1,6 +1,8 @@ #ifndef RTCLIENT_USER_H #define RTCLIENT_USER_H +#include "typedefs.h" + enum rtclient_user_lang { RTCLIENT_USER_LANG_NONE = 0, RTCLIENT_USER_LANG_AR, @@ -464,9 +466,9 @@ void rtclient_user_new(const char *name, enum rtclient_user_timezone timezone, bool disabled, bool privileged); - void rtclient_user_showid(struct rtclient_user **userptr, unsigned int id); - void rtclient_user_showname(struct rtclient_user **userptr, const char *name); - void rtclient_user_free(struct rtclient_user *user); +void rtclient_user_showid(unsigned int id, void (*)(struct rtclient_user *)); +void rtclient_user_showname(const char *name, void (*)(struct rtclient_user *)); +void rtclient_user_free(struct rtclient_user *user); #ifdef __cplusplus } -- cgit v1.2.3