romele / git-trace public
62 commits · 1 branch · 1 tag · 1 contributor (top: Romele) · first commit 3d ago · last push 10m ago
src/wcommit.h
#ifndef GT_WCOMMIT_H #define GT_WCOMMIT_H #include "web.h" /* struct app_ctx */ /* * Browser-driven commits: write a file into a bare repo with pure * plumbing — no working tree, no index pollution. Policy parity * with git pushes comes from re-running the same `branch-check` and * `quota-check` subcommands the update hook invokes. * * wc_commit_file returns 0 and fills out_sha on success; on failure * returns nonzero and fills err. */ int wc_commit_file(struct app_ctx *c, const char *repo_dir, const char *branch, const char *path, const void *data, size_t len, const char *msg, const char *author, const char *amail, char out_sha[41], char *err, size_t errlen); /* ---------------- bounded multipart/form-data parsing ---------------- * These live here (not in httpd) because uploads are a web-commit * concern, and exporting them keeps the parser fuzzable. */ /* copy the value of attr="..." out of a bounded header copy */ int wc_mp_attr(const char *hdrs, const char *attr, char *out, size_t outlen); /* locate part `field` in a multipart body; on hit data/dlen point into * the body and fname gets the filename="" attr (if asked). * Returns 1 found, 0 not found. */ int wc_mp_find(char *body, size_t blen, const char *bnd, const char *field, const char **data, size_t *dlen, char *fname, size_t flen); /* csrf from a multipart part rather than a urlencoded field */ int wc_mp_csrf_ok(struct request *r, char *body, size_t blen, const char *bnd); /* extract boundary="..." (or bare) from Content-Type */ int wc_mp_boundary(struct request *r, char *out, size_t outlen); /* basename of a client filename + single-segment validity */ int wc_basename(const char *fname, char *out, size_t outlen); #endif