]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
2 * "$Id: gziptoany.c 6649 2007-07-11 21:46:42Z mike $"
4 * GZIP/raw pre-filter for CUPS.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1993-2007 by Easy Software Products.
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/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Copy (and uncompress) files to stdout.
23 * Include necessary headers...
26 #include <cups/cups-private.h>
30 * 'main()' - Copy (and uncompress) files to stdout.
33 int /* O - Exit status */
34 main(int argc
, /* I - Number of command-line arguments */
35 char *argv
[]) /* I - Command-line arguments */
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 */
44 * Check command-line...
49 _cupsLangPrintf(stderr
,
50 _("Usage: %s job-id user title copies options file"),
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...
60 if (!getenv("FINAL_CONTENT_TYPE"))
61 copies
= atoi(argv
[4]);
69 if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
71 _cupsLangPrintError("ERROR", _("Unable to open print file"));
76 * Copy the file to stdout...
83 if (!getenv("FINAL_CONTENT_TYPE"))
84 fputs("PAGE: 1 1\n", stderr
);
88 while ((bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
89 if (fwrite(buffer
, 1, bytes
, stdout
) < bytes
)
91 _cupsLangPrintFilter(stderr
, "ERROR",
92 _("Unable to write uncompressed print data: %s"),
93 strerror(ferror(stdout
)));
103 * Close the file and return...
113 * End of "$Id: gziptoany.c 6649 2007-07-11 21:46:42Z mike $".