/* * spaspnet.h — scorpiox-scorpioplayer-aspnet-directory-listing-client public API. * * RuntimeType "ASPNET": a web server's directory index (ASP.NET Core UseDirectoryBrowser, * nginx autoindex, Apache mod_autoindex) as a read-only media source. * * The handler is the sprch_handler returned by sprch_get() (sprch.h). The spaspnet_* * exports are the flat P/Invoke surface; they call through sprch_get() with the installed * transport (libcurl by default). See SPEC.md for every decision. * * Strings returned by spaspnet_* are owned by the library and valid until the next call * of the same export on any thread. Copy them. */ #ifndef SPASPNET_H #define SPASPNET_H #include "sprch.h" #include "scorpiox-http.h" #ifdef __cplusplus extern "C" { #endif #if defined(_WIN32) # if defined(SPASPNET_BUILD) # define SPASPNET_API __declspec(dllexport) # else # define SPASPNET_API __declspec(dllimport) # endif #else # define SPASPNET_API __attribute__((visibility("default"))) #endif #define SPASPNET_VERSION "1.0.0" #define SPASPNET_RUNTIME_TYPE "ASPNET" #define SPASPNET_DEFAULT_URL "https://fs.scorpioplayer.com/dl/" /* C#: http://..., 308 -> https */ /* ---- sprch ops through the installed transport ---- */ SPASPNET_API int spaspnet_validate(const char *settings_json, char *out_json, int cap); SPASPNET_API int spaspnet_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPASPNET_API int spaspnet_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPASPNET_API int spaspnet_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* ---- beyond sprch ---- */ /* Ranged GET (bytes=0-0) of one file: {"path","url","http","range":bool,"size"}. * Needs a transport with the scorpiox_http extension (SPEC D3), else SPRCH_E_NOTSUPPORTED. */ SPASPNET_API int spaspnet_stat(const char *settings_json, const char *path, char *out_json, int cap); /* Parse an index page offline: {"dialect","variant","date_order","rejected","skipped","items":[...]}. */ SPASPNET_API int spaspnet_parse(const char *html, const char *page_url, char *out_json, int cap); /* ---- results / identity ---- */ SPASPNET_API const char *spaspnet_last_error(void); /* "" after success; never a secret */ SPASPNET_API const char *spaspnet_result_json(void); /* full JSON of the last call, also after E_BUFFER */ SPASPNET_API const char *spaspnet_version(void); SPASPNET_API const char *spaspnet_runtime_type(void); SPASPNET_API int spaspnet_caps(void); /* ---- transport selection ---- */ SPASPNET_API int spaspnet_set_io(const scorpiox_io *io); /* NULL restores the default; copied */ /* Pair a scorpiox_io with its scorpiox_http extension (Swift URLSession, WinHTTP, ...). * Matched by (http_get, ctx), so copies of the io struct still match. http NULL unbinds. */ SPASPNET_API int spaspnet_bind_http(const scorpiox_io *io, const scorpiox_http *http); SPASPNET_API int spaspnet_use_curl(void); /* SPRCH_E_NOTSUPPORTED if built without */ SPASPNET_API int spaspnet_use_fake(void); /* ---- fake transport (tests, console --test; never touches the network) ---- */ SPASPNET_API void spaspnet_fake_reset(void); /* headers: "Name: value" lines separated by '\n' (e.g. "Location: /dl/"), may be NULL. */ SPASPNET_API int spaspnet_fake_set(const char *url, int http_code, const char *headers, const char *body); SPASPNET_API int spaspnet_fake_fail(const char *url, const char *transport_error); SPASPNET_API int spaspnet_fake_calls(const char *url); /* NULL = total */ /* {"calls":n,"range":"bytes=0-0"|null,"auth":bool} of the last request to url */ SPASPNET_API const char *spaspnet_fake_last_request(const char *url); /* ---- internal (static builds, tests, CLI) ---- */ const scorpiox_io *spaspnet_io_curl(void); const scorpiox_http *spaspnet_http_curl(void); const scorpiox_io *spaspnet_io_fake(void); const scorpiox_http *spaspnet_http_fake(void); const scorpiox_io *spaspnet_io_current(void); #ifdef __cplusplus } #endif #endif /* SPASPNET_H */