Define strings to store special option parsing parameters leaving no OPT_WITH_ARG missing args
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
diff --git a/cgminer.c b/cgminer.c
index 5910e67..b5bebcb 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -202,8 +202,15 @@ float opt_anu_freq = 200;
#endif
bool opt_worktime;
#ifdef USE_AVALON
-char *opt_avalon_options = NULL;
-char *opt_bitburner_fury_options = NULL;
+char *opt_avalon_options;
+char *opt_bitburner_fury_options;
+static char *opt_set_avalon_van;
+static char *opt_set_avalon_freq;
+#endif
+#ifdef USE_AVALON2
+static char *opt_set_avalon2_freq;
+static char *opt_set_avalon2_fan;
+static char *opt_set_avalon2_voltage;
#endif
#ifdef USE_KLONDIKE
char *opt_klondike_options = NULL;
@@ -217,8 +224,15 @@ char *opt_bab_options = NULL;
char *opt_bitmine_a1_options = NULL;
#endif
#ifdef USE_ANT_S1
-char *opt_bitmain_options = NULL;
+char *opt_bitmain_options;
+static char *opt_set_bitmain_fan;
+static char *opt_set_bitmain_freq;
+#endif
+#ifdef USE_HASHFAST
+static char *opt_set_hfa_fan;
#endif
+static char *opt_set_null;
+
#ifdef USE_USBUTILS
char *opt_usb_select = NULL;
int opt_usbdump = -1;
@@ -718,6 +732,7 @@ static char *set_int_1_to_10(const char *arg, int *i)
}
#ifdef USE_FPGA_SERIAL
+static char *opt_add_serial;
static char *add_serial(char *arg)
{
string_elist_add(arg, &scan_devices);
@@ -902,6 +917,9 @@ static char *enable_debug(bool *flag)
return NULL;
}
+static char *opt_set_sched_start;
+static char *opt_set_sched_stop;
+
static char *set_schedtime(const char *arg, struct schedtime *st)
{
if (sscanf(arg, "%d:%d", &st->tm.tm_hour, &st->tm.tm_min) != 2)
@@ -912,6 +930,17 @@ static char *set_schedtime(const char *arg, struct schedtime *st)
return NULL;
}
+static char *set_sched_start(const char *arg)
+{
+ return set_schedtime(arg, &schedstart);
+}
+
+static char *set_sched_stop(const char *arg)
+{
+ return set_schedtime(arg, &schedstop);
+}
+
+static char *opt_set_sharelog;
static char* set_sharelog(char *arg)
{
char *r = "";
@@ -935,6 +964,7 @@ static char* set_sharelog(char *arg)
}
static char *temp_cutoff_str = NULL;
+static char *opt_set_temp_cutoff;
char *set_temp_cutoff(char *arg)
{
@@ -1051,10 +1081,10 @@ static struct opt_table opt_config_table[] = {
set_int_0_to_100, opt_show_intval, &opt_avalon_overheat,
"Set avalon overheat cut off temperature"),
OPT_WITH_ARG("--avalon-fan",
- set_avalon_fan, NULL, NULL,
+ set_avalon_fan, NULL, &opt_set_avalon_van,
"Set fanspeed percentage for avalon, single value or range (default: 20-100)"),
OPT_WITH_ARG("--avalon-freq",
- set_avalon_freq, NULL, NULL,
+ set_avalon_freq, NULL, &opt_set_avalon_freq,
"Set frequency range for avalon-auto, single value or range"),
OPT_WITH_ARG("--avalon-options",
opt_set_charp, NULL, &opt_avalon_options,
@@ -1065,13 +1095,13 @@ static struct opt_table opt_config_table[] = {
#endif
#ifdef USE_AVALON2
OPT_WITH_ARG("--avalon2-freq",
- set_avalon2_freq, NULL, NULL,
+ set_avalon2_freq, NULL, &opt_set_avalon2_freq,
"Set frequency range for Avalon2, single value or range"),
OPT_WITH_ARG("--avalon2-fan",
- set_avalon2_fan, NULL, NULL,
+ set_avalon2_fan, NULL, &opt_set_avalon2_fan,
"Set Avalon2 target fan speed"),
OPT_WITH_ARG("--avalon2-voltage",
- set_avalon2_voltage, NULL, NULL,
+ set_avalon2_voltage, NULL, &opt_set_avalon2_voltage,
"Set Avalon2 core voltage, in millivolts"),
#endif
#ifdef USE_BAB
@@ -1120,10 +1150,10 @@ static struct opt_table opt_config_table[] = {
set_int_0_to_100, opt_show_intval, &opt_bitmain_overheat,
"Set bitmain overheat cut off temperature"),
OPT_WITH_ARG("--bitmain-fan",
- set_bitmain_fan, NULL, NULL,
+ set_bitmain_fan, NULL, &opt_set_bitmain_fan,
"Set fanspeed percentage for bitmain, single value or range (default: 20-100)"),
OPT_WITH_ARG("--bitmain-freq",
- set_bitmain_freq, NULL, NULL,
+ set_bitmain_freq, NULL, &opt_set_bitmain_freq,
"Set frequency range for bitmain-auto, single value or range"),
OPT_WITHOUT_ARG("--bitmain-hwerror",
opt_set_bool, &opt_bitmain_hwerror,
@@ -1206,7 +1236,7 @@ static struct opt_table opt_config_table[] = {
set_int_0_to_100, opt_show_intval, &opt_hfa_fail_drop,
"Set how many MHz to drop clockspeed each failure on an overlocked hashfast device"),
OPT_WITH_ARG("--hfa-fan",
- set_hfa_fan, NULL, NULL,
+ set_hfa_fan, NULL, &opt_set_hfa_fan,
"Set fanspeed percentage for hashfast, single value or range (default: 10-85)"),
OPT_WITH_ARG("--hfa-name",
opt_set_charp, NULL, &opt_hfa_name,
@@ -1285,13 +1315,13 @@ static struct opt_table opt_config_table[] = {
opt_set_invbool, &opt_submit_stale,
"Don't submit shares if they are detected as stale"),
OPT_WITH_ARG("--pass|-p",
- set_pass, NULL, NULL,
+ set_pass, NULL, &opt_set_null,
"Password for bitcoin JSON-RPC server"),
OPT_WITHOUT_ARG("--per-device-stats",
opt_set_bool, &want_per_device_stats,
"Force verbose mode and output per-device statistics"),
OPT_WITH_ARG("--pools",
- opt_set_bool, NULL, NULL, opt_hidden),
+ opt_set_bool, NULL, &opt_set_null, opt_hidden),
OPT_WITHOUT_ARG("--protocol-dump|-P",
opt_set_bool, &opt_protocol,
"Verbose dump of protocol-level activities"),
@@ -1302,16 +1332,16 @@ static struct opt_table opt_config_table[] = {
opt_set_bool, &opt_quiet,
"Disable logging output, display status and errors"),
OPT_WITH_ARG("--quota|-U",
- set_quota, NULL, NULL,
+ set_quota, NULL, &opt_set_null,
"quota;URL combination for server with load-balance strategy quotas"),
OPT_WITHOUT_ARG("--real-quiet",
opt_set_bool, &opt_realquiet,
"Disable all output"),
OPT_WITH_ARG("--retries",
- set_null, NULL, NULL,
+ set_null, NULL, &opt_set_null,
opt_hidden),
OPT_WITH_ARG("--retry-pause",
- set_null, NULL, NULL,
+ set_null, NULL, &opt_set_null,
opt_hidden),
OPT_WITH_ARG("--rotate",
set_rotate, opt_show_intval, &opt_rotate_period,
@@ -1321,20 +1351,20 @@ static struct opt_table opt_config_table[] = {
"Change multipool strategy from failover to round robin on failure"),
#ifdef USE_FPGA_SERIAL
OPT_WITH_ARG("--scan-serial|-S",
- add_serial, NULL, NULL,
+ add_serial, NULL, &opt_add_serial,
"Serial port to probe for Serial FPGA Mining device"),
#endif
OPT_WITH_ARG("--scan-time|-s",
set_int_0_to_9999, opt_show_intval, &opt_scantime,
"Upper bound on time spent scanning current work, in seconds"),
OPT_WITH_ARG("--sched-start",
- set_schedtime, NULL, &schedstart,
+ set_sched_start, NULL, &opt_set_sched_start,
"Set a time of day in HH:MM to start mining (a once off without a stop time)"),
OPT_WITH_ARG("--sched-stop",
- set_schedtime, NULL, &schedstop,
+ set_sched_stop, NULL, &opt_set_sched_stop,
"Set a time of day in HH:MM to stop mining (will quit without a start time)"),
OPT_WITH_ARG("--sharelog",
- set_sharelog, NULL, NULL,
+ set_sharelog, NULL, &opt_set_sharelog,
"Append share log to file"),
OPT_WITH_ARG("--shares",
opt_set_intval, NULL, &opt_shares,
@@ -1349,7 +1379,7 @@ static struct opt_table opt_config_table[] = {
#endif
#if defined(USE_BITFORCE) || defined(USE_MODMINER) || defined(USE_BFLSC)
OPT_WITH_ARG("--temp-cutoff",
- set_temp_cutoff, opt_show_intval, &opt_cutofftemp,
+ set_temp_cutoff, opt_show_intval, &opt_set_temp_cutoff,
"Temperature where a device will be automatically disabled, one value or comma separated list"),
#endif
OPT_WITHOUT_ARG("--text-only|-T",
@@ -1361,7 +1391,7 @@ static struct opt_table opt_config_table[] = {
#endif
),
OPT_WITH_ARG("--url|-o",
- set_url, NULL, NULL,
+ set_url, NULL, &opt_set_null,
"URL for bitcoin JSON-RPC server"),
#ifdef USE_USBUTILS
OPT_WITH_ARG("--usb",
@@ -1375,10 +1405,10 @@ static struct opt_table opt_config_table[] = {
opt_hidden),
#endif
OPT_WITH_ARG("--user|-u",
- set_user, NULL, NULL,
+ set_user, NULL, &opt_set_null,
"Username for bitcoin JSON-RPC server"),
OPT_WITH_ARG("--userpass|-O",
- set_userpass, NULL, NULL,
+ set_userpass, NULL, &opt_set_null,
"Username:Password pair for bitcoin JSON-RPC server"),
OPT_WITHOUT_ARG("--verbose",
opt_set_bool, &opt_log_output,
@@ -1623,11 +1653,11 @@ char *display_devs(int *ndevs)
/* These options are available from commandline only */
static struct opt_table opt_cmdline_table[] = {
OPT_WITH_ARG("--config|-c",
- load_config, NULL, NULL,
+ load_config, NULL, &opt_set_null,
"Load a JSON-format configuration file\n"
"See example.conf for an example configuration."),
OPT_WITH_ARG("--default-config",
- set_default_config, NULL, NULL,
+ set_default_config, NULL, &opt_set_null,
"Specify the filename of the default config file\n"
"Loaded at start and used when saving without a name."),
OPT_WITHOUT_ARG("--help|-h",
@@ -4840,7 +4870,7 @@ void write_config(FILE *fcfg)
}
if (opt->type & OPT_HASARG &&
- ((void *)opt->cb_arg == (void *)opt_set_charp)) {
+ (opt->u.arg != &opt_set_null)) {
char *carg = *(char **)opt->u.arg;
if (carg)
@@ -4860,10 +4890,6 @@ void write_config(FILE *fcfg)
fputs(",\n\"round-robin\" : true", fcfg);
if (pool_strategy == POOL_ROTATE)
fprintf(fcfg, ",\n\"rotate\" : \"%d\"", opt_rotate_period);
- if (schedstart.enable)
- fprintf(fcfg, ",\n\"sched-start\" : \"%d:%d\"", schedstart.tm.tm_hour, schedstart.tm.tm_min);
- if (schedstop.enable)
- fprintf(fcfg, ",\n\"sched-stop\" : \"%d:%d\"", schedstop.tm.tm_hour, schedstop.tm.tm_min);
fputs("\n}\n", fcfg);
json_escape_free();