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

Function append_json_string

src/foundation/log.c:189–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189static void append_json_string(char *buf, size_t bufsz, size_t *pos, const char *s) {
190 append_char(buf, bufsz, pos, '"');
191 if (s) {
192 while (*s) {
193 unsigned char ch = (unsigned char)*s++;
194 switch (ch) {
195 case '"':
196 append_raw(buf, bufsz, pos, "\\\"");
197 break;
198 case '\\':
199 append_raw(buf, bufsz, pos, "\\\\");
200 break;
201 case '\b':
202 append_raw(buf, bufsz, pos, "\\b");
203 break;
204 case '\f':
205 append_raw(buf, bufsz, pos, "\\f");
206 break;
207 case '\n':
208 append_raw(buf, bufsz, pos, "\\n");
209 break;
210 case '\r':
211 append_raw(buf, bufsz, pos, "\\r");
212 break;
213 case '\t':
214 append_raw(buf, bufsz, pos, "\\t");
215 break;
216 default:
217 if (ch < 0x20) {
218 static const char hex[] = "0123456789abcdef";
219 append_raw(buf, bufsz, pos, "\\u00");
220 append_char(buf, bufsz, pos, hex[ch >> 4]);
221 append_char(buf, bufsz, pos, hex[ch & 0xf]);
222 } else {
223 append_char(buf, bufsz, pos, (char)ch);
224 }
225 break;
226 }
227 }
228 }
229 append_char(buf, bufsz, pos, '"');
230}
231
232static void finish_line(char *buf, size_t bufsz, size_t pos) {
233 if (bufsz == 0) {

Callers 2

cbm_logFunction · 0.70
cbm_log_control_recordFunction · 0.70

Calls 2

append_charFunction · 0.85
append_rawFunction · 0.85

Tested by

no test coverage detected