+static void config_mix2_str(struct json_object *config, int optid, const char *val)
+{
+ size_t st1, st2;
+ const char *api, *key;
+ struct json_object *obj, *sub;
+ enum json_tokener_error jerr;
+
+ st1 = strcspn(val, "/:{[\"");
+ st2 = strcspn(&val[st1], ":{[\"");
+ if (val[st1] != '/' || val[st1 + st2] != ':') {
+ obj = json_tokener_parse_verbose(val, &jerr);
+ if (jerr != json_tokener_success)
+ obj = json_object_new_string(val);
+ } else {
+ api = st1 == 0 ? "*" : strndupa(val, st1);
+ val += st1 + 1;
+ key = st2 <= 1 || (st2 == 2 && *val == '*') ? NULL : strndupa(val, st2 - 1);
+ val += st2;
+ sub = json_tokener_parse_verbose(val, &jerr);
+ if (jerr != json_tokener_success)
+ sub = json_object_new_string(val);
+
+ if (key) {
+ obj = json_object_new_object();
+ json_object_object_add(obj, key, sub);
+ sub = obj;
+ }
+ obj = json_object_new_object();
+ json_object_object_add(obj, api, sub);
+ }
+ config_mix2(config, optid, obj);
+ json_object_put(obj);
+}
+
+static void config_mix2_optstr(struct json_object *config, int optid)
+{
+ config_mix2_str(config, optid, get_arg(optid));
+}
+
+/*---------------------------------------------------------
+ | set the log levels
+ +--------------------------------------------------------- */
+
+static void set_log(const char *args)
+{
+ char o = 0, s, *p, *i = strdupa(args);
+ int lvl;
+
+ for(;;) switch (*i) {
+ case 0:
+ return;
+ case '+':
+ case '-':
+ o = *i;
+ /*@fallthrough@*/
+ case ' ':
+ case ',':
+ i++;
+ break;
+ default:
+ p = i;
+ while (isalpha(*p)) p++;
+ s = *p;
+ *p = 0;
+ lvl = verbose_level_of_name(i);
+ if (lvl < 0) {
+ i = strdupa(i);
+ *p = s;
+ ERROR("Bad log name '%s' in %s", i, args);
+ exit(1);
+ }
+ *p = s;
+ i = p;
+ if (o == '-')
+ verbose_sub(lvl);
+ else {
+ if (!o) {
+ verbose_clear();
+ o = '+';
+ }
+ verbose_add(lvl);
+ }
+ break;
+ }
+}
+
+/*---------------------------------------------------------
+ | Parse option and launch action
+ +--------------------------------------------------------- */
+
+static void parse_arguments_inner(int argc, char **argv, struct json_object *config, struct option *options)
+{
+ struct json_object *conf;
+ int optid, cind, dodump = 0;
+
+ for (;;) {
+ cind = optind;
+ optid = getopt_long(argc, argv, shortopts, options, NULL);
+ if (optid < 0) {
+ /* end of options */
+ break;
+ }
+ switch (optid) {