#ifndef SMRSS_H #define SMRSS_H #include #include #ifdef __cplusplus extern "C" { #endif #if defined(_WIN32) || defined(__CYGWIN__) # ifdef SMRSS_BUILD # define SMRSS_API __declspec(dllexport) # else # define SMRSS_API __declspec(dllimport) # endif #else # if defined(__GNUC__) || defined(__clang__) # define SMRSS_API __attribute__((visibility("default"))) # else # define SMRSS_API # endif #endif SMRSS_API const char *smrss_version(void); SMRSS_API int smrss_abi_version(void); SMRSS_API const char *smrss_last_error(void); SMRSS_API void smrss_free(void *ptr); /* Parse an RSS 2.0 + iTunes XML feed into canonical JSON. * Caller frees the returned string with smrss_free(). Returns NULL on error. */ SMRSS_API char *smrss_parse_feed_json(const char *xml, size_t xml_len, const char *feed_url); /* Parse a Kestrel HTML directory index into a JSON array of playlist slugs * (e.g. ["all","worship","chill"]), putting "all" first and excluding "video"/dot dirs. * Caller frees the returned string with smrss_free(). */ SMRSS_API char *smrss_discover_slugs_json(const char *html, size_t html_len); /* Parse "H:MM:SS", "MM:SS", or "SS" into seconds (0.0 on invalid/empty). */ SMRSS_API double smrss_parse_duration(const char *str); /* Format seconds into "H:MM:SS" or "M:SS". Returns written length or -1 on error. */ SMRSS_API int smrss_format_duration(double seconds, char *buf, size_t buf_len); /* Parse RFC 2822 (or ISO-8601 UTC) pubDate into Unix epoch seconds (0 on invalid). */ SMRSS_API int64_t smrss_parse_rfc2822_date(const char *str); /* Clean raw track title: strip trailing [11-char YouTube ID], replace '_' with space, * collapse duplicate spaces, trim. Caller frees with smrss_free(). */ SMRSS_API char *smrss_clean_title(const char *raw); /* Validate an http:// or https:// RSS feed URL. Returns 0 if valid, -1 otherwise. */ SMRSS_API int smrss_validate_feed_url(const char *url); /* Safely construct "///feed.xml", rejecting traversal/bad chars. * Caller frees with smrss_free(). Returns NULL on invalid input. */ SMRSS_API char *smrss_build_user_feed_url(const char *base_url, const char *user_id, const char *slug); /* Built-in offline self-test. Returns 0 on PASS, non-zero on FAIL. */ SMRSS_API int smrss_selftest(void); #ifdef __cplusplus } #endif #endif /* SMRSS_H */