From: Colin Patrick McCabe Date: Mon, 28 Mar 2011 23:02:11 +0000 (-0700) Subject: common: more argument parsing into ceph_argparse X-Git-Tag: v0.27~236 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=51e21a71bbbcb459c06173e08d27a7a628f4e563;p=ceph.git common: more argument parsing into ceph_argparse Signed-off-by: Colin McCabe --- diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 748fab0ac6f7..35cf438f174f 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -43,6 +43,91 @@ #undef generic_dout #undef dendl +static bool cmd_is_char(const char *cmd) +{ + return ((cmd[0] == '-') && + cmd[1] && !cmd[2]); +} + +bool ceph_argparse_cmd_equals(const char *cmd, const char *opt, char char_opt, + unsigned int *val_pos) +{ + unsigned int i; + unsigned int len = strlen(opt); + + *val_pos = 0; + + if (!*cmd) + return false; + + if (char_opt && cmd_is_char(cmd)) + return (char_opt == cmd[1]); + + if ((cmd[0] != '-') || (cmd[1] != '-')) + return false; + + for (i=0; iparse(val); - break; - default: - return false; - } - - return true; -} - bool conf_set_conf_val(void *field, opt_type_t type, const char *val, long long intval, double doubleval) { switch (type) { @@ -508,51 +469,6 @@ static void set_conf_name(config_option *opt) opt->conf_name = (const char *)newconf; } -static bool cmd_is_char(const char *cmd) -{ - return ((cmd[0] == '-') && - cmd[1] && !cmd[2]); -} - -bool conf_cmd_equals(const char *cmd, const char *opt, char char_opt, unsigned int *val_pos) -{ - unsigned int i; - unsigned int len = strlen(opt); - - *val_pos = 0; - - if (!*cmd) - return false; - - if (char_opt && cmd_is_char(cmd)) - return (char_opt == cmd[1]); - - if ((cmd[0] != '-') || (cmd[1] != '-')) - return false; - - for (i=0; i