Allow decimal numbers for '-t', '-i', '-p', and '-Q'. fixes #133

pull/145/head
David Schweikert 6 years ago
parent cc7316b7b8
commit 4b7d4cb536

@ -3,6 +3,7 @@ fping 4.2 (UNRELEASED)
## Bugfixes and other changes ## Bugfixes and other changes
- Allow decimal numbers for '-t', '-i', '-p', and '-Q'
- Fix build with --disable-ipv6 (#134, thanks @Polynomial-C) - Fix build with --disable-ipv6 (#134, thanks @Polynomial-C)
- Fix hang with '-6', with ipv6 kernel module, but not loaded (#140, thanks @abelbeck) - Fix hang with '-6', with ipv6 kernel module, but not loaded (#140, thanks @abelbeck)
- Assume '-6' if the binary is named 'fping6' (this is mostly for special - Assume '-6' if the binary is named 'fping6' (this is mostly for special

@ -422,7 +422,7 @@ int main(int argc, char** argv)
{ 0, 0, 0 } { 0, 0, 0 }
}; };
//while ((c = optparse(&optparse_state, "46ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:")) != EOF) { float opt_value_float;
while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) { while ((c = optparse_long(&optparse_state, longopts, NULL)) != EOF) {
switch (c) { switch (c) {
case '4': case '4':
@ -467,10 +467,13 @@ int main(int argc, char** argv)
break; break;
case 't': case 't':
if (!(timeout = (unsigned int)atoi(optparse_state.optarg) * 100)) if (!sscanf(optparse_state.optarg, "%f", &opt_value_float))
usage(1); usage(1);
if (opt_value_float < 0) {
usage(1);
}
timeout = opt_value_float * 100;
timeout_flag = 1; timeout_flag = 1;
break; break;
case 'r': case 'r':
@ -479,14 +482,21 @@ int main(int argc, char** argv)
break; break;
case 'i': case 'i':
if (!sscanf(optparse_state.optarg, "%u", &interval)) if (!sscanf(optparse_state.optarg, "%f", &opt_value_float))
usage(1); usage(1);
interval *= 100; if (opt_value_float < 0) {
usage(1);
}
interval = opt_value_float * 100;
break; break;
case 'p': case 'p':
if (!(perhost_interval = (unsigned int)atoi(optparse_state.optarg) * 100)) if (!sscanf(optparse_state.optarg, "%f", &opt_value_float))
usage(1); usage(1);
if (opt_value_float < 0) {
usage(1);
}
perhost_interval = opt_value_float * 100;
break; break;
@ -523,8 +533,12 @@ int main(int argc, char** argv)
case 'Q': case 'Q':
verbose_flag = 0; verbose_flag = 0;
quiet_flag = 1; quiet_flag = 1;
if (!(report_interval = (unsigned int)atoi(optparse_state.optarg) * 100000)) if (!sscanf(optparse_state.optarg, "%f", &opt_value_float))
usage(1); usage(1);
if (opt_value_float < 0) {
usage(1);
}
report_interval = opt_value_float * 100000;
break; break;

Loading…
Cancel
Save