791
static pair<string, string> parse_size_suffixes(string s)
793
size_t equal_pos= s.find("=");
794
if (equal_pos != string::npos)
796
string arg_key(s.substr(0, equal_pos));
797
string arg_val(s.substr(equal_pos+1));
801
size_t size_suffix_pos= arg_val.find_last_of("kmgKMG");
802
if (size_suffix_pos == arg_val.size()-1)
804
char suffix= arg_val[size_suffix_pos];
805
string size_val(arg_val.substr(0, size_suffix_pos));
807
uint64_t base_size= boost::lexical_cast<uint64_t>(size_val);
808
uint64_t new_size= 0;
814
new_size= base_size * 1024;
818
new_size= base_size * 1024 * 1024;
822
new_size= base_size * 1024 * 1024 * 1024;
825
return make_pair(arg_key,
826
boost::lexical_cast<string>(new_size));
831
/* Screw it, let the normal parser take over */
835
return make_pair(string(""), string(""));
838
static pair<string, string> parse_size_arg(string s)
840
if (s.find("--") == 0)
842
return parse_size_suffixes(s.substr(2));
844
return make_pair(string(""), string(""));
791
847
int init_server_components(module::Registry &plugins)
824
880
po::parsed_options parsed= po::command_line_parser(defaults_argc,
826
options(long_options).allow_unregistered().run();
882
options(long_options).extra_parser(parse_size_arg).
883
allow_unregistered().run();
828
885
vector<string> unknown_options=
829
886
po::collect_unrecognized(parsed.options, po::include_positional);