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