# scorpiox-scorpioplayer-spfs-http-file-client

RuntimeType **`SPFS`**: a ScorpioMediaServer HTTP file server as a read-only media source and a #26
storage backend. Pure C99, libc + vendored yyjson (+ libcurl for the default transport).

- validate: `GET /api/Version` (a .NET Version >= 1.1.0.0) + `/api/Folders`; writes `FullUrl`, `RuntimeType`, `ID`
- shared roots: the keys of `/api/Folders` (values are host paths: never read out)
- browse: the row 32 `?format=json` pages when the server has them, else the ASP.NET
  `DirectoryBrowser` HTML, from the same request; culture-free sizes and dates
- files: a range-readable URL (+ `Authorization: Bearer <ServerKey>`) for #20

SPEC.md holds every decision (D1-D15), the wire contract, limits and the measured legacy defects (S1-S9).

## Build / test

```sh
apt-get install -y libcurl4-openssl-dev libclang-rt-18-dev gcc-mingw-w64-x86-64 dotnet-sdk-8.0 locales
make                       # build/libscorpiox-scorpioplayer-spfs-http-file-client.so + build/spfsc
make test                  # unit, fixtures (5 locales), handler, sprch conformance, loopback (libcurl),
                           # perf (15,243 rows), fuzz corpus replay, exports-check
make asan                  # the same under ASAN + UBSAN (leak detection on)
make fuzz FUZZ_SECONDS=300 # libFuzzer: html, dates (size/date/version), json (whole handler), url
make win                   # mingw DLL (no transport built in) + export table == exports.json
make oracle                # tools/oracle/run.sh: ASP.NET SPFS emulators (4 cultures, JSON, JSON+key),
                           # the C# reference compiled unmodified; writes tools/oracle/results/
cd console-harness && dotnet run -- --test
```

Locales for test_listing's re-runs: uncomment de_DE / fr_FR / ja_JP / en_NZ / en_US UTF-8 in
`/etc/locale.gen`, `locale-gen` (missing ones are skipped and said so).

## Layout

| Path | What |
|---|---|
| `include/spfsc.h` | the public API (31 exports, `exports.json`, `spspfs.map`) |
| `include/sprch.h`, `spffa.h`, `scorpiox-io.h`, `scorpiox-http.h`, `sprch_conformance.h` | shared contracts, verbatim |
| `src/listing_parse.{h,c}` | row 62's standalone culture-free index parser, verbatim |
| `src/spfsc_engine.c` | `/api/Version`, `/api/Folders`, one folder (JSON pages / HTML), item JSON |
| `src/spfsc_handler.c` | the sprch handler: settings, validate, list, stream_url, download |
| `src/spfsc_exports.c` | transport selection, results, the stateful `spfsc_*` face |
| `src/spfsc_util.c` | FullUrl (D1), paths, redaction, .NET Version, stable hash, ids (D8) |
| `src/spfsc_fetch.c` | one GET: headers, key, redirects, bounds (D4, D5) |
| `src/spfsc_io_curl.c`, `src/spfsc_io_fake.c` | libcurl and in-memory transports (both faces) |
| `src/cli.c` | `spfsc full-url / validate / folders / list / walk / cat / parse / handler` |
| `tests/` | the C tests, loopback server, fixtures (captured from the oracle), fuzz harnesses + corpora |
| `tools/oracle/` | `make_tree.py`, `spfs-server` (ASP.NET Core 8), `servers.sh`, `capture.sh`, `oracle.py`, results |
| `tools/csharp-legacy/` | the C# reference compiled unmodified + shims + the reconstructed SPFSService |
| `console-harness/` | net8.0 P/Invoke harness (becomes the `.console` repo) |
