File: mxbmse.h

package info (click to toggle)
egenix-mx-base 2.0.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,028 kB
  • ctags: 4,762
  • sloc: ansic: 14,965; python: 11,739; sh: 313; makefile: 117
file content (62 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download | duplicates (3)
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
#ifndef MXBMSE_H
#define MXBMSE_H
/* 
  mxbmse -- Fast Boyer Moore Search Algorithm (Version 0.8)

  The implementation is reentrant and thread safe. While the
  general idea behind the Boyer Moore algorithm are in the public
  domain, this implementation falls under the following copyright:

  Copyright (c) 1997-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
  Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com

                        All Rights Reserved

  See the documentation for copying information or contact the author
  (mal@lemburg.com).

*/

#ifdef __cplusplus
extern "C" {
#endif

/* sanity check switches */
/*#define SAFER 1*/

/* [X]SHIFT must have enough bits to store len(match) 
   - using 'char' here makes the routines run 15% slower than
     with 'int', on the other hand, 'int' is at least 4 times
     larger than 'char'
*/
#define SHIFT_TYPE int
#define XSHIFT_TYPE char

typedef struct {
    char *match;
    int len_match;
    char *eom;
    char *pt;
    SHIFT_TYPE shift[256]; /* char-based shift table */
} mxbmse_data;

/* Boyer-Moore Algorithm */

extern mxbmse_data *bm_init(char *match,
			      int len_match);
extern void bm_free(mxbmse_data *c);
extern int bm_search(mxbmse_data *c,
		     char *text,
		     int start,
		     int len_text);
extern int bm_tr_search(mxbmse_data *c,
			char *text,
			int start,
			int len_text,
			char *tr);

/* EOF */
#ifdef __cplusplus
}
#endif
#endif