Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
2db3b288
Commit
2db3b288
authored
Apr 10, 1999
by
Pavel Machek
Browse files
Decrease number of warnings.
parent
49ed70b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
filter/config.Y
View file @
2db3b288
...
...
@@ -129,30 +129,30 @@ block:
;
constant:
CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a
rg1
= T_INT; $$->a
rg2
= $3; }
| NUM { $$ = f_new_inst(); $$->code = 'c'; $$->a
rg1
= T_INT; $$->a
rg2
= $1; }
| TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->a
rg1
= T_BOOL; $$->a
rg2
= 1; }
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->a
rg1
= T_BOOL; $$->a
rg2
= 0; }
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->a
rg1
= T_STRING; $$->a
rg2
= $1; }
CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a
1.i
= T_INT; $$->a
2.i
= $3; }
| NUM { $$ = f_new_inst(); $$->code = 'c'; $$->a
1.i
= T_INT; $$->a
2.i
= $1; }
| TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->a
1.i
= T_BOOL; $$->a
2.i
= 1; }
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->a
1.i
= T_BOOL; $$->a
2.i
= 0; }
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->a
1.i
= T_STRING; $$->a
2.p
= $1; }
;
term:
term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a
rg1
= $1; $$->a
rg2
= $3; }
term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a
1.p
= $1; $$->a
2.p
= $3; }
| term '=' term { $$ = f_new_inst(); $$->code = '=='; $$->a
rg1
= $1; $$->a
rg2
= $3; }
| term '!' '=' term { $$ = f_new_inst(); $$->code = '!='; $$->a
rg1
= $1; $$->a
rg2
= $4; }
| term '<' term { $$ = f_new_inst(); $$->code = '<'; $$->a
rg1
= $1; $$->a
rg2
= $3; }
| term '<' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a
rg1
= $1; $$->a
rg2
= $4; }
| term '>' term { $$ = f_new_inst(); $$->code = '<'; $$->a
rg1
= $3; $$->a
rg2
= $1; }
| term '>' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a
rg1
= $4; $$->a
rg2
= $1; }
| term '=' term { $$ = f_new_inst(); $$->code = '=='; $$->a
1.p
= $1; $$->a
2.p
= $3; }
| term '!' '=' term { $$ = f_new_inst(); $$->code = '!='; $$->a
1.p
= $1; $$->a
2.p
= $4; }
| term '<' term { $$ = f_new_inst(); $$->code = '<'; $$->a
1.p
= $1; $$->a
2.p
= $3; }
| term '<' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a
1.p
= $1; $$->a
2.p
= $4; }
| term '>' term { $$ = f_new_inst(); $$->code = '<'; $$->a
1.p
= $3; $$->a
2.p
= $1; }
| term '>' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a
1.p
= $4; $$->a
2.p
= $1; }
| SYM {
$$ = f_new_inst();
switch ($1->class) {
case SYM_VARIABLE | T_INT:
$$->code = 'i';
$$->a
rg1
= T_INT;
$$->a
rg2
= &($1->aux);
$$->a
1.i
= T_INT;
$$->a
2.p
= &($1->aux);
break;
default:
cf_error("Can not use this class of symbol as variable" );
...
...
@@ -173,13 +173,13 @@ ifthen:
IF term THEN block {
$$ = f_new_inst();
$$->code = '?';
$$->a
rg1
= $2;
$$->a
rg2
= $4;
$$->a
1.p
= $2;
$$->a
2.p
= $4;
}
;
print_one:
term { $$ = f_new_inst(); $$->code = 'p'; $$->a
rg1
= $1; $$->a
rg2
= NULL; }
term { $$ = f_new_inst(); $$->code = 'p'; $$->a
1.p
= $1; $$->a
2.p
= NULL; }
;
print_list: /* EMPTY */ { $$ = NULL; }
...
...
@@ -199,8 +199,8 @@ cmd:
| ifthen ELSE block {
$$ = f_new_inst();
$$->code = '?';
$$->a
rg1
= $1;
$$->a
rg2
= $3;
$$->a
1.p
= $1;
$$->a
2.p
= $3;
}
| SYM '=' term ';' {
$$ = f_new_inst();
...
...
@@ -208,10 +208,10 @@ cmd:
if (($1->class & ~T_MASK) != SYM_VARIABLE)
cf_error( "You may only set variables, and this is %x.\n", $1->class );
$$->code = 's';
$$->a
rg1
= $1;
$$->a
rg2
= $3;
$$->a
1.p
= $1;
$$->a
2.p
= $3;
}
| break_command print_list ';' { $$ = f_new_inst(); $$->code = 'p,'; $$->a
rg1
= $2; $$->a
rg2
= $1; }
| break_command print_list ';' { $$ = f_new_inst(); $$->code = 'p,'; $$->a
1.p
= $2; $$->a
2.i
= $1; }
;
CF_END
filter/filter.c
View file @
2db3b288
...
...
@@ -36,9 +36,9 @@ struct f_inst *startup_func = NULL;
if (x.type == T_RETURN) \
return x;
#define ONEARG ARG(v1, a
rg1
)
#define TWOARGS ARG(v1, a
rg1
) \
ARG(v2, a
rg2
)
#define ONEARG ARG(v1, a
1.p
)
#define TWOARGS ARG(v1, a
1.p
) \
ARG(v2, a
2.p
)
#define TWOARGS_C TWOARGS \
if (v1.type != v2.type) \
runtime( "Can not operate with values of incompatible types" );
...
...
@@ -113,8 +113,8 @@ interpret(struct f_inst *what)
/* Set */
case
's'
:
ARG
(
v2
,
a
rg2
);
sym
=
what
->
a
rg1
;
ARG
(
v2
,
a
2
.
p
);
sym
=
what
->
a
1
.
p
;
switch
(
res
.
type
=
v2
.
type
)
{
case
T_VOID
:
runtime
(
"Can not assign void values"
);
case
T_INT
:
...
...
@@ -126,12 +126,12 @@ interpret(struct f_inst *what)
break
;
case
'c'
:
res
.
type
=
(
int
)
what
->
a
rg1
;
res
.
val
.
i
=
(
int
)
what
->
a
rg2
;
res
.
type
=
what
->
a
1
.
i
;
res
.
val
.
i
=
(
int
)
what
->
a
2
.
p
;
break
;
case
'i'
:
res
.
type
=
(
int
)
what
->
a
rg1
;
res
.
val
.
i
=
*
((
int
*
)
what
->
a
rg2
);
res
.
type
=
what
->
a
1
.
i
;
res
.
val
.
i
=
*
((
int
*
)
what
->
a
2
.
p
);
break
;
case
'p'
:
ONEARG
;
...
...
@@ -147,7 +147,7 @@ interpret(struct f_inst *what)
if
(
v1
.
type
!=
T_BOOL
)
runtime
(
"If requires bool expression"
);
if
(
v1
.
val
.
i
)
{
ARG
(
res
,
a
rg2
);
ARG
(
res
,
a
2
.
p
);
res
.
val
.
i
=
0
;
}
else
res
.
val
.
i
=
1
;
res
.
type
=
T_BOOL
;
...
...
@@ -159,7 +159,7 @@ interpret(struct f_inst *what)
ONEARG
;
printf
(
"
\n
"
);
switch
(
(
int
)
what
->
a
rg2
)
{
switch
(
what
->
a
2
.
i
)
{
case
F_QUITBIRD
:
die
(
"Filter asked me to die"
);
case
F_ACCEPT
:
...
...
@@ -167,7 +167,7 @@ interpret(struct f_inst *what)
case
F_ERROR
:
case
F_REJECT
:
res
.
type
=
T_RETURN
;
res
.
val
.
i
=
(
int
)
what
->
a
rg1
;
res
.
val
.
i
=
what
->
a
1
.
i
;
break
;
case
F_NOP
:
break
;
...
...
filter/filter.h
View file @
2db3b288
...
...
@@ -15,9 +15,19 @@
struct
f_inst
{
/* Instruction */
struct
f_inst
*
next
;
/* Structure is 16 bytes, anyway */
int
code
;
void
*
arg1
,
*
arg2
;
union
{
int
i
;
void
*
p
;
}
a1
;
union
{
int
i
;
void
*
p
;
}
a2
;
};
#define arg1 a1.p
#define arg2 a2.p
struct
prefix
{
ip_addr
ip
;
int
len
;
...
...
@@ -27,7 +37,8 @@ struct f_val {
int
type
;
union
{
int
i
;
struct
prefix
*
px
;
ip_addr
ip
;
struct
prefix
px
;
char
*
s
;
}
val
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment