/* * spdr.h — scorpiox-scorpioplayer-real-debrid-client: Real-Debrid as the sprch handler * "REALDEBRID" (row 51). * * 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 spdr_result_json(). A * result that does not fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by spdr_* are owned by the library, per calling thread, and stay * valid until the same thread's next spdr_* call. Copy them. */ #ifndef SPDR_H #define SPDR_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPDR_STATIC) # define SPDR_API #elif defined(_WIN32) # if defined(SPDR_BUILD) # define SPDR_API __declspec(dllexport) # else # define SPDR_API __declspec(dllimport) # endif #else # define SPDR_API __attribute__((visibility("default"))) #endif #define SPDR_VERSION "1.0.0" #define SPDR_RUNTIME_TYPE "REALDEBRID" #define SPDR_CAPS 0x2Fu /* LIST|STREAM|DOWNLOAD|WRITES|VALIDATE */ /* ---- identity ---- */ SPDR_API const char *spdr_version(void); SPDR_API const char *spdr_runtime_type(void); SPDR_API int spdr_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPDR_API int spdr_validate(const char *settings_json, char *out_json, int cap); SPDR_API int spdr_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPDR_API int spdr_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPDR_API int spdr_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* Guards download() + spdr_delete_transfer() (and the selectFiles they drive): * 0 = writes refused, != 0 = allowed. */ SPDR_API int spdr_allow_writes(int enable); /* ---- results ---- */ SPDR_API const char *spdr_result_json(void); /* the last op's output JSON ("" if none) */ SPDR_API const char *spdr_last_error(void); /* "" after a success; never holds a secret */ /* ---- pure helpers (no transport) ---- */ /* The API base the ops would build for these settings (SPEC section 4), or NULL. */ SPDR_API const char *spdr_base_url(void); /* ParseSeasonEpisode (SPEC section 7): out_season/out_episode set when 1 is returned. */ SPDR_API int spdr_parse_season_episode(const char *filename, int *out_season, int *out_episode); /* bencode torrent sniff (SPEC D5): 1 = looks like a .torrent file. */ SPDR_API int spdr_is_torrent_file(const char *bytes, size_t n); /* `magnet:?xt=urn:btih:<40 hex|32 base32>` check (MD:137). */ SPDR_API int spdr_is_magnet_link(const char *link); /* The legacy `IsVideoType` test on an RD file path (VT:374, the 17-entry VideoTypes list). */ SPDR_API int spdr_is_video_path(const char *path); /* A URL with token / apikey / Authorization masked (SPEC section 5). */ SPDR_API const char *spdr_redact(const char *url); /* ---- transport selection ---- */ SPDR_API int spdr_set_io(const scorpiox_io *io); /* NULL => back to libcurl */ SPDR_API int spdr_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPDR_API int spdr_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. */ SPDR_API void spdr_fake_reset(void); SPDR_API int spdr_fake_set(const char *method, const char *url, int http_code, const char *body); SPDR_API int spdr_fake_fail(const char *method, const char *url, const char *transport_error); SPDR_API int spdr_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPDR_API const char *spdr_fake_last_body(const char *url); /* last POST body to url */ SPDR_API const char *spdr_fake_last_url(void); /* last URL requested */ #ifdef __cplusplus } #endif #endif /* SPDR_H */