MCPcopy Index your code
hub / github.com/RsyncProject/rsync / filtered_fwrite

Function filtered_fwrite

log.c:225–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225static void filtered_fwrite(FILE *f, const char *in_buf, int in_len, int use_isprint, char end_char)
226{
227 char outbuf[1024], *ob = outbuf;
228 const char *end = in_buf + in_len;
229 while (in_buf < end) {
230 if (ob - outbuf >= (int)sizeof outbuf - 10) {
231 if (fwrite(outbuf, ob - outbuf, 1, f) != 1)
232 exit_cleanup(RERR_MESSAGEIO);
233 ob = outbuf;
234 }
235 if ((in_buf < end - 4 && *in_buf == '\\' && in_buf[1] == '#'
236 && isDigit(in_buf + 2) && isDigit(in_buf + 3) && isDigit(in_buf + 4))
237 || (*in_buf != '\t' && ((use_isprint && !isPrint(in_buf)) || *(uchar*)in_buf < ' ')))
238 ob += snprintf(ob, 6, "\\#%03o", *(uchar*)in_buf++);
239 else
240 *ob++ = *in_buf++;
241 }
242 if (end_char) /* The "- 10" above means that there is always room for one more char here. */
243 *ob++ = end_char;
244 if (ob != outbuf && fwrite(outbuf, ob - outbuf, 1, f) != 1)
245 exit_cleanup(RERR_MESSAGEIO);
246}
247
248/* this is the underlying (unformatted) rsync debugging function. Call
249 * it with FINFO, FERROR_*, FWARNING, FLOG, or FCLIENT. Note: recursion

Callers 1

rwriteFunction · 0.85

Calls 2

isDigitFunction · 0.85
isPrintFunction · 0.85

Tested by

no test coverage detected