diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/qntan/Qntan.h | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/include/qntan/Qntan.h b/include/qntan/Qntan.h index 4991ff2..2a44cdf 100644 --- a/include/qntan/Qntan.h +++ b/include/qntan/Qntan.h @@ -80,6 +80,9 @@ struct Qntan_JsonTreeDec; struct Qntan_JsonTreeDec_JsonNode; struct Qntan_XmlDec; struct Qntan_XmlDec_Mentor; +struct Qntan_HttpClient; +struct Qntan_HttpClient_Exchg; +struct Qntan_HttpClient_Exchg_Opts; struct Qntan_JavaBytecodeParser; struct Qntan_JavaBytecodeParser_Mentor; struct Qntan_CamtAccount; @@ -850,7 +853,8 @@ struct Qntan_JsonEnc { /* throws away the current state and sets the encoder for a new run. */ void (*flush)( struct Qntan_JsonEnc** ); - /**/ + /* TODO: to me, looks like this should be async and take an 'onDone' cback. + */ void (*objBeg)( struct Qntan_JsonEnc** ); /**/ void (*objEnd)( struct Qntan_JsonEnc** ); @@ -1028,6 +1032,101 @@ struct Qntan_XmlDec_Mentor { +struct Qntan_HttpClient_Exchg_Opts { + /* WARN: HTTP IS EXPERMIMENTAL! DO NOT TRUST ANYTHING HERE! + */ + char const *mthd; + /* Eg: 'GET', 'POST', ... + */ + char const *host; + /* Eg: 'example.com', '127.0.0.1', ... + */ + uint16_t port; + /* TCP port to connect to. + */ + char const *url; + /* Eg: "/foo/bar?blubb=true" + */ + char **hdrs; + /* Eg: {"key1", "val1", "key2", "val2", NULL} + */ + uint8_t isTls; + /**/ + char const *body; + /* can be NULL, which means body gets written through separate calls. + * MUST be null-byte-terminated. + * MUST NOT contain null-bytes. If you have to, set NULL and use separate + * write calls instead. + */ + Qntan_Cls cls; + /**/ + void (*onRspHdr)( char const*proto, int code, char const*msg, char const*const*hdrs, Qntan_Cls ); + /* 'proto' looks like "HTTP/1.1". Is zero-terminated. + * 'code' eg 404, simply the http response code. + * 'msg' eg "Not Found", simply the http response phrase. Is zero-terminated. + * 'hdrs' response headers. Same format as the request headers. + */ + void (*onBodyChunk)( char const*buf, int len, int flgs, Qntan_Cls ); + /* @param len + * Negative values indicate errors. + * If positive, it indicates how long 'buf' is. + * WARN: if zero or negative, value of 'buf' is unspecified! + * @param flgs + * 'flgs & 4' means this is last buffer (EndOfMsg). + * WARN: Other flags are reserved and may hold ANY value. + */ +}; + +struct Qntan_HttpClient_Exchg { + /* WARN: HTTP IS EXPERMIMENTAL! DO NOT TRUST ANYTHING HERE! + */ + void (*write)( struct Qntan_HttpClient_Exchg**, void*buf, int len, int flgs, + void(*onDone)(int,Qntan_Cls), Qntan_Cls ); + /* Write another request body chunk. + * @param flgs + * 'flgs & 4' means this is the last buffer (aka EndOfMsg). + * WARN: Other flags are reserved and may hold ANY value. + */ + void (*pause)( struct Qntan_HttpClient_Exchg** ); + /* Set backpressure. This means that callbacks won't be called anymore. + * Events will be held back until resumed. + */ + void (*resume)( struct Qntan_HttpClient_Exchg** ); + /* Cancel backpressure. + */ +}; + +struct Qntan_HttpClient { + /* WARN: HTTP IS EXPERMIMENTAL! DO NOT TRUST ANYTHING HERE! + */ + void (*httpReq)( struct Qntan_HttpClient**, struct Qntan_HttpClient_Exchg_Opts*, + void(*onDone)( int err, struct Qntan_HttpClient_Exchg**exchg, + void(*unref)(struct Qntan_HttpClient_Exchg**), + Qntan_Cls onDoneArg), + Qntan_Cls onDoneArg ); + /* Creates a new HTTP exchange (aka request/response). + * @param onDone + * Will be called with the result. + * @param err + * Negative on erorrs. Zero if 'exchg' is ready-to-use. + * @param exchg + * WARN: Only valid if 'err' is zero. The requested instance. + * @param unref + * The function to be called as soon 'exchg' is no longer used. + * @param onDoneArg + * Passed through closure (aka context). + */ +}; + + + + + + + + + + struct Qntan_JavaBytecodeParser { /**/ void (*write)( |
