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

Function resp_has_key

tests/test_incremental.c:1068–1085  ·  view source on GitHub ↗

Check response contains a specific key (in nested JSON) */

Source from the content-addressed store, hash-verified

1066
1067/* Check response contains a specific key (in nested JSON) */
1068static int resp_has_key(const char *resp, const char *key) {
1069 if (!resp)
1070 return 0;
1071 char pattern[64];
1072 snprintf(pattern, sizeof(pattern), "\"%s\"", key);
1073 if (strstr(resp, pattern) != NULL)
1074 return 1;
1075 snprintf(pattern, sizeof(pattern), "\\\"%s\\\"", key);
1076 if (strstr(resp, pattern) != NULL)
1077 return 1;
1078 /* TOON scalar form (`key: value`), the search_graph default output. */
1079 snprintf(pattern, sizeof(pattern), "%s: ", key);
1080 if (strstr(resp, pattern) != NULL)
1081 return 1;
1082 /* TOON table-header form (`key[N]{...}:`), used by trace_path. */
1083 snprintf(pattern, sizeof(pattern), "%s[", key);
1084 return strstr(resp, pattern) != NULL;
1085}
1086
1087/* Check response does NOT contain a specific key */
1088static int resp_lacks_key(const char *resp, const char *key) {

Callers 2

resp_lacks_keyFunction · 0.85
test_incremental.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected