}
/**
- * conf_get_param_pair - Get the next 'name=value' parameter pair.
+ * conf_replace_char - replace one char with another.
+ */
+
+char *conf_replace_char(char *s, char from, char to)
+{
+ if (!s)
+ return NULL;
+
+ for ( ; *s; s++)
+ if (*s == from)
+ *s = to;
+
+ return s;
+}
+
+/**
+ * conf_get_pair - Get the next 'name/value' parameter pair.
* @str: The string to process.
* @name_out: Returns a pointer to the name.
* @value_out: Returns a pointer to the value.
- * @terminator: The pair separator/terminator.
+ * @tdelimiter: The pair separator.
+ * @terminator: The pair terminator.
*
* Parses a name=value pair returning pointers in @name_out and @value_out.
* The pair can be terminated by @terminator or a zero.
* string.
*/
-char *conf_get_param_pair(char *str, char **name_out, char **value_out,
- char terminator)
+char *conf_get_pair(struct conf_context __attribute__((unused)) *conf, char *str,
+ char **name_out, char **value_out, char delimiter, char terminator)
{
char *sep, *end;
+ *name_out = *value_out = NULL;
+
/* terminate the value */
end = strchr(str, terminator);
if (end)
*end = 0;
- sep = strchr(str, '=');
+ conf_replace_char(str, '\t', ' ');
+
+ str = conf_strip_str(str);
+
+ if (!str)
+ goto exit;
+
+ sep = strchr(str, delimiter);
if (!sep) {
*name_out = NULL;
*value_out = conf_strip_str(sep + 1);
}
+exit:
pb_log("%s: @%s@%s@\n", __func__, *name_out, *value_out);
return end ? end + 1 : NULL;
return 0;
}
+/**
+ * conf_init_global_options - Zero the global option table.
+ */
+
+void conf_init_global_options(struct conf_context *conf)
+{
+ int i;
+
+ if (!conf->global_options)
+ return;
+
+ for (i = 0; conf->global_options[i].name; i++)
+ conf->global_options[i].value = NULL;
+}
+
/**
* conf_set_global_option - Set a value in the global option table.
*
{
int i;
+ assert(conf->global_options);
+
for (i = 0; conf->global_options[i].name; i++) {
if (streq(name, conf->global_options[i].name)) {
conf->global_options[i].value
= talloc_strdup(conf, value);
- pb_log("%s: %s:%s\n", __func__, name, value);
+ pb_log("%s: @%s@%s@\n", __func__, name, value);
return 1;
}
}
{
int i;
+ assert(conf->global_options);
+
for (i = 0; conf->global_options[i].name ;i++)
- if (streq(name, conf->global_options[i].name))
+ if (streq(name, conf->global_options[i].name)) {
+ pb_log("%s: @%s@%s@\n", __func__, name,
+ conf->global_options[i].value);
return conf->global_options[i].value;
+ }
assert(0 && "unknown global name");
return NULL;
{
char *pos, *name, *value;
+ assert(conf->get_pair);
+ assert(conf->process_pair);
+
for (pos = conf->buf; pos;) {
- pos = conf_get_param_pair(pos, &name, &value, '\n');
+ pos = conf->get_pair(conf, pos, &name, &value, '\n');
if (!value)
continue;