]> git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
Update svn:keyword properties.
[thirdparty/cups.git] / filter / gziptoany.c
1 /*
2 * "$Id$"
3 *
4 * GZIP/raw pre-filter for CUPS.
5 *
6 * Copyright 2007-2012 by Apple Inc.
7 * Copyright 1993-2007 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 *
17 * Contents:
18 *
19 * main() - Copy (and uncompress) files to stdout.
20 */
21
22 /*
23 * Include necessary headers...
24 */
25
26 #include <cups/cups-private.h>
27
28
29 /*
30 * 'main()' - Copy (and uncompress) files to stdout.
31 */
32
33 int /* O - Exit status */
34 main(int argc, /* I - Number of command-line arguments */
35 char *argv[]) /* I - Command-line arguments */
36 {
37 cups_file_t *fp; /* File */
38 char buffer[8192]; /* Data buffer */
39 int bytes; /* Number of bytes read/written */
40 int copies; /* Number of copies */
41
42
43 /*
44 * Check command-line...
45 */
46
47 if (argc != 7)
48 {
49 _cupsLangPrintf(stderr,
50 _("Usage: %s job-id user title copies options [file]"),
51 argv[0]);
52 return (1);
53 }
54
55 /*
56 * Get the copy count; if we have no final content type, this is a
57 * raw queue or raw print file, so we need to make copies...
58 */
59
60 if (!getenv("FINAL_CONTENT_TYPE"))
61 copies = atoi(argv[4]);
62 else
63 copies = 1;
64
65 /*
66 * Open the file...
67 */
68
69 if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
70 {
71 _cupsLangPrintError("ERROR", _("Unable to open print file"));
72 return (1);
73 }
74
75 /*
76 * Copy the file to stdout...
77 */
78
79 while (copies > 0)
80 {
81 if (!getenv("FINAL_CONTENT_TYPE"))
82 fputs("PAGE: 1 1\n", stderr);
83
84 cupsFileRewind(fp);
85
86 while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
87 if (write(1, buffer, bytes) < bytes)
88 {
89 _cupsLangPrintFilter(stderr, "ERROR",
90 _("Unable to write uncompressed print data: %s"),
91 strerror(errno));
92 cupsFileClose(fp);
93
94 return (1);
95 }
96
97 copies --;
98 }
99
100 /*
101 * Close the file and return...
102 */
103
104 cupsFileClose(fp);
105
106 return (0);
107 }
108
109
110 /*
111 * End of "$Id$".
112 */