mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-03 15:56:00 +00:00
- Pull up 3.0 changes.
- Support malloc debug. - Parse ganged events, let, unset, parenthesized if statements, eval. - Part of backwards compatibility for BCTEL (doesn't work yet)
This commit is contained in:
243
common/parse.c
243
common/parse.c
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: parse.c,v 1.58 2000/01/08 01:36:39 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: parse.c,v 1.59 2000/01/25 01:13:21 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -112,7 +112,7 @@ char *parse_string (cfile)
|
|||||||
skip_to_semi (cfile);
|
skip_to_semi (cfile);
|
||||||
return (char *)0;
|
return (char *)0;
|
||||||
}
|
}
|
||||||
s = (char *)malloc (strlen (val) + 1);
|
s = (char *)dmalloc (strlen (val) + 1, MDL);
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("no memory for string %s.", val);
|
log_fatal ("no memory for string %s.", val);
|
||||||
strcpy (s, val);
|
strcpy (s, val);
|
||||||
@@ -147,7 +147,7 @@ char *parse_host_name (cfile)
|
|||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
|
|
||||||
/* Store this identifier... */
|
/* Store this identifier... */
|
||||||
if (!(s = (char *)malloc (strlen (val) + 1)))
|
if (!(s = (char *)dmalloc (strlen (val) + 1, MDL)))
|
||||||
log_fatal ("can't allocate temp space for hostname.");
|
log_fatal ("can't allocate temp space for hostname.");
|
||||||
strcpy (s, val);
|
strcpy (s, val);
|
||||||
c = cons ((caddr_t)s, c);
|
c = cons ((caddr_t)s, c);
|
||||||
@@ -160,7 +160,7 @@ char *parse_host_name (cfile)
|
|||||||
} while (token == DOT);
|
} while (token == DOT);
|
||||||
|
|
||||||
/* Assemble the hostname together into a string. */
|
/* Assemble the hostname together into a string. */
|
||||||
if (!(s = (char *)malloc (len)))
|
if (!(s = (char *)dmalloc (len, MDL)))
|
||||||
log_fatal ("can't allocate space for hostname.");
|
log_fatal ("can't allocate space for hostname.");
|
||||||
t = s + len;
|
t = s + len;
|
||||||
*--t = 0;
|
*--t = 0;
|
||||||
@@ -170,8 +170,8 @@ char *parse_host_name (cfile)
|
|||||||
t -= l;
|
t -= l;
|
||||||
memcpy (t, (char *)(c -> car), l);
|
memcpy (t, (char *)(c -> car), l);
|
||||||
/* Free up temp space. */
|
/* Free up temp space. */
|
||||||
free (c -> car);
|
dfree (c -> car, MDL);
|
||||||
free (c);
|
dfree (c, MDL);
|
||||||
c = cdr;
|
c = cdr;
|
||||||
if (t != s)
|
if (t != s)
|
||||||
*--t = '.';
|
*--t = '.';
|
||||||
@@ -291,7 +291,7 @@ void parse_hardware_param (cfile, hardware)
|
|||||||
if (!t)
|
if (!t)
|
||||||
return;
|
return;
|
||||||
if (hlen + 1 > sizeof hardware -> hbuf) {
|
if (hlen + 1 > sizeof hardware -> hbuf) {
|
||||||
free (t);
|
dfree (t, MDL);
|
||||||
parse_warn (cfile, "hardware address too long");
|
parse_warn (cfile, "hardware address too long");
|
||||||
} else {
|
} else {
|
||||||
hardware -> hlen = hlen + 1;
|
hardware -> hlen = hlen + 1;
|
||||||
@@ -299,7 +299,7 @@ void parse_hardware_param (cfile, hardware)
|
|||||||
if (hlen + 1 < sizeof hardware -> hbuf)
|
if (hlen + 1 < sizeof hardware -> hbuf)
|
||||||
memset (&hardware -> hbuf [hlen + 1], 0,
|
memset (&hardware -> hbuf [hlen + 1], 0,
|
||||||
(sizeof hardware -> hbuf) - hlen - 1);
|
(sizeof hardware -> hbuf) - hlen - 1);
|
||||||
free (t);
|
dfree (t, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
@@ -354,7 +354,7 @@ unsigned char *parse_numeric_aggregate (cfile, buf,
|
|||||||
pair c = (pair)0;
|
pair c = (pair)0;
|
||||||
|
|
||||||
if (!bufp && *max) {
|
if (!bufp && *max) {
|
||||||
bufp = (unsigned char *)malloc (*max * size / 8);
|
bufp = (unsigned char *)dmalloc (*max * size / 8, MDL);
|
||||||
if (!bufp)
|
if (!bufp)
|
||||||
log_fatal ("no space for numeric aggregate");
|
log_fatal ("no space for numeric aggregate");
|
||||||
s = 0;
|
s = 0;
|
||||||
@@ -396,7 +396,7 @@ unsigned char *parse_numeric_aggregate (cfile, buf,
|
|||||||
convert_num (cfile, s, val, base, size);
|
convert_num (cfile, s, val, base, size);
|
||||||
s += size / 8;
|
s += size / 8;
|
||||||
} else {
|
} else {
|
||||||
t = (unsigned char *)malloc (strlen (val) + 1);
|
t = (unsigned char *)dmalloc (strlen (val) + 1, MDL);
|
||||||
if (!t)
|
if (!t)
|
||||||
log_fatal ("no temp space for number.");
|
log_fatal ("no temp space for number.");
|
||||||
strcpy ((char *)t, val);
|
strcpy ((char *)t, val);
|
||||||
@@ -406,7 +406,7 @@ unsigned char *parse_numeric_aggregate (cfile, buf,
|
|||||||
|
|
||||||
/* If we had to cons up a list, convert it now. */
|
/* If we had to cons up a list, convert it now. */
|
||||||
if (c) {
|
if (c) {
|
||||||
bufp = (unsigned char *)malloc (count * size / 8);
|
bufp = (unsigned char *)dmalloc (count * size / 8, MDL);
|
||||||
if (!bufp)
|
if (!bufp)
|
||||||
log_fatal ("no space for numeric aggregate.");
|
log_fatal ("no space for numeric aggregate.");
|
||||||
s = bufp + count - size / 8;
|
s = bufp + count - size / 8;
|
||||||
@@ -417,8 +417,8 @@ unsigned char *parse_numeric_aggregate (cfile, buf,
|
|||||||
convert_num (cfile, s, (char *)(c -> car), base, size);
|
convert_num (cfile, s, (char *)(c -> car), base, size);
|
||||||
s -= size / 8;
|
s -= size / 8;
|
||||||
/* Free up temp space. */
|
/* Free up temp space. */
|
||||||
free (c -> car);
|
dfree (c -> car, MDL);
|
||||||
free (c);
|
dfree (c, MDL);
|
||||||
c = cdr;
|
c = cdr;
|
||||||
}
|
}
|
||||||
return bufp;
|
return bufp;
|
||||||
@@ -749,7 +749,7 @@ struct option *parse_option_name (cfile, allocate, known)
|
|||||||
skip_to_semi (cfile);
|
skip_to_semi (cfile);
|
||||||
return (struct option *)0;
|
return (struct option *)0;
|
||||||
}
|
}
|
||||||
uname = malloc (strlen (val) + 1);
|
uname = dmalloc (strlen (val) + 1, MDL);
|
||||||
if (!uname)
|
if (!uname)
|
||||||
log_fatal ("no memory for uname information.");
|
log_fatal ("no memory for uname information.");
|
||||||
strcpy (uname, val);
|
strcpy (uname, val);
|
||||||
@@ -803,9 +803,8 @@ struct option *parse_option_name (cfile, allocate, known)
|
|||||||
option -> name = val;
|
option -> name = val;
|
||||||
else {
|
else {
|
||||||
char *s;
|
char *s;
|
||||||
free (uname);
|
dfree (uname, MDL);
|
||||||
s = dmalloc (strlen (val) + 1,
|
s = dmalloc (strlen (val) + 1, MDL);
|
||||||
"parse_option_name");
|
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("no memory for option %s.%s",
|
log_fatal ("no memory for option %s.%s",
|
||||||
universe -> name, val);
|
universe -> name, val);
|
||||||
@@ -826,7 +825,7 @@ struct option *parse_option_name (cfile, allocate, known)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Free the initial identifier token. */
|
/* Free the initial identifier token. */
|
||||||
free (uname);
|
dfree (uname, MDL);
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,7 +852,7 @@ void parse_option_space_decl (cfile)
|
|||||||
log_fatal ("No memory for new option space.");
|
log_fatal ("No memory for new option space.");
|
||||||
|
|
||||||
/* Set up the server option universe... */
|
/* Set up the server option universe... */
|
||||||
s = dmalloc (strlen (val) + 1, "parse_option_space_decl");
|
s = dmalloc (strlen (val) + 1, MDL);
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("No memory for new option space name.");
|
log_fatal ("No memory for new option space name.");
|
||||||
strcpy (s, val);
|
strcpy (s, val);
|
||||||
@@ -872,13 +871,12 @@ void parse_option_space_decl (cfile)
|
|||||||
nu -> store_length = putUChar;
|
nu -> store_length = putUChar;
|
||||||
nu -> index = universe_count++;
|
nu -> index = universe_count++;
|
||||||
if (nu -> index >= universe_max) {
|
if (nu -> index >= universe_max) {
|
||||||
ua = dmalloc (universe_max * 2 * sizeof *ua,
|
ua = dmalloc (universe_max * 2 * sizeof *ua, MDL);
|
||||||
"parse_option_space_decl");
|
|
||||||
if (!ua)
|
if (!ua)
|
||||||
log_fatal ("No memory to expand option space array.");
|
log_fatal ("No memory to expand option space array.");
|
||||||
memcpy (ua, universes, universe_max * sizeof *ua);
|
memcpy (ua, universes, universe_max * sizeof *ua);
|
||||||
universe_max *= 2;
|
universe_max *= 2;
|
||||||
dfree (universes, "parse_option_space_decl");
|
dfree (universes, MDL);
|
||||||
universes = ua;
|
universes = ua;
|
||||||
}
|
}
|
||||||
universes [nu -> index] = nu;
|
universes [nu -> index] = nu;
|
||||||
@@ -1084,7 +1082,7 @@ int parse_option_code_definition (cfile, option)
|
|||||||
skip_to_semi (cfile);
|
skip_to_semi (cfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
s = dmalloc (tokix + arrayp + 1, "parse_option_code_definition");
|
s = dmalloc (tokix + arrayp + 1, MDL);
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("no memory for option format.");
|
log_fatal ("no memory for option format.");
|
||||||
memcpy (s, tokbuf, tokix);
|
memcpy (s, tokbuf, tokix);
|
||||||
@@ -1128,15 +1126,14 @@ int parse_cshl (data, cfile)
|
|||||||
skip_to_semi (cfile);
|
skip_to_semi (cfile);
|
||||||
for (; sl; sl = next) {
|
for (; sl; sl = next) {
|
||||||
next = sl -> next;
|
next = sl -> next;
|
||||||
dfree (sl, "parse_cshl");
|
dfree (sl, MDL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ilen == sizeof ibuf) {
|
if (ilen == sizeof ibuf) {
|
||||||
next = (struct option_tag *)
|
next = (struct option_tag *)
|
||||||
dmalloc (ilen - 1 +
|
dmalloc (ilen - 1 +
|
||||||
sizeof (struct option_tag),
|
sizeof (struct option_tag), MDL);
|
||||||
"parse_cshl");
|
|
||||||
if (!next)
|
if (!next)
|
||||||
log_fatal ("no memory for string list.");
|
log_fatal ("no memory for string list.");
|
||||||
memcpy (next -> data, ibuf, ilen);
|
memcpy (next -> data, ibuf, ilen);
|
||||||
@@ -1164,7 +1161,7 @@ int parse_cshl (data, cfile)
|
|||||||
next = sl -> next;
|
next = sl -> next;
|
||||||
memcpy (rvp, sl -> data, sizeof ibuf);
|
memcpy (rvp, sl -> data, sizeof ibuf);
|
||||||
rvp += sizeof ibuf;
|
rvp += sizeof ibuf;
|
||||||
dfree (sl, "parse_cshl");
|
dfree (sl, MDL);
|
||||||
sl = next;
|
sl = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1375,7 +1372,6 @@ int parse_executable_statement (result, cfile, lose, case_context)
|
|||||||
|
|
||||||
case TOKEN_SET:
|
case TOKEN_SET:
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
token = next_token (&val, cfile);
|
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != NAME && token != NUMBER_OR_NAME) {
|
if (token != NAME && token != NUMBER_OR_NAME) {
|
||||||
@@ -1391,9 +1387,8 @@ int parse_executable_statement (result, cfile, lose, case_context)
|
|||||||
(result,
|
(result,
|
||||||
"parse_executable_statement"))
|
"parse_executable_statement"))
|
||||||
log_fatal ("no memory for set statement.");
|
log_fatal ("no memory for set statement.");
|
||||||
(*result) -> op = default_statement;
|
(*result) -> op = set_statement;
|
||||||
(*result) -> data.set.name = dmalloc (strlen (val) + 1,
|
(*result) -> data.set.name = dmalloc (strlen (val) + 1, MDL);
|
||||||
"parse_executable_stmt");
|
|
||||||
if (!(*result)->data.set.name)
|
if (!(*result)->data.set.name)
|
||||||
log_fatal ("can't allocate variable name");
|
log_fatal ("can't allocate variable name");
|
||||||
strcpy ((*result) -> data.set.name, val);
|
strcpy ((*result) -> data.set.name, val);
|
||||||
@@ -1419,6 +1414,56 @@ int parse_executable_statement (result, cfile, lose, case_context)
|
|||||||
parse_semi (cfile);
|
parse_semi (cfile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UNSET:
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
if (token != NAME && token != NUMBER_OR_NAME) {
|
||||||
|
parse_warn (cfile,
|
||||||
|
"%s can't be a variable name", val);
|
||||||
|
badunset:
|
||||||
|
skip_to_semi (cfile);
|
||||||
|
*lose = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!executable_statement_allocate
|
||||||
|
(result,
|
||||||
|
"parse_executable_statement"))
|
||||||
|
log_fatal ("no memory for set statement.");
|
||||||
|
(*result) -> op = unset_statement;
|
||||||
|
(*result) -> data.unset = dmalloc (strlen (val) + 1, MDL);
|
||||||
|
if (!(*result)->data.unset)
|
||||||
|
log_fatal ("can't allocate variable name");
|
||||||
|
strcpy ((*result) -> data.unset, val);
|
||||||
|
parse_semi (cfile);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVAL:
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
|
||||||
|
if (!executable_statement_allocate
|
||||||
|
(result,
|
||||||
|
"parse_executable_statement"))
|
||||||
|
log_fatal ("no memory for eval statement.");
|
||||||
|
(*result) -> op = eval_statement;
|
||||||
|
|
||||||
|
if (!parse_expression (&(*result) -> data.eval,
|
||||||
|
cfile, lose, context_data, /* XXX */
|
||||||
|
(struct expression **)0, expr_none)) {
|
||||||
|
if (!*lose)
|
||||||
|
parse_warn (cfile,
|
||||||
|
"expecting data expression.");
|
||||||
|
else
|
||||||
|
*lose = 1;
|
||||||
|
skip_to_semi (cfile);
|
||||||
|
executable_statement_dereference
|
||||||
|
(result, "parse_executable_statement");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
parse_semi (cfile);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*lose = 0;
|
*lose = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1455,11 +1500,11 @@ int parse_on_statement (result, cfile, lose)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case COMMIT:
|
case COMMIT:
|
||||||
(*result) -> data.on.evtypes = ON_COMMIT;
|
(*result) -> data.on.evtypes |= ON_COMMIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RELEASE:
|
case RELEASE:
|
||||||
(*result) -> data.on.evtypes = ON_RELEASE;
|
(*result) -> data.on.evtypes |= ON_RELEASE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1468,7 +1513,7 @@ int parse_on_statement (result, cfile, lose)
|
|||||||
*lose = 1;
|
*lose = 1;
|
||||||
executable_statement_dereference
|
executable_statement_dereference
|
||||||
(result, "parse_on_statement");
|
(result, "parse_on_statement");
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
} while (token == OR);
|
} while (token == OR);
|
||||||
@@ -1641,12 +1686,21 @@ int parse_if_statement (result, cfile, lose)
|
|||||||
{
|
{
|
||||||
enum dhcp_token token;
|
enum dhcp_token token;
|
||||||
const char *val;
|
const char *val;
|
||||||
|
int parenp;
|
||||||
|
|
||||||
if (!executable_statement_allocate (result, "parse_if_statement"))
|
if (!executable_statement_allocate (result, "parse_if_statement"))
|
||||||
log_fatal ("no memory for if statement.");
|
log_fatal ("no memory for if statement.");
|
||||||
|
|
||||||
(*result) -> op = if_statement;
|
(*result) -> op = if_statement;
|
||||||
|
|
||||||
|
token = peek_token (&val, cfile);
|
||||||
|
if (token == LPAREN) {
|
||||||
|
parenp = 1;
|
||||||
|
next_token (&val, cfile);
|
||||||
|
} else
|
||||||
|
parenp = 0;
|
||||||
|
|
||||||
|
|
||||||
if (!parse_boolean_expression (&(*result) -> data.ie.expr,
|
if (!parse_boolean_expression (&(*result) -> data.ie.expr,
|
||||||
cfile, lose)) {
|
cfile, lose)) {
|
||||||
if (!*lose)
|
if (!*lose)
|
||||||
@@ -1659,6 +1713,16 @@ int parse_if_statement (result, cfile, lose)
|
|||||||
#if defined (DEBUG_EXPRESSION_PARSE)
|
#if defined (DEBUG_EXPRESSION_PARSE)
|
||||||
print_expression ("if condition", if_condition);
|
print_expression ("if condition", if_condition);
|
||||||
#endif
|
#endif
|
||||||
|
if (parenp) {
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
if (token != RPAREN) {
|
||||||
|
parse_warn (cfile, "expecting right paren.");
|
||||||
|
*lose = 1;
|
||||||
|
executable_statement_dereference
|
||||||
|
(result, "parse_if_statement");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != LBRACE) {
|
if (token != LBRACE) {
|
||||||
parse_warn (cfile, "left brace expected.");
|
parse_warn (cfile, "left brace expected.");
|
||||||
@@ -1884,6 +1948,8 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
int known;
|
int known;
|
||||||
enum expr_op opcode;
|
enum expr_op opcode;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
struct executable_statement *stmt;
|
||||||
|
int i;
|
||||||
|
|
||||||
token = peek_token (&val, cfile);
|
token = peek_token (&val, cfile);
|
||||||
|
|
||||||
@@ -2176,7 +2242,7 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
goto norparen;
|
goto norparen;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PICK_FIRST_VALUE:
|
case PICK:
|
||||||
/* pick (a, b, c) actually produces an internal representation
|
/* pick (a, b, c) actually produces an internal representation
|
||||||
that looks like pick (a, pick (b, pick (c, nil))). */
|
that looks like pick (a, pick (b, pick (c, nil))). */
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
@@ -2220,70 +2286,75 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
parse_warn (cfile,
|
parse_warn (cfile,
|
||||||
"Please rebuild dhcpd with --with-nsupdate.");
|
"Please rebuild dhcpd with --with-nsupdate.");
|
||||||
#endif
|
#endif
|
||||||
|
token = next_token (&val, cfile);
|
||||||
if (token == DNS_UPDATE)
|
if (token == DNS_UPDATE)
|
||||||
opcode = expr_ns_add;
|
opcode = expr_ns_add;
|
||||||
else
|
else
|
||||||
opcode = expr_ns_delete;
|
opcode = expr_ns_delete;
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
|
||||||
if (!expression_allocate (expr,
|
|
||||||
"parse_expression: DNS_UPDATE"))
|
|
||||||
log_fatal ("can't allocate expression");
|
|
||||||
(*expr) -> op = expr_dns_transaction;
|
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != LPAREN)
|
if (token != LPAREN)
|
||||||
goto nolparen;
|
goto nolparen;
|
||||||
|
|
||||||
nexp = (struct expression *)0;
|
|
||||||
if (!expression_allocate (&nexp,
|
|
||||||
"parse_expression: DNS_UPDATE1"))
|
|
||||||
log_fatal ("can't allocate expression");
|
|
||||||
nexp -> op = opcode;
|
|
||||||
(*expr) -> data.dns_transaction.car = nexp;
|
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != STRING) {
|
if (token != STRING) {
|
||||||
parse_warn (cfile,
|
parse_warn (cfile,
|
||||||
"parse_expression: expecting string.");
|
"parse_expression: expecting string.");
|
||||||
badnsupdate:
|
badnsupdate:
|
||||||
expression_dereference
|
|
||||||
(expr, "parse_expression");
|
|
||||||
skip_to_semi (cfile);
|
skip_to_semi (cfile);
|
||||||
*lose = 1;
|
*lose = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp (val, "a"))
|
if (!strcasecmp (val, "a"))
|
||||||
nexp -> data.ns_add.rrtype = T_A;
|
i = T_A;
|
||||||
else if (!strcasecmp (val, "ptr"))
|
else if (!strcasecmp (val, "ptr"))
|
||||||
nexp -> data.ns_add.rrtype = T_PTR;
|
i = T_PTR;
|
||||||
else if (!strcasecmp (val, "mx"))
|
else if (!strcasecmp (val, "mx"))
|
||||||
nexp -> data.ns_add.rrtype = T_MX;
|
i = T_MX;
|
||||||
else if (!strcasecmp (val, "cname"))
|
else if (!strcasecmp (val, "cname"))
|
||||||
nexp -> data.ns_add.rrtype = T_CNAME;
|
i = T_CNAME;
|
||||||
else if (!strcasecmp (val, "TXT"))
|
else if (!strcasecmp (val, "TXT"))
|
||||||
nexp -> data.ns_add.rrtype = T_TXT;
|
i = T_TXT;
|
||||||
else {
|
else {
|
||||||
parse_warn (cfile, "unexpected rrtype: %s", val);
|
parse_warn (cfile, "unexpected rrtype: %s", val);
|
||||||
goto badnsupdate;
|
goto badnsupdate;
|
||||||
}
|
}
|
||||||
nexp -> data.ns_add.rrclass = C_IN;
|
|
||||||
|
if (!expression_allocate (expr,
|
||||||
|
"parse_expression: DNS_UPDATE"))
|
||||||
|
log_fatal ("can't allocate expression");
|
||||||
|
#if 0
|
||||||
|
(*expr) -> op = expr_funcall;
|
||||||
|
(*expr) -> data.funcall.context = context_boolean;
|
||||||
|
(*expr) -> data.funcall.name =
|
||||||
|
|
||||||
|
if (!make_let (&(*expr) -> data.funcall.statements, "rrtype"))
|
||||||
|
log_fatal ("can't allocate rrtype let.");
|
||||||
|
stmt = (*expr) -> data.funcall.statements;
|
||||||
|
if (!make_const_int (stmt -> data.let.value, i))
|
||||||
|
log_fatal ("can't allocate rrtype value.");
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != COMMA)
|
if (token != COMMA)
|
||||||
goto nocomma;
|
goto nocomma;
|
||||||
|
|
||||||
if (!(parse_data_expression
|
if (!make_let (&stmt -> data.let.statements, "rrname"))
|
||||||
(&nexp -> data.ns_add.rrname, cfile, lose)))
|
log_fatal ("can't allocate rrname let.");
|
||||||
|
stmt = stmt -> data.let.statements;
|
||||||
|
if (!(parse_data_expression (&stmt -> data.let.expr,
|
||||||
|
cfile, lose)))
|
||||||
goto nodata;
|
goto nodata;
|
||||||
|
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != COMMA)
|
if (token != COMMA)
|
||||||
goto nocomma;
|
goto nocomma;
|
||||||
|
|
||||||
if (!(parse_data_expression
|
if (!make_let (&stmt -> data.let.statements, "rrdata"))
|
||||||
(&nexp -> data.ns_add.rrdata, cfile, lose)))
|
log_fatal ("can't allocate rrname let.");
|
||||||
|
stmt = stmt -> data.let.statements;
|
||||||
|
if (!(parse_data_expression (&stmt -> data.let.expr,
|
||||||
|
cfile, lose)))
|
||||||
goto nodata;
|
goto nodata;
|
||||||
|
|
||||||
if (opcode == expr_ns_add) {
|
if (opcode == expr_ns_add) {
|
||||||
@@ -2291,14 +2362,18 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
if (token != COMMA)
|
if (token != COMMA)
|
||||||
goto nocomma;
|
goto nocomma;
|
||||||
|
|
||||||
|
if (!make_let (&stmt -> data.let.statements, "ttl"))
|
||||||
|
log_fatal ("can't allocate rrname let.");
|
||||||
|
stmt = stmt -> data.let.statements;
|
||||||
|
|
||||||
if (!(parse_numeric_expression
|
if (!(parse_numeric_expression
|
||||||
(&nexp -> data.ns_add.ttl, cfile, lose))) {
|
(&stmt -> data.let.expr, cfile, lose))) {
|
||||||
parse_warn (cfile,
|
parse_warn (cfile,
|
||||||
"expecting data expression.");
|
"expecting numeric expression.");
|
||||||
goto badnsupdate;
|
goto badnsupdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (token != RPAREN)
|
if (token != RPAREN)
|
||||||
goto norparen;
|
goto norparen;
|
||||||
@@ -2354,7 +2429,12 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
|
|
||||||
/* NOT EXISTS is special cased above... */
|
/* NOT EXISTS is special cased above... */
|
||||||
not_exists:
|
not_exists:
|
||||||
token = next_token (&val, cfile);
|
token = peek_token (&val, cfile);
|
||||||
|
if (token != EXISTS) {
|
||||||
|
parse_warn (cfile, "expecting DNS prerequisite.");
|
||||||
|
*lose = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
opcode = expr_ns_not_exists;
|
opcode = expr_ns_not_exists;
|
||||||
goto nsupdatecode;
|
goto nsupdatecode;
|
||||||
case TOKEN_ADD:
|
case TOKEN_ADD:
|
||||||
@@ -2498,6 +2578,22 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
(*expr) -> op = expr_leased_address;
|
(*expr) -> op = expr_leased_address;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FILENAME:
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
if (!expression_allocate (expr,
|
||||||
|
"parse_expression: FILENAME"))
|
||||||
|
log_fatal ("can't allocate expression");
|
||||||
|
(*expr) -> op = expr_filename;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVER_NAME:
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
if (!expression_allocate (expr,
|
||||||
|
"parse_expression: SERVER_NAME"))
|
||||||
|
log_fatal ("can't allocate expression");
|
||||||
|
(*expr) -> op = expr_sname;
|
||||||
|
break;
|
||||||
|
|
||||||
case LEASE_TIME:
|
case LEASE_TIME:
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
if (!expression_allocate (expr,
|
if (!expression_allocate (expr,
|
||||||
@@ -2552,7 +2648,7 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
log_fatal ("can't allocate expression");
|
log_fatal ("can't allocate expression");
|
||||||
(*expr) -> op = expr_variable_reference;
|
(*expr) -> op = expr_variable_reference;
|
||||||
(*expr) -> data.variable =
|
(*expr) -> data.variable =
|
||||||
dmalloc (strlen (s) + 1, "parse_expression");
|
dmalloc (strlen (s) + 1, MDL);
|
||||||
if (!(*expr) -> data.variable)
|
if (!(*expr) -> data.variable)
|
||||||
log_fatal ("can't allocate variable name.");
|
log_fatal ("can't allocate variable name.");
|
||||||
strcpy ((*expr) -> data.variable, s);
|
strcpy ((*expr) -> data.variable, s);
|
||||||
@@ -2832,8 +2928,7 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
if (!expression_allocate (expr, "parse_expression"))
|
if (!expression_allocate (expr, "parse_expression"))
|
||||||
log_fatal ("can't allocate expression");
|
log_fatal ("can't allocate expression");
|
||||||
(*expr) -> op = expr_variable_exists;
|
(*expr) -> op = expr_variable_exists;
|
||||||
(*expr) -> data.variable = dmalloc (strlen (val) + 1,
|
(*expr) -> data.variable = dmalloc (strlen (val) + 1, MDL);
|
||||||
"parse_expression");
|
|
||||||
if (!(*expr)->data.variable)
|
if (!(*expr)->data.variable)
|
||||||
log_fatal ("can't allocate variable name");
|
log_fatal ("can't allocate variable name");
|
||||||
strcpy ((*expr) -> data.variable, val);
|
strcpy ((*expr) -> data.variable, val);
|
||||||
@@ -2851,8 +2946,7 @@ int parse_non_binary (expr, cfile, lose, context)
|
|||||||
if (!expression_allocate (expr, "parse_expression"))
|
if (!expression_allocate (expr, "parse_expression"))
|
||||||
log_fatal ("can't allocate expression");
|
log_fatal ("can't allocate expression");
|
||||||
(*expr) -> op = expr_variable_reference;
|
(*expr) -> op = expr_variable_reference;
|
||||||
(*expr) -> data.variable = dmalloc (strlen (val) + 1,
|
(*expr) -> data.variable = dmalloc (strlen (val) + 1, MDL);
|
||||||
"parse_expression");
|
|
||||||
if (!(*expr)->data.variable)
|
if (!(*expr)->data.variable)
|
||||||
log_fatal ("can't allocate variable name");
|
log_fatal ("can't allocate variable name");
|
||||||
strcpy ((*expr) -> data.variable, val);
|
strcpy ((*expr) -> data.variable, val);
|
||||||
@@ -3131,6 +3225,7 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
|
|||||||
int len;
|
int len;
|
||||||
unsigned char *ob;
|
unsigned char *ob;
|
||||||
struct iaddr addr;
|
struct iaddr addr;
|
||||||
|
int num;
|
||||||
|
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case 'U':
|
case 'U':
|
||||||
@@ -3194,9 +3289,19 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'T': /* Lease interval. */
|
||||||
|
token = next_token (&val, cfile);
|
||||||
|
if (token != INFINITE)
|
||||||
|
goto check_number;
|
||||||
|
putLong (buf, -1);
|
||||||
|
if (!make_const_data (&t, buf, 4, 0, 1))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'L': /* Unsigned 32-bit integer... */
|
case 'L': /* Unsigned 32-bit integer... */
|
||||||
case 'l': /* Signed 32-bit integer... */
|
case 'l': /* Signed 32-bit integer... */
|
||||||
token = next_token (&val, cfile);
|
token = next_token (&val, cfile);
|
||||||
|
check_number:
|
||||||
if (token != NUMBER) {
|
if (token != NUMBER) {
|
||||||
need_number:
|
need_number:
|
||||||
parse_warn (cfile, "expecting number.");
|
parse_warn (cfile, "expecting number.");
|
||||||
|
Reference in New Issue
Block a user