mirror of
https://github.com/upa/mscp.git
synced 2026-02-16 10:54:47 +08:00
fix bitrate factor should be 1 when unit is not specified
This commit is contained in:
27
src/main.c
27
src/main.c
@@ -268,8 +268,8 @@ int main(int argc, char **argv)
|
|||||||
int direction = 0;
|
int direction = 0;
|
||||||
char *remote = NULL, *checkpoint_save = NULL, *checkpoint_load = NULL;
|
char *remote = NULL, *checkpoint_save = NULL, *checkpoint_load = NULL;
|
||||||
bool dryrun = false, resume = false;
|
bool dryrun = false, resume = false;
|
||||||
char *u;
|
size_t factor = 1;
|
||||||
size_t mag = 0;
|
char *unit;
|
||||||
|
|
||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
memset(&o, 0, sizeof(o));
|
memset(&o, 0, sizeof(o));
|
||||||
@@ -314,23 +314,24 @@ int main(int argc, char **argv)
|
|||||||
o.buf_sz = atoi(optarg);
|
o.buf_sz = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
u = optarg + (strlen(optarg) - 1);
|
factor = 1;
|
||||||
if (*u == 'k' || *u == 'K') {
|
unit = optarg + (strlen(optarg) - 1);
|
||||||
mag = 1000;
|
if (*unit == 'k' || *unit == 'K') {
|
||||||
*u = '\0';
|
factor = 1000;
|
||||||
} else if (*u == 'm' || *u == 'M') {
|
*unit = '\0';
|
||||||
mag = 1000000;
|
} else if (*unit == 'm' || *unit == 'M') {
|
||||||
*u = '\0';
|
factor = 1000000;
|
||||||
} else if (*u == 'g' || *u == 'G') {
|
*unit = '\0';
|
||||||
mag = 1000000000;
|
} else if (*unit == 'g' || *unit == 'G') {
|
||||||
*u = '\0';
|
factor = 1000000000;
|
||||||
|
*unit = '\0';
|
||||||
}
|
}
|
||||||
o.bitrate = atol(optarg);
|
o.bitrate = atol(optarg);
|
||||||
if (o.bitrate == 0) {
|
if (o.bitrate == 0) {
|
||||||
pr_err("invalid bitrate: %s", optarg);
|
pr_err("invalid bitrate: %s", optarg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
o.bitrate *= mag;
|
o.bitrate *= factor;
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
s.ai_family = AF_INET;
|
s.ai_family = AF_INET;
|
||||||
|
|||||||
Reference in New Issue
Block a user