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

Function rprintf

log.c:406–443  ·  view source on GitHub ↗

This is the rsync debugging function. Call it with FINFO, FERROR_*, * FWARNING, FLOG, or FCLIENT. */

Source from the content-addressed store, hash-verified

404/* This is the rsync debugging function. Call it with FINFO, FERROR_*,
405 * FWARNING, FLOG, or FCLIENT. */
406void rprintf(enum logcode code, const char *format, ...)
407{
408 va_list ap;
409 char buf[BIGPATHBUFLEN];
410 size_t len;
411
412 va_start(ap, format);
413 len = vsnprintf(buf, sizeof buf, format, ap);
414 va_end(ap);
415
416 /* Deal with buffer overruns. Instead of panicking, just
417 * truncate the resulting string. (Note that configure ensures
418 * that we have a vsnprintf() that doesn't ever return -1.) */
419 if (len > sizeof buf - 1) {
420 static const char ellipsis[] = "[...]";
421
422 /* Reset length, and zero-terminate the end of our buffer */
423 len = sizeof buf - 1;
424 buf[len] = '\0';
425
426 /* Copy the ellipsis to the end of the string, but give
427 * us one extra character:
428 *
429 * v--- null byte at buf[sizeof buf - 1]
430 * abcdefghij0
431 * -> abcd[...]00 <-- now two null bytes at end
432 *
433 * If the input format string has a trailing newline,
434 * we copy it into that extra null; if it doesn't, well,
435 * all we lose is one byte. */
436 memcpy(buf+len-sizeof ellipsis, ellipsis, sizeof ellipsis);
437 if (format[strlen(format)-1] == '\n') {
438 buf[len-1] = '\n';
439 }
440 }
441
442 rwrite(code, buf, len, 0);
443}
444
445/* This is like rprintf, but it also tries to print some
446 * representation of the error code. Normally errcode = errno.

Callers 15

receive_sumsFunction · 0.70
successful_sendFunction · 0.70
send_filesFunction · 0.70
idev_findFunction · 0.70
maybe_hard_linkFunction · 0.70
hard_link_checkFunction · 0.70
finish_hard_linkFunction · 0.70
make_output_optionFunction · 0.70
parse_output_wordsFunction · 0.70
output_item_helpFunction · 0.70
option_errorFunction · 0.70
parse_one_refuse_matchFunction · 0.70

Calls 1

rwriteFunction · 0.85

Tested by

no test coverage detected