summaryrefslogtreecommitdiffstats
path: root/src/librados-config.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/librados-config.cc
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librados-config.cc')
-rw-r--r--src/librados-config.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/librados-config.cc b/src/librados-config.cc
new file mode 100644
index 000000000..7948598b1
--- /dev/null
+++ b/src/librados-config.cc
@@ -0,0 +1,59 @@
+// -*- 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.
+ *
+ */
+#include <iostream>
+
+#include <boost/program_options/cmdline.hpp>
+#include <boost/program_options/option.hpp>
+#include <boost/program_options/options_description.hpp>
+#include <boost/program_options/parsers.hpp>
+#include <boost/program_options/variables_map.hpp>
+
+#include "include/rados/librados.h"
+#include "ceph_ver.h"
+
+namespace po = boost::program_options;
+
+int main(int argc, const char **argv)
+{
+ po::options_description desc{"usage: librados-config [option]"};
+ desc.add_options()
+ ("help,h", "print this help message")
+ ("version", "library version")
+ ("vernum", "library version code")
+ ("release", "print release name");
+
+ po::parsed_options parsed =
+ po::command_line_parser(argc, argv).options(desc).run();
+ po::variables_map vm;
+ po::store(parsed, vm);
+ po::notify(vm);
+
+ if (vm.count("help")) {
+ std::cout << desc << std::endl;
+ } else if (vm.count("version")) {
+ int maj, min, ext;
+ rados_version(&maj, &min, &ext);
+ std::cout << maj << "." << min << "." << ext << std::endl;
+ } else if (vm.count("vernum")) {
+ std::cout << std::hex << LIBRADOS_VERSION_CODE << std::dec << std::endl;
+ } else if (vm.count("release")) {
+ std::cout << CEPH_RELEASE_NAME << ' '
+ << '(' << CEPH_RELEASE_TYPE << ')'
+ << std::endl;
+ } else {
+ std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ return 1;
+ }
+}
+