/* * sponed.h — scorpiox-scorpioplayer-onedrive-graph-client: OneDrive (Microsoft Graph v1.0) as the * sprch handler "ONEDRIVE" (row 57), plus the deprecated ONEDRIVEB read-only compat (SPEC D10). * * 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 sponed_result_json(). A result that does not * fit returns SPRCH_E_BUFFER and writes nothing past cap. * * Strings returned by sponed_* are owned by the library, per calling thread, and stay valid until * the same thread's next sponed_* call. Copy them. */ #ifndef SPONED_H #define SPONED_H #include "sprch.h" #ifdef __cplusplus extern "C" { #endif #if defined(SPONED_STATIC) # define SPONED_API #elif defined(_WIN32) # if defined(SPONED_BUILD) # define SPONED_API __declspec(dllexport) # else # define SPONED_API __declspec(dllimport) # endif #else # define SPONED_API __attribute__((visibility("default"))) #endif #define SPONED_VERSION "1.0.0" #define SPONED_RUNTIME_TYPE "ONEDRIVE" /* ---- identity ---- */ SPONED_API const char *sponed_version(void); SPONED_API const char *sponed_runtime_type(void); SPONED_API int sponed_caps(void); /* ---- sprch ops through the selected transport (SPRCH_OK or SPRCH_E_*) ---- */ SPONED_API int sponed_validate(const char *settings_json, char *out_json, int cap); SPONED_API int sponed_list(const char *settings_json, const char *folder_id, char *out_json, int cap); SPONED_API int sponed_stream_url(const char *settings_json, const char *entry_json, char *out_json, int cap); /* download is not a OneDrive capability (SPEC D-download): it answers SPRCH_E_NOTSUPPORTED without * a request, whatever the config. Present on the flat face for ABI parity. */ SPONED_API int sponed_download(const char *settings_json, const char *config_json, char *out_json, int cap); /* ---- results ---- */ SPONED_API const char *sponed_result_json(void); /* the last op's output JSON ("" if none) */ SPONED_API const char *sponed_last_error(void); /* "" after a success; never holds a secret */ /* ---- pure helpers (no transport) ---- */ /* The Graph base the ops would use ("https://graph.microsoft.com/v1.0", SPEC D1), or NULL * (sponed_last_error says why). OneDrive is fixed-host: the settings carry no URL keys. */ SPONED_API const char *sponed_drive_base(const char *settings_json); /* One Graph children answer body -> {"items":[...]} in the #26 item shape (SPEC §5). * parent_id is the virtual path the page belongs to ("" = the Path root). */ SPONED_API int sponed_parse_items(const char *body, const char *parent_id, char *out_json, int cap); /* A URL with the token query params / the secrets masked (SPEC D7). */ SPONED_API const char *sponed_redact(const char *url); /* Drop every cached access token (SPEC D9). */ SPONED_API void sponed_forget_tokens(void); /* ---- transport selection ---- */ SPONED_API int sponed_set_io(const scorpiox_io *io); /* NULL => back to libcurl */ SPONED_API int sponed_use_curl(void); /* SPRCH_E_NOTSUPPORTED in a no-curl build */ SPONED_API int sponed_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. */ SPONED_API void sponed_fake_reset(void); SPONED_API int sponed_fake_set(const char *method, const char *url, int http_code, const char *body); SPONED_API int sponed_fake_fail(const char *method, const char *url, const char *transport_error); SPONED_API int sponed_fake_calls(const char *method, const char *url); /* url NULL => all calls */ SPONED_API const char *sponed_fake_last_body(const char *url); /* last POST body to url */ SPONED_API const char *sponed_fake_last_url(void); /* last URL requested */ #ifdef __cplusplus } #endif #endif /* SPONED_H */