config input handling improvements
This commit changes a few things in the config handling: * When reading the configuration from multiple sources, a source can now override settings already set by a preceding source for settings that are not lists. Previously, trying to change the value of a setting in a subsequence file would be considered an error, just like trying to set the value of a particular setting multiple times in a single configuration file. * A configuration fragment in CYCLONEDDS_URI now no longer requires the CycloneDDS top-level tag to be specified. If it is missing it will be assumed. This is only true for configuration fragments contained in CYCLONEDDS_URI, not for data read from a file. * A configuration fragment in CYCLONEDDS_URI no longer requires that all elements are properly closed: a missing close tag is treated as-if it is the end of the fragment and any elements are implicitly closed. Again this does not apply to files. * The configuration dump now lists explicitly which sources affected each setting, with a default value indicated by an empty set. The result of the latter two is that one can almost pretend that it is a sane format instead of XML. For example, if one would like to override tracing settings, one could just write: CYCLONEDDS_URI="$CYCLONEDDS_URI,<Tracing><Verbosity>finest" Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
c2cf340a1b
commit
a6d92aac8c
5 changed files with 1159 additions and 1248 deletions
|
@ -238,7 +238,7 @@ struct config
|
|||
char *tracingOutputFileName;
|
||||
int tracingTimestamps;
|
||||
int tracingAppendToFile;
|
||||
unsigned allowMulticast;
|
||||
uint32_t allowMulticast;
|
||||
enum transport_selector transport_selector;
|
||||
enum boolean_default compat_use_ipv6;
|
||||
enum boolean_default compat_tcp_enable;
|
||||
|
@ -413,6 +413,7 @@ struct cfgst;
|
|||
|
||||
struct cfgst *config_init (const char *configfile);
|
||||
void config_print_cfgst (struct cfgst *cfgst);
|
||||
void config_free_source_info (struct cfgst *cfgst);
|
||||
void config_fini (struct cfgst *cfgst);
|
||||
|
||||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -584,8 +584,10 @@ int rtps_config_prep (struct cfgst *cfgst)
|
|||
thread_states_init (max_threads);
|
||||
}
|
||||
|
||||
/* Now the per-thread-log-buffers are set up, so print the configuration */
|
||||
/* Now the per-thread-log-buffers are set up, so print the configuration. After this there
|
||||
is no value to the source information for the various configuration elements, so free those. */
|
||||
config_print_cfgst (cfgst);
|
||||
config_free_source_info (cfgst);
|
||||
return 0;
|
||||
|
||||
err_config_late_error:
|
||||
|
|
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
|
||||
#define DDSRT_XMLP_REQUIRE_EOF 1u /* set by default; if not set, junk may follow top-level closing tag */
|
||||
#define DDSRT_XMLP_ANONYMOUS_CLOSE_TAG 2u /* clear by default; if set allow closing an element with </> instead of </name> */
|
||||
|
||||
#define DDSRT_XMLP_MISSING_CLOSE_AS_EOF 4u /* clear by default; if set, treat missing close tag as EOF */
|
||||
DDS_EXPORT struct ddsrt_xmlp_state *ddsrt_xmlp_new_file (FILE *fp, void *varg, const struct ddsrt_xmlp_callbacks *cb);
|
||||
DDS_EXPORT struct ddsrt_xmlp_state *ddsrt_xmlp_new_string (const char *string, void *varg, const struct ddsrt_xmlp_callbacks *cb);
|
||||
DDS_EXPORT void ddsrt_xmlp_set_options (struct ddsrt_xmlp_state *st, unsigned options);
|
||||
|
|
|
@ -35,6 +35,7 @@ struct ddsrt_xmlp_state {
|
|||
size_t cbufn; /* number of bytes in cbuf (cbufp <= cbufn) */
|
||||
size_t cbufmax; /* allocated size of cbuf (cbufn <= cbufmax) */
|
||||
size_t cbufmark; /* NORMARKER or marker position (cbufmark <= cbufp) for rewinding */
|
||||
int eof; /* fake EOF (for treating missing close tags as EOF) */
|
||||
char *cbuf; /* parser input buffer */
|
||||
FILE *fp; /* file to refill cbuf from, or NULL if parsing a string */
|
||||
int line; /* current line number */
|
||||
|
@ -97,6 +98,7 @@ static void ddsrt_xmlp_new_common (struct ddsrt_xmlp_state *st)
|
|||
{
|
||||
st->cbufp = 0;
|
||||
st->cbufmark = NOMARKER;
|
||||
st->eof = 0;
|
||||
st->tpp = 0;
|
||||
st->tpescp = 0;
|
||||
st->tpsz = 1024;
|
||||
|
@ -170,6 +172,9 @@ void ddsrt_xmlp_free (struct ddsrt_xmlp_state *st)
|
|||
static int make_chars_available (struct ddsrt_xmlp_state *st, size_t nmin)
|
||||
{
|
||||
size_t n, pos;
|
||||
if (st->eof) {
|
||||
return 0;
|
||||
}
|
||||
pos = (st->cbufmark != NOMARKER) ? st->cbufmark : st->cbufp;
|
||||
assert (st->cbufn >= st->cbufp);
|
||||
assert (st->cbufmax >= st->cbufn);
|
||||
|
@ -215,6 +220,11 @@ static void discard_input_marker (struct ddsrt_xmlp_state *st)
|
|||
st->linemark = 0;
|
||||
}
|
||||
|
||||
static int have_input_marker (struct ddsrt_xmlp_state *st)
|
||||
{
|
||||
return (st->cbufmark != NOMARKER);
|
||||
}
|
||||
|
||||
static void rewind_to_input_marker (struct ddsrt_xmlp_state *st)
|
||||
{
|
||||
assert (st->cbufmark != NOMARKER);
|
||||
|
@ -680,12 +690,22 @@ static int parse_element (struct ddsrt_xmlp_state *st, uintptr_t parentinfo)
|
|||
}
|
||||
}
|
||||
st->nest--;
|
||||
set_input_marker (st);
|
||||
if (((tok = next_token (st, &ename)) != TOK_CLOSE_TAG && tok != TOK_SHORTHAND_CLOSE_TAG) || next_char (st) != '>') {
|
||||
if (!(st->options & DDSRT_XMLP_MISSING_CLOSE_AS_EOF)) {
|
||||
PE_LOCAL_ERROR ("expecting closing tag", name);
|
||||
} else {
|
||||
rewind_to_input_marker (st);
|
||||
st->eof = 1;
|
||||
tok = TOK_SHORTHAND_CLOSE_TAG;
|
||||
}
|
||||
}
|
||||
if (tok != TOK_SHORTHAND_CLOSE_TAG && strcmp (name, ename) != 0) {
|
||||
PE_LOCAL_ERROR ("open/close tag mismatch", ename);
|
||||
}
|
||||
if (have_input_marker (st)) {
|
||||
discard_input_marker (st);
|
||||
}
|
||||
ret = st->cb.elem_close (st->varg, eleminfo);
|
||||
goto ok;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue