/* * spemby.h — scorpiox-scorpioplayer-emby-client: Emby as the sprch handler "EMBY" (row 56). * * The sprch vtable (sprch.h, sprch_get) is the fleet boundary. This header is the flat P/Invoke * face: every op takes the legacy RuntimeSettings JSON and goes through sprch_get() with the * transport chosen here (libcurl by default, or the in-memory fake, or a caller's scorpiox_io). * * Buffers: an op writes its JSON into (out, cap). out == NULL or cap == 0 is allowed on the flat * exports: the op runs, and its JSON is only kept for spemby_result_json(). A result that does not * fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by spemby_* are owned by the library, per calling thread, and stay valid until * the same thread's next spemby_* call. Copy them. */ #ifndef SPEMBY_H #define SPEMBY_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPEMBY_STATIC) # define SPEMBY_API #elif defined(_WIN32) # if defined(SPEMBY_BUILD) # define SPEMBY_API __declspec(dllexport) # else # define SPEMBY_API __declspec(dllimport) # endif #else # define SPEMBY_API __attribute__((visibility("default"))) #endif #define SPEMBY_VERSION "1.0.0" #define SPEMBY_RUNTIME_TYPE "EMBY" /* ---- identity ---- */ SPEMBY_API const char *spemby_version(void); SPEMBY_API const char *spemby_runtime_type(void); SPEMBY_API int spemby_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPEMBY_API int spemby_validate(const char *settings_json, char *out_json, int cap); SPEMBY_API int spemby_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPEMBY_API int spemby_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPEMBY_API int spemby_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* This client has no write ops (SPEC section 2): enable != 0 => SPRCH_E_NOTSUPPORTED, 0 => SPRCH_OK. */ SPEMBY_API int spemby_allow_writes(int enable); /* ---- results ---- */ SPEMBY_API const char *spemby_result_json(void); /* the last op's output JSON ("" if none) */ SPEMBY_API const char *spemby_last_error(void); /* "" after a success; never holds a secret */ /* ---- pure helpers (no transport) ---- */ /* The base URL the ops would use for these settings (SPEC D2), or NULL (spemby_last_error says why). */ SPEMBY_API const char *spemby_full_url(const char *settings_json); /* One /Items response body -> {"items":[...]} in the #26 item shape (SPEC section 5). */ SPEMBY_API int spemby_parse_items(const char *body, char *out_json, int cap); /* A URL with api_key / X-Emby-Token / userinfo masked (SPEC D13). */ SPEMBY_API const char *spemby_redact(const char *url); /* Drop every cached login token (SPEC D5). */ SPEMBY_API void spemby_forget_tokens(void); /* ---- transport selection ---- */ SPEMBY_API int spemby_set_io(const scorpiox_io *io); /* NULL => back to libcurl */ SPEMBY_API int spemby_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPEMBY_API int spemby_use_fake(void); /* ---- the in-memory fake transport (tests, the .console harness's --test) ---- */ /* method "GET" or "POST"; url exact. body NULL + transport_error => a transport failure. */ SPEMBY_API void spemby_fake_reset(void); SPEMBY_API int spemby_fake_set(const char *method, const char *url, int http_code, const char *body); SPEMBY_API int spemby_fake_fail(const char *method, const char *url, const char *transport_error); SPEMBY_API int spemby_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPEMBY_API const char *spemby_fake_last_body(const char *url); /* last POST body to url */ SPEMBY_API const char *spemby_fake_last_url(void); /* last URL requested */ #ifdef __cplusplus } #endif #endif /* SPEMBY_H */