-
Notifications
You must be signed in to change notification settings - Fork 9
/
wumanber_impl.h
55 lines (46 loc) · 1.63 KB
/
wumanber_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* wumanber_impl.h -- data structures and API for wumanber_impl.c
*
* Copyright (C) 2010, Juergen Weigert, Novell inc.
* Distribute,modify under GPLv2 or GPLv3, or perl license.
*/
#define N_SYMB 256 // characters per byte
#define SHIFT_SZ 4096 // sizeof shift_min
#define PAT_HASH_SZ 8192 // =(1<<13), must be a power of two
#define W_DELIM 128 // magic, unused
#define L_DELIM 10 // must be '\n', unused
struct pat_list
{
int index;
struct pat_list *next;
};
struct WuManber
{
unsigned int n_pat; // number of patterns;
unsigned char **patt; // list of patterns;
unsigned int *pat_len; // length array of patterns;
unsigned char tr[N_SYMB];
unsigned char tr1[N_SYMB];
int use_bs3;
int use_bs1;
int p_size;
unsigned char shift_min[SHIFT_SZ];
struct pat_list *pat_hash[PAT_HASH_SZ];
int n_matches;
#if 0
int match_word_boundaries;
int match_whole_line;
#endif
int nocase;
int one_match_per_line; // report all patterns that match in a line. (unlike agrep)
int one_match_per_offset; // report all patterns that would match at an offset. (unlike agrep)
void (*cb)(unsigned int idx, unsigned long off, void *data);
void *cb_data;
char *progname;
};
struct WuManber *wm_search_init(unsigned char **pat_list, int n_pat, int nocase, char*progname);
void wm_search_prep_pat(struct WuManber *wm, int n_pat, unsigned char **pat_p, int nocase);
void wm_search_defaults(struct WuManber *wm, char *name);
unsigned int wm_search_text(struct WuManber *wm, unsigned char *text, int end,
void (*)(unsigned int idx, unsigned long off, void *data), void *data);
void wm_search_free(struct WuManber **wmp);