Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 101 lines (90 sloc) 1.866 kb
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
%option nodefault
%option nomain
%option noyywrap
%option prefix="dump_"

num [0-9]{1,}
byte [0-9]{1,3}
ipaddr {byte}"."{byte}"."{byte}"."{byte}
ip6addr ([0-9a-fA-F]*:){2,}[0-9a-fA-F]*(%[0-9a-zA-Z]+)?
atext [A-Za-z0-9!#$%&'*+/=?$^_`}{|~.-]{1,}
qtext "\""[!-~]{1,}"\""
mailbox {atext}|{qtext}
domain [A-Za-z0-9._-]{1,}
email "<"?{mailbox}"\@"?{domain}?">"?
void_email "<>"
comment #.*$
blank [ \t]{1,}
auto [Aa][Uu][Tt][Oo]
tarpit [Tt][Aa][Rr][Pp][Ii][Tt]

%{
#include "config.h"

#ifdef HAVE_SYS_CDEFS_H
#ifndef HAVE_BROKEN_RCSID
#include <sys/cdefs.h>
#ifdef __RCSID
__RCSID("$Id: dump_lex.l,v 1.21 2007/07/08 21:02:28 manu Exp $");
#endif
#endif
#endif

#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <sysexits.h>
#ifdef USE_DMALLOC
#include <dmalloc.h>
#endif

#define YY_NO_UNPUT

int dump_line = 1;
%}

%%
{auto} { return AUTO; }
{tarpit} { return TARPIT; }
{blank}
{comment}
{ipaddr} {
socklen_t salen = sizeof(yylval.ipaddr);

if (ipfromstring(yytext, SA(&yylval.ipaddr), &salen,
AF_INET) != 1)
REJECT;
return IPADDR;
}
{ip6addr} {
#ifdef AF_INET6
socklen_t salen = sizeof(yylval.ip6addr);

if (ipfromstring(yytext, SA(&yylval.ip6addr), &salen,
AF_INET6) != 1)
REJECT;
#endif
return IP6ADDR;
}
{num} {
yylval.time = atoi(yytext);
return TIME;
}
{email}|{void_email} {
strncpy(yylval.email, yytext, ADDRLEN);
yylval.email[ADDRLEN] = '\0';
return EMAIL;
}
\n {
dump_line++;
return yytext[0];
}
<*>.|\n {
mg_log(LOG_DEBUG,
"unknown token \"%s\" line %d, skipping\n",
yytext, dump_line);
return GARBAGE;
}
%%

void
yyerror(err)
char *err;
{
mg_log(LOG_DEBUG, "dump error at line %d: %s\n", dump_line, err);
return;
}

void
dump_dispose_input_file(void) {
dump__flush_buffer(YY_CURRENT_BUFFER);
}
Something went wrong with that request. Please try again.