/* * sppod.h — scorpiox-scorpioplayer-podcast-rss-source-client public API. * * The handler itself is the sprch_handler returned by sprch_get() (sprch.h, * RuntimeType "PODCASTS", caps 0x23 = VALIDATE|LIST|STREAM). * The sppod_* exports are the flat P/Invoke surface; they call through * sprch_get() with the installed scorpiox_io backend (libcurl by default, * fake for tests, URLSession on iOS). See SPEC.md for every decision. */ #ifndef SPPOD_H #define SPPOD_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(_WIN32) # if defined(SPPOD_BUILD) # define SPPOD_API __declspec(dllexport) # else # define SPPOD_API __declspec(dllimport) # endif #else # define SPPOD_API __attribute__((visibility("default"))) #endif #define SPPOD_VERSION "1.0.0" /* ---- sprch ops through the installed backend ---- */ SPPOD_API int sppod_validate(const char *settings_json, char *out_json, int cap); SPPOD_API int sppod_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPPOD_API int sppod_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPPOD_API int sppod_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* ---- results / identity ---- */ SPPOD_API const char *sppod_last_error(void); /* "" after a successful call; never a secret */ SPPOD_API const char *sppod_result_json(void); /* full JSON of the last call, even after E_BUFFER */ SPPOD_API const char *sppod_version(void); SPPOD_API const char *sppod_runtime_type(void); SPPOD_API int sppod_caps(void); /* ---- backend selection ---- */ SPPOD_API int sppod_set_io(const scorpiox_io *io); /* NULL restores the default */ SPPOD_API int sppod_use_curl(void); /* SPRCH_E_NOTSUPPORTED if built without */ SPPOD_API int sppod_use_fake(void); /* ---- fake backend (tests; never touches the network) ---- */ SPPOD_API void sppod_fake_reset(void); SPPOD_API int sppod_fake_set(const char *url, int http_code, const char *body); /* int: same width on every ABI */ SPPOD_API int sppod_fake_fail(const char *url, const char *transport_error); SPPOD_API int sppod_fake_calls(const char *url); /* NULL = total */ /* ---- cache (SPEC D16) ---- */ SPPOD_API void sppod_cache_clear(void); SPPOD_API int sppod_cache_set_max_age(int seconds); /* default 21600; 0 = always revalidate */ SPPOD_API const char *sppod_stats_json(void); /* {"http":{...},"cache":{...},"feeds":{...},"items":{...}} */ /* ---- internal (static builds, tests, CLI) ---- */ const scorpiox_io *sppod_io_curl(void); const scorpiox_io *sppod_io_fake(void); const scorpiox_io *sppod_io_current(void); /* ---- pure parser, exported for the fuzzer and the unit tests (SPEC D10) ---- */ /* Parses `xml` (RSS 2.0 / RSS 1.0-RDF / Atom) into `out_json`: * {"title":..,"image":..,"format":"rss2|rdf|atom","items":[ * {"title","id","id_fallback","url","size","mtime_ms","duration_s","enclosure_type","link"}]} * `err` (n>0) receives a human message on failure. * Returns 0 on success, -1 on a protocol violation (DTD/ENTITY/depth/size/utf8/malformed). * The output is malloc'd NUL-terminated; free() it. `out_json` is NULL on failure. */ SPPOD_API int sppod_parse_feed(const char *xml, long long len, char **out_json, char *err, int n); /* itunes:duration in all its forms (SPEC D7): "ss", "mm:ss", "hh:mm:ss", "120s", "2m", * "1.5h". Returns seconds (>=0) or -1 when absent/invalid. */ SPPOD_API long long sppod_parse_duration(const char *s); /* Feed discovery over HTML (SPEC D2): . * Returns a malloc'd JSON array of {"url","title"} in document order, relative refs * resolved against `page_url`, duplicates dropped. `out_json` NULL on OOM. 0 = ok. */ SPPOD_API int sppod_discover_feeds(const char *html, long long len, const char *page_url, char **out_json, char *err, int n); #ifdef __cplusplus } #endif #endif /* SPPOD_H */