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

Function append_json_string

src/foundation/log.c:144–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144static void append_json_string(char *buf, size_t bufsz, size_t *pos, const char *s) {
145 append_char(buf, bufsz, pos, '"');
146 if (s) {
147 while (*s) {
148 unsigned char ch = (unsigned char)*s++;
149 switch (ch) {
150 case '"':
151 append_raw(buf, bufsz, pos, "\\\"");
152 break;
153 case '\\':
154 append_raw(buf, bufsz, pos, "\\\\");
155 break;
156 case '\b':
157 append_raw(buf, bufsz, pos, "\\b");
158 break;
159 case '\f':
160 append_raw(buf, bufsz, pos, "\\f");
161 break;
162 case '\n':
163 append_raw(buf, bufsz, pos, "\\n");
164 break;
165 case '\r':
166 append_raw(buf, bufsz, pos, "\\r");
167 break;
168 case '\t':
169 append_raw(buf, bufsz, pos, "\\t");
170 break;
171 default:
172 if (ch < 0x20) {
173 static const char hex[] = "0123456789abcdef";
174 append_raw(buf, bufsz, pos, "\\u00");
175 append_char(buf, bufsz, pos, hex[ch >> 4]);
176 append_char(buf, bufsz, pos, hex[ch & 0xf]);
177 } else {
178 append_char(buf, bufsz, pos, (char)ch);
179 }
180 break;
181 }
182 }
183 }
184 append_char(buf, bufsz, pos, '"');
185}
186
187static void finish_line(char *buf, size_t bufsz, size_t pos) {
188 if (bufsz == 0) {

Callers 1

cbm_logFunction · 0.70

Calls 2

append_charFunction · 0.85
append_rawFunction · 0.85

Tested by

no test coverage detected