]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
2 * "$Id: gziptoany.c 4494 2005-02-18 02:18:11Z mike $"
4 * GZIP pre-filter for the Common UNIX Printing System (CUPS).
6 * Copyright 1993-2005 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
28 * main() - Uncompress gzip'd files and send them to stdout...
32 * Include necessary headers...
35 #include <cups/string.h>
41 #endif /* HAVE_LIBZ */
45 * 'main()' - Uncompress gzip'd files and send them to stdout...
48 int /* O - Exit status */
49 main(int argc
, /* I - Number of command-line arguments */
50 char *argv
[]) /* I - Command-line arguments */
53 gzFile fp
; /* GZIP'd file */
54 char buffer
[8192]; /* Data buffer */
55 int bytes
; /* Number of bytes read/written */
56 int copies
; /* Number of copies */
57 const char *content_type
; /* Content type for file... */
61 * Check command-line...
66 fputs("ERROR: gziptoany job-id user title copies options file\n", stderr
);
71 * Get the copy count; if the MIME type is "application/vnd.cups-raw" then
72 * make copies since the file is going straight to a backend...
75 if ((content_type
= getenv("CONTENT_TYPE")) != NULL
&&
76 !strcasecmp(content_type
, "application/vnd.cups-raw"))
77 copies
= atoi(argv
[4]);
82 * Open the gzip file...
85 if ((fp
= gzopen(argv
[6], "rb")) == NULL
)
87 fprintf(stderr
, "ERROR: Unable to open GZIP file: %s\n", strerror(errno
));
92 * Copy the gzip file to stdout...
101 while ((bytes
= gzread(fp
, buffer
, sizeof(buffer
))) > 0)
102 if (fwrite(buffer
, 1, bytes
, stdout
) < bytes
)
104 fprintf(stderr
, "ERROR: Unable to write uncompressed document data: %s\n",
105 strerror(ferror(stdout
)));
115 * Close the file and return...
122 fputs("INFO: Hint: recompile CUPS with ZLIB.\n", stderr
);
123 fputs("ERROR: GZIP compression support not compiled in!\n", stderr
);
125 #endif /* HAVE_LIBZ */
130 * End of "$Id: gziptoany.c 4494 2005-02-18 02:18:11Z mike $".