Build filter using CMake

This commit is contained in:
David Adrian 2013-10-04 10:53:03 -04:00
parent 9df8f678a3
commit f6ea0a79a8
10 changed files with 37 additions and 33 deletions

View File

@ -17,7 +17,7 @@ if(ENABLE_DEVELOPMENT)
"-Wnested-externs -Wbad-function-cast -Winit-self"
"-Wmissing-noreturn -Wnormalized=id"
"-Wstack-protector"
"-Werror"
#"-Werror"
)
# Fix line breaks

4
src/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
lexer.c
lexer.h
parser.c
parser.h

View File

@ -11,6 +11,7 @@ SET(LIB_SOURCES
${PROJECT_SOURCE_DIR}/lib/logger.c
${PROJECT_SOURCE_DIR}/lib/random.c
${PROJECT_SOURCE_DIR}/lib/rijndael-alg-fst.c
${PROJECT_SOURCE_DIR}/lib/xalloc.c
)
# ADD YOUR PROBE MODULE HERE
@ -41,16 +42,21 @@ SET(PROBE_MODULE_SOURCES
SET(SOURCES
aesrand.c
cyclic.c
expression.c
fieldset.c
filter.c
get_gateway.c
monitor.c
recv.c
send.c
stack.c
state.c
validate.c
zmap.c
zopt_compat.c
"${CMAKE_CURRENT_BINARY_DIR}/zopt.h"
"${CMAKE_CURRENT_BINARY_DIR}/lexer.c"
"${CMAKE_CURRENT_BINARY_DIR}/parser.c"
${EXTRA_PROBE_MODULES}
${EXTRA_OUTPUT_MODULES}
${PROBE_MODULE_SOURCES}
@ -70,6 +76,14 @@ add_custom_command(OUTPUT zopt.h
COMMAND gengetopt -C --no-help --no-version -i "${CMAKE_CURRENT_SOURCE_DIR}/zopt.ggo" -F "${CMAKE_CURRENT_BINARY_DIR}/zopt"
)
add_custom_command(OUTPUT lexer.c
COMMAND flex -o "${CMAKE_CURRENT_BINARY_DIR}/lexer.c" --header-file="${CMAKE_CURRENT_BINARY_DIR}/lexer.h" lexer.l
)
add_custom_command(OUTPUT parser.c
COMMAND byacc -d -o parser.c parser.y
)
add_executable(zmap ${SOURCES})
target_link_libraries(

View File

@ -45,4 +45,6 @@ node_t* make_int_node(int literal);
int evaluate_expression(node_t *root, fieldset_t *fields);
void print_expression(node_t *root);
#endif /* ZMAP_TREE_H */

View File

@ -1,7 +1,8 @@
#include "filter.h"
#include "state.h"
#include "lexer.h"
#include "y.tab.h"
#include "parser.h"
#include "expression.h"
#include "../lib/logger.h"
#include <string.h>

View File

@ -1,5 +1,6 @@
#line 2 "/home/david/mac/SourceCode/zmap/src/lexer.c"
#line 3 "<stdout>"
#line 4 "/home/david/mac/SourceCode/zmap/src/lexer.c"
#define YY_INT_ALIGNED short int
@ -469,10 +470,10 @@ char *yytext;
#line 1 "lexer.l"
#line 2 "lexer.l"
#include <string.h>
#include "y.tab.h"
#include "parser.h"
#define YY_NO_INPUT 1
#line 476 "<stdout>"
#line 477 "/home/david/mac/SourceCode/zmap/src/lexer.c"
#define INITIAL 0
@ -659,7 +660,7 @@ YY_DECL
#line 9 "lexer.l"
#line 663 "<stdout>"
#line 664 "/home/david/mac/SourceCode/zmap/src/lexer.c"
if ( !(yy_init) )
{
@ -818,7 +819,7 @@ YY_RULE_SETUP
#line 25 "lexer.l"
ECHO;
YY_BREAK
#line 822 "<stdout>"
#line 823 "/home/david/mac/SourceCode/zmap/src/lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();

View File

@ -2,7 +2,9 @@
#define yyHEADER_H 1
#define yyIN_HEADER 1
#line 6 "lexer.h"
#line 6 "/home/david/mac/SourceCode/zmap/src/lexer.h"
#line 8 "/home/david/mac/SourceCode/zmap/src/lexer.h"
#define YY_INT_ALIGNED short int
@ -325,6 +327,6 @@ extern int yylex (void);
#line 25 "lexer.l"
#line 329 "lexer.h"
#line 331 "/home/david/mac/SourceCode/zmap/src/lexer.h"
#undef yyIN_HEADER
#endif /* yyHEADER_H */

View File

@ -1,6 +1,6 @@
%{
#include <string.h>
#include "y.tab.h"
#include "parser.h"
%}

View File

@ -49,7 +49,7 @@ typedef union {
struct node *expr;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
#line 52 "y.tab.c"
#line 52 "parser.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@ -250,7 +250,7 @@ static YYSTACKDATA yystack;
#line 144 "parser.y"
#line 253 "y.tab.c"
#line 253 "parser.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@ -566,7 +566,7 @@ case 15:
yyval.expr->right_child = make_field_node(yystack.l_mark[0].string_literal);
}
break;
#line 569 "y.tab.c"
#line 569 "parser.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@ -1,20 +0,0 @@
#define T_AND 257
#define T_OR 258
#define T_NUMBER 259
#define T_FIELD 260
#define T_NOT_EQ 261
#define T_GT_EQ 262
#define T_LT_EQ 263
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
typedef union {
int int_literal;
char *string_literal;
struct node *expr;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
extern YYSTYPE yylval;