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 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
70 | | |
71 | | |
72 | | |
73 | | |
74 | | |
75 | | |
76 | | |
77 | | |
78 | | |
79 | | |
80 | | |
81 | | |
82 | | |
83 | | |
84 | | |
85 | | |
86 | | |
87 | | |
88 | | |
89 | | |
90 | | |
91 | | |
92 | | |
93 | | |
94 | | |
95 | | |
96 | | |
97 | | |
98 | | |
99 | | |
100 | | |
101 | | |
| | | | | | | | #ifndef PIKE_SEARCH_H | #define PIKE_SEARCH_H | | #define MEMSEARCH_LINKS 512 | #define BMLEN 768 | #define CHARS 256 | #define TUNAFISH | | struct hubbe_search_link | { | struct hubbe_search_link *next; | ptrdiff_t offset; | INT32 key; | }; | | struct hubbe_searcher | { | void *needle; | ptrdiff_t needlelen; | | size_t hsize, max; | struct hubbe_search_link links[MEMSEARCH_LINKS]; | struct hubbe_search_link *set[MEMSEARCH_LINKS]; | }; | | struct boyer_moore_hubbe_searcher | { | void *needle; | ptrdiff_t needlelen; | | ptrdiff_t plen; | ptrdiff_t d1[CHARS+1]; | ptrdiff_t d2[BMLEN]; | }; | | struct SearchMojtS; | | #define FNORD(N,C) \ | typedef C (* PIKE_CONCAT(SearchMojtFunc,N) )(void*, C, size_t) | | | FNORD(0,p_wchar0 *); | FNORD(1,p_wchar1 *); | FNORD(2,p_wchar2 *); | FNORD(N,PCHARP); | | struct SearchMojtVtable | { | SearchMojtFunc0 func0; | SearchMojtFunc1 func1; | SearchMojtFunc2 func2; | SearchMojtFuncN funcN; | }; | | typedef struct SearchMojt | { | const struct SearchMojtVtable *vtab; | void *data; | struct object *container; | } SearchMojt; | | struct pike_mem_searcher | { | SearchMojt mojt; | struct pike_string *s; | union memsearcher_data | { | struct hubbe_searcher hubbe; | struct boyer_moore_hubbe_searcher bm; | } data; | }; | | | | PMOD_EXPORT void pike_init_memsearch(struct pike_mem_searcher *s, | PCHARP needle, | ptrdiff_t needlelen, | ptrdiff_t max_haystacklen); | PMOD_EXPORT SearchMojt compile_memsearcher(PCHARP needle, | ptrdiff_t needlelen, | int max_haystacklen, | struct pike_string *hashkey); | PMOD_EXPORT SearchMojt simple_compile_memsearcher(struct pike_string *str); | PMOD_EXPORT char *my_memmem(char *needle, | size_t needlelen, | char *haystack, | size_t haystacklen); | void init_pike_searching(void); | void exit_pike_searching(void); | | | #endif | | |
|