]> git.proxmox.com Git - ceph.git/blame - ceph/src/librados-config.cc
update sources to 12.2.2
[ceph.git] / ceph / src / librados-config.cc
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License version 2, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15#include "common/config.h"
16
17#include "common/ceph_argparse.h"
18#include "global/global_init.h"
19#include "global/global_context.h"
20#include "include/rados/librados.h"
21
22void usage()
23{
24 cout << "usage: librados-config [option]\n"
25 << "where options are:\n"
26 << " --version library version\n"
27 << " --vernum library version code\n";
28}
29
30void usage_exit()
31{
32 usage();
33 exit(1);
34}
35
36int main(int argc, const char **argv)
37{
38 vector<const char*> args;
39 argv_to_vec(argc, argv, args);
40 env_to_vec(args);
41
42 bool opt_version = false;
43 bool opt_vernum = false;
44
45 auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
46 CODE_ENVIRONMENT_UTILITY,
47 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
48 common_init_finish(g_ceph_context);
49 for (std::vector<const char*>::iterator i = args.begin();
50 i != args.end(); ) {
51 if (strcmp(*i, "--") == 0) {
52 break;
53 }
54 else if (strcmp(*i, "--version") == 0) {
55 opt_version = true;
56 i = args.erase(i);
57 }
58 else if (strcmp(*i, "--vernum") == 0) {
59 opt_vernum = true;
60 i = args.erase(i);
61 }
62 else
63 ++i;
64 }
65
66 if (!opt_version && !opt_vernum)
67 usage_exit();
68
69 if (opt_version) {
70 int maj, min, ext;
71 rados_version(&maj, &min, &ext);
72 cout << maj << "." << min << "." << ext << std::endl;
73 } else if (opt_vernum) {
74 cout << hex << LIBRADOS_VERSION_CODE << dec << std::endl;
75 }
76
77 return 0;
78}
79