]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/gziptoany.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / filter / gziptoany.c
CommitLineData
ef416fc2 1/*
7e86f2f6 2 * GZIP/raw pre-filter for CUPS.
ef416fc2 3 *
8e333c29 4 * Copyright 2007-2015 by Apple Inc.
7e86f2f6 5 * Copyright 1993-2007 by Easy Software Products.
ef416fc2 6 *
7e86f2f6
MS
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/".
ef416fc2 12 *
7e86f2f6 13 * This file is subject to the Apple OS-Developed Software exception.
ef416fc2 14 */
15
16/*
17 * Include necessary headers...
18 */
19
71e16022 20#include <cups/cups-private.h>
ef416fc2 21
ef416fc2 22
23/*
f899b121 24 * 'main()' - Copy (and uncompress) files to stdout.
ef416fc2 25 */
26
27int /* O - Exit status */
28main(int argc, /* I - Number of command-line arguments */
29 char *argv[]) /* I - Command-line arguments */
30{
f899b121 31 cups_file_t *fp; /* File */
ef416fc2 32 char buffer[8192]; /* Data buffer */
7e86f2f6 33 ssize_t bytes; /* Number of bytes read/written */
ef416fc2 34 int copies; /* Number of copies */
ef416fc2 35
36
37 /*
38 * Check command-line...
39 */
40
8e333c29 41 if (argc < 6 || argc > 7)
ef416fc2 42 {
0837b7e8 43 _cupsLangPrintf(stderr,
f3c17241 44 _("Usage: %s job-id user title copies options [file]"),
0837b7e8 45 argv[0]);
ef416fc2 46 return (1);
47 }
48
49 /*
f899b121 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...
ef416fc2 52 */
53
f899b121 54 if (!getenv("FINAL_CONTENT_TYPE"))
ef416fc2 55 copies = atoi(argv[4]);
56 else
57 copies = 1;
58
59 /*
f899b121 60 * Open the file...
ef416fc2 61 */
62
8e333c29 63 if (argc == 6)
ef416fc2 64 {
8e333c29
MS
65 copies = 1;
66 fp = cupsFileStdin();
67 }
68 else if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
69 {
70 fprintf(stderr, "DEBUG: Unable to open \"%s\".\n", argv[6]);
0837b7e8 71 _cupsLangPrintError("ERROR", _("Unable to open print file"));
ef416fc2 72 return (1);
73 }
74
75 /*
f899b121 76 * Copy the file to stdout...
ef416fc2 77 */
78
ef416fc2 79 while (copies > 0)
80 {
f42414bf 81 if (!getenv("FINAL_CONTENT_TYPE"))
82 fputs("PAGE: 1 1\n", stderr);
83
f899b121 84 cupsFileRewind(fp);
ef416fc2 85
f899b121 86 while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
7e86f2f6 87 if (write(1, buffer, (size_t)bytes) < bytes)
ef416fc2 88 {
0837b7e8
MS
89 _cupsLangPrintFilter(stderr, "ERROR",
90 _("Unable to write uncompressed print data: %s"),
c8fef167 91 strerror(errno));
8e333c29
MS
92 if (argc == 7)
93 cupsFileClose(fp);
ef416fc2 94
95 return (1);
96 }
97
98 copies --;
99 }
100
101 /*
102 * Close the file and return...
103 */
104
8e333c29
MS
105 if (argc == 7)
106 cupsFileClose(fp);
ef416fc2 107
108 return (0);
ef416fc2 109}