]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
4 * GZIP/raw pre-filter for CUPS.
6 * Copyright 2007-2014 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 * Include necessary headers...
22 #include <cups/cups-private.h>
26 * 'main()' - Copy (and uncompress) files to stdout.
29 int /* O - Exit status */
30 main(int argc
, /* I - Number of command-line arguments */
31 char *argv
[]) /* I - Command-line arguments */
33 cups_file_t
*fp
; /* File */
34 char buffer
[8192]; /* Data buffer */
35 ssize_t bytes
; /* Number of bytes read/written */
36 int copies
; /* Number of copies */
40 * Check command-line...
45 _cupsLangPrintf(stderr
,
46 _("Usage: %s job-id user title copies options [file]"),
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...
56 if (!getenv("FINAL_CONTENT_TYPE"))
57 copies
= atoi(argv
[4]);
65 if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
67 _cupsLangPrintError("ERROR", _("Unable to open print file"));
72 * Copy the file to stdout...
77 if (!getenv("FINAL_CONTENT_TYPE"))
78 fputs("PAGE: 1 1\n", stderr
);
82 while ((bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
83 if (write(1, buffer
, (size_t)bytes
) < bytes
)
85 _cupsLangPrintFilter(stderr
, "ERROR",
86 _("Unable to write uncompressed print data: %s"),
97 * Close the file and return...