]>
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 the Common UNIX Printing System (CUPS).
6 * Copyright 2007 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/file.h>
27 #include <cups/string.h>
28 #include <cups/i18n.h>
34 * 'main()' - Copy (and uncompress) files to stdout.
37 int /* O - Exit status */
38 main(int argc
, /* I - Number of command-line arguments */
39 char *argv
[]) /* I - Command-line arguments */
41 cups_file_t
*fp
; /* File */
42 char buffer
[8192]; /* Data buffer */
43 int bytes
; /* Number of bytes read/written */
44 int copies
; /* Number of copies */
48 * Check command-line...
53 fprintf(stderr
, _("Usage: %s job-id user title copies options file\n"),
59 * Get the copy count; if we have no final content type, this is a
60 * raw queue or raw print file, so we need to make copies...
63 if (!getenv("FINAL_CONTENT_TYPE"))
64 copies
= atoi(argv
[4]);
72 if ((fp
= cupsFileOpen(argv
[6], "r")) == NULL
)
74 fprintf(stderr
, _("ERROR: Unable to open file \"%s\": %s\n"), argv
[6],
80 * Copy the file to stdout...
87 if (!getenv("FINAL_CONTENT_TYPE"))
88 fputs("PAGE: 1 1\n", stderr
);
92 while ((bytes
= cupsFileRead(fp
, buffer
, sizeof(buffer
))) > 0)
93 if (fwrite(buffer
, 1, bytes
, stdout
) < bytes
)
96 _("ERROR: Unable to write uncompressed document data: %s\n"),
97 strerror(ferror(stdout
)));
107 * Close the file and return...
117 * End of "$Id: gziptoany.c 6649 2007-07-11 21:46:42Z mike $".