A_GUZMAN c-copper v0.03
← 02_WORK
[0x02] SYSTEMS // FRAMEWORKS · LANGUAGES

From the socket up.

c-copper is the C framework serving this page. Around it: Lunar, a typed superset of Lua with its own compiler and LSP; Cobre, the opinionated successor framework; and Axon, the archived first pass at an LLM gateway.

1,559
LINES OF C
src + controllers
15
HTTP ROUTES
registered
3
TEMPLATE
directives
0
RUNTIME
dependencies
01 // LIVE_SOURCE

src/router.c — thread-safe pattern matching.

Literal routes short-circuit on strcmp. Parameterised routes tokenise both pattern and path with strtok_r, binding {param} segments onto the request. First match wins.

src/server.csocket loop / pthread dispatch
src/router.cpattern match + param bind
src/middleware.clinked-list chain
src/static.c/static/* → public/*
src/view.chandlebars-style engine
src/response.chtml / json / bytes
// Thread-safe URL pattern matching using strtok_r
static int match_pattern(const char* pattern, const char* path, Request* req)
{
    if (!strchr(pattern, '{'))
        return strcmp(pattern, path) == 0;

    char pat_copy[256], path_copy[256];
    strncat(pat_copy, pattern, sizeof(pat_copy) - 1);
    strncat(path_copy, path, sizeof(path_copy) - 1);

    char *save1, *save2;
    char* p_seg    = strtok_r(pat_copy,  "/", &save1);
    char* path_seg = strtok_r(path_copy, "/", &save2);

    while (p_seg && path_seg) {
        if (p_seg[0] == '{') {
            // extract {id} → bind to request param
            request_set_param(req, param, path_seg);
        } else if (strcmp(p_seg, path_seg) != 0) {
            return 0;
        }
        p_seg    = strtok_r(NULL, "/", &save1);
        path_seg = strtok_r(NULL, "/", &save2);
    }
    return (p_seg == NULL && path_seg == NULL);
}
02 // REQUEST_PIPELINE

Five stages, each one a file you can read.

socket()
accept + read
middleware
log + static
router
match + bind
controller
ACTION()
view
render + layout
TEMPLATE_DIRECTIVES
{{ key }}interpolate
{{#if x}} ... {{/if}}conditional
{{#each rows}} ... {{/each}}iterate
03 // ADJACENT_SYSTEMS
[0x02]

Cobre — Razor-pages-inspired web framework in C

IN_DEV

.cob source files transpile to .gen.c, then compile to .so and hot-load. Arena allocator with a Str type, goto cleanup error handling, TOML config. The opinionated successor to c-copper.

Ctranspilerarena allocator.so hot-load
[0x03]

Lunar — statically-typed superset of Lua

ACTIVE

Compiler, LSP, bundler, test framework — all in Go. TypeScript-for-Lua, end to end. Strong types on top of Lua semantics so projects that grew past the comfortable Lua size still have a teaching tool for the next person to read them.

GocompilerLSPbundlersource →
[0x04]

Axon — self-hosted LLM gateway

ARCHIVED

First pass at an on-premise LLM gateway in C#. Routing, request shaping, prompt template layering. Useful exercise in API surface design and provider abstraction; stays in the archive.

C#gatewaypredecessor