/* Copyright (C) 1995, 2000 artofcode LLC. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307. */ /*$Id: zfzlib.c,v 1.3.6.1.2.1 2003/01/17 00:49:06 giles Exp $ */ /* zlib and Flate filter creation */ #include "ghost.h" #include "oper.h" #include "idict.h" #include "strimpl.h" #include "spdiffx.h" #include "spngpx.h" #include "szlibx.h" #include "idparam.h" #include "ifilter.h" #include "ifrpred.h" #include "ifwpred.h" /* Common setup for zlib (Flate) filter */ private int filter_zlib(i_ctx_t *i_ctx_p, stream_zlib_state *pzls) { os_ptr op = osp; int code = 0; (*s_zlibE_template.set_defaults)((stream_state *)pzls); if (r_has_type(op, t_dictionary)) code = dict_int_param(op, "Effort", -1, 9, -1, &pzls->level); return code; } /* zlibEncode/filter */ /* zlibEncode/filter */ private int zzlibE(i_ctx_t *i_ctx_p) { stream_zlib_state zls; int code = filter_zlib(i_ctx_p, &zls); if (code < 0) return code; return filter_write(i_ctx_p, 0, &s_zlibE_template, (stream_state *)&zls, 0); } /* zlibDecode/filter */ /* zlibDecode/filter */ private int zzlibD(i_ctx_t *i_ctx_p) { stream_zlib_state zls; (*s_zlibD_template.set_defaults)((stream_state *)&zls); return filter_read(i_ctx_p, 0, &s_zlibD_template, (stream_state *)&zls, 0); } /* FlateEncode/filter */ /* FlateEncode/filter */ private int zFlateE(i_ctx_t *i_ctx_p) { stream_zlib_state zls; int code = filter_zlib(i_ctx_p, &zls); if (code < 0) return code; return filter_write_predictor(i_ctx_p, 0, &s_zlibE_template, (stream_state *)&zls); } /* FlateDecode/filter */ /* FlateDecode/filter */ private int zFlateD(i_ctx_t *i_ctx_p) { stream_zlib_state zls; (*s_zlibD_template.set_defaults)((stream_state *)&zls); return filter_read_predictor(i_ctx_p, 0, &s_zlibD_template, (stream_state *)&zls); } /* ------ Initialization procedure ------ */ const op_def zfzlib_op_defs[] = { op_def_begin_filter(), {"1zlibEncode", zzlibE}, {"1zlibDecode", zzlibD}, {"1FlateEncode", zFlateE}, {"1FlateDecode", zFlateD}, op_def_end(0) };