/* * spsyn.h — scorpiox-scorpioplayer-synology-dsm-client: Synology DSM as the sprch handler "SYNOLOGY" * (row 58). * * 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 spsyn_result_json(). A result that does not * fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by spsyn_* are owned by the library, per calling thread, and stay valid until * the same thread's next spsyn_* call. Copy them. */ #ifndef SPSYN_H #define SPSYN_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPSYN_STATIC) # define SPSYN_API #elif defined(_WIN32) # if defined(SPSYN_BUILD) # define SPSYN_API __declspec(dllexport) # else # define SPSYN_API __declspec(dllimport) # endif #else # define SPSYN_API __attribute__((visibility("default"))) #endif #define SPSYN_VERSION "1.0.0" #define SPSYN_RUNTIME_TYPE "SYNOLOGY" /* ---- identity ---- */ SPSYN_API const char *spsyn_version(void); SPSYN_API const char *spsyn_runtime_type(void); SPSYN_API int spsyn_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPSYN_API int spsyn_validate(const char *settings_json, char *out_json, int cap); SPSYN_API int spsyn_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPSYN_API int spsyn_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); SPSYN_API int spsyn_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* download() adds a DownloadStation task (SPEC D10): enable != 0 arms it, 0 refuses every write * with SPRCH_E_REFUSED_WRITE. Refusing twice is fine. Refused state is the default. */ SPSYN_API int spsyn_allow_writes(int enable); /* ---- results ---- */ SPSYN_API const char *spsyn_result_json(void); /* the last op's output JSON ("" if none) */ SPSYN_API const char *spsyn_last_error(void); /* "" after a success; never holds a secret */ /* ---- pure helpers (no transport) ---- */ /* The base URL the ops would use for these settings (SPEC D1), or NULL (spsyn_last_error says why). */ SPSYN_API const char *spsyn_full_url(const char *settings_json); /* One SYNO.FileStation.List / list_share answer body -> {"items":[...]} in the #26 item shape (SPEC §5). * parent_id is the folder the page belongs to (NULL = a share page). */ SPSYN_API int spsyn_parse_items(const char *body, const char *parent_id, char *out_json, int cap); /* A URL with passwd= / _sid= / userinfo masked (SPEC D7). */ SPSYN_API const char *spsyn_redact(const char *url); /* Drop every cached login sid (SPEC D9). */ SPSYN_API void spsyn_forget_tokens(void); /* ---- transport selection ---- */ SPSYN_API int spsyn_set_io(const scorpiox_io *io); /* NULL => back to libcurl */ SPSYN_API int spsyn_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPSYN_API int spsyn_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. */ SPSYN_API void spsyn_fake_reset(void); SPSYN_API int spsyn_fake_set(const char *method, const char *url, int http_code, const char *body); SPSYN_API int spsyn_fake_fail(const char *method, const char *url, const char *transport_error); SPSYN_API int spsyn_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPSYN_API const char *spsyn_fake_last_body(const char *url); /* last POST body to url */ SPSYN_API const char *spsyn_fake_last_url(void); /* last URL requested */ #ifdef __cplusplus } #endif #endif /* SPSYN_H */