]>
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 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include <cups/cups-private.h>
18 * 'main()' - Copy (and uncompress) files to stdout.
21 int /* O - Exit status */
22 main(int argc
, /* I - Number of command-line arguments */
23 char *argv
[]) /* I - Command-line arguments */
25 cups_file_t
*fp
; /* File */
26 char buffer
[8192]; /* Data buffer */
27 ssize_t bytes
; /* Number of bytes read/written */
28 int copies
; /* Number of copies */
32 * Check command-line...
35 if (argc
< 6 || argc
> 7)
37 _cupsLangPrintf(stderr
,
38 _("Usage: %s job-id user title copies options [file]"),
44 * Get the copy count; if we have no final content type, this is a
45 * raw queue or raw print file, so we need to make copies...
48 if (!getenv("FINAL_CONTENT_TYPE"))
49 copies
= atoi(argv
[4]);
62 else if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
64 fprintf(stderr
, "DEBUG: Unable to open \"%s\".\n", argv
[6]);
65 _cupsLangPrintError("ERROR", _("Unable to open print file"));
70 * Copy the file to stdout...
75 if (!getenv("FINAL_CONTENT_TYPE"))
76 fputs("PAGE: 1 1\n", stderr
);
80 while ((bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
81 if (write(1, buffer
, (size_t)bytes
) < bytes
)
83 _cupsLangPrintFilter(stderr
, "ERROR",
84 _("Unable to write uncompressed print data: %s"),
96 * Close the file and return...