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

Function append_json_string

src/foundation/log.c:181–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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