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

Function elem_content

internal/cbm/iris_export_xml.c:76–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75}
76static const char *elem_content(const char *p, const char *end, const char *tag, char *buf,
77 size_t bufsz) {
78 buf[0] = '\0';
79 char open[MAX_NAME + 2];
80 snprintf(open, sizeof(open), "<%s", tag);
81 const char *start = find_s(p, end, open);
82 if (!start)
83 return NULL;
84 const char *gt = find_s(start, end, ">");
85 if (!gt)
86 return NULL;
87 if (is_self_closing(start, gt))
88 return gt + 1;
89 const char *cs = gt + 1;
90 if (sw(cs, end, "<![CDATA[")) {
91 cs += 9;
92 const char *ce = find_s(cs, end, "]]>");
93 if (!ce)
94 return NULL;
95 size_t l = (size_t)(ce - cs);
96 if (l >= bufsz)
97 l = bufsz - 1;
98 memcpy(buf, cs, l);
99 buf[l] = '\0';
100 return ce + 3;
101 }
102 char close[MAX_NAME + 4];
103 snprintf(close, sizeof(close), "</%s>", tag);
104 const char *cl = find_s(cs, end, close);
105 if (!cl)
106 return NULL;
107 size_t l = (size_t)(cl - cs);
108 if (l >= bufsz)
109 l = bufsz - 1;
110 memcpy(buf, cs, l);
111 buf[l] = '\0';
112 return cl + strlen(close);
113}
114static bool tag_is_one(const char *p, const char *end, const char *tag) {
115 char buf[8];
116 return elem_content(p, end, tag, buf, sizeof(buf)) && strcmp(buf, "1") == 0;

Callers 7

tag_is_oneFunction · 0.85
emit_headerFunction · 0.85
emit_methodFunction · 0.85
emit_propertyFunction · 0.85
emit_parameterFunction · 0.85
emit_indexFunction · 0.85
emit_xdataFunction · 0.85

Calls 3

find_sFunction · 0.85
is_self_closingFunction · 0.85
swFunction · 0.85

Tested by

no test coverage detected