Fabcoin Core
0.16.2
P2P Digital Currency
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
cpp-ethereum
ethminer
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
*/
25
// Solves the problem of including windows.h before including winsock.h
26
// as detailed here:
27
// http://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h
28
29
#if defined(_WIN32)
30
#define _WINSOCKAPI_
31
#include <windows.h>
32
#endif // defined(_WIN32)
33
34
#include <clocale>
35
36
#include "
MinerAux.h
"
37
38
using namespace
std
;
39
using namespace
dev
;
40
using namespace
dev::eth
;
41
using namespace
boost::algorithm
;
42
43
#undef RETURN
44
45
void
help
()
46
{
47
cout
48
<<
"Usage ethminer [OPTIONS]"
<< endl
49
<<
"Options:"
<< endl << endl;
50
MinerCLI::streamHelp
(cout);
51
cout
52
<<
"General Options:"
<< endl
53
<<
" -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8)."
<< endl
54
<<
" -V,--version Show the version and exit."
<< endl
55
<<
" -h,--help Show this help message and exit."
<< endl
56
;
57
exit(0);
58
}
59
60
void
version
()
61
{
62
cout <<
"ethminer version "
<<
dev::Version
<< endl;
63
cout <<
"Build: "
<<
DEV_QUOTED
(ETH_BUILD_PLATFORM) <<
"/"
<<
DEV_QUOTED
(ETH_BUILD_TYPE) << endl;
64
exit(0);
65
}
66
67
/*
68
The equivalent of setlocale(LC_ALL, āCā) is called before any user code is run.
69
If the user has an invalid environment setting then it is possible for the call
70
to set locale to fail, so there are only two possible actions, the first is to
71
throw a runtime exception and cause the program to quit (default behaviour),
72
or the second is to modify the environment to something sensible (least
73
surprising behaviour).
74
75
The follow code produces the least surprising behaviour. It will use the user
76
specified default locale if it is valid, and if not then it will modify the
77
environment the process is running in to use a sensible default. This also means
78
that users do not need to install language packs for their OS.
79
*/
80
void
setDefaultOrCLocale
()
81
{
82
#if __unix__
83
if
(!std::setlocale(LC_ALL,
""
))
84
{
85
setenv(
"LC_ALL"
,
"C"
, 1);
86
}
87
#endif
88
}
89
90
int
main
(
int
argc,
char
** argv)
91
{
92
setDefaultOrCLocale
();
93
MinerCLI
m(
MinerCLI::OperationMode::Farm
);
94
95
for
(
int
i = 1; i < argc; ++i)
96
{
97
string
arg = argv[i];
98
if
(m.
interpretOption
(i, argc, argv))
99
{}
100
else
if
((arg ==
"-v"
|| arg ==
"--verbosity"
) && i + 1 < argc)
101
g_logVerbosity
=
atoi
(argv[++i]);
102
else
if
(arg ==
"-h"
|| arg ==
"--help"
)
103
help
();
104
else
if
(arg ==
"-V"
|| arg ==
"--version"
)
105
version
();
106
else
107
{
108
cerr <<
"Invalid argument: "
<< arg << endl;
109
exit(-1);
110
}
111
}
112
113
m.
execute
();
114
115
return
0;
116
}
dev
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition:
Arith256.cpp:15
help
void help()
Definition:
main.cpp:39
std
std::hash for asio::adress
Definition:
Common.h:323
dev::eth
Definition:
Arith256.cpp:17
MinerCLI::streamHelp
static void streamHelp(ostream &_out)
Definition:
MinerAux.h:242
DEV_QUOTED
#define DEV_QUOTED(s)
Definition:
Common.h:61
version
void version()
Definition:
main.cpp:53
setDefaultOrCLocale
void setDefaultOrCLocale()
Definition:
main.cpp:72
main
int main(int argc, char **argv)
Definition:
main.cpp:149
MinerCLI::interpretOption
bool interpretOption(int &i, int argc, char **argv)
Definition:
MinerAux.h:107
MinerAux.h
MinerCLI::OperationMode::Farm
dev::g_logVerbosity
int g_logVerbosity
The logging system's current verbosity.
Definition:
Log.cpp:37
dev::Version
char const * Version
Definition:
Common.cpp:36
MinerCLI
Definition:
MinerAux.h:89
algorithm
atoi
int atoi(const std::string &str)
Definition:
utilstrencodings.cpp:612
MinerCLI::execute
void execute()
Definition:
MinerAux.h:230
Generated on Mon Oct 22 2018 15:15:27 for Fabcoin Core by
1.8.11