This is a CHM / ITSS archive reader, ported and cleaned from CHMLib.
- plain C, no dependencies
- wasm build to be used in web apps
- simpler / cleaned API
- easy to integrate: copy
dist/chm.handdist/chm.cto your project (amalgamated build like sqlite) - in-memory only (no incremental I/O)
- fuzzed for robustness
- battle tested in SumatraPDF
See src/chm.h. Basic usage:
chm_ctx *ctx = chm_open(NULL, data, len); /* data must outlive ctx */
struct chm_entry **entries = NULL;
int n = chm_get_entries(ctx, &entries);
for (int i = 0; i < n; i++) {
if (strcmp(entries[i]->path, "/foo/bar.html") == 0) {
uint8_t *buf = malloc(entries[i]->length);
if (buf) {
chm_read_entry(ctx, entries[i], buf);
free(buf);
}
break;
}
}
chm_close(ctx);For dev, we require bun and use msvc and clang as C compilers.
bun cmd/build.ts # builds out/clang/chm_test
bun cmd/get-deps.ts # download public .chm samples → testfiles/chm
bun cmd/tests.ts # smoke tests over testfiles/chm (auto get-deps)
bun cmd/build-dist.ts # updates dist/chm.{h,c} (+ wasm when run as main)
bun cmd/build-wasm.ts # dist/wasm/chm.js + chm.wasm + demo.html (bootstraps emsdk if needed)
bun cmd/verify-wasm.ts f.chm # open/list through the wasm glue (CI)
bun cmd/run-wasm-demo.ts # serve the browser demo
bun cmd/fuzz.ts # libFuzzer (seeded from testfiles/chm)
bun cmd/fuzz.ts -check-crashes # replay fuzz/crashes/* under ASan (CI)
CI (GitHub Actions): .github/workflows/ci.yml — Windows/Linux/macOS smoke +
CHMLib oracle tests + amalgamation, fuzz crash regression, WASM open/list.
CLI:
chm_test -list file.chm
Port of CHMLib (from SumatraPDF's ext/CHMLib) cleaned up coding conventions, with ctx/alloc, amalgamated build, fuzzing, wasm build.
See LICENSE.md (LGPL-ish origin from CHMLib, adapted).