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

Function forward_filesfrom_data

io.c:370–478  ·  view source on GitHub ↗

This is only called when files-from data is known to be available. We read * a chunk of data and put it into the output buffer. */

Source from the content-addressed store, hash-verified

368/* This is only called when files-from data is known to be available. We read
369 * a chunk of data and put it into the output buffer. */
370static void forward_filesfrom_data(void)
371{
372 ssize_t len;
373
374 len = read(ff_forward_fd, ff_xb.buf + ff_xb.len, ff_xb.size - ff_xb.len);
375 if (len <= 0) {
376 if (len == 0 || errno != EINTR) {
377 /* Send end-of-file marker */
378 ff_forward_fd = -1;
379 write_buf(iobuf.out_fd, "\0\0", ff_lastchar ? 2 : 1);
380 free_xbuf(&ff_xb);
381 if (ff_reenable_multiplex >= 0)
382 io_start_multiplex_out(ff_reenable_multiplex);
383 free_implied_include_partial_string();
384 }
385 return;
386 }
387
388 if (DEBUG_GTE(IO, 2)) {
389 rprintf(FINFO, "[%s] files-from read=%" SIZE_T_FMT_MOD "d\n",
390 who_am_i(), (SIZE_T_FMT_CAST)len);
391 }
392
393#ifdef ICONV_OPTION
394 len += ff_xb.len;
395#endif
396
397 if (!eol_nulls) {
398 char *s = ff_xb.buf + len;
399 /* Transform CR and/or LF into '\0' */
400 while (s-- > ff_xb.buf) {
401 if (*s == '\n' || *s == '\r')
402 *s = '\0';
403 }
404 }
405
406 if (ff_lastchar)
407 ff_xb.pos = 0;
408 else {
409 char *s = ff_xb.buf;
410 /* Last buf ended with a '\0', so don't let this buf start with one. */
411 while (len && *s == '\0')
412 s++, len--;
413 ff_xb.pos = s - ff_xb.buf;
414 }
415
416#ifdef ICONV_OPTION
417 if (filesfrom_convert && len) {
418 char *sob = ff_xb.buf + ff_xb.pos, *s = sob;
419 char *eob = sob + len;
420 int flags = ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE | ICB_CIRCULAR_OUT;
421 if (ff_lastchar == '\0')
422 flags |= ICB_INIT;
423 /* Convert/send each null-terminated string separately, skipping empties. */
424 while (s != eob) {
425 if (*s++ == '\0') {
426 ff_xb.len = s - sob - 1;
427 add_implied_include(sob, 0);

Callers 1

perform_ioFunction · 0.85

Calls 10

write_bufFunction · 0.85
free_xbufFunction · 0.85
io_start_multiplex_outFunction · 0.85
add_implied_includeFunction · 0.85
iconvbufsFunction · 0.85
memmoveFunction · 0.85
rprintfFunction · 0.70
who_am_iFunction · 0.70

Tested by

no test coverage detected