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

Function agent_json_scan_object

src/cli/agent_clients.c:761–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759static int agent_json_scan_value(agent_json_scanner_t *scanner, unsigned depth);
760
761static int agent_json_scan_object(agent_json_scanner_t *scanner, unsigned depth) {
762 if (depth >= AGENT_JSON_MAX_DEPTH || scanner->position >= scanner->length ||
763 scanner->data[scanner->position++] != '{') {
764 return -1;
765 }
766 if (agent_json_skip_space(scanner) != 0) {
767 return -1;
768 }
769 if (scanner->position < scanner->length && scanner->data[scanner->position] == '}') {
770 scanner->position++;
771 return 0;
772 }
773 for (;;) {
774 if (scanner->position >= scanner->length) {
775 return -1;
776 }
777 if (scanner->data[scanner->position] == '"' || scanner->data[scanner->position] == '\'') {
778 if (agent_json_scan_string(scanner, NULL, NULL) != 0) {
779 return -1;
780 }
781 } else {
782 size_t start = scanner->position;
783 while (scanner->position < scanner->length &&
784 (isalnum((unsigned char)scanner->data[scanner->position]) ||
785 strchr("_$-", scanner->data[scanner->position]))) {
786 scanner->position++;
787 }
788 if (scanner->position == start) {
789 return -1;
790 }
791 }
792 if (agent_json_skip_space(scanner) != 0 || scanner->position >= scanner->length ||
793 scanner->data[scanner->position++] != ':' ||
794 agent_json_scan_value(scanner, depth + 1U) != 0 ||
795 agent_json_skip_space(scanner) != 0 || scanner->position >= scanner->length) {
796 return -1;
797 }
798 char separator = scanner->data[scanner->position++];
799 if (separator == '}') {
800 return 0;
801 }
802 if (separator != ',') {
803 return -1;
804 }
805 if (agent_json_skip_space(scanner) != 0) {
806 return -1;
807 }
808 if (scanner->position < scanner->length && scanner->data[scanner->position] == '}') {
809 scanner->position++;
810 return 0;
811 }
812 }
813}
814
815static int agent_json_scan_array(agent_json_scanner_t *scanner, unsigned depth) {
816 if (depth >= AGENT_JSON_MAX_DEPTH) {

Callers 1

agent_json_scan_valueFunction · 0.85

Calls 3

agent_json_skip_spaceFunction · 0.85
agent_json_scan_stringFunction · 0.85
agent_json_scan_valueFunction · 0.85

Tested by

no test coverage detected