+ struct json_object *x;
+ return json_object_object_get_ex(config, name_of_optid(optid), &x)
+ && json_object_get_boolean(x);
+}
+
+static int config_has_str(struct json_object *config, int optid, const char *val)
+{
+ int i, n;
+ struct json_object *a;
+
+ if (!json_object_object_get_ex(config, name_of_optid(optid), &a))
+ return 0;
+
+ if (!json_object_is_type(a, json_type_array))
+ return !strcmp(val, json_object_get_string(a));
+
+ n = (int)json_object_array_length(a);
+ for (i = 0 ; i < n ; i++) {
+ if (!strcmp(val, json_object_get_string(json_object_array_get_idx(a, i))))
+ return 1;
+ }
+ return 0;
+}
+
+static void config_set(struct json_object *config, int optid, struct json_object *val)
+{
+ json_object_object_add(config, name_of_optid(optid), val);
+}
+
+static void config_set_str(struct json_object *config, int optid, const char *val)
+{
+ config_set(config, optid, to_jstr(val));
+}
+
+static void config_set_optstr(struct json_object *config, int optid)
+{
+ config_set_str(config, optid, get_arg(optid));
+}
+
+static void config_set_int(struct json_object *config, int optid, int value)
+{
+ config_set(config, optid, to_jint(value));
+}
+
+static void config_set_bool(struct json_object *config, int optid, int value)
+{
+ config_set(config, optid, to_jbool(value));
+}
+
+static void config_set_optint_base(struct json_object *config, int optid, int mini, int maxi, int base)
+{
+ const char *beg, *end;