/* scorpiox-scorpioplayer-smb-v2-file-server — read-only SMB 3.0/3.0.2/3.1.1 file server (spsmb3s_). * * SCORPIO PLAYER 2027 engine, row 44. Pure C99, zero external deps (vendored yyjson only). * MS-SMB2 dialects 0x0202/0x0210 + 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. * 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; spsmb3s_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 SPSMB3S_H #define SPSMB3S_H #ifdef __cplusplus extern "C" { #endif #if defined(SPSMB3S_STATIC) # define SPSMB3S_API #elif defined(_WIN32) # if defined(SPSMB3S_BUILD) # define SPSMB3S_API __declspec(dllexport) # else # define SPSMB3S_API __declspec(dllimport) # endif #else # define SPSMB3S_API __attribute__((visibility("default"))) #endif /* ---- error codes ---- */ #define SPSMB3S_OK 0 #define SPSMB3S_E_ARG -1 /* bad argument / option */ #define SPSMB3S_E_NOTFOUND -2 /* share path missing, unknown share or user */ #define SPSMB3S_E_EXISTS -3 /* share name taken */ #define SPSMB3S_E_STATE -4 /* already running */ #define SPSMB3S_E_NET -5 /* socket / bind / listen / thread failure */ #define SPSMB3S_E_LIMIT -6 /* too many shares / users / CIDRs */ #define SPSMB3S_E_PATH -7 /* the path rule refused the argument */ #define SPSMB3S_E_BUFFER -8 /* transcript does not fit the cap */ /* ---- identity ---- */ SPSMB3S_API const char *spsmb3s_version(void); /* ---- lifecycle ---- */ /* bind_ip NULL/"" = 127.0.0.1, port 0 = any free port (spsmb3s_port tells which), * server_name NULL = "SCORPIOPLAYER". SPEC section 2. */ SPSMB3S_API int spsmb3s_start(const char *bind_ip, int port, const char *server_name); SPSMB3S_API void spsmb3s_stop(void); SPSMB3S_API int spsmb3s_port(void); /* bound port, 0 = stopped */ SPSMB3S_API int spsmb3s_set_option(const char *key, const char *value); /* SPEC section 9 */ /* ---- shares, users, access (R4, R6, R3) ---- */ SPSMB3S_API int spsmb3s_add_share(const char *share, const char *path); /* folder or single file */ SPSMB3S_API int spsmb3s_remove_share(const char *share); SPSMB3S_API int spsmb3s_add_user(const char *user, const char *pass); /* none added = guest */ SPSMB3S_API int spsmb3s_remove_user(const char *user); SPSMB3S_API int spsmb3s_allow_cidr(const char *cidr); /* loopback always allowed */ /* ---- status ---- */ SPSMB3S_API int spsmb3s_session_count(void); /* authenticated SMB2 sessions */ SPSMB3S_API int spsmb3s_client_count(void); /* open TCP connections */ SPSMB3S_API const char *spsmb3s_stats_json(void); /* SPEC section 11 */ /* ---- pure (no socket) ---- * spsmb3s_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. */ SPSMB3S_API const char *spsmb3s_simulate(const char *script, const char *client_ip); /* ---- results ---- */ SPSMB3S_API const char *spsmb3s_last_error(void); #ifdef __cplusplus } #endif #endif /* SPSMB3S_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. */ SPSMB3S_API const char *spsmb3s_selftest(void);