• Home
  • Raw
  • Download

Lines Matching refs:fp

68 static ssize_t	cups_compress(cups_file_t *fp, const char *buf, size_t bytes);
70 static ssize_t cups_fill(cups_file_t *fp);
72 static ssize_t cups_read(cups_file_t *fp, char *buf, size_t bytes);
73 static ssize_t cups_write(cups_file_t *fp, const char *buf, size_t bytes);
352 cupsFileClose(cups_file_t *fp) /* I - CUPS file */ in cupsFileClose() argument
359 DEBUG_printf(("cupsFileClose(fp=%p)", (void *)fp)); in cupsFileClose()
365 if (!fp) in cupsFileClose()
372 if (fp->mode == 'w') in cupsFileClose()
373 status = cupsFileFlush(fp); in cupsFileClose()
378 if (fp->compressed && status >= 0) in cupsFileClose()
380 if (fp->mode == 'r') in cupsFileClose()
386 inflateEnd(&fp->stream); in cupsFileClose()
398 fp->stream.avail_in = 0; in cupsFileClose()
402 if (fp->stream.next_out > fp->cbuf) in cupsFileClose()
404 if (cups_write(fp, (char *)fp->cbuf, in cupsFileClose()
405 (size_t)(fp->stream.next_out - fp->cbuf)) < 0) in cupsFileClose()
408 fp->stream.next_out = fp->cbuf; in cupsFileClose()
409 fp->stream.avail_out = sizeof(fp->cbuf); in cupsFileClose()
415 done = deflate(&fp->stream, Z_FINISH) == Z_STREAM_END && in cupsFileClose()
416 fp->stream.next_out == fp->cbuf; in cupsFileClose()
423 trailer[0] = (unsigned char)fp->crc; in cupsFileClose()
424 trailer[1] = (unsigned char)(fp->crc >> 8); in cupsFileClose()
425 trailer[2] = (unsigned char)(fp->crc >> 16); in cupsFileClose()
426 trailer[3] = (unsigned char)(fp->crc >> 24); in cupsFileClose()
427 trailer[4] = (unsigned char)fp->pos; in cupsFileClose()
428 trailer[5] = (unsigned char)(fp->pos >> 8); in cupsFileClose()
429 trailer[6] = (unsigned char)(fp->pos >> 16); in cupsFileClose()
430 trailer[7] = (unsigned char)(fp->pos >> 24); in cupsFileClose()
432 if (cups_write(fp, (char *)trailer, 8) < 0) in cupsFileClose()
439 deflateEnd(&(fp->stream)); in cupsFileClose()
449 if (fp->is_stdio) in cupsFileClose()
456 fd = fp->fd; in cupsFileClose()
457 mode = fp->mode; in cupsFileClose()
459 if (fp->printf_buffer) in cupsFileClose()
460 free(fp->printf_buffer); in cupsFileClose()
462 free(fp); in cupsFileClose()
487 cupsFileCompression(cups_file_t *fp) /* I - CUPS file */ in cupsFileCompression() argument
489 return (fp ? fp->compressed : CUPS_FILE_NONE); in cupsFileCompression()
500 cupsFileEOF(cups_file_t *fp) /* I - CUPS file */ in cupsFileEOF() argument
502 return (fp ? fp->eof : 1); in cupsFileEOF()
620 cupsFileFlush(cups_file_t *fp) /* I - CUPS file */ in cupsFileFlush() argument
625 DEBUG_printf(("cupsFileFlush(fp=%p)", (void *)fp)); in cupsFileFlush()
631 if (!fp || fp->mode != 'w') in cupsFileFlush()
637 bytes = (ssize_t)(fp->ptr - fp->buf); in cupsFileFlush()
645 if (fp->compressed) in cupsFileFlush()
646 bytes = cups_compress(fp, fp->buf, (size_t)bytes); in cupsFileFlush()
649 bytes = cups_write(fp, fp->buf, (size_t)bytes); in cupsFileFlush()
654 fp->ptr = fp->buf; in cupsFileFlush()
668 cupsFileGetChar(cups_file_t *fp) /* I - CUPS file */ in cupsFileGetChar() argument
674 DEBUG_printf(("4cupsFileGetChar(fp=%p)", (void *)fp)); in cupsFileGetChar()
676 if (!fp || (fp->mode != 'r' && fp->mode != 's')) in cupsFileGetChar()
686 …(("5cupsFileGetChar: fp->eof=%d, fp->ptr=%p, fp->end=%p", fp->eof, (void *)fp->ptr, (void *)fp->en… in cupsFileGetChar()
688 if (fp->ptr >= fp->end) in cupsFileGetChar()
689 if (cups_fill(fp) <= 0) in cupsFileGetChar()
699 DEBUG_printf(("5cupsFileGetChar: Returning %d...", *(fp->ptr) & 255)); in cupsFileGetChar()
701 fp->pos ++; in cupsFileGetChar()
703 DEBUG_printf(("6cupsFileGetChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileGetChar()
705 return (*(fp->ptr)++ & 255); in cupsFileGetChar()
716 cupsFileGetConf(cups_file_t *fp, /* I - CUPS file */ in cupsFileGetConf() argument
730 …", value=%p, linenum=%p)", (void *)fp, (void *)buf, CUPS_LLCAST buflen, (void *)value, (void *)lin… in cupsFileGetConf()
732 if (!fp || (fp->mode != 'r' && fp->mode != 's') || in cupsFileGetConf()
747 while (cupsFileGets(fp, buf, buflen)) in cupsFileGetConf()
859 cupsFileGetLine(cups_file_t *fp, /* I - File to read from */ in cupsFileGetLine() argument
872 …DEBUG_printf(("2cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, C… in cupsFileGetLine()
874 if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 3) in cupsFileGetLine()
883 if (fp->ptr >= fp->end) in cupsFileGetLine()
884 if (cups_fill(fp) <= 0) in cupsFileGetLine()
887 *ptr++ = ch = *(fp->ptr)++; in cupsFileGetLine()
888 fp->pos ++; in cupsFileGetLine()
896 if (fp->ptr >= fp->end) in cupsFileGetLine()
897 if (cups_fill(fp) <= 0) in cupsFileGetLine()
900 if (*(fp->ptr) == '\n') in cupsFileGetLine()
902 *ptr++ = *(fp->ptr)++; in cupsFileGetLine()
903 fp->pos ++; in cupsFileGetLine()
920 DEBUG_printf(("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileGetLine()
933 cupsFileGets(cups_file_t *fp, /* I - CUPS file */ in cupsFileGets() argument
946 …DEBUG_printf(("2cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS… in cupsFileGets()
948 if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2) in cupsFileGets()
957 if (fp->ptr >= fp->end) in cupsFileGets()
958 if (cups_fill(fp) <= 0) in cupsFileGets()
966 ch = *(fp->ptr)++; in cupsFileGets()
967 fp->pos ++; in cupsFileGets()
975 if (fp->ptr >= fp->end) in cupsFileGets()
976 if (cups_fill(fp) <= 0) in cupsFileGets()
979 if (*(fp->ptr) == '\n') in cupsFileGets()
981 fp->ptr ++; in cupsFileGets()
982 fp->pos ++; in cupsFileGets()
1001 DEBUG_printf(("4cupsFileGets: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileGets()
1014 cupsFileLock(cups_file_t *fp, /* I - CUPS file */ in cupsFileLock() argument
1021 if (!fp || fp->mode == 's') in cupsFileLock()
1029 return (_locking(fp->fd, block ? _LK_LOCK : _LK_NBLCK, 0)); in cupsFileLock()
1031 return (lockf(fp->fd, block ? F_LOCK : F_TLOCK, 0)); in cupsFileLock()
1043 cupsFileNumber(cups_file_t *fp) /* I - CUPS file */ in cupsFileNumber() argument
1045 if (fp) in cupsFileNumber()
1046 return (fp->fd); in cupsFileNumber()
1075 cups_file_t *fp; /* New CUPS file */ in cupsFileOpen() local
1165 if ((fp = cupsFileOpenFd(fd, mode)) == NULL) in cupsFileOpen()
1177 return (fp); in cupsFileOpen()
1197 cups_file_t *fp; /* New CUPS file */ in cupsFileOpenFd() local
1215 if ((fp = calloc(1, sizeof(cups_file_t))) == NULL) in cupsFileOpenFd()
1222 fp->fd = fd; in cupsFileOpenFd()
1227 fp->pos = lseek(fd, 0, SEEK_END); in cupsFileOpenFd()
1230 fp->mode = 'w'; in cupsFileOpenFd()
1231 fp->ptr = fp->buf; in cupsFileOpenFd()
1232 fp->end = fp->buf + sizeof(fp->buf); in cupsFileOpenFd()
1258 cups_write(fp, (char *)header, 10); in cupsFileOpenFd()
1264 deflateInit2(&(fp->stream), mode[1] - '0', Z_DEFLATED, -15, 8, in cupsFileOpenFd()
1267 fp->stream.next_out = fp->cbuf; in cupsFileOpenFd()
1268 fp->stream.avail_out = sizeof(fp->cbuf); in cupsFileOpenFd()
1269 fp->compressed = 1; in cupsFileOpenFd()
1270 fp->crc = crc32(0L, Z_NULL, 0); in cupsFileOpenFd()
1276 fp->mode = 'r'; in cupsFileOpenFd()
1280 fp->mode = 's'; in cupsFileOpenFd()
1292 fcntl(fp->fd, F_SETFD, fcntl(fp->fd, F_GETFD) | FD_CLOEXEC); in cupsFileOpenFd()
1295 return (fp); in cupsFileOpenFd()
1304 _cupsFilePeekAhead(cups_file_t *fp, /* I - CUPS file */ in _cupsFilePeekAhead() argument
1307 return (fp && fp->ptr && memchr(fp->ptr, ch, (size_t)(fp->end - fp->ptr))); in _cupsFilePeekAhead()
1318 cupsFilePeekChar(cups_file_t *fp) /* I - CUPS file */ in cupsFilePeekChar() argument
1324 if (!fp || (fp->mode != 'r' && fp->mode != 's')) in cupsFilePeekChar()
1331 if (fp->ptr >= fp->end) in cupsFilePeekChar()
1332 if (cups_fill(fp) <= 0) in cupsFilePeekChar()
1339 return (*(fp->ptr) & 255); in cupsFilePeekChar()
1350 cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */ in cupsFilePrintf() argument
1358 DEBUG_printf(("2cupsFilePrintf(fp=%p, format=\"%s\", ...)", (void *)fp, format)); in cupsFilePrintf()
1360 if (!fp || !format || (fp->mode != 'w' && fp->mode != 's')) in cupsFilePrintf()
1363 if (!fp->printf_buffer) in cupsFilePrintf()
1369 if ((fp->printf_buffer = malloc(1024)) == NULL) in cupsFilePrintf()
1372 fp->printf_size = 1024; in cupsFilePrintf()
1376 bytes = vsnprintf(fp->printf_buffer, fp->printf_size, format, ap); in cupsFilePrintf()
1379 if (bytes >= (ssize_t)fp->printf_size) in cupsFilePrintf()
1391 if ((temp = realloc(fp->printf_buffer, (size_t)(bytes + 1))) == NULL) in cupsFilePrintf()
1394 fp->printf_buffer = temp; in cupsFilePrintf()
1395 fp->printf_size = (size_t)(bytes + 1); in cupsFilePrintf()
1398 bytes = vsnprintf(fp->printf_buffer, fp->printf_size, format, ap); in cupsFilePrintf()
1402 if (fp->mode == 's') in cupsFilePrintf()
1404 if (cups_write(fp, fp->printf_buffer, (size_t)bytes) < 0) in cupsFilePrintf()
1407 fp->pos += bytes; in cupsFilePrintf()
1409 DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFilePrintf()
1414 if ((fp->ptr + bytes) > fp->end) in cupsFilePrintf()
1415 if (cupsFileFlush(fp)) in cupsFilePrintf()
1418 fp->pos += bytes; in cupsFilePrintf()
1420 DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFilePrintf()
1422 if ((size_t)bytes > sizeof(fp->buf)) in cupsFilePrintf()
1425 if (fp->compressed) in cupsFilePrintf()
1426 return ((int)cups_compress(fp, fp->printf_buffer, (size_t)bytes)); in cupsFilePrintf()
1429 return ((int)cups_write(fp, fp->printf_buffer, (size_t)bytes)); in cupsFilePrintf()
1433 memcpy(fp->ptr, fp->printf_buffer, (size_t)bytes); in cupsFilePrintf()
1434 fp->ptr += bytes; in cupsFilePrintf()
1436 if (fp->is_stdio && cupsFileFlush(fp)) in cupsFilePrintf()
1451 cupsFilePutChar(cups_file_t *fp, /* I - CUPS file */ in cupsFilePutChar() argument
1458 if (!fp || (fp->mode != 'w' && fp->mode != 's')) in cupsFilePutChar()
1461 if (fp->mode == 's') in cupsFilePutChar()
1472 if (send(fp->fd, &ch, 1, 0) < 1) in cupsFilePutChar()
1481 if (fp->ptr >= fp->end) in cupsFilePutChar()
1482 if (cupsFileFlush(fp)) in cupsFilePutChar()
1485 *(fp->ptr) ++ = (char)c; in cupsFilePutChar()
1488 fp->pos ++; in cupsFilePutChar()
1490 DEBUG_printf(("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFilePutChar()
1505 cupsFilePutConf(cups_file_t *fp, /* I - CUPS file */ in cupsFilePutConf() argument
1514 if (!fp || !directive || !*directive) in cupsFilePutConf()
1517 if ((bytes = cupsFilePuts(fp, directive)) < 0) in cupsFilePutConf()
1520 if (cupsFilePutChar(fp, ' ') < 0) in cupsFilePutConf()
1532 if ((temp = cupsFileWrite(fp, value, (size_t)(ptr - value))) < 0) in cupsFilePutConf()
1536 if (cupsFilePutChar(fp, '\\') < 0) in cupsFilePutConf()
1540 if ((temp = cupsFilePuts(fp, ptr)) < 0) in cupsFilePutConf()
1544 else if ((temp = cupsFilePuts(fp, value)) < 0) in cupsFilePutConf()
1550 if (cupsFilePutChar(fp, '\n') < 0) in cupsFilePutConf()
1566 cupsFilePuts(cups_file_t *fp, /* I - CUPS file */ in cupsFilePuts() argument
1576 if (!fp || !s || (fp->mode != 'w' && fp->mode != 's')) in cupsFilePuts()
1585 if (fp->mode == 's') in cupsFilePuts()
1587 if (cups_write(fp, s, (size_t)bytes) < 0) in cupsFilePuts()
1590 fp->pos += bytes; in cupsFilePuts()
1592 DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFilePuts()
1597 if ((fp->ptr + bytes) > fp->end) in cupsFilePuts()
1598 if (cupsFileFlush(fp)) in cupsFilePuts()
1601 fp->pos += bytes; in cupsFilePuts()
1603 DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFilePuts()
1605 if ((size_t)bytes > sizeof(fp->buf)) in cupsFilePuts()
1608 if (fp->compressed) in cupsFilePuts()
1609 return ((int)cups_compress(fp, s, (size_t)bytes)); in cupsFilePuts()
1612 return ((int)cups_write(fp, s, (size_t)bytes)); in cupsFilePuts()
1616 memcpy(fp->ptr, s, (size_t)bytes); in cupsFilePuts()
1617 fp->ptr += bytes; in cupsFilePuts()
1619 if (fp->is_stdio && cupsFileFlush(fp)) in cupsFilePuts()
1634 cupsFileRead(cups_file_t *fp, /* I - CUPS file */ in cupsFileRead() argument
1642 …DEBUG_printf(("2cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_… in cupsFileRead()
1648 if (!fp || !buf || (fp->mode != 'r' && fp->mode != 's')) in cupsFileRead()
1661 if (fp->ptr >= fp->end) in cupsFileRead()
1662 if (cups_fill(fp) <= 0) in cupsFileRead()
1673 count = (ssize_t)(fp->end - fp->ptr); in cupsFileRead()
1677 memcpy(buf, fp->ptr,(size_t) count); in cupsFileRead()
1678 fp->ptr += count; in cupsFileRead()
1679 fp->pos += count; in cupsFileRead()
1681 DEBUG_printf(("4cupsFileRead: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileRead()
1710 cupsFileRewind(cups_file_t *fp) /* I - CUPS file */ in cupsFileRewind() argument
1716 DEBUG_printf(("cupsFileRewind(fp=%p)", (void *)fp)); in cupsFileRewind()
1717 DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileRewind()
1719 if (!fp || fp->mode != 'r') in cupsFileRewind()
1726 if (fp->bufpos == 0) in cupsFileRewind()
1732 fp->pos = 0; in cupsFileRewind()
1734 if (fp->ptr) in cupsFileRewind()
1736 fp->ptr = fp->buf; in cupsFileRewind()
1737 fp->eof = 0; in cupsFileRewind()
1740 DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileRewind()
1750 if (fp->compressed) in cupsFileRewind()
1752 inflateEnd(&fp->stream); in cupsFileRewind()
1753 fp->compressed = 0; in cupsFileRewind()
1757 if (lseek(fp->fd, 0, SEEK_SET)) in cupsFileRewind()
1763 fp->bufpos = 0; in cupsFileRewind()
1764 fp->pos = 0; in cupsFileRewind()
1765 fp->ptr = NULL; in cupsFileRewind()
1766 fp->end = NULL; in cupsFileRewind()
1767 fp->eof = 0; in cupsFileRewind()
1769 DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileRewind()
1782 cupsFileSeek(cups_file_t *fp, /* I - CUPS file */ in cupsFileSeek() argument
1788 DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")", (void *)fp, CUPS_LLCAST pos)); in cupsFileSeek()
1789 DEBUG_printf(("2cupsFileSeek: fp->pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileSeek()
1790 DEBUG_printf(("2cupsFileSeek: fp->ptr=%p, fp->end=%p", (void *)fp->ptr, (void *)fp->end)); in cupsFileSeek()
1796 if (!fp || pos < 0 || fp->mode != 'r') in cupsFileSeek()
1804 return (cupsFileRewind(fp)); in cupsFileSeek()
1806 if (fp->ptr) in cupsFileSeek()
1808 bytes = (ssize_t)(fp->end - fp->buf); in cupsFileSeek()
1812 if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) in cupsFileSeek()
1818 fp->pos = pos; in cupsFileSeek()
1819 fp->ptr = fp->buf + pos - fp->bufpos; in cupsFileSeek()
1820 fp->eof = 0; in cupsFileSeek()
1827 if (!fp->compressed && !fp->ptr) in cupsFileSeek()
1833 if (cups_fill(fp) <= 0) in cupsFileSeek()
1842 fp->eof = 0; in cupsFileSeek()
1844 if (pos < fp->bufpos) in cupsFileSeek()
1853 if (fp->compressed) in cupsFileSeek()
1855 inflateEnd(&fp->stream); in cupsFileSeek()
1857 lseek(fp->fd, 0, SEEK_SET); in cupsFileSeek()
1858 fp->bufpos = 0; in cupsFileSeek()
1859 fp->pos = 0; in cupsFileSeek()
1860 fp->ptr = NULL; in cupsFileSeek()
1861 fp->end = NULL; in cupsFileSeek()
1863 while ((bytes = cups_fill(fp)) > 0) in cupsFileSeek()
1864 if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) in cupsFileSeek()
1870 fp->ptr = fp->buf + pos - fp->bufpos; in cupsFileSeek()
1871 fp->pos = pos; in cupsFileSeek()
1876 fp->bufpos = lseek(fp->fd, pos, SEEK_SET); in cupsFileSeek()
1877 fp->pos = fp->bufpos; in cupsFileSeek()
1878 fp->ptr = NULL; in cupsFileSeek()
1879 fp->end = NULL; in cupsFileSeek()
1882 CUPS_LLCAST fp->pos)); in cupsFileSeek()
1894 if (fp->compressed) in cupsFileSeek()
1896 while ((bytes = cups_fill(fp)) > 0) in cupsFileSeek()
1898 if (pos >= fp->bufpos && pos < (fp->bufpos + bytes)) in cupsFileSeek()
1905 fp->ptr = fp->buf + pos - fp->bufpos; in cupsFileSeek()
1906 fp->pos = pos; in cupsFileSeek()
1911 fp->bufpos = lseek(fp->fd, pos, SEEK_SET); in cupsFileSeek()
1912 fp->pos = fp->bufpos; in cupsFileSeek()
1913 fp->ptr = NULL; in cupsFileSeek()
1914 fp->end = NULL; in cupsFileSeek()
1917 CUPS_LLCAST fp->pos)); in cupsFileSeek()
1921 DEBUG_printf(("2cupsFileSeek: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileSeek()
1923 return (fp->pos); in cupsFileSeek()
2036 cupsFileTell(cups_file_t *fp) /* I - CUPS file */ in cupsFileTell() argument
2038 DEBUG_printf(("2cupsFileTell(fp=%p)", (void *)fp)); in cupsFileTell()
2039 DEBUG_printf(("3cupsFileTell: pos=" CUPS_LLFMT, CUPS_LLCAST (fp ? fp->pos : -1))); in cupsFileTell()
2041 return (fp ? fp->pos : 0); in cupsFileTell()
2052 cupsFileUnlock(cups_file_t *fp) /* I - CUPS file */ in cupsFileUnlock() argument
2058 DEBUG_printf(("cupsFileUnlock(fp=%p)", (void *)fp)); in cupsFileUnlock()
2060 if (!fp || fp->mode == 's') in cupsFileUnlock()
2068 return (_locking(fp->fd, _LK_UNLCK, 0)); in cupsFileUnlock()
2070 return (lockf(fp->fd, F_ULOCK, 0)); in cupsFileUnlock()
2082 cupsFileWrite(cups_file_t *fp, /* I - CUPS file */ in cupsFileWrite() argument
2090 …DEBUG_printf(("2cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS… in cupsFileWrite()
2092 if (!fp || !buf || (fp->mode != 'w' && fp->mode != 's')) in cupsFileWrite()
2102 if (fp->mode == 's') in cupsFileWrite()
2104 if (cups_write(fp, buf, bytes) < 0) in cupsFileWrite()
2107 fp->pos += (off_t)bytes; in cupsFileWrite()
2109 DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileWrite()
2114 if ((fp->ptr + bytes) > fp->end) in cupsFileWrite()
2115 if (cupsFileFlush(fp)) in cupsFileWrite()
2118 fp->pos += (off_t)bytes; in cupsFileWrite()
2120 DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); in cupsFileWrite()
2122 if (bytes > sizeof(fp->buf)) in cupsFileWrite()
2125 if (fp->compressed) in cupsFileWrite()
2126 return (cups_compress(fp, buf, bytes)); in cupsFileWrite()
2129 return (cups_write(fp, buf, bytes)); in cupsFileWrite()
2133 memcpy(fp->ptr, buf, bytes); in cupsFileWrite()
2134 fp->ptr += bytes; in cupsFileWrite()
2146 cups_compress(cups_file_t *fp, /* I - CUPS file */ in cups_compress() argument
2150 …DEBUG_printf(("7cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS… in cups_compress()
2156 fp->crc = crc32(fp->crc, (const Bytef *)buf, (uInt)bytes); in cups_compress()
2162 fp->stream.next_in = (Bytef *)buf; in cups_compress()
2163 fp->stream.avail_in = (uInt)bytes; in cups_compress()
2165 while (fp->stream.avail_in > 0) in cups_compress()
2172 fp->stream.avail_in, fp->stream.avail_out)); in cups_compress()
2174 if (fp->stream.avail_out < (uInt)(sizeof(fp->cbuf) / 8)) in cups_compress()
2176 if (cups_write(fp, (char *)fp->cbuf, (size_t)(fp->stream.next_out - fp->cbuf)) < 0) in cups_compress()
2179 fp->stream.next_out = fp->cbuf; in cups_compress()
2180 fp->stream.avail_out = sizeof(fp->cbuf); in cups_compress()
2183 deflate(&(fp->stream), Z_NO_FLUSH); in cups_compress()
2196 cups_fill(cups_file_t *fp) /* I - CUPS file */ in cups_fill() argument
2206 DEBUG_printf(("7cups_fill(fp=%p)", (void *)fp)); in cups_fill()
2207 …fpos=" CUPS_LLFMT ", fp->eof=%d", (void *)fp->ptr, (void *)fp->end, (void *)fp->buf, CUPS_LLCAST f… in cups_fill()
2209 if (fp->ptr && fp->end) in cups_fill()
2210 fp->bufpos += fp->end - fp->buf; in cups_fill()
2213 DEBUG_printf(("9cups_fill: fp->compressed=%d", fp->compressed)); in cups_fill()
2215 while (!fp->ptr || fp->compressed) in cups_fill()
2222 if (!fp->ptr) in cups_fill()
2228 fp->compressed = 0; in cups_fill()
2235 if ((bytes = cups_read(fp, (char *)fp->buf, sizeof(fp->buf))) < 0) in cups_fill()
2244 fp->eof = 1; in cups_fill()
2249 if (bytes < 10 || fp->buf[0] != 0x1f || in cups_fill()
2250 (fp->buf[1] & 255) != 0x8b || in cups_fill()
2251 fp->buf[2] != 8 || (fp->buf[3] & 0xe0) != 0) in cups_fill()
2257 fp->ptr = fp->buf; in cups_fill()
2258 fp->end = fp->buf + bytes; in cups_fill()
2270 ptr = (unsigned char *)fp->buf + 10; in cups_fill()
2271 end = (unsigned char *)fp->buf + bytes; in cups_fill()
2273 if (fp->buf[3] & 0x04) in cups_fill()
2287 fp->eof = 1; in cups_fill()
2304 fp->eof = 1; in cups_fill()
2311 if (fp->buf[3] & 0x08) in cups_fill()
2330 fp->eof = 1; in cups_fill()
2337 if (fp->buf[3] & 0x10) in cups_fill()
2356 fp->eof = 1; in cups_fill()
2363 if (fp->buf[3] & 0x02) in cups_fill()
2379 fp->eof = 1; in cups_fill()
2391 memcpy(fp->cbuf, ptr, (size_t)bytes); in cups_fill()
2397 fp->stream.zalloc = (alloc_func)0; in cups_fill()
2398 fp->stream.zfree = (free_func)0; in cups_fill()
2399 fp->stream.opaque = (voidpf)0; in cups_fill()
2400 fp->stream.next_in = (Bytef *)fp->cbuf; in cups_fill()
2401 fp->stream.next_out = NULL; in cups_fill()
2402 fp->stream.avail_in = (uInt)bytes; in cups_fill()
2403 fp->stream.avail_out = 0; in cups_fill()
2404 fp->crc = crc32(0L, Z_NULL, 0); in cups_fill()
2406 if ((status = inflateInit2(&(fp->stream), -15)) != Z_OK) in cups_fill()
2410 fp->eof = 1; in cups_fill()
2416 fp->compressed = 1; in cups_fill()
2419 if (fp->compressed) in cups_fill()
2425 if (fp->eof) in cups_fill()
2436 if (fp->stream.avail_in == 0) in cups_fill()
2438 if ((bytes = cups_read(fp, (char *)fp->cbuf, sizeof(fp->cbuf))) <= 0) in cups_fill()
2442 fp->eof = 1; in cups_fill()
2447 fp->stream.next_in = fp->cbuf; in cups_fill()
2448 fp->stream.avail_in = (uInt)bytes; in cups_fill()
2455 fp->stream.next_out = (Bytef *)fp->buf; in cups_fill()
2456 fp->stream.avail_out = sizeof(fp->buf); in cups_fill()
2458 status = inflate(&(fp->stream), Z_NO_FLUSH); in cups_fill()
2460 if (fp->stream.next_out > (Bytef *)fp->buf) in cups_fill()
2461 fp->crc = crc32(fp->crc, (Bytef *)fp->buf, in cups_fill()
2462 (uInt)(fp->stream.next_out - (Bytef *)fp->buf)); in cups_fill()
2474 if (fp->stream.avail_in > 0) in cups_fill()
2476 if (fp->stream.avail_in > sizeof(trailer)) in cups_fill()
2479 tbytes = (ssize_t)fp->stream.avail_in; in cups_fill()
2481 memcpy(trailer, fp->stream.next_in, (size_t)tbytes); in cups_fill()
2482 fp->stream.next_in += tbytes; in cups_fill()
2483 fp->stream.avail_in -= (size_t)tbytes; in cups_fill()
2488 …if (read(fp->fd, trailer + tbytes, sizeof(trailer) - (size_t)tbytes) < ((ssize_t)sizeof(trailer) -… in cups_fill()
2496 fp->eof = 1; in cups_fill()
2506 if (tcrc != fp->crc) in cups_fill()
2512 …9cups_fill: tcrc=%08x != fp->crc=%08x, returning -1.", (unsigned int)tcrc, (unsigned int)fp->crc)); in cups_fill()
2514 fp->eof = 1; in cups_fill()
2525 inflateEnd(&fp->stream); in cups_fill()
2527 fp->compressed = 0; in cups_fill()
2533 fp->eof = 1; in cups_fill()
2539 bytes = (ssize_t)sizeof(fp->buf) - (ssize_t)fp->stream.avail_out; in cups_fill()
2545 fp->ptr = fp->buf; in cups_fill()
2546 fp->end = fp->buf + bytes; in cups_fill()
2561 if ((bytes = cups_read(fp, fp->buf, sizeof(fp->buf))) <= 0) in cups_fill()
2567 fp->eof = 1; in cups_fill()
2568 fp->ptr = fp->buf; in cups_fill()
2569 fp->end = fp->buf; in cups_fill()
2577 fp->eof = 0; in cups_fill()
2578 fp->ptr = fp->buf; in cups_fill()
2579 fp->end = fp->buf + bytes; in cups_fill()
2681 cups_read(cups_file_t *fp, /* I - CUPS file */ in cups_read() argument
2688 …DEBUG_printf(("7cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLC… in cups_read()
2697 if (fp->mode == 's') in cups_read()
2698 total = (ssize_t)recv(fp->fd, buf, (unsigned)bytes, 0); in cups_read()
2700 total = (ssize_t)read(fp->fd, buf, (unsigned)bytes); in cups_read()
2702 if (fp->mode == 's') in cups_read()
2703 total = recv(fp->fd, buf, bytes, 0); in cups_read()
2705 total = read(fp->fd, buf, bytes); in cups_read()
2736 cups_write(cups_file_t *fp, /* I - CUPS file */ in cups_write() argument
2744 …DEBUG_printf(("7cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LL… in cups_write()
2754 if (fp->mode == 's') in cups_write()
2755 count = (ssize_t)send(fp->fd, buf, (unsigned)bytes, 0); in cups_write()
2757 count = (ssize_t)write(fp->fd, buf, (unsigned)bytes); in cups_write()
2759 if (fp->mode == 's') in cups_write()
2760 count = send(fp->fd, buf, bytes, 0); in cups_write()
2762 count = write(fp->fd, buf, bytes); in cups_write()