MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_http_replyf

Function cbm_http_replyf

src/ui/httpd.c:541–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541void cbm_http_replyf(cbm_http_conn_t *c, int status, const char *extra_headers, const char *fmt,
542 ...) {
543 va_list ap;
544 va_start(ap, fmt);
545 va_list ap2;
546 va_copy(ap2, ap);
547 int need = vsnprintf(NULL, 0, fmt, ap);
548 va_end(ap);
549 if (need < 0) {
550 va_end(ap2);
551 return;
552 }
553
554 char stack_buf[4096];
555 char *body = stack_buf;
556 if ((size_t)need >= sizeof(stack_buf)) {
557 body = malloc((size_t)need + 1);
558 if (!body) {
559 va_end(ap2);
560 return;
561 }
562 }
563 vsnprintf(body, (size_t)need + 1, fmt, ap2);
564 va_end(ap2);
565
566 cbm_http_reply_buf(c, status, extra_headers, body, (size_t)need);
567 if (body != stack_buf)
568 free(body);
569}
570
571/* ── Pure helpers ─────────────────────────────────────────────── */
572

Callers 15

handle_ui_configFunction · 0.85
handle_repo_infoFunction · 0.85
handle_logsFunction · 0.85
handle_processesFunction · 0.85
http_server.cFile · 0.85
handle_browseFunction · 0.85
handle_adr_getFunction · 0.85
handle_adr_saveFunction · 0.85
handle_index_startFunction · 0.85
handle_index_statusFunction · 0.85
handle_delete_projectFunction · 0.85
handle_project_healthFunction · 0.85

Calls 1

cbm_http_reply_bufFunction · 0.85

Tested by

no test coverage detected