2011-01-06 23:04:07 +00:00
|
|
|
// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
|
|
|
|
*
|
|
|
|
* This is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License version 2, as published by the Free Software
|
|
|
|
* Foundation. See file COPYING.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-02-22 16:38:45 +00:00
|
|
|
#include "common/config.h"
|
2011-01-06 23:04:07 +00:00
|
|
|
|
2011-02-20 17:18:03 +00:00
|
|
|
#include "common/ceph_argparse.h"
|
2011-06-17 03:15:24 +00:00
|
|
|
#include "global/global_init.h"
|
2011-06-22 20:42:28 +00:00
|
|
|
#include "global/global_context.h"
|
2011-02-03 19:07:21 +00:00
|
|
|
#include "include/rados/librados.h"
|
2011-01-06 23:04:07 +00:00
|
|
|
|
|
|
|
void usage()
|
|
|
|
{
|
|
|
|
cout << "usage: librados-config [option]\n"
|
|
|
|
<< "where options are:\n"
|
|
|
|
<< " --version library version\n"
|
|
|
|
<< " --vernum library version code\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void usage_exit()
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-02-08 11:22:21 +00:00
|
|
|
|
2011-01-06 23:04:07 +00:00
|
|
|
int main(int argc, const char **argv)
|
|
|
|
{
|
|
|
|
vector<const char*> args;
|
|
|
|
DEFINE_CONF_VARS(usage_exit);
|
|
|
|
argv_to_vec(argc, argv, args);
|
|
|
|
env_to_vec(args);
|
|
|
|
|
|
|
|
bool opt_version = false;
|
|
|
|
bool opt_vernum = false;
|
|
|
|
|
2011-02-08 11:22:21 +00:00
|
|
|
for (std::vector<const char*>::iterator i = args.begin();
|
|
|
|
i != args.end(); ) {
|
|
|
|
if (strcmp(*i, "--version") == 0) {
|
|
|
|
opt_version = true;
|
|
|
|
i = args.erase(i);
|
|
|
|
}
|
|
|
|
else if (strcmp(*i, "--vernum") == 0) {
|
|
|
|
opt_vernum = true;
|
|
|
|
i = args.erase(i);
|
2011-01-06 23:04:07 +00:00
|
|
|
}
|
2011-02-08 11:22:21 +00:00
|
|
|
else
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2011-06-17 03:15:24 +00:00
|
|
|
global_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
|
2011-06-21 19:28:16 +00:00
|
|
|
common_init_finish(g_ceph_context);
|
2011-02-08 11:22:21 +00:00
|
|
|
|
|
|
|
FOR_EACH_ARG(args) {
|
|
|
|
usage_exit();
|
2011-01-06 23:04:07 +00:00
|
|
|
}
|
|
|
|
if (!opt_version && !opt_vernum)
|
|
|
|
usage_exit();
|
|
|
|
|
|
|
|
if (opt_version) {
|
|
|
|
int maj, min, ext;
|
2011-02-12 22:20:16 +00:00
|
|
|
rados_version(&maj, &min, &ext);
|
2011-01-06 23:04:07 +00:00
|
|
|
cout << maj << "." << min << "." << ext << std::endl;
|
|
|
|
} else if (opt_vernum) {
|
|
|
|
cout << hex << LIBRADOS_VERSION_CODE << dec << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|