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

Function cupsFileClose

cups/file.c:344–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 */
343
344int /* O - 0 on success, -1 on error */
345cupsFileClose(cups_file_t *fp) /* I - CUPS file */
346{
347 int fd; /* File descriptor */
348 char mode; /* Open mode */
349 int status; /* Return status */
350
351
352 DEBUG_printf(("cupsFileClose(fp=%p)", (void *)fp));
353
354 /*
355 * Range check...
356 */
357
358 if (!fp)
359 return (-1);
360
361 /*
362 * Flush pending write data...
363 */
364
365 if (fp->mode == 'w')
366 status = cupsFileFlush(fp);
367 else
368 status = 0;
369
370#ifdef HAVE_LIBZ
371 if (fp->compressed && status >= 0)
372 {
373 if (fp->mode == 'r')
374 {
375 /*
376 * Free decompression data...
377 */
378
379 inflateEnd(&fp->stream);
380 }
381 else
382 {
383 /*
384 * Flush any remaining compressed data...
385 */
386
387 unsigned char trailer[8]; /* Trailer CRC and length */
388 int done; /* Done writing... */
389
390
391 fp->stream.avail_in = 0;
392
393 for (done = 0;;)
394 {
395 if (fp->stream.next_out > fp->cbuf)
396 {
397 if (cups_write(fp, (char *)fp->cbuf,
398 (size_t)(fp->stream.next_out - fp->cbuf)) < 0)
399 status = -1;
400
401 fp->stream.next_out = fp->cbuf;

Callers 15

mainFunction · 0.85
do_testFunction · 0.85
mime_load_convsFunction · 0.85
mime_load_typesFunction · 0.85
cupsdCheckLogFileFunction · 0.85
mainFunction · 0.85
cat_drvFunction · 0.85
cat_staticFunction · 0.85
cat_tarFunction · 0.85
list_ppdsFunction · 0.85
load_driversFunction · 0.85

Calls 3

cupsFileFlushFunction · 0.85
cups_writeFunction · 0.85
httpAddrCloseFunction · 0.85

Tested by 8

mainFunction · 0.68
check_basicsFunction · 0.68
mainFunction · 0.68
print_fileFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
random_testsFunction · 0.68
read_write_testsFunction · 0.68