]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/gziptoany.c
Fix compile error.
[thirdparty/cups.git] / filter / gziptoany.c
CommitLineData
ef416fc2 1/*
f2d18633 2 * "$Id$"
ef416fc2 3 *
7e86f2f6 4 * GZIP/raw pre-filter for CUPS.
ef416fc2 5 *
8e333c29 6 * Copyright 2007-2015 by Apple Inc.
7e86f2f6 7 * Copyright 1993-2007 by Easy Software Products.
ef416fc2 8 *
7e86f2f6
MS
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/".
ef416fc2 14 *
7e86f2f6 15 * This file is subject to the Apple OS-Developed Software exception.
ef416fc2 16 */
17
18/*
19 * Include necessary headers...
20 */
21
71e16022 22#include <cups/cups-private.h>
ef416fc2 23
ef416fc2 24
25/*
f899b121 26 * 'main()' - Copy (and uncompress) files to stdout.
ef416fc2 27 */
28
29int /* O - Exit status */
30main(int argc, /* I - Number of command-line arguments */
31 char *argv[]) /* I - Command-line arguments */
32{
f899b121 33 cups_file_t *fp; /* File */
ef416fc2 34 char buffer[8192]; /* Data buffer */
7e86f2f6 35 ssize_t bytes; /* Number of bytes read/written */
ef416fc2 36 int copies; /* Number of copies */
ef416fc2 37
38
39 /*
40 * Check command-line...
41 */
42
8e333c29 43 if (argc < 6 || argc > 7)
ef416fc2 44 {
0837b7e8 45 _cupsLangPrintf(stderr,
f3c17241 46 _("Usage: %s job-id user title copies options [file]"),
0837b7e8 47 argv[0]);
ef416fc2 48 return (1);
49 }
50
51 /*
f899b121 52 * Get the copy count; if we have no final content type, this is a
53 * raw queue or raw print file, so we need to make copies...
ef416fc2 54 */
55
f899b121 56 if (!getenv("FINAL_CONTENT_TYPE"))
ef416fc2 57 copies = atoi(argv[4]);
58 else
59 copies = 1;
60
61 /*
f899b121 62 * Open the file...
ef416fc2 63 */
64
8e333c29 65 if (argc == 6)
ef416fc2 66 {
8e333c29
MS
67 copies = 1;
68 fp = cupsFileStdin();
69 }
70 else if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
71 {
72 fprintf(stderr, "DEBUG: Unable to open \"%s\".\n", argv[6]);
0837b7e8 73 _cupsLangPrintError("ERROR", _("Unable to open print file"));
ef416fc2 74 return (1);
75 }
76
77 /*
f899b121 78 * Copy the file to stdout...
ef416fc2 79 */
80
ef416fc2 81 while (copies > 0)
82 {
f42414bf 83 if (!getenv("FINAL_CONTENT_TYPE"))
84 fputs("PAGE: 1 1\n", stderr);
85
f899b121 86 cupsFileRewind(fp);
ef416fc2 87
f899b121 88 while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
7e86f2f6 89 if (write(1, buffer, (size_t)bytes) < bytes)
ef416fc2 90 {
0837b7e8
MS
91 _cupsLangPrintFilter(stderr, "ERROR",
92 _("Unable to write uncompressed print data: %s"),
c8fef167 93 strerror(errno));
8e333c29
MS
94 if (argc == 7)
95 cupsFileClose(fp);
ef416fc2 96
97 return (1);
98 }
99
100 copies --;
101 }
102
103 /*
104 * Close the file and return...
105 */
106
8e333c29
MS
107 if (argc == 7)
108 cupsFileClose(fp);
ef416fc2 109
110 return (0);
ef416fc2 111}
112
113
114/*
f2d18633 115 * End of "$Id$".
ef416fc2 116 */