]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
9adc376fabb1f3911c9f9cab90d90f24f6cf4d89
4 * GZIP/raw pre-filter for CUPS.
6 * Copyright 2007-2015 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...
43 if (argc
< 6 || argc
> 7)
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]);
70 else if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
72 fprintf(stderr
, "DEBUG: Unable to open \"%s\".\n", argv
[6]);
73 _cupsLangPrintError("ERROR", _("Unable to open print file"));
78 * 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 (write(1, buffer
, (size_t)bytes
) < bytes
)
91 _cupsLangPrintFilter(stderr
, "ERROR",
92 _("Unable to write uncompressed print data: %s"),
104 * Close the file and return...