version 1.1, 2012/02/21 22:30:18
|
version 1.1.1.1, 2012/10/09 09:06:54
|
Line 3
|
Line 3
|
Support for executable statements. */ |
Support for executable statements. */ |
|
|
/* |
/* |
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC") | * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC") |
| * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC") |
* Copyright (c) 1998-2003 by Internet Software Consortium |
* Copyright (c) 1998-2003 by Internet Software Consortium |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 327 int execute_statements (result, packet, lease, client_
|
Line 328 int execute_statements (result, packet, lease, client_
|
case set_statement: |
case set_statement: |
case define_statement: |
case define_statement: |
if (!scope) { |
if (!scope) { |
log_error ("set %s: no scope", | log_error("set %s: no scope", |
r -> data.set.name); | r->data.set.name); |
status = 0; |
status = 0; |
break; |
break; |
} |
} |
if (!*scope) { |
if (!*scope) { |
if (!binding_scope_allocate (scope, MDL)) { | if (!binding_scope_allocate(scope, MDL)) { |
log_error ("set %s: can't allocate scope", | log_error("set %s: can't allocate scope", |
r -> data.set.name); | r->data.set.name); |
status = 0; |
status = 0; |
break; |
break; |
} |
} |
} |
} |
binding = find_binding (*scope, r -> data.set.name); | binding = find_binding(*scope, r->data.set.name); |
#if defined (DEBUG_EXPRESSIONS) |
#if defined (DEBUG_EXPRESSIONS) |
log_debug ("exec: set %s", r -> data.set.name); | log_debug("exec: set %s", r->data.set.name); |
#endif |
#endif |
if (!binding) { | if (binding == NULL) { |
binding = dmalloc (sizeof *binding, MDL); | binding = dmalloc(sizeof(*binding), MDL); |
if (binding) { | if (binding != NULL) { |
memset (binding, 0, sizeof *binding); | memset(binding, 0, sizeof(*binding)); |
binding -> name = | binding->name = |
dmalloc (strlen | dmalloc(strlen |
(r -> data.set.name) + 1, | (r->data.set.name) + 1, |
MDL); | MDL); |
if (binding -> name) { | if (binding->name != NULL) { |
strcpy (binding -> name, | strcpy(binding->name, r->data.set.name); |
r -> data.set.name); | binding->next = (*scope)->bindings; |
binding -> next = (*scope) -> bindings; | (*scope)->bindings = binding; |
(*scope) -> bindings = binding; | |
} else { |
} else { |
dfree (binding, MDL); | dfree(binding, MDL); |
binding = (struct binding *)0; | binding = NULL; |
} |
} |
} |
} |
} |
} |
if (binding) { | if (binding != NULL) { |
if (binding -> value) | if (binding->value != NULL) |
binding_value_dereference |
binding_value_dereference |
(&binding -> value, MDL); | (&binding->value, MDL); |
if (r -> op == set_statement) { | if (r->op == set_statement) { |
status = (evaluate_expression |
status = (evaluate_expression |
(&binding -> value, packet, | (&binding->value, packet, |
lease, client_state, |
lease, client_state, |
in_options, out_options, |
in_options, out_options, |
scope, r -> data.set.expr, | scope, r->data.set.expr, |
MDL)); |
MDL)); |
} else { |
} else { |
if (!(binding_value_allocate |
if (!(binding_value_allocate |
(&binding -> value, MDL))) { | (&binding->value, MDL))) { |
dfree (binding, MDL); | dfree(binding, MDL); |
binding = (struct binding *)0; | binding = NULL; |
} |
} |
if (binding -> value) { | if ((binding != NULL) && |
binding -> value -> type = | (binding->value != NULL)) { |
binding_function; | binding->value->type = |
(fundef_reference | binding_function; |
(&binding -> value -> value.fundef, | (fundef_reference |
r -> data.set.expr -> data.func, | (&binding->value->value.fundef, |
MDL)); | r->data.set.expr->data.func, |
| MDL)); |
} |
} |
} |
} |
} |
} |