X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcommon%2Fceph_argparse.h;fp=src%2Fceph%2Fsrc%2Fcommon%2Fceph_argparse.h;h=9e33d939b17e33efade2642c1dea2ab819e90ea3;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/common/ceph_argparse.h b/src/ceph/src/common/ceph_argparse.h new file mode 100644 index 0000000..9e33d93 --- /dev/null +++ b/src/ceph/src/common/ceph_argparse.h @@ -0,0 +1,73 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2008-2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_ARGPARSE_H +#define CEPH_ARGPARSE_H + +/* + * Ceph argument parsing library + * + * We probably should eventually replace this with something standard like popt. + * Until we do that, though, this file is the place for argv parsing + * stuff to live. + */ + +#include +#include + +#include "common/entity_name.h" + +/////////////////////// Types /////////////////////// +class CephInitParameters +{ +public: + explicit CephInitParameters(uint32_t module_type_); + std::list get_conf_files() const; + + uint32_t module_type; + EntityName name; +}; + +/////////////////////// Functions /////////////////////// +extern void string_to_vec(std::vector& args, std::string argstr); +extern void env_to_vec(std::vector& args, const char *name=NULL); +extern void argv_to_vec(int argc, const char **argv, + std::vector& args); +extern void vec_to_argv(const char *argv0, std::vector& args, + int *argc, const char ***argv); + +extern bool parse_ip_port_vec(const char *s, std::vector& vec); +bool ceph_argparse_double_dash(std::vector &args, + std::vector::iterator &i); +bool ceph_argparse_flag(std::vector &args, + std::vector::iterator &i, ...); +bool ceph_argparse_witharg(std::vector &args, + std::vector::iterator &i, std::string *ret, + std::ostream &oss, ...); +bool ceph_argparse_witharg(std::vector &args, + std::vector::iterator &i, std::string *ret, ...); +template +bool ceph_argparse_witharg(std::vector &args, + std::vector::iterator &i, T *ret, + std::ostream &oss, ...); +bool ceph_argparse_binary_flag(std::vector &args, + std::vector::iterator &i, int *ret, + std::ostream *oss, ...); +extern CephInitParameters ceph_argparse_early_args + (std::vector& args, uint32_t module_type, + std::string *cluster, std::string *conf_file_list); +extern void generic_server_usage(); +extern void generic_client_usage(); + +#endif