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