/* * sprch_registry.h — scorpiox-scorpioplayer-runtime-config-handler-registry * * The registry + dispatch half of the SCORPIO PLAYER 2027 source boundary. * C twin of SP2025 `RuntimeConfigHandlerHelper` (SCORPIOXINC.Toolkit.Std/ * RuntimeConfigHandlerHelper.cs) and of the hardcoded `GetAllHandlers()` list * (IOSLegacy Adapters/Class1.cs:80-107, TPlayer Adapters/RuntimeConfigHandlerShared.cs). * * Handlers implement `sprch_handler` from sprch.h. The host links the handler * DLLs it ships and calls sprch_register() for each (static registration, no * reflection, no dlopen scanning). * * Threading: single-threaded global state (fleet style). Call from one thread. * Strings: every const char * returned is owned by the library and valid until * the next sprch_* call. Copy it immediately. * Return codes: SPRCH_OK (0) or SPRCH_E_* (<0) from sprch.h. A few predicates * return 1/0 and say so. */ #ifndef SPRCH_REGISTRY_H #define SPRCH_REGISTRY_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPRCH_STATIC) # define SPRCH_API #elif defined(_WIN32) # if defined(SPRCH_BUILD) # define SPRCH_API __declspec(dllexport) # else # define SPRCH_API __declspec(dllimport) # endif #else # define SPRCH_API __attribute__((visibility("default"))) #endif #define SPRCH_MAX_HANDLERS 64 /* ---- version / errors ---- */ SPRCH_API const char *sprch_version(void); SPRCH_API int sprch_abi_version(void); SPRCH_API int sprch_last_code(void); SPRCH_API const char *sprch_last_error(void); /* secrets scrubbed */ SPRCH_API const char *sprch_strerror(int code); SPRCH_API const char *sprch_result(void); /* last string result (JSON or text) */ SPRCH_API int sprch_result_len(void); /* ---- registry (= GetAllHandlers + GetByType) ---- */ SPRCH_API int sprch_register(const sprch_handler *h); SPRCH_API int sprch_register_builtin(void); /* DEBRIDSETTINGS, MEDIASERVERSETTINGS (+ SPRCH_EXTRA_BUILTINS) */ SPRCH_API void sprch_reset(void); /* unregister all, forget io/seed, clear errors */ SPRCH_API int sprch_count(void); SPRCH_API const char *sprch_runtime_type(int i); /* "" if out of range */ SPRCH_API int sprch_caps(int i); /* -1 if out of range */ SPRCH_API int sprch_find(const char *runtime_type); /* first index, exact + case-sensitive, alias-aware; -1 */ SPRCH_API int sprch_alias_count(void); SPRCH_API const char *sprch_alias_from(int i); SPRCH_API const char *sprch_alias_to(int i); SPRCH_API int sprch_route(const char *settings_json); /* which handlers a dispatch would try; JSON in result */ /* ---- dispatch (= RuntimeConfigHandlerHelper). Result JSON in sprch_result() ---- */ SPRCH_API void sprch_set_io(const scorpiox_io *io); /* NULL = built-in "no transport" io */ SPRCH_API void sprch_set_id_seed(unsigned long long seed); /* deterministic ID generation (tests) */ SPRCH_API int sprch_validate(const char *settings_json); /* -> merged settings */ SPRCH_API int sprch_list(const char *settings_json, const char *folder_id); /* -> items JSON */ SPRCH_API int sprch_stream_url(const char *settings_json, const char *entry_json);/* -> {"url":..} */ SPRCH_API int sprch_download(const char *settings_json, const char *config_json); /* -> DebridInstantDownloadResponse */ /* ---- settings JSON helpers (pure; key order stable; unknown keys preserved) ---- */ SPRCH_API int sprch_settings_normalize(const char *json); /* parse + re-serialise, Newtonsoft-compatible */ SPRCH_API int sprch_settings_count(const char *json); /* >=0 keys, or SPRCH_E_CONFIG */ SPRCH_API int sprch_settings_keys(const char *json); /* JSON array of keys in result */ SPRCH_API int sprch_settings_has(const char *json, const char *key); /* 1 present (even null), 0 absent, E_CONFIG */ SPRCH_API int sprch_settings_get(const char *json, const char *key); /* OK + value; E_NOTFOUND if absent or null */ SPRCH_API int sprch_settings_set(const char *json, const char *key, const char *value); /* value NULL => JSON null */ SPRCH_API int sprch_settings_remove(const char *json, const char *key); SPRCH_API int sprch_settings_merge(const char *base_json, const char *delta_json); SPRCH_API int sprch_settings_redact(const char *json); SPRCH_API int sprch_is_secret_key(const char *key); /* 1/0 */ SPRCH_API int sprch_scrub(const char *text, const char *settings_json); /* text with secret values -> *** */ /* ---- inventory: every legacy RuntimeType -> the C repo that implements it ---- */ SPRCH_API int sprch_inventory_count(void); SPRCH_API const char *sprch_inventory_field(int i, const char *field); /* fields: runtime_type, status, repo, row, legacy_class, legacy_caps, ios, uwp, note */ SPRCH_API int sprch_inventory_find(const char *runtime_type); /* index or -1 (exact) */ SPRCH_API int sprch_inventory_json(void); /* ---- test support: fake transport, two fake handlers, legacy mirror, conformance ---- */ SPRCH_API const scorpiox_io *sprch_fake_io(void); SPRCH_API int sprch_fake_io_load(const char *routes_json); /* {"":{"code":200,"body":"..."} | {"fail":"msg"}, ..., "*":{...}} ; replaces all routes */ SPRCH_API void sprch_fake_io_reset(void); SPRCH_API int sprch_fake_io_calls(void); SPRCH_API const char *sprch_fake_io_last_url(void); SPRCH_API const sprch_handler *sprch_fake_handler(int which); /* 0 = media server (JELLYFIN-shaped), 1 = debrid (ALLDEBRID-shaped) */ SPRCH_API int sprch_legacy_mirror_register(int platform); /* 0 = iOS list (29), 1 = TPlayer UWP list (25); returns count */ SPRCH_API const char *sprch_legacy_mirror_class(int platform, int i); /* the C# class behind mirror handler i */ SPRCH_API int sprch_conformance(const sprch_handler *h, const scorpiox_io *io, const char *settings_json, const char *entry_json, const char *config_json); /* failures (0 = pass), report in result */ #ifdef __cplusplus } #endif #endif /* SPRCH_REGISTRY_H */