aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/srv/unittoull.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-07-12 15:23:36 +0000
committerrsc <devnull@localhost>2005-07-12 15:23:36 +0000
commita0d146edd7a7de6236a0d60baafeeb59f8452aae (patch)
treeb55baa526d9f5adfc73246e6ee2fadf455e0b7a2 /src/cmd/venti/srv/unittoull.c
parent88bb285e3d87ec2508840af33f7e0af53ec3c13c (diff)
downloadplan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.tar.gz
plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.tar.bz2
plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.zip
return of venti
Diffstat (limited to 'src/cmd/venti/srv/unittoull.c')
-rw-r--r--src/cmd/venti/srv/unittoull.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/cmd/venti/srv/unittoull.c b/src/cmd/venti/srv/unittoull.c
new file mode 100644
index 00000000..1f741170
--- /dev/null
+++ b/src/cmd/venti/srv/unittoull.c
@@ -0,0 +1,30 @@
+#include "stdinc.h"
+
+#define TWID64 ((u64int)~(u64int)0)
+
+u64int
+unittoull(char *s)
+{
+ char *es;
+ u64int n;
+
+ if(s == nil)
+ return TWID64;
+ n = strtoul(s, &es, 0);
+ if(*es == 'k' || *es == 'K'){
+ n *= 1024;
+ es++;
+ }else if(*es == 'm' || *es == 'M'){
+ n *= 1024*1024;
+ es++;
+ }else if(*es == 'g' || *es == 'G'){
+ n *= 1024*1024*1024;
+ es++;
+ }else if(*es == 't' || *es == 'T'){
+ n *= 1024*1024;
+ n *= 1024*1024;
+ }
+ if(*es != '\0')
+ return TWID64;
+ return n;
+}