summaryrefslogtreecommitdiff
path: root/cups/file.c
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2018-10-17 11:31:45 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2018-10-17 11:31:45 -0400
commit5a855d856a17c7986e5396c38f8e75616775983a (patch)
tree6157dd12679bc856336c0477776876d189302658 /cups/file.c
parent104c5283581719f72d18cd5038aaeb21387695d4 (diff)
downloadcups-5a855d856a17c7986e5396c38f8e75616775983a.tar.gz
Remove dependency on zlib headers outside of libcups.
Diffstat (limited to 'cups/file.c')
-rw-r--r--cups/file.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/cups/file.c b/cups/file.c
index 5356d5ce6..759f6dc5d 100644
--- a/cups/file.c
+++ b/cups/file.c
@@ -6,10 +6,11 @@
* our own file functions allows us to provide transparent support of
* different line endings, gzip'd print files, PPD files, etc.
*
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
@@ -20,6 +21,39 @@
#include <sys/stat.h>
#include <sys/types.h>
+# ifdef HAVE_LIBZ
+# include <zlib.h>
+# endif /* HAVE_LIBZ */
+
+
+/*
+ * Internal structures...
+ */
+
+struct _cups_file_s /**** CUPS file structure... ****/
+
+{
+ int fd; /* File descriptor */
+ char mode, /* Mode ('r' or 'w') */
+ compressed, /* Compression used? */
+ is_stdio, /* stdin/out/err? */
+ eof, /* End of file? */
+ buf[4096], /* Buffer */
+ *ptr, /* Pointer into buffer */
+ *end; /* End of buffer data */
+ off_t pos, /* Position in file */
+ bufpos; /* File position for start of buffer */
+
+#ifdef HAVE_LIBZ
+ z_stream stream; /* (De)compression stream */
+ Bytef cbuf[4096]; /* (De)compression buffer */
+ uLong crc; /* (De)compression CRC */
+#endif /* HAVE_LIBZ */
+
+ char *printf_buffer; /* cupsFilePrintf buffer */
+ size_t printf_size; /* Size of cupsFilePrintf buffer */
+};
+
/*
* Local functions...
@@ -1258,6 +1292,18 @@ cupsFileOpenFd(int fd, /* I - File descriptor */
/*
+ * '_cupsFilePeekAhead()' - See if the requested character is buffered up.
+ */
+
+int /* O - 1 if present, 0 otherwise */
+_cupsFilePeekAhead(cups_file_t *fp, /* I - CUPS file */
+ int ch) /* I - Character */
+{
+ return (fp && fp->ptr && memchr(fp->ptr, ch, (size_t)(fp->end - fp->ptr)));
+}
+
+
+/*
* 'cupsFilePeekChar()' - Peek at the next character from a file.
*
* @since CUPS 1.2/macOS 10.5@