]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: rename old argument parsing macros
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 28 Mar 2011 23:10:33 +0000 (16:10 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 28 Mar 2011 23:14:47 +0000 (16:14 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
17 files changed:
src/cauthtool.cc
src/cconf.cc
src/cfuse.cc
src/cmds.cc
src/cmon.cc
src/common/ceph_argparse.h
src/common/config.cc
src/cosd.cc
src/crushtool.cc
src/monmaptool.cc
src/osdmaptool.cc
src/rados.cc
src/rbd.cc
src/rgw/rgw_admin.cc
src/test/TestSignalHandlers.cc
src/tools/ceph.cc
src/tools/gceph.cc

index c49528153c1628a86fc409fd7c8371462ef48bd9..4c1e7ec7dd93dfea349464c59688b9b32148731d 100644 (file)
@@ -74,32 +74,32 @@ int main(int argc, const char **argv)
   bool bin_keyring = false;
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("gen-key", 'g')) {
-      CONF_SAFE_SET_ARG_VAL(&gen_key, OPT_BOOL);
-    } else if (CONF_ARG_EQ("gen-print-key", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&gen_print_key, OPT_BOOL);
-    } else if (CONF_ARG_EQ("add-key", 'a')) {
-      CONF_SAFE_SET_ARG_VAL(&add_key, OPT_STR);
-    } else if (CONF_ARG_EQ("list", 'l')) {
-      CONF_SAFE_SET_ARG_VAL(&list, OPT_BOOL);
-    } else if (CONF_ARG_EQ("caps", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&caps_fn, OPT_STR);
-    } else if (CONF_ARG_EQ("cap", '\0')) {
+    if (CEPH_ARGPARSE_EQ("gen-key", 'g')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&gen_key, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("gen-print-key", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&gen_print_key, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("add-key", 'a')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&add_key, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("list", 'l')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&list, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("caps", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&caps_fn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("cap", '\0')) {
       const char *key, *val;
-      CONF_SAFE_SET_ARG_VAL(&key, OPT_STR);
-      CONF_SAFE_SET_ARG_VAL(&val, OPT_STR);
+      CEPH_ARGPARSE_SET_ARG_VAL(&key, OPT_STR);
+      CEPH_ARGPARSE_SET_ARG_VAL(&val, OPT_STR);
       ::encode(val, caps[key]);
-    } else if (CONF_ARG_EQ("print-key", 'p')) {
-      CONF_SAFE_SET_ARG_VAL(&print_key, OPT_BOOL);
-    } else if (CONF_ARG_EQ("create-keyring", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&create_keyring, OPT_BOOL);
-    } else if (CONF_ARG_EQ("import-keyring", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&import_keyring, OPT_STR);
-    } else if (CONF_ARG_EQ("set-uid", 'u')) {
-      CONF_SAFE_SET_ARG_VAL(&auid, OPT_LONGLONG);
+    } else if (CEPH_ARGPARSE_EQ("print-key", 'p')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&print_key, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("create-keyring", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&create_keyring, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("import-keyring", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&import_keyring, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("set-uid", 'u')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&auid, OPT_LONGLONG);
       set_auid = true;
-    } else if (CONF_ARG_EQ("bin", 'b')) {
-      CONF_SAFE_SET_ARG_VAL(&bin_keyring, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("bin", 'b')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&bin_keyring, OPT_BOOL);
     } else if (!fn) {
       fn = args[i];
     } else 
index 7b8a18b1e1cad0a350c121f90c8b7e4144d9047d..ee5901a5469b1170120c1422adbd87315750a4f6 100644 (file)
@@ -128,17 +128,17 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("section", 's')) {
-      CONF_SAFE_SET_ARG_VAL(&section, OPT_STR);
+    if (CEPH_ARGPARSE_EQ("section", 's')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&section, OPT_STR);
       sections.push_back(section);
-    } else if (CONF_ARG_EQ("resolve-search", 'r')) {
-      CONF_SAFE_SET_ARG_VAL(&resolve_search, OPT_BOOL);
-    } else if (CONF_ARG_EQ("help", 'h')) {
-      CONF_SAFE_SET_ARG_VAL(&do_help, OPT_BOOL);
-    } else if (CONF_ARG_EQ("list-sections", 'l')) {
-      CONF_SAFE_SET_ARG_VAL(&do_list, OPT_BOOL);
-    } else if (CONF_ARG_EQ("lookup", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&do_lookup, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("resolve-search", 'r')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&resolve_search, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("help", 'h')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&do_help, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("list-sections", 'l')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&do_list, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("lookup", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&do_lookup, OPT_BOOL);
     }
     else {
       nargs.push_back(args[i]);
index 100cbf333a33e0e3eac4dd37f53600816b7b919b..3c53bf04c54d1a4e9fa2107e66d139bbafbb850a 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, const char **argv, const char *envp[]) {
 
   vector<const char*> nargs;
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("localize-reads", '\0')) {
+    if (CEPH_ARGPARSE_EQ("localize-reads", '\0')) {
       cerr << "setting CEPH_OSD_FLAG_LOCALIZE_READS" << std::endl;
       filer_flags |= CEPH_OSD_FLAG_LOCALIZE_READS;
     }
index 459613a646738a8ec66196dacde52f14ec2d6723..aa55e052254e4b5a841c0d736eba9cee0594aa3c 100644 (file)
@@ -74,15 +74,15 @@ int main(int argc, const char **argv)
   const char *dump_file = NULL;
   int reset_journal = -1;
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("dump-journal", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&dump_journal, OPT_INT);
-      CONF_SAFE_SET_ARG_VAL(&dump_file, OPT_STR);
+    if (CEPH_ARGPARSE_EQ("dump-journal", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&dump_journal, OPT_INT);
+      CEPH_ARGPARSE_SET_ARG_VAL(&dump_file, OPT_STR);
       dout(0) << "dumping journal for mds" << dump_journal << " to " << dump_file << dendl;
-    } else if (CONF_ARG_EQ("reset-journal", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&reset_journal, OPT_INT);
-    } else if (CONF_ARG_EQ("journal-check", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("reset-journal", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&reset_journal, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("journal-check", '\0')) {
       int check_rank;
-      CONF_SAFE_SET_ARG_VAL(&check_rank, OPT_INT);
+      CEPH_ARGPARSE_SET_ARG_VAL(&check_rank, OPT_INT);
       
       if (shadow) {
         dout(0) << "Error: can only select one standby state" << dendl;
@@ -92,9 +92,9 @@ int main(int argc, const char **argv)
       shadow = MDSMap::STATE_ONESHOT_REPLAY;
       g_conf.mds_standby_for_rank = check_rank;
       ++i;
-    } else if (CONF_ARG_EQ("hot-standby", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("hot-standby", '\0')) {
       int check_rank;
-      CONF_SAFE_SET_ARG_VAL(&check_rank, OPT_INT);
+      CEPH_ARGPARSE_SET_ARG_VAL(&check_rank, OPT_INT);
       if (shadow) {
         dout(0) << "Error: can only select one standby state" << dendl;
         return -1;
@@ -104,7 +104,7 @@ int main(int argc, const char **argv)
       g_conf.mds_standby_for_rank = check_rank;
     } else {
       derr << "unrecognized arg " << args[i] << dendl;
-      ARGS_USAGE();
+      usage();
     }
   }
   if (g_conf.name->has_default_id() && dump_journal < 0 && reset_journal < 0) {
index 96ed18deb7f4d17b0fd629b439f36ba1d7dfde7c..2f54c67154f24b22cc827ea91774defe487540a4 100644 (file)
@@ -65,10 +65,10 @@ int main(int argc, const char **argv)
   keyring_init(&g_conf);
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("mkfs", '\0')) {
+    if (CEPH_ARGPARSE_EQ("mkfs", '\0')) {
       mkfs = true;
-    } else if (CONF_ARG_EQ("osdmap", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&osdmapfn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("osdmap", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&osdmapfn, OPT_STR);
     } else
       usage();
   }
index b53a086791654fcab0032e67028e0c198d576ec2..22e8bacfb4649715225e9700992918499ef803f2 100644 (file)
        __isarg = 1 < args.size(); \
        for (unsigned i=0; i<args.size(); i++, __isarg = i+1 < args.size())
 
-#define ARGS_USAGE() args_usage();
-
 #define DEFINE_CONF_VARS(usage_func) \
        unsigned int val_pos __attribute__((unused)); \
        void (*args_usage)() __attribute__((unused)) = usage_func; \
        bool __isarg __attribute__((unused))
 
-#define CONF_NEXT_VAL (val_pos ? &args[i][val_pos] : args[++i])
-
-#define CONF_SET_ARG_VAL(dest, type) \
-       ceph_argparse_cmdline_val(dest, type, CONF_NEXT_VAL)
+#define CEPH_ARGPARSE_NEXT_VAL (val_pos ? &args[i][val_pos] : args[++i])
 
-#define CONF_VAL args[i]
+#define CEPH_ARGPARSE_VAL args[i]
 
-#define CONF_SAFE_SET_ARG_VAL(dest, type) \
+#define CEPH_ARGPARSE_SET_ARG_VAL(dest, type) \
        do { \
           __isarg = i+1 < args.size(); \
           if (__isarg && !val_pos && \
               __isarg = false; \
           if (type == OPT_BOOL) { \
                if (val_pos) { \
-                       CONF_SET_ARG_VAL(dest, type); \
+                       ceph_argparse_cmdline_val(dest, type, CEPH_ARGPARSE_NEXT_VAL); \
                } else \
                        ceph_argparse_cmdline_val(dest, type, "true"); \
           } else if (__isarg || val_pos) { \
-               CONF_SET_ARG_VAL(dest, type); \
+               ceph_argparse_cmdline_val(dest, type, CEPH_ARGPARSE_NEXT_VAL); \
          } else if (args_usage) \
                args_usage(); \
        } while (0)
 
-#define CONF_ARG_EQ(str_cmd, char_cmd) \
+#define CEPH_ARGPARSE_EQ(str_cmd, char_cmd) \
        ceph_argparse_cmd_equals(args[i], str_cmd, char_cmd, &val_pos)
 
 extern bool ceph_argparse_cmdline_val(void *field, int type,
index 4cada825d72bfff1410d72a26aec2d08311f1936..36b9fbb02c4b0c6a19c953b43a7a9be150e85274 100644 (file)
@@ -782,12 +782,12 @@ parse_argv_part2(std::vector<const char*>& args)
     int optn;
 
     for (optn = 0; optn < opt_len; optn++) {
-      if (CONF_ARG_EQ("lockdep", '\0')) {
-       CONF_SAFE_SET_ARG_VAL(&g_lockdep, OPT_INT);
-      } else if (CONF_ARG_EQ(config_optionsp[optn].name,
+      if (CEPH_ARGPARSE_EQ("lockdep", '\0')) {
+       CEPH_ARGPARSE_SET_ARG_VAL(&g_lockdep, OPT_INT);
+      } else if (CEPH_ARGPARSE_EQ(config_optionsp[optn].name,
            config_optionsp[optn].char_option)) {
         if (__isarg || val_pos || config_optionsp[optn].type == OPT_BOOL)
-           CONF_SAFE_SET_ARG_VAL(config_optionsp[optn].val_ptr, config_optionsp[optn].type);
+           CEPH_ARGPARSE_SET_ARG_VAL(config_optionsp[optn].val_ptr, config_optionsp[optn].type);
         else
           continue;
       } else {
index 817d491557e0836feaad89313f6ac039e0b20b50..c1624115b6ccfa1b0c2d524e85a56ad4ec224287 100644 (file)
@@ -65,17 +65,17 @@ int main(int argc, const char **argv)
   bool flushjournal = false;
   char *dump_pg_log = 0;
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("mkfs", '\0')) {
+    if (CEPH_ARGPARSE_EQ("mkfs", '\0')) {
       mkfs = true;
-    } else if (CONF_ARG_EQ("mkjournal", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("mkjournal", '\0')) {
       mkjournal = true;
-    } else if (CONF_ARG_EQ("flush-journal", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("flush-journal", '\0')) {
       flushjournal = true;
-    } else if (CONF_ARG_EQ("dump-pg-log", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&dump_pg_log, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("dump-pg-log", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&dump_pg_log, OPT_STR);
     } else {
       derr << "unrecognized arg " << args[i] << dendl;
-      ARGS_USAGE();
+      usage();
     }
   }
 
index add1c27e0130abf6f12041dc75644b1542bcb0b2..e60b623532cb60962e84795cda6ffbab5d5fcf8e 100644 (file)
@@ -797,46 +797,46 @@ int main(int argc, const char **argv)
   DEFINE_CONF_VARS(usage);
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("clobber", '\0')) {
+    if (CEPH_ARGPARSE_EQ("clobber", '\0')) {
       clobber = true;
-    } else if (CONF_ARG_EQ("decompile", 'd')) {
-      CONF_SAFE_SET_ARG_VAL(&infn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("decompile", 'd')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&infn, OPT_STR);
       decompile = true;
-    } else if (CONF_ARG_EQ("outfn", 'o')) {
-      CONF_SAFE_SET_ARG_VAL(&outfn, OPT_STR);
-    } else if (CONF_ARG_EQ("compile", 'c')) {
-      CONF_SAFE_SET_ARG_VAL(&srcfn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("outfn", 'o')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&outfn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("compile", 'c')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&srcfn, OPT_STR);
       compile = true;
-    } else if (CONF_ARG_EQ("test", 't')) {
-      CONF_SAFE_SET_ARG_VAL(&infn, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("test", 't')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&infn, OPT_STR);
       test = true;
-    } else if (CONF_ARG_EQ("verbose", 'v')) {
+    } else if (CEPH_ARGPARSE_EQ("verbose", 'v')) {
       verbose++;
-    } else if (CONF_ARG_EQ("build", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&build, OPT_BOOL);
-    } else if (CONF_ARG_EQ("num_osds", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&num_osds, OPT_INT);
-    } else if (CONF_ARG_EQ("num_rep", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&num_rep, OPT_INT);
-    } else if (CONF_ARG_EQ("max_x", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&max_x, OPT_INT);
-    } else if (CONF_ARG_EQ("min_x", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&min_x, OPT_INT);
-    } else if (CONF_ARG_EQ("x", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&min_x, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("build", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&build, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("num_osds", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&num_osds, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("num_rep", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&num_rep, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("max_x", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&max_x, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("min_x", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&min_x, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("x", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&min_x, OPT_INT);
       max_x = min_x;
-    } else if (CONF_ARG_EQ("max_rule", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&max_rule, OPT_INT);
-    } else if (CONF_ARG_EQ("min_rule", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&min_rule, OPT_INT);
-    } else if (CONF_ARG_EQ("rule", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&min_rule, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("max_rule", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&max_rule, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("min_rule", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&min_rule, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("rule", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&min_rule, OPT_INT);
       max_rule = min_rule;
-    } else if (CONF_ARG_EQ("weight", 'w')) {
+    } else if (CEPH_ARGPARSE_EQ("weight", 'w')) {
       int dev;
-      CONF_SAFE_SET_ARG_VAL(&dev, OPT_INT);
+      CEPH_ARGPARSE_SET_ARG_VAL(&dev, OPT_INT);
       float f;
-      CONF_SAFE_SET_ARG_VAL(&f, OPT_FLOAT);
+      CEPH_ARGPARSE_SET_ARG_VAL(&f, OPT_FLOAT);
       int w = (int)(f * 0x10000);
       if (w < 0)
        w = 0;
index 9f126c4b3ccff7d44798d439f0704ceb616e4ed8..fac8b3aca6e725f376c1e097996db08ba0721fec 100644 (file)
@@ -52,13 +52,13 @@ int main(int argc, const char **argv)
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
              CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("print", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&print, OPT_BOOL);
-    } else if (CONF_ARG_EQ("create", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&create, OPT_BOOL);
-    } else if (CONF_ARG_EQ("clobber", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&clobber, OPT_BOOL);
-    } else if (CONF_ARG_EQ("add", '\0')) {
+    if (CEPH_ARGPARSE_EQ("print", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&print, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("create", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&create, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("clobber", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&clobber, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("add", '\0')) {
       if (++i >= args.size())
        usage();
       string name = args[i];
@@ -71,7 +71,7 @@ int main(int argc, const char **argv)
       }
       add[name] = addr;
       modified = true;
-    } else if (CONF_ARG_EQ("rm", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("rm", '\0')) {
       if (++i >= args.size())
        usage();
       string name = args[i];
index 77c49b085e2038601f8c10c52ffbcc02cc5eb573..33bc284d884b5668d79d612a2b7e4a32ee433636 100644 (file)
@@ -71,33 +71,33 @@ int main(int argc, const char **argv)
   bool test_crush = false;
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("help", 'h')) {
+    if (CEPH_ARGPARSE_EQ("help", 'h')) {
       usage();
-    } else if (CONF_ARG_EQ("print", 'p')) {
-      CONF_SAFE_SET_ARG_VAL(&print, OPT_BOOL);
-    } else if (CONF_ARG_EQ("createsimple", '\0')) {
+    } else if (CEPH_ARGPARSE_EQ("print", 'p')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&print, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("createsimple", '\0')) {
       createsimple = true;
-      CONF_SAFE_SET_ARG_VAL(&num_osd, OPT_INT);
-    } else if (CONF_ARG_EQ("clobber", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&clobber, OPT_BOOL);
-    } else if (CONF_ARG_EQ("pg_bits", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&pg_bits, OPT_INT);
-    } else if (CONF_ARG_EQ("pgp_bits", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&pgp_bits, OPT_INT);
-    } else if (CONF_ARG_EQ("lpg_bits", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&lpg_bits, OPT_INT);
-    } else if (CONF_ARG_EQ("num_dom", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&num_dom, OPT_INT);
-    } else if (CONF_ARG_EQ("export_crush", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&export_crush, OPT_STR);
-    } else if (CONF_ARG_EQ("import_crush", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&import_crush, OPT_STR);
-    } else if (CONF_ARG_EQ("test_map_pg", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&test_map_pg, OPT_STR);
-    } else if (CONF_ARG_EQ("test_map_object", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&test_map_object, OPT_STR);
-    } else if (CONF_ARG_EQ("test_crush", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&test_crush, OPT_BOOL);
+      CEPH_ARGPARSE_SET_ARG_VAL(&num_osd, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("clobber", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&clobber, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("pg_bits", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&pg_bits, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("pgp_bits", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&pgp_bits, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("lpg_bits", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&lpg_bits, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("num_dom", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&num_dom, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("export_crush", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&export_crush, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("import_crush", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&import_crush, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("test_map_pg", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&test_map_pg, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("test_map_object", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&test_map_object, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("test_crush", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&test_crush, OPT_BOOL);
     } else if (!fn)
       fn = args[i];
     else 
index 525774c0055c4ae234e33c4d12c3b4098bba73ba..1b3279d6bb30f487cf508af7462eca0303b8d763 100644 (file)
@@ -284,20 +284,20 @@ int main(int argc, const char **argv)
   bool create_pool = false;
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("pool", 'p')) {
-      CONF_SAFE_SET_ARG_VAL(&pool_name, OPT_STR);
-    } else if (CONF_ARG_EQ("snapid", 'S')) {
-      CONF_SAFE_SET_ARG_VAL(&snapid, OPT_LONGLONG);
-    } else if (CONF_ARG_EQ("snap", 's')) {
-      CONF_SAFE_SET_ARG_VAL(&snapname, OPT_STR);
-    } else if (CONF_ARG_EQ("help", 'h')) {
+    if (CEPH_ARGPARSE_EQ("pool", 'p')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&pool_name, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("snapid", 'S')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&snapid, OPT_LONGLONG);
+    } else if (CEPH_ARGPARSE_EQ("snap", 's')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&snapname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("help", 'h')) {
       usage();
-    } else if (CONF_ARG_EQ("concurrent-ios", 't')) {
-      CONF_SAFE_SET_ARG_VAL(&concurrent_ios, OPT_INT);
-    } else if (CONF_ARG_EQ("block-size", 'b')) {
-      CONF_SAFE_SET_ARG_VAL(&op_size, OPT_INT);
-    } else if (CONF_ARG_EQ("create-pool", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&create_pool, OPT_BOOL);
+    } else if (CEPH_ARGPARSE_EQ("concurrent-ios", 't')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&concurrent_ios, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("block-size", 'b')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&op_size, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("create-pool", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&create_pool, OPT_BOOL);
     } else if (args[i][0] == '-' && nargs.empty()) {
       cerr << "unrecognized option " << args[i] << std::endl;
       usage();
index f4e789b21abde9eea4b81e0c7c9710ed15a61f34..56021a1b50d39e3017895c9047828ccd0eea7398 100644 (file)
@@ -591,34 +591,34 @@ int main(int argc, const char **argv)
   const char *imgname = NULL, *snapname = NULL, *destname = NULL, *dest_poolname = NULL, *path = NULL;
   bool is_snap_cmd = false;
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("pool", 'p')) {
-      CONF_SAFE_SET_ARG_VAL(&poolname, OPT_STR);
-    } else if (CONF_ARG_EQ("dest-pool", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&dest_poolname, OPT_STR);
-    } else if (CONF_ARG_EQ("snap", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&snapname, OPT_STR);
-    } else if (CONF_ARG_EQ("image", 'i')) {
-      CONF_SAFE_SET_ARG_VAL(&imgname, OPT_STR);
-    } else if (CONF_ARG_EQ("size", 's')) {
-      CONF_SAFE_SET_ARG_VAL(&size, OPT_LONGLONG);
+    if (CEPH_ARGPARSE_EQ("pool", 'p')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&poolname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("dest-pool", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&dest_poolname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("snap", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&snapname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("image", 'i')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&imgname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("size", 's')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&size, OPT_LONGLONG);
       size <<= 20; // MB -> bytes
-    } else if (CONF_ARG_EQ("order", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&order, OPT_INT);
-    } else if (CONF_ARG_EQ("path", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&path, OPT_STR);
-    } else if (CONF_ARG_EQ("dest", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&destname, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("order", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&order, OPT_INT);
+    } else if (CEPH_ARGPARSE_EQ("path", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&path, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("dest", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&destname, OPT_STR);
     } else {
       if (!opt_cmd) {
-        opt_cmd = get_cmd(CONF_VAL, &is_snap_cmd);
+        opt_cmd = get_cmd(CEPH_ARGPARSE_VAL, &is_snap_cmd);
         if (opt_cmd < 0) {
-          cerr << "invalid command: " << CONF_VAL << std::endl;
+          cerr << "invalid command: " << CEPH_ARGPARSE_VAL << std::endl;
           usage_exit();
         }
       } else {
         switch (opt_cmd) {
           case OPT_LIST:
-            set_conf_param(CONF_VAL, &poolname, NULL);
+            set_conf_param(CEPH_ARGPARSE_VAL, &poolname, NULL);
             break;
           case OPT_INFO:
           case OPT_CREATE:
@@ -629,17 +629,17 @@ int main(int argc, const char **argv)
           case OPT_SNAP_REMOVE:
           case OPT_SNAP_LIST:
           case OPT_WATCH:
-            set_conf_param(CONF_VAL, &imgname, NULL);
+            set_conf_param(CEPH_ARGPARSE_VAL, &imgname, NULL);
             break;
           case OPT_EXPORT:
-            set_conf_param(CONF_VAL, &imgname, &path);
+            set_conf_param(CEPH_ARGPARSE_VAL, &imgname, &path);
             break;
           case OPT_IMPORT:
-            set_conf_param(CONF_VAL, &path, &destname);
+            set_conf_param(CEPH_ARGPARSE_VAL, &path, &destname);
             break;
           case OPT_COPY:
           case OPT_RENAME:
-            set_conf_param(CONF_VAL, &imgname, &destname);
+            set_conf_param(CEPH_ARGPARSE_VAL, &imgname, &destname);
             break;
         }
       }
index 669bbabb47145efd28d18c7d0d9bdf3da03ea0c4..bd6cb81520006eb210fbc8bbbd1082a957b49468 100644 (file)
@@ -188,46 +188,46 @@ int main(int argc, char **argv)
   bool need_more;
 
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("uid", 'i')) {
-      CONF_SAFE_SET_ARG_VAL(&user_id, OPT_STR);
-    } else if (CONF_ARG_EQ("secret", 's')) {
-      CONF_SAFE_SET_ARG_VAL(&secret_key, OPT_STR);
-    } else if (CONF_ARG_EQ("email", 'e')) {
-      CONF_SAFE_SET_ARG_VAL(&user_email, OPT_STR);
-    } else if (CONF_ARG_EQ("display-name", 'n')) {
-      CONF_SAFE_SET_ARG_VAL(&display_name, OPT_STR);
-    } else if (CONF_ARG_EQ("bucket", 'b')) {
-      CONF_SAFE_SET_ARG_VAL(&bucket, OPT_STR);
-    } else if (CONF_ARG_EQ("object", 'o')) {
-      CONF_SAFE_SET_ARG_VAL(&object, OPT_STR);
-    } else if (CONF_ARG_EQ("auth-uid", 'a')) {
-      CONF_SAFE_SET_ARG_VAL(&auid, OPT_LONGLONG);
-    } else if (CONF_ARG_EQ("os-user", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&openstack_user, OPT_STR);
-    } else if (CONF_ARG_EQ("os-secret", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&openstack_key, OPT_STR);
-    } else if (CONF_ARG_EQ("date", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&date, OPT_STR);
+    if (CEPH_ARGPARSE_EQ("uid", 'i')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&user_id, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("secret", 's')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&secret_key, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("email", 'e')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&user_email, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("display-name", 'n')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&display_name, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("bucket", 'b')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&bucket, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("object", 'o')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&object, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("auth-uid", 'a')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&auid, OPT_LONGLONG);
+    } else if (CEPH_ARGPARSE_EQ("os-user", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&openstack_user, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("os-secret", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&openstack_key, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("date", '\0')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(&date, OPT_STR);
     } else {
       if (!opt_cmd) {
-        opt_cmd = get_cmd(CONF_VAL, prev_cmd, &need_more);
+        opt_cmd = get_cmd(CEPH_ARGPARSE_VAL, prev_cmd, &need_more);
         if (opt_cmd < 0) {
           cerr << "unrecognized arg " << args[i] << std::endl;
-          ARGS_USAGE();
+          usage();
         }
         if (need_more) {
-          prev_cmd = CONF_VAL;
+          prev_cmd = CEPH_ARGPARSE_VAL;
           continue;
         }
       } else {
         cerr << "unrecognized arg " << args[i] << std::endl;
-        ARGS_USAGE();
+        usage();
       }
     }
   }
 
   if (opt_cmd == OPT_NO_CMD)
-    ARGS_USAGE();
+    usage();
 
   store = RGWAccess::init_storage_provider("rados", &g_conf);
   if (!store) {
@@ -399,7 +399,7 @@ int main(int argc, char **argv)
         cerr << "date was not specified" << std::endl;
       if (!bucket)
         cerr << "bucket was not specified" << std::endl;
-      ARGS_USAGE();
+      usage();
     }
 
     string log_bucket = RGW_LOG_BUCKET_NAME;
index 2159fabe6d53414b449487c1b23a742ad13f7da3..71bc8bee4ab55dc3dc00607b2b9aa51473bfb5b5 100644 (file)
@@ -98,13 +98,13 @@ int main(int argc, const char **argv)
 
   DEFINE_CONF_VARS(usage);
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("simple_segv", 's')) {
+    if (CEPH_ARGPARSE_EQ("simple_segv", 's')) {
       simple_segv_test();
     }
-    else if (CONF_ARG_EQ("infinite_recursion", 'r')) {
+    else if (CEPH_ARGPARSE_EQ("infinite_recursion", 'r')) {
       infinite_recursion_test();
     }
-    else if (CONF_ARG_EQ("help", 'h')) {
+    else if (CEPH_ARGPARSE_EQ("help", 'h')) {
       usage();
     }
   }
index e024a07f10fcbed67f661fa02837c9ffdf24b501..6bdaa4697b06bd71f749b611dd7c85bfe2a54056 100644 (file)
@@ -55,17 +55,17 @@ static void parse_cmd_args(const vector<const char*> &args,
 {
   DEFINE_CONF_VARS(usage);
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("in_file", 'i')) {
-      CONF_SAFE_SET_ARG_VAL(in_file, OPT_STR);
-    } else if (CONF_ARG_EQ("concise", '\0')) {
+    if (CEPH_ARGPARSE_EQ("in_file", 'i')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(in_file, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("concise", '\0')) {
       g.concise = true;
-    } else if (CONF_ARG_EQ("out_file", 'o')) {
-      CONF_SAFE_SET_ARG_VAL(out_file, OPT_STR);
-    } else if (CONF_ARG_EQ("status", 's')) {
+    } else if (CEPH_ARGPARSE_EQ("out_file", 'o')) {
+      CEPH_ARGPARSE_SET_ARG_VAL(out_file, OPT_STR);
+    } else if (CEPH_ARGPARSE_EQ("status", 's')) {
       *mode = CEPH_TOOL_MODE_ONE_SHOT_OBSERVER;
-    } else if (CONF_ARG_EQ("watch", 'w')) {
+    } else if (CEPH_ARGPARSE_EQ("watch", 'w')) {
       *mode = CEPH_TOOL_MODE_OBSERVER;
-    } else if (CONF_ARG_EQ("help", 'h')) {
+    } else if (CEPH_ARGPARSE_EQ("help", 'h')) {
       usage();
     } else if (args[i][0] == '-' && nargs->empty()) {
       derr << "unrecognized option " << args[i] << dendl;
index 105de642bfee591aff85c3d11c15d2a274f983d4..63d8d3f31ae0310ff4ccf82a58880c40b4884138 100644 (file)
@@ -41,7 +41,7 @@ static void parse_gceph_args(const vector<const char*> &args)
 {
   DEFINE_CONF_VARS(usage);
   FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("help", 'h')) {
+    if (CEPH_ARGPARSE_EQ("help", 'h')) {
       usage();
     }
   }