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

Function agent_json_key_equals

src/cli/agent_clients.c:885–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

883}
884
885static bool agent_json_key_equals(const char *data, size_t start, size_t end, const char *key) {
886 if (end < start) {
887 return false;
888 }
889 size_t key_offset = 0U;
890 size_t key_len = strlen(key);
891 for (size_t cursor = start; cursor < end;) {
892 unsigned value = (unsigned char)data[cursor++];
893 if (value == '\\') {
894 if (cursor >= end) {
895 return false;
896 }
897 char escape = data[cursor++];
898 if (escape == 'u' || escape == 'x') {
899 size_t digits = escape == 'u' ? 4U : 2U;
900 if (end - cursor < digits) {
901 return false;
902 }
903 value = 0U;
904 for (size_t i = 0U; i < digits; i++) {
905 unsigned char digit = (unsigned char)data[cursor++];
906 if (digit >= '0' && digit <= '9') {
907 value = value * 16U + (unsigned)(digit - '0');
908 } else if (digit >= 'a' && digit <= 'f') {
909 value = value * 16U + (unsigned)(digit - 'a' + 10U);
910 } else if (digit >= 'A' && digit <= 'F') {
911 value = value * 16U + (unsigned)(digit - 'A' + 10U);
912 } else {
913 return false;
914 }
915 }
916 } else if (strchr("\\/\"'", escape)) {
917 value = (unsigned char)escape;
918 } else {
919 return false;
920 }
921 }
922 if (value > 0x7fU || key_offset >= key_len || (unsigned char)key[key_offset++] != value) {
923 return false;
924 }
925 }
926 return key_offset == key_len;
927}
928
929/* Returns 0 found, 1 absent, -1 malformed/ambiguous/not-an-object. */
930static int agent_json_find_member(const char *data, size_t object_start, size_t object_end,

Callers 1

agent_json_find_memberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected