]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/zfzlib.c
Copyright update...
[thirdparty/cups.git] / pstoraster / zfzlib.c
1 /*
2 Copyright 1993-2002 by Easy Software Products
3 Copyright 1995, 1996, 1998 Aladdin Enterprises. All rights reserved.
4
5 This file is part of GNU Ghostscript.
6
7 GNU Ghostscript is distributed in the hope that it will be useful, but
8 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
9 to anyone for the consequences of using it or for whether it serves any
10 particular purpose or works at all, unless he says so in writing. Refer
11 to the GNU General Public License for full details.
12
13 Everyone is granted permission to copy, modify and redistribute GNU
14 Ghostscript, but only under the conditions described in the GNU General
15 Public License. A copy of this license is supposed to have been given
16 to you along with GNU Ghostscript so you can know your rights and
17 responsibilities. It should be in a file named COPYING. Among other
18 things, the copyright notice and this notice must be preserved on all
19 copies.
20
21 Aladdin Enterprises supports the work of the GNU Project, but is not
22 affiliated with the Free Software Foundation or the GNU Project. GNU
23 Ghostscript, as distributed by Aladdin Enterprises, does not require any
24 GNU software to build or run it.
25 */
26
27 #include <config.h>
28 #ifdef HAVE_LIBZ
29 /*$Id: zfzlib.c,v 1.6 2002/01/02 17:59:13 mike Exp $ */
30 /* zlib and Flate filter creation */
31 #include "ghost.h"
32 #include "oper.h"
33 #include "idict.h"
34 #include "strimpl.h"
35 #include "spdiffx.h"
36 #include "spngpx.h"
37 #include "szlibx.h"
38 #include "ifilter.h"
39
40 /* Import the Predictor machinery from zfdecode.c and zfilter2.c. */
41 int filter_read_predictor(P4(os_ptr op, int npop,
42 const stream_template * template,
43 stream_state * st));
44 int filter_write_predictor(P4(os_ptr op, int npop,
45 const stream_template * template,
46 stream_state * st));
47
48 /* <source> zlibEncode/filter <file> */
49 /* <source> <dict> zlibEncode/filter <file> */
50 private int
51 zzlibE(os_ptr op)
52 {
53 stream_zlib_state zls;
54
55 (*s_zlibE_template.set_defaults)((stream_state *)&zls);
56 return filter_write(op, 0, &s_zlibE_template, (stream_state *)&zls, 0);
57 }
58
59 /* <target> zlibDecode/filter <file> */
60 /* <target> <dict> zlibDecode/filter <file> */
61 private int
62 zzlibD(os_ptr op)
63 {
64 stream_zlib_state zls;
65
66 (*s_zlibD_template.set_defaults)((stream_state *)&zls);
67 return filter_read(op, 0, &s_zlibD_template, (stream_state *)&zls, 0);
68 }
69
70 /* <source> FlateEncode/filter <file> */
71 /* <source> <dict> FlateEncode/filter <file> */
72 private int
73 zFlateE(os_ptr op)
74 {
75 stream_zlib_state zls;
76
77 (*s_zlibE_template.set_defaults)((stream_state *)&zls);
78 return filter_write_predictor(op, 0, &s_zlibE_template,
79 (stream_state *)&zls);
80 }
81
82 /* <target> FlateDecode/filter <file> */
83 /* <target> <dict> FlateDecode/filter <file> */
84 private int
85 zFlateD(os_ptr op)
86 {
87 stream_zlib_state zls;
88
89 (*s_zlibD_template.set_defaults)((stream_state *)&zls);
90 return filter_read_predictor(op, 0, &s_zlibD_template,
91 (stream_state *)&zls);
92 }
93
94 /* ------ Initialization procedure ------ */
95
96 const op_def zfzlib_op_defs[] =
97 {
98 op_def_begin_filter(),
99 {"1zlibEncode", zzlibE},
100 {"1zlibDecode", zzlibD},
101 {"1FlateEncode", zFlateE},
102 {"1FlateDecode", zFlateD},
103 op_def_end(0)
104 };
105 #endif /* HAVE_LIBZ */