]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/gziptoany.c
This commit was manufactured by cvs2svn to create branch 'branch-1.2'.
[thirdparty/cups.git] / filter / gziptoany.c
CommitLineData
2a5bf7e5 1/*
2 * "$Id: gziptoany.c,v 1.1 2003/03/30 21:43:00 mike Exp $"
3 *
4 * GZIP pre-filter for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1993-2003 by Easy Software Products.
7 *
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
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
19 *
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 *
26 * Contents:
27 *
28 * main() - Uncompress gzip'd files and send them to stdout...
29 */
30
31/*
32 * Include necessary headers...
33 */
34
35#include <cups/string.h>
36#include <errno.h>
37
38#ifdef HAVE_LIBZ
39# include <zlib.h>
40#endif /* HAVE_LIBZ */
41
42
43/*
44 * 'main()' - Uncompress gzip'd files and send them to stdout...
45 */
46
47int /* O - Exit status */
48main(int argc, /* I - Number of command-line arguments */
49 char *argv[]) /* I - Command-line arguments */
50{
51#ifdef HAVE_LIBZ
52 gzFile fp; /* GZIP'd file */
53 char buffer[8192]; /* Data buffer */
54 int bytes; /* Number of bytes read/written */
55
56
57 /*
58 * Check command-line...
59 */
60
61 if (argc != 7)
62 {
63 fputs("ERROR: gziptoany job-id user title copies options file\n", stderr);
64 return (1);
65 }
66
67 /*
68 * Open the gzip file...
69 */
70
71 if ((fp = gzopen(argv[6], "rb")) == NULL)
72 {
73 fprintf(stderr, "ERROR: Unable to open GZIP file: %s\n", strerror(errno));
74 return (1);
75 }
76
77 /*
78 * Copy the gzip file to stdout...
79 */
80
81 setbuf(stdout, NULL);
82
83 while ((bytes = gzread(fp, buffer, sizeof(buffer))) > 0)
84 if (fwrite(buffer, 1, bytes, stdout) < bytes)
85 {
86 fprintf(stderr, "ERROR: Unable to write uncompressed document data: %s\n",
87 strerror(ferror(stdout)));
88 gzclose(fp);
89
90 return (1);
91 }
92
93 /*
94 * Close the file and return...
95 */
96
97 gzclose(fp);
98
99 return (0);
100#else
101 fputs("INFO: Hint: recompile CUPS with ZLIB.\n", stderr);
102 fputs("ERROR: GZIP compression support not compiled in!\n", stderr);
103 return (1);
104#endif /* HAVE_LIBZ */
105}
106
107
108/*
109 * End of "$Id: gziptoany.c,v 1.1 2003/03/30 21:43:00 mike Exp $".
110 */