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