1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2008-2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_ARGPARSE_H
16 #define CEPH_ARGPARSE_H
19 * Ceph argument parsing library
21 * We probably should eventually replace this with something standard like popt.
22 * Until we do that, though, this file is the place for argv parsing
29 #include "common/entity_name.h"
31 /////////////////////// Types ///////////////////////
32 class CephInitParameters
35 explicit CephInitParameters(uint32_t module_type_
);
36 std::list
<std::string
> get_conf_files() const;
40 bool no_config_file
= false;
43 /////////////////////// Functions ///////////////////////
44 extern void string_to_vec(std::vector
<std::string
>& args
, std::string argstr
);
45 extern void clear_g_str_vec();
46 extern void env_to_vec(std::vector
<const char*>& args
, const char *name
=nullptr);
47 extern std::vector
<const char*> argv_to_vec(int argc
, const char* const * argv
);
48 extern void vec_to_argv(const char *argv0
, std::vector
<const char*>& args
,
49 int *argc
, const char ***argv
);
51 extern bool parse_ip_port_vec(const char *s
, std::vector
<entity_addrvec_t
>& vec
,
53 bool ceph_argparse_double_dash(std::vector
<const char*> &args
,
54 std::vector
<const char*>::iterator
&i
);
55 bool ceph_argparse_flag(std::vector
<const char*> &args
,
56 std::vector
<const char*>::iterator
&i
, ...);
57 bool ceph_argparse_witharg(std::vector
<const char*> &args
,
58 std::vector
<const char*>::iterator
&i
, std::string
*ret
,
59 std::ostream
&oss
, ...);
60 bool ceph_argparse_witharg(std::vector
<const char*> &args
,
61 std::vector
<const char*>::iterator
&i
, std::string
*ret
, ...);
63 bool ceph_argparse_witharg(std::vector
<const char*> &args
,
64 std::vector
<const char*>::iterator
&i
, T
*ret
,
65 std::ostream
&oss
, ...);
66 bool ceph_argparse_binary_flag(std::vector
<const char*> &args
,
67 std::vector
<const char*>::iterator
&i
, int *ret
,
68 std::ostream
*oss
, ...);
69 extern CephInitParameters ceph_argparse_early_args
70 (std::vector
<const char*>& args
, uint32_t module_type
,
71 std::string
*cluster
, std::string
*conf_file_list
);
72 extern bool ceph_argparse_need_usage(const std::vector
<const char*>& args
);
73 extern void generic_server_usage();
74 extern void generic_client_usage();