/* * spjelly.h — scorpiox-scorpioplayer-jellyfin-client: Jellyfin as the sprch handler "JELLYFIN" (row 55). * * 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 (the vendored fleet transport via libcurl by default, or the in-memory * fake, or a caller's scorpiox_io carrying a scorpiox_http — SPEC D1). * * 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 spjelly_result_json(). A result that does not * fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by spjelly_* are owned by the library, per calling thread, and stay valid until * the same thread's next spjelly_* call. Copy them. */ #ifndef SPJELLY_H #define SPJELLY_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPJELLY_STATIC) # define SPJELLY_API #elif defined(SPJELLY_NO_DLLEXPORT) # define SPJELLY_API /* the .def file exports; no attribute needed */ #elif defined(_WIN32) # if defined(SPJELLY_BUILD) # define SPJELLY_API __declspec(dllexport) # else # define SPJELLY_API __declspec(dllimport) # endif #else # define SPJELLY_API __attribute__((visibility("default"))) #endif #define SPJELLY_VERSION "1.0.0" #define SPJELLY_RUNTIME_TYPE "JELLYFIN" /* ---- identity ---- */ SPJELLY_API const char *spjelly_version(void); SPJELLY_API const char *spjelly_runtime_type(void); SPJELLY_API int spjelly_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPJELLY_API int spjelly_validate(const char *settings_json, char *out_json, int cap); SPJELLY_API int spjelly_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPJELLY_API int spjelly_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPJELLY_API int spjelly_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. */ SPJELLY_API int spjelly_allow_writes(int enable); /* ---- results ---- */ SPJELLY_API const char *spjelly_result_json(void); /* the last op's output JSON ("" if none) */ SPJELLY_API const char *spjelly_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 (spjelly_last_error says why). */ SPJELLY_API const char *spjelly_full_url(const char *settings_json); /* One /Items response body -> {"items":[...]} in the #26 item shape (SPEC section 5). */ SPJELLY_API int spjelly_parse_items(const char *body, char *out_json, int cap); /* A URL with api_key / Token= / userinfo masked (SPEC D10). */ SPJELLY_API const char *spjelly_redact(const char *url); /* Drop every cached login token (SPEC D4). */ SPJELLY_API void spjelly_forget_tokens(void); /* The DeviceId the engine would use for these settings (SPEC D3): the settings key, else the * derived per-process id. malloc'd, caller frees. */ SPJELLY_API char *spjelly_device_id(const char *settings_json); /* ---- transport selection ---- */ /* io must carry a scorpiox_http behind it (scorpiox_http_of(io) != NULL): the fleet transport, * because Jellyfin 12 needs request headers (SPEC D1). A bare scorpiox_io => SPRCH_E_NOTSUPPORTED. */ SPJELLY_API int spjelly_set_io(const scorpiox_io *io); SPJELLY_API int spjelly_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPJELLY_API int spjelly_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. * req_headers: "Name: value\n" lines or NULL — recorded, and spjelly_fake_last_headers returns * the last request's headers so tests can assert the auth headers actually went out (SPEC D3). */ SPJELLY_API void spjelly_fake_reset(void); SPJELLY_API int spjelly_fake_set(const char *method, const char *url, int http_code, const char *body); SPJELLY_API int spjelly_fake_fail(const char *method, const char *url, const char *transport_error); SPJELLY_API int spjelly_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPJELLY_API const char *spjelly_fake_last_body(const char *url); /* last POST body to url */ SPJELLY_API const char *spjelly_fake_last_url(void); /* last URL requested */ SPJELLY_API const char *spjelly_fake_last_headers(void); /* "Name: value\n" lines */ #ifdef __cplusplus } #endif #endif /* SPJELLY_H */