2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 05:47:45 +00:00

Add expression debugging printfs. Supply input and output options to execute_statements.

This commit is contained in:
Ted Lemon 1998-11-05 18:40:40 +00:00
parent 62366286cf
commit a1933e2df8

View File

@ -42,17 +42,20 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: execute.c,v 1.1 1998/06/25 03:57:00 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n"; "$Id: execute.c,v 1.2 1998/11/05 18:40:40 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
int execute_statements (packet, options, statements) int execute_statements (packet, in_options, out_options, statements)
struct packet *packet; struct packet *packet;
struct option_state *options; struct option_state *in_options;
struct option_state *out_options;
struct executable_statement *statements; struct executable_statement *statements;
{ {
struct executable_statement *r; struct executable_statement *r;
int result;
int status;
if (!statements) if (!statements)
return 1; return 1;
@ -60,32 +63,81 @@ int execute_statements (packet, options, statements)
for (r = statements; r; r = r -> next) { for (r = statements; r; r = r -> next) {
switch (r -> op) { switch (r -> op) {
case if_statement: case if_statement:
status = evaluate_boolean_expression
(&result, packet,
in_options, r -> data.ie.expr);
#if defined (DEBUG_EXPRESSIONS)
note ("exec: if %s", (status
? (result ? "true" : "false")
: "NULL"));
#endif
/* XXX Treat NULL as false */
if (!status)
result = 0;
if (!execute_statements if (!execute_statements
(packet, options, (packet, in_options, out_options,
evaluate_boolean_expression (packet, result ? r -> data.ie.true : r -> data.ie.false))
r -> data.ie.expr)
? r -> data.ie.true : r -> data.ie.false))
return 0; return 0;
break; break;
case eval_statement: case eval_statement:
evaluate_boolean_expression (packet, r -> data.eval); status = evaluate_boolean_expression
(&result,
packet, in_options, r -> data.eval);
#if defined (DEBUG_EXPRESSIONS)
note ("exec: evaluate: %s",
(status
? (result ? "true" : "false") : "NULL"));
#endif
break; break;
case add_statement: case add_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: add %s", (r -> data.add -> name
? r -> data.add -> name
: "<unnamed class>"));
#endif
classify (packet, r -> data.add); classify (packet, r -> data.add);
break; break;
case break_statement: case break_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: break");
#endif
return 0; return 0;
case supersede_option_statement: case supersede_option_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: supersede option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case default_option_statement: case default_option_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: default option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case append_option_statement: case append_option_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: append option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case prepend_option_statement: case prepend_option_statement:
#if defined (DEBUG_EXPRESSIONS)
note ("exec: prepend option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
option_statement:
#endif
if (r -> data.option -> option -> universe -> set_func) if (r -> data.option -> option -> universe -> set_func)
(r -> data.option -> option -> (r -> data.option -> option ->
universe -> set_func) (options, universe -> set_func) (out_options,
r -> data.option, r -> data.option,
r -> op); r -> op);
break; break;
@ -113,6 +165,7 @@ void execute_statements_in_scope (packet, options, group, limiting_group)
for (scope = group; for (scope = group;
scope && scope != limiting_group; scope = scope -> next) { scope && scope != limiting_group; scope = scope -> next) {
execute_statements (packet, options, scope -> statements); execute_statements (packet, options, options,
scope -> statements);
} }
} }