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

Function cupsFileFlush

cups/file.c:612–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610 */
611
612int /* O - 0 on success, -1 on error */
613cupsFileFlush(cups_file_t *fp) /* I - CUPS file */
614{
615 ssize_t bytes; /* Bytes to write */
616
617
618 DEBUG_printf(("cupsFileFlush(fp=%p)", (void *)fp));
619
620 /*
621 * Range check input...
622 */
623
624 if (!fp || fp->mode != 'w')
625 {
626 DEBUG_puts("1cupsFileFlush: Attempt to flush a read-only file...");
627 return (-1);
628 }
629
630 bytes = (ssize_t)(fp->ptr - fp->buf);
631
632 DEBUG_printf(("2cupsFileFlush: Flushing " CUPS_LLFMT " bytes...",
633 CUPS_LLCAST bytes));
634
635 if (bytes > 0)
636 {
637#ifdef HAVE_LIBZ
638 if (fp->compressed)
639 bytes = cups_compress(fp, fp->buf, (size_t)bytes);
640 else
641#endif /* HAVE_LIBZ */
642 bytes = cups_write(fp, fp->buf, (size_t)bytes);
643
644 if (bytes < 0)
645 return (-1);
646
647 fp->ptr = fp->buf;
648 }
649
650 return (0);
651}
652
653
654/*

Callers 10

cupsdLogPageFunction · 0.85
cupsdLogRequestFunction · 0.85
cupsdWriteErrorLogFunction · 0.85
helpSaveIndexFunction · 0.85
cupsFileCloseFunction · 0.85
cupsFilePrintfFunction · 0.85
cupsFilePutCharFunction · 0.85
cupsFilePutsFunction · 0.85
cupsFileWriteFunction · 0.85

Calls 2

cups_compressFunction · 0.85
cups_writeFunction · 0.85

Tested by

no test coverage detected