1 %option nodefault 2 %option nomain 3 %option noyywrap 4 %option prefix="dump_" 5 6 num [0-9]{1,} 7 byte [0-9]{1,3} 8 ipaddr {byte}"."{byte}"."{byte}"."{byte} 9 ip6addr ([0-9a-fA-F]*:){2,}[0-9a-fA-F]*(%[0-9a-zA-Z]+)? 10 atext [A-Za-z0-9!#$%&'*+/=?$^_`}{|~.-]{1,} 11 qtext "\""[!-~]{1,}"\"" 12 mailbox {atext}|{qtext} 13 domain [A-Za-z0-9._-]{1,} 14 email "<"?{mailbox}"\@"?{domain}?">"? 15 void_email "<>" 16 comment #.*$ 17 blank [ \t]{1,} 18 auto [Aa][Uu][Tt][Oo] 19 tarpit [Tt][Aa][Rr][Pp][Ii][Tt] 20 21 %{ 22 #include "config.h" 23 24 #ifdef HAVE_SYS_CDEFS_H 25 #ifndef HAVE_BROKEN_RCSID 26 #include <sys/cdefs.h> 27 #ifdef __RCSID 28 __RCSID("$Id: dump_lex.l,v 1.22 2009/09/07 12:56:54 manu Exp $"); 29 #endif 30 #endif 31 #endif 32 33 #include <string.h> 34 #include <errno.h> 35 #include <syslog.h> 36 #include <sysexits.h> 37 #ifdef USE_DMALLOC 38 #include <dmalloc.h> 39 #endif 40 41 #define YY_NO_UNPUT 42 43 int dump_line = 1; 44 %} 45 46 %% 47 {auto} { return AUTO; } 48 {tarpit} { return TARPIT; } 49 {blank} 50 {comment} 51 {ipaddr} { 52 socklen_t salen = sizeof(yylval.ipaddr); 53 54 if (ipfromstring(yytext, SA(&yylval.ipaddr), &salen, 55 AF_INET) != 1) 56 REJECT; 57 return IPADDR; 58 } 59 {ip6addr} { 60 #ifdef AF_INET6 61 socklen_t salen = sizeof(yylval.ip6addr); 62 63 if (ipfromstring(yytext, SA(&yylval.ip6addr), &salen, 64 AF_INET6) != 1) 65 REJECT; 66 #endif 67 return IP6ADDR; 68 } 69 {num} { 70 yylval.time = atoi(yytext); 71 return TIME; 72 } 73 {email}|{void_email} { 74 strncpy(yylval.email, yytext, ADDRLEN); 75 yylval.email[ADDRLEN] = '\0'; 76 return EMAIL; 77 } 78 \n { 79 dump_line++; 80 return yytext[0]; 81 } 82 <*>.|\n { 83 mg_log(LOG_DEBUG, 84 "unknown token \"%s\" line %d, skipping\n", 85 yytext, dump_line); 86 return GARBAGE; 87 } 88 %% 89 90 void 91 yyerror(err) 92 char *err; 93 { 94 mg_log(LOG_DEBUG, "dump error at line %d: %s\n", dump_line, err); 95 return; 96 } 97 98 void 99 dump_dispose_input_file(void) { 100 dump__flush_buffer(YY_CURRENT_BUFFER); 101 } 102