vector<const char*> args, nargs;
deque<const char *> sections;
unsigned i;
+ std::vector<const char *> empty_args;
+ char buf[1024];
DEFINE_CONF_VARS(usage);
argv_to_vec(argc, argv, args);
goto done_ok;
}
+ parse_startup_config_options(empty_args, type);
+ if (ceph_def_conf_by_name(key, buf, sizeof(buf)))
+ cout << buf << std::endl;
+
exit(1);
done_ok:
return true;
}
+static int def_conf_to_str(config_option *opt, char *buf, int len)
+{
+ int ret = 0;
+
+ switch (opt->type) {
+ case OPT_INT:
+ case OPT_BOOL:
+ ret = snprintf(buf, len, "%d", (int)opt->def_longlong);
+ break;
+ case OPT_LONGLONG:
+ ret = snprintf(buf, len, "%lld", opt->def_longlong);
+ break;
+ case OPT_STR:
+ case OPT_ADDR:
+ ret = snprintf(buf, len, "%s", opt->def_str);
+ break;
+ case OPT_FLOAT:
+ case OPT_DOUBLE:
+ ret = snprintf(buf, len, "%f", opt->def_double);
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+int ceph_def_conf_by_name(const char *name, char *buf, int buflen)
+{
+ char *newname = strdup(name);
+ int len = strlen(name);
+ config_option *opt;
+ int ret = 0;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (newname[i] == ' ')
+ newname[i] = '_';
+ }
+
+ len = sizeof(config_optionsp)/sizeof(config_option);
+
+ for (i = 0; i < len; i++) {
+ opt = &config_optionsp[i];
+ if (strcmp(opt->name, newname) == 0) {
+ ret = def_conf_to_str(opt, buf, buflen);
+ break;
+ }
+ }
+ free(newname);
+ return ret;
+}
+
static void fini_g_conf()
{
int len = sizeof(config_optionsp)/sizeof(config_option);
int conf_read_key(const char *alt_section, const char *key, opt_type_t type, void *out, void *def, bool free_old_val = false);
bool conf_set_conf_val(void *field, opt_type_t type, const char *val);
bool conf_cmd_equals(const char *cmd, const char *opt, char char_opt, unsigned int *val_pos);
+int ceph_def_conf_by_name(const char *name, char *buf, int len);
class ExportControl;
ExportControl *conf_get_export_control();