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

Function append_json_string

src/foundation/log.c:162–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162static void append_json_string(char *buf, size_t bufsz, size_t *pos, const char *s) {
163 append_char(buf, bufsz, pos, '"');
164 if (s) {
165 while (*s) {
166 unsigned char ch = (unsigned char)*s++;
167 switch (ch) {
168 case '"':
169 append_raw(buf, bufsz, pos, "\\\"");
170 break;
171 case '\\':
172 append_raw(buf, bufsz, pos, "\\\\");
173 break;
174 case '\b':
175 append_raw(buf, bufsz, pos, "\\b");
176 break;
177 case '\f':
178 append_raw(buf, bufsz, pos, "\\f");
179 break;
180 case '\n':
181 append_raw(buf, bufsz, pos, "\\n");
182 break;
183 case '\r':
184 append_raw(buf, bufsz, pos, "\\r");
185 break;
186 case '\t':
187 append_raw(buf, bufsz, pos, "\\t");
188 break;
189 default:
190 if (ch < 0x20) {
191 static const char hex[] = "0123456789abcdef";
192 append_raw(buf, bufsz, pos, "\\u00");
193 append_char(buf, bufsz, pos, hex[ch >> 4]);
194 append_char(buf, bufsz, pos, hex[ch & 0xf]);
195 } else {
196 append_char(buf, bufsz, pos, (char)ch);
197 }
198 break;
199 }
200 }
201 }
202 append_char(buf, bufsz, pos, '"');
203}
204
205static void finish_line(char *buf, size_t bufsz, size_t pos) {
206 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