/* scorpiox-scorpioplayer-smb-v1-cifs-file-server — read-only SMB 1 / CIFS file server (spsmb1s_). * * SCORPIO PLAYER 2027 engine, row 42. Pure C99, zero external deps (vendored yyjson only). * MS-CIFS dialect NT LM 0.12 + MS-NLMP NTLMv2 + RFC 4178 SPNEGO + MS-SRVS share enum. * Named shares (folders or single files) added/removed at runtime, anonymous/guest or a * caller-supplied user list, a loopback-only client allow-list by default. Nothing writes. * OFF BY DEFAULT: spsmb1s_start refuses until set_option("allow_smb1","1") (SPEC R0). * See SPEC.md for every rule and decision (D1..D13) referenced below. * * One server per process (singleton API). All functions return 0 on success and a negative * value on error unless documented otherwise; spsmb1s_last_error() explains it. Returned * const char * point to static storage valid until the next call on this thread's API use; * copy them immediately. */ #ifndef SPSMB1S_H #define SPSMB1S_H #ifdef __cplusplus extern "C" { #endif #if defined(SPSMB1S_STATIC) # define SPSMB1S_API #elif defined(_WIN32) # if defined(SPSMB1S_BUILD) # define SPSMB1S_API __declspec(dllexport) # else # define SPSMB1S_API __declspec(dllimport) # endif #else # define SPSMB1S_API __attribute__((visibility("default"))) #endif /* ---- error codes ---- */ #define SPSMB1S_OK 0 #define SPSMB1S_E_ARG -1 /* bad argument / option */ #define SPSMB1S_E_NOTFOUND -2 /* share path missing, unknown share or user */ #define SPSMB1S_E_EXISTS -3 /* share name taken */ #define SPSMB1S_E_STATE -4 /* already running */ #define SPSMB1S_E_NET -5 /* socket / bind / listen / thread failure */ #define SPSMB1S_E_LIMIT -6 /* too many shares / users / CIDRs */ #define SPSMB1S_E_PATH -7 /* the path rule refused the argument */ #define SPSMB1S_E_BUFFER -8 /* transcript does not fit the cap */ #define SPSMB1S_E_OFF -9 /* start refused: SMB1 not enabled (allow_smb1=1 missing) */ /* ---- identity ---- */ SPSMB1S_API const char *spsmb1s_version(void); /* ---- lifecycle ---- */ /* bind_ip NULL/"" = 127.0.0.1, port 0 = any free port (spsmb1s_port tells which), * server_name NULL = "SCORPIOPLAYER". SPEC section 2. */ SPSMB1S_API int spsmb1s_start(const char *bind_ip, int port, const char *server_name); SPSMB1S_API void spsmb1s_stop(void); SPSMB1S_API int spsmb1s_port(void); /* bound port, 0 = stopped */ SPSMB1S_API int spsmb1s_set_option(const char *key, const char *value); /* SPEC section 9 — allow_smb1 ("0"/"1", default "0") gates start */ /* ---- shares, users, access (R4, R6, R3) ---- */ SPSMB1S_API int spsmb1s_add_share(const char *share, const char *path); /* folder or single file */ SPSMB1S_API int spsmb1s_remove_share(const char *share); SPSMB1S_API int spsmb1s_add_user(const char *user, const char *pass); /* none added = guest */ SPSMB1S_API int spsmb1s_remove_user(const char *user); SPSMB1S_API int spsmb1s_allow_cidr(const char *cidr); /* loopback always allowed */ /* ---- status ---- */ SPSMB1S_API int spsmb1s_session_count(void); /* authenticated SMB2 sessions */ SPSMB1S_API int spsmb1s_client_count(void); /* open TCP connections */ SPSMB1S_API const char *spsmb1s_stats_json(void); /* SPEC section 11 */ /* ---- pure (no socket) ---- * spsmb1s_simulate runs a whole connection (NBSS frames as hex, one per line, "!raw " * for unframed input, "# ..." comments) through the real state machine with an in-memory * transport and returns the transcript of SPEC section 12. */ SPSMB1S_API const char *spsmb1s_simulate(const char *script, const char *client_ip); /* ---- results ---- */ SPSMB1S_API const char *spsmb1s_last_error(void); #ifdef __cplusplus } #endif #endif /* SPSMB1S_H */ /* ---- self test ---- */ /* runs the crypto + framing self test and returns a human-readable result ("...ok" / "...FAILED"). * The pointer is valid until the next call on this thread. */ SPSMB1S_API const char *spsmb1s_selftest(void);