diff options
author | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2007-03-21 22:24:16 +0000 |
---|---|---|
committer | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2007-03-21 22:24:16 +0000 |
commit | f899b121701998b043508771602bb641a5f8d895 (patch) | |
tree | 5c2162ee35b1ed8baa8745020fda85a71c88945e /filter/gziptoany.c | |
parent | 7594b2247beeb33717701f1c58d243995d7ab81a (diff) | |
download | cups-f899b121701998b043508771602bb641a5f8d895.tar.gz |
Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@294 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'filter/gziptoany.c')
-rw-r--r-- | filter/gziptoany.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/filter/gziptoany.c b/filter/gziptoany.c index b83082fb4..9f246bd11 100644 --- a/filter/gziptoany.c +++ b/filter/gziptoany.c @@ -1,9 +1,9 @@ /* - * "$Id: gziptoany.c 4494 2005-02-18 02:18:11Z mike $" + * "$Id: gziptoany.c 6378 2007-03-21 07:18:18Z mike $" * - * GZIP pre-filter for the Common UNIX Printing System (CUPS). + * GZIP/raw pre-filter for the Common UNIX Printing System (CUPS). * - * Copyright 1993-2005 by Easy Software Products. + * Copyright 1993-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -25,36 +25,31 @@ * * Contents: * - * main() - Uncompress gzip'd files and send them to stdout... + * main() - Copy (and uncompress) files to stdout. */ /* * Include necessary headers... */ +#include <cups/file.h> #include <cups/string.h> #include <stdlib.h> #include <errno.h> -#ifdef HAVE_LIBZ -# include <zlib.h> -#endif /* HAVE_LIBZ */ - /* - * 'main()' - Uncompress gzip'd files and send them to stdout... + * 'main()' - Copy (and uncompress) files to stdout. */ int /* O - Exit status */ main(int argc, /* I - Number of command-line arguments */ char *argv[]) /* I - Command-line arguments */ { -#ifdef HAVE_LIBZ - gzFile fp; /* GZIP'd file */ + cups_file_t *fp; /* File */ char buffer[8192]; /* Data buffer */ int bytes; /* Number of bytes read/written */ int copies; /* Number of copies */ - const char *content_type; /* Content type for file... */ /* @@ -68,42 +63,43 @@ main(int argc, /* I - Number of command-line arguments */ } /* - * Get the copy count; if the MIME type is "application/vnd.cups-raw" then - * make copies since the file is going straight to a backend... + * Get the copy count; if we have no final content type, this is a + * raw queue or raw print file, so we need to make copies... */ - if ((content_type = getenv("CONTENT_TYPE")) != NULL && - !strcasecmp(content_type, "application/vnd.cups-raw")) + if (!getenv("FINAL_CONTENT_TYPE")) copies = atoi(argv[4]); else copies = 1; /* - * Open the gzip file... + * Open the file... */ - if ((fp = gzopen(argv[6], "rb")) == NULL) + if ((fp = cupsFileOpen(argv[6], "r")) == NULL) { - fprintf(stderr, "ERROR: Unable to open GZIP file: %s\n", strerror(errno)); + fprintf(stderr, "ERROR: Unable to open file \"%s\": %s\n", argv[6], + strerror(errno)); return (1); } /* - * Copy the gzip file to stdout... + * Copy the file to stdout... */ setbuf(stdout, NULL); while (copies > 0) { - gzrewind(fp); + cupsFileRewind(fp); - while ((bytes = gzread(fp, buffer, sizeof(buffer))) > 0) + while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) if (fwrite(buffer, 1, bytes, stdout) < bytes) { - fprintf(stderr, "ERROR: Unable to write uncompressed document data: %s\n", + fprintf(stderr, + "ERROR: Unable to write uncompressed document data: %s\n", strerror(ferror(stdout))); - gzclose(fp); + cupsFileClose(fp); return (1); } @@ -115,17 +111,12 @@ main(int argc, /* I - Number of command-line arguments */ * Close the file and return... */ - gzclose(fp); + cupsFileClose(fp); return (0); -#else - fputs("INFO: Hint: recompile CUPS with ZLIB.\n", stderr); - fputs("ERROR: GZIP compression support not compiled in!\n", stderr); - return (1); -#endif /* HAVE_LIBZ */ } /* - * End of "$Id: gziptoany.c 4494 2005-02-18 02:18:11Z mike $". + * End of "$Id: gziptoany.c 6378 2007-03-21 07:18:18Z mike $". */ |