MCPcopy Create free account
hub / github.com/OpenPrinting/cups / copy_bytes

Function copy_bytes

filter/pstops.c:514–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512 */
513
514static void
515copy_bytes(cups_file_t *fp, /* I - File to read from */
516 off_t offset, /* I - Offset to page data */
517 size_t length) /* I - Length of page data */
518{
519 char buffer[8192]; /* Data buffer */
520 ssize_t nbytes; /* Number of bytes read */
521 size_t nleft; /* Number of bytes left/remaining */
522
523
524 nleft = length;
525
526 if (cupsFileSeek(fp, offset) < 0)
527 {
528 _cupsLangPrintError("ERROR", _("Unable to see in file"));
529 return;
530 }
531
532 while (nleft > 0 || length == 0)
533 {
534 if (nleft > sizeof(buffer) || length == 0)
535 nbytes = sizeof(buffer);
536 else
537 nbytes = (ssize_t)nleft;
538
539 if ((nbytes = cupsFileRead(fp, buffer, (size_t)nbytes)) < 1)
540 return;
541
542 nleft -= (size_t)nbytes;
543
544 fwrite(buffer, 1, (size_t)nbytes, stdout);
545 }
546}
547
548
549/*

Callers 2

copy_dscFunction · 0.85
copy_non_dscFunction · 0.85

Calls 3

cupsFileSeekFunction · 0.85
_cupsLangPrintErrorFunction · 0.85
cupsFileReadFunction · 0.85

Tested by

no test coverage detected