Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/psi/zfzlib.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2025 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* zlib and Flate filter creation */
18
#include "ghost.h"
19
#include "oper.h"
20
#include "idict.h"
21
#include "strimpl.h"
22
#include "spdiffx.h"
23
#include "spngpx.h"
24
#include "szlibx.h"
25
#include "idparam.h"
26
#include "ifilter.h"
27
#include "ifrpred.h"
28
#include "ifwpred.h"
29
30
/* Common setup for zlib (Flate) filter */
31
static int
32
filter_zlib(i_ctx_t *i_ctx_p, stream_zlib_state *pzls)
33
0
{
34
0
    os_ptr op = osp;
35
0
    int code = 0;
36
37
0
    (*s_zlibE_template.set_defaults)((stream_state *)pzls);
38
0
    if (r_has_type(op, t_dictionary))
39
0
        code = dict_int_param(op, "Effort", -1, 9, -1, &pzls->level);
40
0
    return code;
41
0
}
42
43
/* <source> FlateEncode/filter <file> */
44
/* <source> <dict> FlateEncode/filter <file> */
45
static int
46
zFlateE(i_ctx_t *i_ctx_p)
47
0
{
48
0
    stream_zlib_state zls;
49
0
    int code = filter_zlib(i_ctx_p, &zls);
50
51
0
    if (code < 0)
52
0
        return code;
53
0
    return filter_write_predictor(i_ctx_p, 0, &s_zlibE_template,
54
0
                                  (stream_state *)&zls);
55
0
}
56
57
/* <target> FlateDecode/filter <file> */
58
/* <target> <dict> FlateDecode/filter <file> */
59
static int
60
zFlateD(i_ctx_t *i_ctx_p)
61
0
{
62
0
    stream_zlib_state zls;
63
64
0
    (*s_zlibD_template.set_defaults)((stream_state *)&zls);
65
0
    return filter_read_predictor(i_ctx_p, 0, &s_zlibD_template,
66
0
                                 (stream_state *)&zls);
67
0
}
68
69
/* ------ Initialization procedure ------ */
70
71
const op_def zfzlib_op_defs[] =
72
{
73
    op_def_begin_filter(),
74
    {"1FlateEncode", zFlateE},
75
    {"1FlateDecode", zFlateD},
76
    op_def_end(0)
77
};