#ifndef SCORPIOX_HTTP_EXPORTS_H #define SCORPIOX_HTTP_EXPORTS_H /* * scorpiox-http-exports.h — the P/Invoke surface (exports.json is generated from this). * scorpiox-http.h and scorpiox-http-util.h are the API engines include; this header only * names the exported symbols. */ #include "scorpiox-http-util.h" #include "scorpiox-io.h" #if defined(SCORPIOX_HTTP_NO_DLLEXPORT) # define SXH_API /* the .def file exports; no attribute needed */ #elif defined(_WIN32) # define SXH_API __declspec(dllexport) #else # define SXH_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif /* ---- backends ---- */ SXH_API const scorpiox_http *scorpiox_http_curl(void); /* NULL when built without libcurl */ SXH_API const scorpiox_http *scorpiox_http_winhttp(void); /* NULL off Windows */ SXH_API const scorpiox_http *scorpiox_http_fake(void); /* ---- adapter: a frozen scorpiox_io over any scorpiox_http (magic ctx) ---- */ SXH_API const scorpiox_io *scorpiox_io_over_http(const scorpiox_http *http, void *user); /* ---- helpers (src/scorpiox_http_util.c) ---- */ SXH_API const scorpiox_http *scorpiox_http_of(const struct scorpiox_io *io); SXH_API const scorpiox_http *scorpiox_http_from_ctx(const void *ctx); /* io->ctx or the ctx itself */ SXH_API int scorpiox_header_line(const char *name, const char *value, char *out, size_t n); SXH_API const char *scorpiox_header_get(const scorpiox_http_request *rq, const char *name); SXH_API int scorpiox_method_ok(const char *method); SXH_API const char *scorpiox_hdrs_get(const scorpiox_buf *hdrs, const char *name); SXH_API int scorpiox_content_range(const char *v, long long *a, long long *b, long long *total); SXH_API void scorpiox_collect_init(scorpiox_collect *c, size_t max); SXH_API int scorpiox_collect_header(void *user, const char *name, const char *value); SXH_API int scorpiox_collect_body(void *user, const void *data, size_t n); SXH_API void scorpiox_collect_free(scorpiox_collect *c); SXH_API int scorpiox_http_range(const scorpiox_http *h, const char *url, long long start, long long end, scorpiox_collect *c, long *status, char **out_err); SXH_API int scorpiox_buf_add(scorpiox_buf *b, const void *d, size_t n); SXH_API int scorpiox_buf_addc(scorpiox_buf *b, unsigned char c); SXH_API int scorpiox_buf_adds(scorpiox_buf *b, const char *s); SXH_API void scorpiox_buf_free(scorpiox_buf *b); SXH_API char *scorpiox_strdup(const char *s); SXH_API char *scorpiox_strndup(const char *s, size_t n); /* ---- the fake backend (tests, .console --test): no network, ever ---- */ SXH_API void scorpiox_fake_reset(void); /* A canned answer for method + url. headers: "Name: value\n" lines or NULL. */ SXH_API int scorpiox_fake_set(const char *method, const char *url, long http_code, const char *headers, const unsigned char *body, size_t body_len); /* A file for GET: range_support 1 honours Range (206 / 416), 0 ignores it (200), * 2 answers 416 to a range crossing EOF. */ SXH_API int scorpiox_fake_file(const char *url, const unsigned char *data, size_t n, int range_support); /* A slow drip: SFX chunk every 10 ms; drop_after chunks delivered, then it stops forever * (B10 stalled-transfer guard). */ SXH_API int scorpiox_fake_drip(const char *url, long http_code, const unsigned char *data, size_t n, int drop_after); SXH_API int scorpiox_fake_fail(const char *method, const char *url, const char *transport_error); SXH_API unsigned long scorpiox_fake_calls(const char *method, const char *url); /* NULL = any */ SXH_API unsigned long scorpiox_fake_writes_sent(void); SXH_API const char *scorpiox_fake_last_request(void); /* JSON, valid until the next call */ /* ---- MD5 (Digest auth + conformance proofs; public-domain RFC 1321) ---- */ SXH_API void scorpiox_md5(const unsigned char *p, size_t n, unsigned char out[16]); #ifdef __cplusplus } #endif #endif /* SCORPIOX_HTTP_EXPORTS_H */