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

Function parse_content_length

src/mcp/mcp.c:21101–21128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21099}
21100
21101static bool parse_content_length(const char *line, size_t *out) {
21102 if (!line || !out || strncmp(line, "Content-Length:", SLEN("Content-Length:")) != 0) {
21103 return false;
21104 }
21105
21106 const char *cursor = line + MCP_CONTENT_PREFIX;
21107 while (*cursor == ' ' || *cursor == '\t') {
21108 cursor++;
21109 }
21110 if (!isdigit((unsigned char)*cursor)) {
21111 return false;
21112 }
21113
21114 errno = 0;
21115 char *end = NULL;
21116 unsigned long long parsed = strtoull(cursor, &end, CBM_DECIMAL_BASE);
21117 if (errno == ERANGE || end == cursor) {
21118 return false;
21119 }
21120 while (*end == ' ' || *end == '\t') {
21121 end++;
21122 }
21123 if (*end != '\0' || parsed == 0 || parsed > MCP_MAX_MESSAGE_SIZE) {
21124 return false;
21125 }
21126 *out = (size_t)parsed;
21127 return true;
21128}
21129
21130int cbm_mcp_read_message(FILE *in, char **message, bool *content_length_framed) {
21131 if (!in || !message || !content_length_framed) {

Callers 1

cbm_mcp_read_messageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected