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

Function cupsFileRewind

cups/file.c:1773–1837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1771 */
1772
1773off_t /* O - New file position or -1 on error */
1774cupsFileRewind(cups_file_t *fp) /* I - CUPS file */
1775{
1776 /*
1777 * Range check input...
1778 */
1779
1780 DEBUG_printf(("cupsFileRewind(fp=%p)", (void *)fp));
1781
1782 if (!fp || fp->mode != 'r')
1783 return (-1);
1784
1785 DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
1786
1787 /*
1788 * Handle special cases...
1789 */
1790
1791 if (fp->bufpos == 0)
1792 {
1793 /*
1794 * No seeking necessary...
1795 */
1796
1797 fp->pos = 0;
1798
1799 if (fp->ptr)
1800 {
1801 fp->ptr = fp->buf;
1802 fp->eof = 0;
1803 }
1804
1805 DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
1806
1807 return (0);
1808 }
1809
1810 /*
1811 * Otherwise, seek in the file and cleanup any compression buffers...
1812 */
1813
1814#ifdef HAVE_LIBZ
1815 if (fp->compressed)
1816 {
1817 inflateEnd(&fp->stream);
1818 fp->compressed = 0;
1819 }
1820#endif /* HAVE_LIBZ */
1821
1822 if (lseek(fp->fd, 0, SEEK_SET))
1823 {
1824 DEBUG_printf(("1cupsFileRewind: lseek failed: %s", strerror(errno)));
1825 return (-1);
1826 }
1827
1828 fp->bufpos = 0;
1829 fp->pos = 0;
1830 fp->ptr = NULL;

Callers 8

load_ppdsFunction · 0.85
copy_modelFunction · 0.85
get_utf16Function · 0.85
mainFunction · 0.85
ppdcFileMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
cupsFileSeekFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68