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

Function cbm_http_replyf

src/ui/httpd.c:769–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void cbm_http_replyf(cbm_http_conn_t *c, int status, const char *extra_headers, const char *fmt,
770 ...) {
771 va_list ap;
772 va_start(ap, fmt);
773 va_list ap2;
774 va_copy(ap2, ap);
775 int need = vsnprintf(NULL, 0, fmt, ap);
776 va_end(ap);
777 if (need < 0) {
778 va_end(ap2);
779 return;
780 }
781
782 char stack_buf[4096];
783 char *body = stack_buf;
784 if ((size_t)need >= sizeof(stack_buf)) {
785 body = malloc((size_t)need + 1);
786 if (!body) {
787 va_end(ap2);
788 return;
789 }
790 }
791 vsnprintf(body, (size_t)need + 1, fmt, ap2);
792 va_end(ap2);
793
794 cbm_http_reply_buf(c, status, extra_headers, body, (size_t)need);
795 if (body != stack_buf)
796 free(body);
797}
798
799/* ── Pure helpers ─────────────────────────────────────────────── */
800

Callers 15

handle_ui_configFunction · 0.85
handle_repo_infoFunction · 0.85
handle_logsFunction · 0.85
handle_agent_eventsFunction · 0.85
handle_ui_log_postFunction · 0.85
handle_ui_log_getFunction · 0.85
handle_processesFunction · 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

Calls 1

cbm_http_reply_bufFunction · 0.85

Tested by

no test coverage detected