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

Function cups_fill

cups/file.c:2265–2665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2263 */
2264
2265static ssize_t /* O - Number of bytes or -1 */
2266cups_fill(cups_file_t *fp) /* I - CUPS file */
2267{
2268 ssize_t bytes; /* Number of bytes read */
2269#ifdef HAVE_LIBZ
2270 int status; /* Decompression status */
2271 const unsigned char *ptr, /* Pointer into buffer */
2272 *end; /* End of buffer */
2273#endif /* HAVE_LIBZ */
2274
2275
2276 DEBUG_printf(("7cups_fill(fp=%p)", (void *)fp));
2277 DEBUG_printf(("9cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, fp->bufpos=" CUPS_LLFMT ", fp->eof=%d", (void *)fp->ptr, (void *)fp->end, (void *)fp->buf, CUPS_LLCAST fp->bufpos, fp->eof));
2278
2279 if (fp->ptr && fp->end)
2280 fp->bufpos += fp->end - fp->buf;
2281
2282#ifdef HAVE_LIBZ
2283 DEBUG_printf(("9cups_fill: fp->compressed=%d", fp->compressed));
2284
2285 while (!fp->ptr || fp->compressed)
2286 {
2287 /*
2288 * Check to see if we have read any data yet; if not, see if we have a
2289 * compressed file...
2290 */
2291
2292 if (!fp->ptr)
2293 {
2294 /*
2295 * Reset the file position in case we are seeking...
2296 */
2297
2298 fp->compressed = 0;
2299
2300 /*
2301 * Read the first bytes in the file to determine if we have a gzip'd
2302 * file...
2303 */
2304
2305 if ((bytes = cups_read(fp, (char *)fp->buf, sizeof(fp->buf))) < 0)
2306 {
2307 /*
2308 * Can't read from file!
2309 */
2310
2311 DEBUG_printf(("9cups_fill: cups_read() returned " CUPS_LLFMT,
2312 CUPS_LLCAST bytes));
2313
2314 fp->eof = 1;
2315
2316 return (-1);
2317 }
2318
2319 if (bytes < 10 || fp->buf[0] != 0x1f ||
2320 (fp->buf[1] & 255) != 0x8b ||
2321 fp->buf[2] != 8 || (fp->buf[3] & 0xe0) != 0)
2322 {

Callers 6

cupsFileGetCharFunction · 0.85
cupsFileGetLineFunction · 0.85
cupsFileGetsFunction · 0.85
cupsFilePeekCharFunction · 0.85
cupsFileReadFunction · 0.85
cupsFileSeekFunction · 0.85

Calls 1

cups_readFunction · 0.85

Tested by

no test coverage detected