Skip to content
Snippets Groups Projects
Commit b7d591f7 authored by Michael Tüxen's avatar Michael Tüxen
Browse files

Allow --define at the beginning of script files.

This is from packetdrill 2.0 with the addition of support for
--define=PROTO=132
parent 62ae8f12
No related branches found
No related tags found
No related merge requests found
...@@ -842,6 +842,9 @@ option ...@@ -842,6 +842,9 @@ option
: option_flag '=' option_value { : option_flag '=' option_value {
$$ = new_option($1, $3); $$ = new_option($1, $3);
} }
| option_flag {
$$ = new_option($1, NULL);
}
option_flag option_flag
: OPTION { $$ = $1; } : OPTION { $$ = $1; }
...@@ -855,6 +858,38 @@ option_value ...@@ -855,6 +858,38 @@ option_value
| IPV6_ADDR { $$ = $1; } | IPV6_ADDR { $$ = $1; }
| IPV4 { $$ = strdup("ipv4"); } | IPV4 { $$ = strdup("ipv4"); }
| IPV6 { $$ = strdup("ipv6"); } | IPV6 { $$ = strdup("ipv6"); }
| WORD '=' INTEGER {
/* For consistency, allow syntax like: --define=PROTO=132 */
char *lhs = $1;
s64 rhs = $3;
asprintf(&($$), "%s=%lld", lhs, rhs);
free(lhs);
}
| WORD '=' WORD {
/* For consistency, allow syntax like: --define=PROTO=IPPROTO_TCP */
char *lhs = $1, *rhs = $3;
asprintf(&($$), "%s=%s", lhs, rhs);
free(lhs);
free(rhs);
}
| WORD '=' STRING {
/* For consistency, allow syntax like: --define=CC="reno" */
char *lhs = $1, *rhs = $3;
asprintf(&($$), "%s=\"%s\"", lhs, rhs);
free(lhs);
free(rhs);
}
| WORD '=' BACK_QUOTED {
/* For consistency, allow syntax like: --define=SCRIPT=`cleanup` */
char *lhs = $1, *rhs = $3;
asprintf(&($$), "%s=`%s`", lhs, rhs);
free(lhs);
free(rhs);
}
; ;
opt_init_command opt_init_command
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment