]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/gziptoany.c
2 * GZIP/raw pre-filter for CUPS.
4 * Copyright 2007-2015 by Apple Inc.
5 * Copyright 1993-2007 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
17 * Include necessary headers...
20 #include <cups/cups-private.h>
24 * 'main()' - Copy (and uncompress) files to stdout.
27 int /* O - Exit status */
28 main(int argc
, /* I - Number of command-line arguments */
29 char *argv
[]) /* I - Command-line arguments */
31 cups_file_t
*fp
; /* File */
32 char buffer
[8192]; /* Data buffer */
33 ssize_t bytes
; /* Number of bytes read/written */
34 int copies
; /* Number of copies */
38 * Check command-line...
41 if (argc
< 6 || argc
> 7)
43 _cupsLangPrintf(stderr
,
44 _("Usage: %s job-id user title copies options [file]"),
50 * Get the copy count; if we have no final content type, this is a
51 * raw queue or raw print file, so we need to make copies...
54 if (!getenv("FINAL_CONTENT_TYPE"))
55 copies
= atoi(argv
[4]);
68 else if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
70 fprintf(stderr
, "DEBUG: Unable to open \"%s\".\n", argv
[6]);
71 _cupsLangPrintError("ERROR", _("Unable to open print file"));
76 * Copy the file to stdout...
81 if (!getenv("FINAL_CONTENT_TYPE"))
82 fputs("PAGE: 1 1\n", stderr
);
86 while ((bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
87 if (write(1, buffer
, (size_t)bytes
) < bytes
)
89 _cupsLangPrintFilter(stderr
, "ERROR",
90 _("Unable to write uncompressed print data: %s"),
102 * Close the file and return...