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

Function format_call_arg

src/pipeline/pass_parallel.c:2148–2170  ·  view source on GitHub ↗

Format one call arg as JSON. Returns snprintf result. */

Source from the content-addressed store, hash-verified

2146
2147/* Format one call arg as JSON. Returns snprintf result. */
2148static int format_call_arg(char *buf, size_t bufsize, const CBMCallArg *a, const char *expr) {
2149 char esc_k[CBM_SZ_128];
2150 char esc_e[CBM_SZ_128];
2151 char esc_v[CBM_SZ_128];
2152 cbm_json_escape(esc_e, sizeof(esc_e), expr);
2153 if (a->keyword && a->value) {
2154 cbm_json_escape(esc_k, sizeof(esc_k), a->keyword);
2155 cbm_json_escape(esc_v, sizeof(esc_v), a->value);
2156 return snprintf(buf, bufsize, "{\"i\":%d,\"k\":\"%s\",\"e\":\"%s\",\"v\":\"%s\"}", a->index,
2157 esc_k, esc_e, esc_v);
2158 }
2159 if (a->keyword) {
2160 cbm_json_escape(esc_k, sizeof(esc_k), a->keyword);
2161 return snprintf(buf, bufsize, "{\"i\":%d,\"k\":\"%s\",\"e\":\"%s\"}", a->index, esc_k,
2162 esc_e);
2163 }
2164 if (a->value) {
2165 cbm_json_escape(esc_v, sizeof(esc_v), a->value);
2166 return snprintf(buf, bufsize, "{\"i\":%d,\"e\":\"%s\",\"v\":\"%s\"}", a->index, esc_e,
2167 esc_v);
2168 }
2169 return snprintf(buf, bufsize, "{\"i\":%d,\"e\":\"%s\"}", a->index, esc_e);
2170}
2171
2172static size_t append_args_json(char *buf, size_t bufsize, size_t pos, const CBMCall *call) {
2173 if (call->arg_count == 0 || pos >= bufsize - PP_ARGS_MARGIN) {

Callers 1

append_args_jsonFunction · 0.85

Calls 1

cbm_json_escapeFunction · 0.85

Tested by

no test coverage detected