/* * spdl.h — scorpiox-scorpioplayer-debrid-link-client: Debrid-Link as the sprch handler * "DEBRIDLINK" (row 53). * * 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 spdl_result_json(). A * result that does not fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by spdl_* are owned by the library, per calling thread, and stay * valid until the same thread's next spdl_* call. Copy them. * * Legacy alias kept for the task-file naming (row 53 used "spdebrid_*" in early drafts): * typedef sprch_handler spdebrid_handler; (see the bottom of this header) */ #ifndef SPDL_H #define SPDL_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPDL_STATIC) # define SPDL_API #elif defined(_WIN32) # if defined(SPDL_BUILD) # define SPDL_API __declspec(dllexport) # else # define SPDL_API __declspec(dllimport) # endif #else # define SPDL_API __attribute__((visibility("default"))) #endif #define SPDL_VERSION "1.0.0" #define SPDL_RUNTIME_TYPE "DEBRIDLINK" #define SPDL_CAPS 0x2Fu /* LIST|STREAM|DOWNLOAD|WRITES|VALIDATE */ /* ---- identity ---- */ SPDL_API const char *spdl_version(void); SPDL_API const char *spdl_runtime_type(void); SPDL_API int spdl_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPDL_API int spdl_validate(const char *settings_json, char *out_json, int cap); SPDL_API int spdl_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPDL_API int spdl_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPDL_API int spdl_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* Guards download() + spdl_delete_transfer(): 0 = writes refused, != 0 = allowed. */ SPDL_API int spdl_allow_writes(int enable); /* ---- results ---- */ SPDL_API const char *spdl_result_json(void); /* the last op's output JSON ("" if none) */ SPDL_API const char *spdl_last_error(void); /* "" after a success; never holds a secret */ /* ---- pure helpers (no transport) ---- */ /* The URL the ops would build for these settings (SPEC section 4), or NULL. */ SPDL_API const char *spdl_base_url(void); /* ParseSeasonEpisode (SPEC section 7): out_season/out_episode set when 1 is returned. */ SPDL_API int spdl_parse_season_episode(const char *filename, int *out_season, int *out_episode); /* bencode torrent sniff (SPEC D5): 1 = looks like a .torrent file. */ SPDL_API int spdl_is_torrent_file(const char *bytes, size_t n); /* `magnet:?xt=urn:btih:<40 hex|32 base32>` check (MD:134). */ SPDL_API int spdl_is_magnet_link(const char *link); /* A URL with apikey / api_key / Authorization masked (SPEC section 5). */ SPDL_API const char *spdl_redact(const char *url); /* ---- transport selection ---- */ SPDL_API int spdl_set_io(const scorpiox_io *io); /* NULL => back to libcurl */ SPDL_API int spdl_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPDL_API int spdl_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. */ SPDL_API void spdl_fake_reset(void); SPDL_API int spdl_fake_set(const char *method, const char *url, int http_code, const char *body); SPDL_API int spdl_fake_fail(const char *method, const char *url, const char *transport_error); SPDL_API int spdl_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPDL_API const char *spdl_fake_last_body(const char *url); /* last POST body to url */ SPDL_API const char *spdl_fake_last_url(void); /* last URL requested */ #ifdef __cplusplus } #endif /* legacy-name alias (row 53 task file used spdebrid_* before sprch.h shipped) */ typedef sprch_handler spdebrid_handler; #endif /* SPDL_H */