1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "executor.h"
#include "minethd.h"
#include "jconf.h"
#include "console.h"
#include "donate-level.h"
#include "httpd.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//Do a press any key for the windows folk. *insert any key joke here*
#ifdef _WIN32
void win_exit()
{
printer::inst()->print_str("Press any key to exit.");
get_key();
return;
}
#define strcasecmp _stricmp
#else
void win_exit() { return; }
#endif // _WIN32
int main(int argc, char *argv[])
{
const char* sFilename = "config.txt";
if(argc >= 2)
{
if(strcmp(argv[1], "-h") == 0)
{
printer::inst()->print_msg(L0, "Usage %s [CONFIG FILE]", argv[0]);
win_exit();
return 0;
}
if(argc >= 3 && strcasecmp(argv[1], "-c") == 0)
sFilename = argv[2];
else
sFilename = argv[1];
}
if(!jconf::inst()->parse_config(sFilename))
{
win_exit();
return 0;
}
if (!minethd::self_test())
{
win_exit();
return 0;
}
if(jconf::inst()->GetHttpdPort() != 0)
{
if (!httpd::inst()->start_daemon())
{
win_exit();
return 0;
}
}
printer::inst()->print_str("-------------------------------------------------------------------\n");
printer::inst()->print_str("XMR-Stak-CPU mining software, CPU Version.\n");
printer::inst()->print_str("Based on CPU mining code by wolf9466 (heavily optimized by myself).\n");
printer::inst()->print_str("Brought to you by fireice_uk under GPLv3.\n\n");
char buffer[64];
snprintf(buffer, sizeof(buffer), "Configurable dev donation level is set to %.1f %%\n\n", fDevDonationLevel * 100.0);
printer::inst()->print_str(buffer);
printer::inst()->print_str("You can use following keys to display reports:\n");
printer::inst()->print_str("'h' - hashrate\n");
printer::inst()->print_str("'r' - results\n");
printer::inst()->print_str("'c' - connection\n");
printer::inst()->print_str("-------------------------------------------------------------------\n");
executor::inst()->ex_start();
int key;
while(true)
{
key = get_key();
switch(key)
{
case 'h':
executor::inst()->push_event(ex_event(EV_USR_HASHRATE));
break;
case 'r':
executor::inst()->push_event(ex_event(EV_USR_RESULTS));
break;
case 'c':
executor::inst()->push_event(ex_event(EV_USR_CONNSTAT));
break;
default:
break;
}
}
return 0;
}
|