Mercurial > dnsbl
comparison src/scanner.cpp @ 75:1142e46be550
start coding on new config syntax
author | carl |
---|---|
date | Wed, 13 Jul 2005 23:04:14 -0700 |
parents | b7449114ebb0 |
children | 81f1e400e8ab |
comparison
equal
deleted
inserted
replaced
74:b7449114ebb0 | 75:1142e46be550 |
---|---|
7 */ | 7 */ |
8 | 8 |
9 #include "includes.h" | 9 #include "includes.h" |
10 | 10 |
11 static char* scanner_version="$Id$"; | 11 static char* scanner_version="$Id$"; |
12 | |
13 //////////////////////////////////////////////// | |
14 // finite state machine | |
15 // | |
16 enum state {// host name recognizer states | |
17 h_init, | |
18 h_host, | |
19 | |
20 // html tag discarder states | |
21 t_init, | |
22 t_tag1, // seen opening < | |
23 t_tag2, // not comment | |
24 t_com1, // seen ! | |
25 t_com2, // seen first - | |
26 t_com3, // seen second -, looking for --> | |
27 t_com4, // seen first - | |
28 t_com5, // seen second - | |
29 t_disc, // looking for closing > | |
30 | |
31 // url recognizer states | |
32 u_init, | |
33 u_http, | |
34 u_sla, | |
35 u_url, | |
36 | |
37 // url decoder states %xx | |
38 d_init, | |
39 d_pcnt, | |
40 d_1, | |
41 | |
42 // html entity decoder states &#nnn; | |
43 e_init, | |
44 e_amp, | |
45 e_num, | |
46 | |
47 // mime decoder states =xx | |
48 m_init, | |
49 m_eq, | |
50 m_1, | |
51 | |
52 // base64 decoder states | |
53 b_init, | |
54 b_lf, | |
55 b_lf2, | |
56 b_64, | |
57 | |
58 // uuencoding decoder states | |
59 uu_init, | |
60 uu_lf, | |
61 uu_lf2, | |
62 uu_64, | |
63 | |
64 // counter for number of columns in the table | |
65 end_state, | |
66 | |
67 // temporary states | |
68 h_end, | |
69 t_bin, | |
70 t_end, | |
71 u_reco, | |
72 d_2, | |
73 e_semi, | |
74 m_2, | |
75 m_cr, | |
76 m_nl, | |
77 b_cr, | |
78 uu_cr | |
79 }; | |
80 | |
81 #define PENDING_LIMIT 100 | |
82 class fsa { | |
83 u_char pending[PENDING_LIMIT]; | |
84 int count; | |
85 state st; | |
86 state init; | |
87 fsa *next1; | |
88 fsa *next2; | |
89 recorder *memory; | |
90 | |
91 public: | |
92 fsa(state init, fsa *next1_, fsa *next2_, recorder *memory_); | |
93 void push(u_char *buf, int len); | |
94 void pusher(); | |
95 void error(char *err); | |
96 }; | |
97 | |
12 | 98 |
13 typedef state PARSE[end_state]; | 99 typedef state PARSE[end_state]; |
14 | 100 |
15 static PARSE parse_table[256] = { | 101 static PARSE parse_table[256] = { |
16 // h_init, h_host, t_init, t_tag1, t_tag2, t_com1, t_com2, t_com3, t_com4, t_com5, t_disc, u_init, u_http, u_sla , u_url, d_init, d_pcnt, d_1, e_init, e_amp, e_num, m_init, m_eq, m_1, b_init, b_lf, b_lf2, b_64 uu_init, uu_lf, uu_lf2, uu_64 | 102 // h_init, h_host, t_init, t_tag1, t_tag2, t_com1, t_com2, t_com3, t_com4, t_com5, t_disc, u_init, u_http, u_sla , u_url, d_init, d_pcnt, d_1, e_init, e_amp, e_num, m_init, m_eq, m_1, b_init, b_lf, b_lf2, b_64 uu_init, uu_lf, uu_lf2, uu_64 |