]> wimlib.net Git - wimlib/blob - src/lz_null.c
Use --enable-ssse3-sha1 for x86_64 Windows builds
[wimlib] / src / lz_null.c
1 /*
2  * lz_null.c
3  *
4  * Dummy "match-finder" for Lempel-Ziv compression.
5  *
6  * Copyright (c) 2014 Eric Biggers.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 #  include "config.h"
34 #endif
35
36 #include "wimlib/lz_mf.h"
37
38 static bool
39 lz_null_params_valid(const struct lz_mf_params *_params)
40 {
41         return true;
42 }
43
44 static u64
45 lz_null_get_needed_memory(u32 max_window_size)
46 {
47         return 0;
48 }
49
50 static bool
51 lz_null_init(struct lz_mf *mf)
52 {
53         if (mf->params.min_match_len == 0)
54                 mf->params.min_match_len = 2;
55
56         if (mf->params.max_match_len == 0)
57                 mf->params.max_match_len = mf->params.max_window_size;
58
59         return true;
60 }
61
62 static void
63 lz_null_load_window(struct lz_mf *mf, const u8 window[], u32 size)
64 {
65 }
66
67 static u32
68 lz_null_get_matches(struct lz_mf *mf, struct lz_match matches[])
69 {
70         mf->cur_window_pos++;
71         return 0;
72 }
73
74 static void
75 lz_null_skip_positions(struct lz_mf *mf, u32 n)
76 {
77         mf->cur_window_pos += n;
78 }
79
80 static void
81 lz_null_destroy(struct lz_mf *mf)
82 {
83 }
84
85 const struct lz_mf_ops lz_null_ops = {
86         .params_valid      = lz_null_params_valid,
87         .get_needed_memory = lz_null_get_needed_memory,
88         .init              = lz_null_init,
89         .load_window       = lz_null_load_window,
90         .get_matches       = lz_null_get_matches,
91         .skip_positions    = lz_null_skip_positions,
92         .destroy           = lz_null_destroy,
93         .struct_size       = sizeof(struct lz_mf),
94 };