summaryrefslogtreecommitdiff
path: root/usr.sbin/altq/tbrconfig
diff options
context:
space:
mode:
authorKenjiro Cho <kjc@cvs.openbsd.org>2001-10-26 07:39:53 +0000
committerKenjiro Cho <kjc@cvs.openbsd.org>2001-10-26 07:39:53 +0000
commit54aadc9b1285ef7536f4365800867aa535f1460d (patch)
tree353d96504025170671c313249df289e4682d4daa /usr.sbin/altq/tbrconfig
parent40b1a802e09c29053d233b7a1c0cb02042b36bb5 (diff)
accept the fact that people continue to use decimal points
to specify bandwidth... make the parser to use strtod(3) instead of strtoul(3).
Diffstat (limited to 'usr.sbin/altq/tbrconfig')
-rw-r--r--usr.sbin/altq/tbrconfig/tbrconfig.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.sbin/altq/tbrconfig/tbrconfig.c b/usr.sbin/altq/tbrconfig/tbrconfig.c
index 0baf7dd60d7..c8a6f06f400 100644
--- a/usr.sbin/altq/tbrconfig/tbrconfig.c
+++ b/usr.sbin/altq/tbrconfig/tbrconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tbrconfig.c,v 1.1 2001/06/27 18:23:36 kjc Exp $ */
+/* $OpenBSD: tbrconfig.c,v 1.2 2001/10/26 07:39:52 kjc Exp $ */
/* $KAME: tbrconfig.c,v 1.3 2001/05/08 04:36:39 itojun Exp $ */
/*
* Copyright (C) 2000
@@ -203,10 +203,10 @@ list_all(void)
static u_long
atobps(const char *s)
{
- u_long bandwidth;
+ double bandwidth;
char *cp;
- bandwidth = strtoul(s, &cp, 0);
+ bandwidth = strtod(s, &cp);
if (cp != NULL) {
if (*cp == 'K' || *cp == 'k')
bandwidth *= 1000;
@@ -215,16 +215,18 @@ atobps(const char *s)
else if (*cp == 'G' || *cp == 'g')
bandwidth *= 1000000000;
}
- return (bandwidth);
+ if (bandwidth < 0)
+ bandwidth = 0;
+ return ((u_long)bandwidth);
}
static u_long
atobytes(const char *s)
{
- u_long bytes;
+ double bytes;
char *cp;
- bytes = strtoul(s, &cp, 0);
+ bytes = strtod(s, &cp);
if (cp != NULL) {
if (*cp == 'K' || *cp == 'k')
bytes *= 1024;
@@ -233,7 +235,9 @@ atobytes(const char *s)
else if (*cp == 'G' || *cp == 'g')
bytes *= 1024 * 1024 * 1024;
}
- return (bytes);
+ if (bytes < 0)
+ bytes = 0;
+ return ((u_long)bytes);
}
/*