/* * spplfm.h — scorpiox-scorpioplayer-playlist-folder-model * * SCORPIO PLAYER 2027 folder browse policy: entry filtering, name * normalisation, classification, the open-folder decision, sort, the * presented playlist, item identity (v2 + byte-exact legacy), resume * keys, companion lookup. * * Pure policy over a listing in #26's (spffa) item JSON model. No * network, no backends, no sockets. Consumes JSON, produces decisions. * * See SPEC.md for every decision and its C# citation, and README.md. * * Threading: single-threaded, global state (fleet style). * * Strings: every const char * returned is owned by the library and valid * until the next call that changes the same state. Copy it. */ #ifndef SPPLFM_H #define SPPLFM_H #include #ifdef __cplusplus extern "C" { #endif #if defined(SPPLFM_STATIC) # define SPPLFM_API #elif defined(_WIN32) # if defined(SPPLFM_BUILD) # define SPPLFM_API __declspec(dllexport) # else # define SPPLFM_API __declspec(dllimport) # endif #else # define SPPLFM_API __attribute__((visibility("default"))) #endif #define SPPLFM_ABI_VERSION 1 /* ---- error taxonomy (SPEC §12) — values are frozen ---- */ #define SPPLFM_OK 0 #define SPPLFM_ERR_BAD_LISTING 1 #define SPPLFM_ERR_INVALID_ARG 2 #define SPPLFM_ERR_OOM 3 #define SPPLFM_ERR_TOO_LARGE 4 /* ---- classification kinds (SPEC §5) — values are frozen ---- */ #define SPPLFM_KIND_VIDEO 0 #define SPPLFM_KIND_AUDIO 1 #define SPPLFM_KIND_SUBTITLE 2 #define SPPLFM_KIND_PICTURE 3 #define SPPLFM_KIND_UNSUPPORTED 4 #define SPPLFM_KIND_CUE 5 #define SPPLFM_KIND_DISC_IMAGE 6 #define SPPLFM_KIND_UNKNOWN 7 /* ---- open-folder actions (SPEC §6) — values are frozen ---- */ #define SPPLFM_ACTION_DESCEND 0 #define SPPLFM_ACTION_OPEN_FILES 1 #define SPPLFM_ACTION_OPEN_DISC 2 #define SPPLFM_ACTION_OPEN_CUE 3 #define SPPLFM_ACTION_EMPTY 4 #define SPPLFM_ACTION_ERROR 5 /* ---- sort keys (SPEC §7) — values are frozen ---- */ #define SPPLFM_SORT_NAME_NATURAL 0 #define SPPLFM_SORT_NAME_ORDINAL 1 #define SPPLFM_SORT_SIZE 2 #define SPPLFM_SORT_MTIME 3 /* input: a listing in #26's item model (JSON, SPEC §2) — * returns SPPLFM_OK, SPPLFM_ERR_BAD_LISTING, SPPLFM_ERR_INVALID_ARG, * SPPLFM_ERR_OOM, SPPLFM_ERR_TOO_LARGE. A bad listing clears the state. */ SPPLFM_API int spplfm_load_listing(const char *listing_json); /* identity context (SPEC §9). NULL → ERR_INVALID_ARG. */ SPPLFM_API int spplfm_set_backend_id(const char *id); SPPLFM_API int spplfm_set_folder_path(const char *path); SPPLFM_API const char *spplfm_backend_id(void); SPPLFM_API const char *spplfm_folder_path(void); /* hidden-entry rules (SPEC §3). n == 0 → documented defaults. * globs == NULL → defaults. */ SPPLFM_API int spplfm_set_hidden_rules(const char *const *globs, int n); /* name normalisation (SPEC §4). n < needed → SPPLFM_ERR_TOO_LARGE. */ SPPLFM_API int spplfm_normalize_name(const char *in, char *out, size_t n); /* classification (SPEC §5) → SPPLFM_KIND_*. NULL → ERR_INVALID_ARG. */ SPPLFM_API int spplfm_classify(const char *name); /* the open-folder decision (SPEC §6) → SPPLFM_ACTION_*. * Requires a loaded listing; without one → ERR_INVALID_ARG. */ SPPLFM_API int spplfm_decide(int detect_bluray); /* sort the presented playlist (SPEC §7). by → SPPLFM_SORT_*. * desc 0/1. Invalid key → ERR_INVALID_ARG. */ SPPLFM_API int spplfm_sort(int by, int desc); /* the presented playlist (SPEC §7): visible files minus * SUBTITLE/PICTURE/UNSUPPORTED, in current sort order. */ SPPLFM_API int spplfm_count(void); SPPLFM_API const char *spplfm_name(int i); SPPLFM_API int spplfm_kind(int i); SPPLFM_API long long spplfm_size(int i); /* -1 = unknown, never 0 */ SPPLFM_API long long spplfm_mtime_ms(int i); /* -1 = unknown */ /* identity (SPEC §9). i indexes the presented playlist. * v2 is PRIMARY; legacy is byte-exact C# ("" for the local empty-id case). */ SPPLFM_API int spplfm_item_id(int i, char *out, size_t n); SPPLFM_API int spplfm_item_legacy_id(int i, char *out, size_t n); /* resume keys (SPEC §9). out receives a NUL-terminated Base64 string. */ SPPLFM_API int spplfm_resume_key(char *out, size_t n); SPPLFM_API int spplfm_legacy_resume_key(char *out, size_t n); /* #26's listing error code name carried by the listing JSON, * or NULL if none (SPEC §6/§12). */ SPPLFM_API const char *spplfm_listing_error_name(void); /* companions (SPEC §10). Indices are into the LISTING (all entries, * original order), not the presented playlist. -1 = none. */ SPPLFM_API int spplfm_subs_folder_index(void); SPPLFM_API int spplfm_cue_audio_index(int cue_index); /* full decision report (SPEC §13) — owned by the library. */ SPPLFM_API const char *spplfm_result_json(void); /* engine error string. */ SPPLFM_API const char *spplfm_last_error(void); #ifdef __cplusplus } #endif #endif /* SPPLFM_H */