diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-12-17 13:59:24 -0500 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-12-17 13:59:24 -0500 |
commit | 9a2f9db55fc4024f5bc7799161752eea77e8290c (patch) | |
tree | 6c5bd2d6588fa34e05d0db0087387478fd180846 /common | |
parent | 79cfe1acf3ddc85708f47bb2b6ff031aed7199e3 (diff) | |
download | isc-dhcp-9a2f9db55fc4024f5bc7799161752eea77e8290c.tar.gz |
[master] Implement and use new option format type 'k'
Merges in #68.
Diffstat (limited to 'common')
-rw-r--r-- | common/options.c | 5 | ||||
-rw-r--r-- | common/parse.c | 28 | ||||
-rw-r--r-- | common/tables.c | 8 |
3 files changed, 38 insertions, 3 deletions
diff --git a/common/options.c b/common/options.c index 4e1fe99e..a7ed84c6 100644 --- a/common/options.c +++ b/common/options.c @@ -1631,6 +1631,7 @@ format_has_text(format) while (*p != '\0') { switch (*p++) { case 't': + case 'k': return 1; /* These symbols are arbitrary, not fixed or @@ -1762,6 +1763,7 @@ format_min_length(format, oc) case 'A': /* Array of all that precedes. */ case 'a': /* Array of preceding symbol. */ case 'Z': /* nothing. */ + case 'k': /* key name */ return min_len; case 'c': /* Compress flag for D atom. */ @@ -1903,7 +1905,9 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes) } hunksize += k; break; + case 't': + case 'k': fmtbuf[l + 1] = 0; numhunk = -2; break; @@ -2047,6 +2051,7 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes) for (; j < numelem; j++) { switch (fmtbuf [j]) { case 't': + case 'k': /* endbuf-1 leaves room for NULL. */ k = pretty_text(&op, endbuf - 1, &dp, data + len, emit_quotes); diff --git a/common/parse.c b/common/parse.c index 8619f852..386a6321 100644 --- a/common/parse.c +++ b/common/parse.c @@ -5058,7 +5058,33 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups) POST(freeval); } break; - + + case 'k': /* key name */ + token = peek_token (&val, &len, cfile); + if (token == STRING) { + token = next_token (&val, &len, cfile); + } else { + val = parse_host_name(cfile); + if (!val) { + parse_warn(cfile, "not a valid key name."); + skip_to_semi(cfile); + return 0; + } + freeval = ISC_TRUE; + } + + if (!make_const_data (&t, (const unsigned char *)val, + strlen(val), 1, 1, MDL)) { + log_fatal ("No memory key name"); + } + + if (freeval == ISC_TRUE) { + dfree((char *)val, MDL); + freeval = ISC_FALSE; + } + + break; + case 'N': f = (*fmt) + 1; g = strchr (*fmt, '.'); diff --git a/common/tables.c b/common/tables.c index c1aa2145..6952bc0f 100644 --- a/common/tables.c +++ b/common/tables.c @@ -84,10 +84,14 @@ HASH_FUNCTIONS (option_code, const unsigned *, struct option, the name of the set of enumeration values to parse or emit, followed by a '.'. The width of the data is specified in the named enumeration. Named enumerations are tracked in parse.c. - d - Domain name (i.e., FOO or FOO.BAR). - D - Domain list (i.e., example.com eng.example.com) + d - Domain name (e.g., FOO or FOO.BAR) no quotes, + on-wire format is RFC 1035. + D - Domain list (e.g., "example.com eng.example.com") quoted, + on-wire format is RFC 1035. c - When following a 'D' atom, enables compression pointers. Z - Zero-length option + k - Key name, unquoted string (e.g. mykey.com or some-text or abc123) + parsed with parse_host_name(). */ struct universe dhcp_universe; |