Fabcoin Core  0.16.2
P2P Digital Currency
main.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
23 #include <thread>
24 #include <fstream>
25 #include <iostream>
26 #include <libdevcore/FileSystem.h>
27 #include <libdevcore/Log.h>
28 #include <libethcore/KeyManager.h>
29 #include "BuildInfo.h"
30 #include "KeyAux.h"
31 using namespace std;
32 using namespace dev;
33 using namespace dev::eth;
34 
35 void help()
36 {
37  cout
38  << "Usage ethkey [OPTIONS]" << endl
39  << "Options:" << endl << endl;
40  KeyCLI::streamHelp(cout);
41  cout
42  << "General Options:" << endl
43  << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8)." << endl
44  << " -V,--version Show the version and exit." << endl
45  << " -h,--help Show this help message and exit." << endl
46  ;
47  exit(0);
48 }
49 
50 void version()
51 {
52  cout << "ethkey version " << dev::Version << endl;
53  cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
54  exit(0);
55 }
56 
57 /*
58 The equivalent of setlocale(LC_ALL, ā€œCā€) is called before any user code is run.
59 If the user has an invalid environment setting then it is possible for the call
60 to set locale to fail, so there are only two possible actions, the first is to
61 throw a runtime exception and cause the program to quit (default behaviour),
62 or the second is to modify the environment to something sensible (least
63 surprising behaviour).
64 
65 The follow code produces the least surprising behaviour. It will use the user
66 specified default locale if it is valid, and if not then it will modify the
67 environment the process is running in to use a sensible default. This also means
68 that users do not need to install language packs for their OS.
69 */
71 {
72 #if __unix__
73  if (!std::setlocale(LC_ALL, ""))
74  {
75  setenv("LC_ALL", "C", 1);
76  }
77 #endif
78 }
79 
80 int main(int argc, char** argv)
81 {
84  g_logVerbosity = 0;
85 
86  for (int i = 1; i < argc; ++i)
87  {
88  string arg = argv[i];
89  if (m.interpretOption(i, argc, argv)) {}
90  else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
91  g_logVerbosity = atoi(argv[++i]);
92  else if (arg == "-h" || arg == "--help")
93  help();
94  else if (arg == "-V" || arg == "--version")
95  version();
96  else
97  {
98  cerr << "Invalid argument: " << arg << endl;
99  exit(-1);
100  }
101  }
102 
103  m.execute();
104 
105  return 0;
106 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
void help()
Definition: main.cpp:39
std::hash for asio::adress
Definition: Common.h:323
#define DEV_QUOTED(s)
Definition: Common.h:61
void execute()
Definition: KeyAux.h:324
void version()
Definition: main.cpp:53
void setDefaultOrCLocale()
Definition: main.cpp:72
int main(int argc, char **argv)
Definition: main.cpp:149
static void streamHelp(ostream &_out)
Definition: KeyAux.h:698
int g_logVerbosity
The logging system&#39;s current verbosity.
Definition: Log.cpp:37
char const * Version
Definition: Common.cpp:36
Definition: KeyAux.h:89
int atoi(const std::string &str)
bool interpretOption(int &i, int argc, char **argv)
Definition: KeyAux.h:118