Generalise a lot more of the command line options simplifying the write config function and making it write far more values unaided
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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
diff --git a/cgminer.c b/cgminer.c
index 87c5c3e..37d7255 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -986,20 +986,6 @@ static void load_temp_cutoffs()
}
#ifdef USE_ICARUS
-static char *set_icarus_options(const char *arg)
-{
- opt_set_charp(arg, &opt_icarus_options);
-
- return NULL;
-}
-
-static char *set_icarus_timing(const char *arg)
-{
- opt_set_charp(arg, &opt_icarus_timing);
-
- return NULL;
-}
-
static char *set_float_125_to_500(const char *arg, float *i)
{
char *err = opt_set_floatval(arg, i);
@@ -1014,82 +1000,6 @@ static char *set_float_125_to_500(const char *arg, float *i)
}
#endif
-#ifdef USE_AVALON
-static char *set_avalon_options(const char *arg)
-{
- opt_set_charp(arg, &opt_avalon_options);
-
- return NULL;
-}
-
-static char *set_bitburner_fury_options(const char *arg)
-{
- opt_set_charp(arg, &opt_bitburner_fury_options);
-
- return NULL;
-}
-#endif
-
-#ifdef USE_HASHFAST
-static char *set_hfa_options(const char *arg)
-{
- opt_set_charp(arg, &opt_hfa_options);
-
- return NULL;
-}
-#endif
-
-#ifdef USE_KLONDIKE
-static char *set_klondike_options(const char *arg)
-{
- opt_set_charp(arg, &opt_klondike_options);
-
- return NULL;
-}
-#endif
-
-#ifdef USE_DRILLBIT
-static char *set_drillbit_options(const char *arg)
-{
- opt_set_charp(arg, &opt_drillbit_options);
-
- return NULL;
-}
-
-static char *set_drillbit_auto(const char *arg)
-{
- opt_set_charp(arg, &opt_drillbit_auto);
-
- return NULL;
-}
-
-#endif
-
-#ifdef USE_BAB
-static char *set_bab_options(const char *arg)
-{
- opt_set_charp(arg, &opt_bab_options);
-
- return NULL;
-}
-#endif
-#ifdef USE_BITMINE_A1
-static char *set_bitmine_a1_options(const char *arg)
-{
- opt_set_charp(arg, &opt_bitmine_a1_options);
-
- return NULL;
-}
-#endif
-#ifdef USE_USBUTILS
-static char *set_usb_select(const char *arg)
-{
- opt_set_charp(arg, &opt_usb_select);
-
- return NULL;
-}
-#endif
-
static char *set_null(const char __maybe_unused *arg)
{
return NULL;
@@ -1149,7 +1059,7 @@ static struct opt_table opt_config_table[] = {
set_avalon_freq, NULL, NULL,
"Set frequency range for avalon-auto, single value or range"),
OPT_WITH_ARG("--avalon-options",
- set_avalon_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_avalon_options,
"Set avalon options baud:miners:asic:timeout:freq:tech"),
OPT_WITH_ARG("--avalon-temp",
set_int_0_to_100, opt_show_intval, &opt_avalon_temp,
@@ -1168,7 +1078,7 @@ static struct opt_table opt_config_table[] = {
#endif
#ifdef USE_BAB
OPT_WITH_ARG("--bab-options",
- set_bab_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_bab_options,
"Set bab options max:def:min:up:down:hz:delay:trf"),
#endif
OPT_WITHOUT_ARG("--balance",
@@ -1201,7 +1111,7 @@ static struct opt_table opt_config_table[] = {
opt_set_intval, NULL, &opt_bitburner_fury_core_voltage,
"Set BitBurner Fury core voltage, in millivolts"),
OPT_WITH_ARG("--bitburner-fury-options",
- set_bitburner_fury_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_bitburner_fury_options,
"Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq"),
#endif
#ifdef USE_ANT_S1
@@ -1229,7 +1139,7 @@ static struct opt_table opt_config_table[] = {
#endif
#ifdef USE_BITMINE_A1
OPT_WITH_ARG("--bitmine-a1-options",
- set_bitmine_a1_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_bitmine_a1_options,
"Bitmine A1 options ref_clk_khz:sys_clk_khz:spi_clk_khz:override_chip_num"),
#endif
#ifdef USE_BITFURY
@@ -1272,11 +1182,11 @@ static struct opt_table opt_config_table[] = {
"Automatically disable pools that continually reject shares"),
#ifdef USE_DRILLBIT
OPT_WITH_ARG("--drillbit-options",
- set_drillbit_options, NULL, NULL,
- "Set drillbit options <int|ext>:clock[:clock_divider][:voltage]"),
+ opt_set_charp, NULL, &opt_drillbit_options,
+ "Set drillbit options <int|ext>:clock[:clock_divider][:voltage]"),
OPT_WITH_ARG("--drillbit-auto",
- set_drillbit_auto, NULL, NULL,
- "Enable drillbit automatic tuning <every>:[<gooderr>:<baderr>:<maxerr>]"),
+ opt_set_charp, NULL, &opt_drillbit_auto,
+ "Enable drillbit automatic tuning <every>:[<gooderr>:<baderr>:<maxerr>]"),
#endif
OPT_WITH_ARG("--expiry|-E",
set_int_0_to_9999, opt_show_intval, &opt_expiry,
@@ -1310,7 +1220,7 @@ static struct opt_table opt_config_table[] = {
opt_set_intval, NULL, &opt_hfa_ntime_roll,
opt_hidden),
OPT_WITH_ARG("--hfa-options",
- set_hfa_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_hfa_options,
"Set hashfast options name:clock (comma separated)"),
OPT_WITHOUT_ARG("--hfa-pll-bypass",
opt_set_bool, &opt_hfa_pll_bypass,
@@ -1332,10 +1242,10 @@ static struct opt_table opt_config_table[] = {
),
#ifdef USE_ICARUS
OPT_WITH_ARG("--icarus-options",
- set_icarus_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_icarus_options,
opt_hidden),
OPT_WITH_ARG("--icarus-timing",
- set_icarus_timing, NULL, NULL,
+ opt_set_charp, NULL, &opt_icarus_timing,
opt_hidden),
#endif
#if defined(HAVE_MODMINER)
@@ -1345,7 +1255,7 @@ static struct opt_table opt_config_table[] = {
#endif
#ifdef USE_KLONDIKE
OPT_WITH_ARG("--klondike-options",
- set_klondike_options, NULL, NULL,
+ opt_set_charp, NULL, &opt_klondike_options,
"Set klondike options clock:temptarget"),
#endif
OPT_WITHOUT_ARG("--load-balance",
@@ -1457,7 +1367,7 @@ static struct opt_table opt_config_table[] = {
"URL for bitcoin JSON-RPC server"),
#ifdef USE_USBUTILS
OPT_WITH_ARG("--usb",
- set_usb_select, NULL, NULL,
+ opt_set_charp, NULL, &opt_usb_select,
"USB device selection"),
OPT_WITH_ARG("--usb-dump",
set_int_0_to_10, opt_show_intval, &opt_usbdump,
@@ -4906,15 +4816,16 @@ void write_config(FILE *fcfg)
fprintf(fcfg, ",\n\"%s\" : true", p+2);
if (opt->type & OPT_HASARG &&
- ((void *)opt->cb_arg == (void *)set_int_0_to_9999 ||
- (void *)opt->cb_arg == (void *)set_int_1_to_65535 ||
- (void *)opt->cb_arg == (void *)set_int_0_to_10 ||
- (void *)opt->cb_arg == (void *)set_int_1_to_10 ||
- (void *)opt->cb_arg == (void *)set_int_0_to_100 ||
- (void *)opt->cb_arg == (void *)set_int_0_to_255 ||
- (void *)opt->cb_arg == (void *)set_int_0_to_200 ||
- (void *)opt->cb_arg == (void *)set_int_32_to_63) &&
- opt->desc != opt_hidden)
+ ((void *)opt->cb_arg == (void *)opt_set_intval ||
+ (void *)opt->cb_arg == (void *)set_int_0_to_9999 ||
+ (void *)opt->cb_arg == (void *)set_int_1_to_65535 ||
+ (void *)opt->cb_arg == (void *)set_int_0_to_10 ||
+ (void *)opt->cb_arg == (void *)set_int_1_to_10 ||
+ (void *)opt->cb_arg == (void *)set_int_0_to_100 ||
+ (void *)opt->cb_arg == (void *)set_int_0_to_255 ||
+ (void *)opt->cb_arg == (void *)set_int_0_to_200 ||
+ (void *)opt->cb_arg == (void *)set_int_32_to_63) &&
+ opt->desc != opt_hidden)
fprintf(fcfg, ",\n\"%s\" : \"%d\"", p+2, *(int *)opt->u.arg);
if (opt->type & OPT_HASARG &&
@@ -4930,57 +4841,10 @@ void write_config(FILE *fcfg)
}
/* Special case options */
- fprintf(fcfg, ",\n\"shares\" : \"%d\"", opt_shares);
- if (pool_strategy == POOL_BALANCE)
- fputs(",\n\"balance\" : true", fcfg);
- if (pool_strategy == POOL_LOADBALANCE)
- fputs(",\n\"load-balance\" : true", fcfg);
- if (pool_strategy == POOL_ROUNDROBIN)
- fputs(",\n\"round-robin\" : true", fcfg);
- if (pool_strategy == POOL_ROTATE)
- fprintf(fcfg, ",\n\"rotate\" : \"%d\"", opt_rotate_period);
-#if defined(unix) || defined(__APPLE__)
- if (opt_stderr_cmd && *opt_stderr_cmd)
- fprintf(fcfg, ",\n\"monitor\" : \"%s\"", json_escape(opt_stderr_cmd));
-#endif // defined(unix)
- if (opt_kernel_path && *opt_kernel_path) {
- char *kpath = strdup(opt_kernel_path);
- if (kpath[strlen(kpath)-1] == '/')
- kpath[strlen(kpath)-1] = 0;
- fprintf(fcfg, ",\n\"kernel-path\" : \"%s\"", json_escape(kpath));
- }
if (schedstart.enable)
fprintf(fcfg, ",\n\"sched-time\" : \"%d:%d\"", schedstart.tm.tm_hour, schedstart.tm.tm_min);
if (schedstop.enable)
fprintf(fcfg, ",\n\"stop-time\" : \"%d:%d\"", schedstop.tm.tm_hour, schedstop.tm.tm_min);
- if (opt_socks_proxy && *opt_socks_proxy)
- fprintf(fcfg, ",\n\"socks-proxy\" : \"%s\"", json_escape(opt_socks_proxy));
-#ifdef USE_ICARUS
- if (opt_icarus_options)
- fprintf(fcfg, ",\n\"icarus-options\" : \"%s\"", json_escape(opt_icarus_options));
- if (opt_icarus_timing)
- fprintf(fcfg, ",\n\"icarus-timing\" : \"%s\"", json_escape(opt_icarus_timing));
-#endif
-#ifdef USE_KLONDIKE
- if (opt_klondike_options)
- fprintf(fcfg, ",\n\"klondike-options\" : \"%s\"", json_escape(opt_klondike_options));
-#endif
-#ifdef USE_DRILLBIT
- if (opt_drillbit_options)
- fprintf(fcfg, ",\n\"drillbit-options\" : \"%s\"", json_escape(opt_drillbit_options));
- if (opt_drillbit_auto)
- fprintf(fcfg, ",\n\"drillbit-auto\" : \"%s\"", json_escape(opt_drillbit_auto));
-#endif
- if (opt_bab_options)
- fprintf(fcfg, ",\n\"bab-options\" : \"%s\"", json_escape(opt_bab_options));
-#ifdef USE_BITMINE_A1
- if (opt_bitmine_a1_options)
- fprintf(fcfg, ",\n\"bitmine-a1-options\" : \"%s\"", json_escape(opt_bitmine_a1_options));
-#endif
-#ifdef USE_USBUTILS
- if (opt_usb_select)
- fprintf(fcfg, ",\n\"usb\" : \"%s\"", json_escape(opt_usb_select));
-#endif
fputs("\n}\n", fcfg);
json_escape_free();