diff options
author | rsc <devnull@localhost> | 2003-11-23 17:54:58 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2003-11-23 17:54:58 +0000 |
commit | 7a4ee46d253e291044bba2d0c54b818b67ac013c (patch) | |
tree | 7bdcaf69a15ecd24c057a697936b67bbde93e00b /src/cmd/venti/unittoull.c | |
parent | 4fbfdd7acd4bf4fc71b1329230e05fc761907566 (diff) | |
download | plan9port-7a4ee46d253e291044bba2d0c54b818b67ac013c.tar.gz plan9port-7a4ee46d253e291044bba2d0c54b818b67ac013c.tar.bz2 plan9port-7a4ee46d253e291044bba2d0c54b818b67ac013c.zip |
Initial stab at Venti.
Diffstat (limited to 'src/cmd/venti/unittoull.c')
-rw-r--r-- | src/cmd/venti/unittoull.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cmd/venti/unittoull.c b/src/cmd/venti/unittoull.c new file mode 100644 index 00000000..db35aa0f --- /dev/null +++ b/src/cmd/venti/unittoull.c @@ -0,0 +1,27 @@ +#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++; + } + if(*es != '\0') + return TWID64; + return n; +} |