diff options
author | James Peach <jpeach@samba.org> | 2006-01-31 06:09:18 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:51:39 -0500 |
commit | 60f8666ae88c5a03b0da58acb94015337442e18b (patch) | |
tree | 685a293456b72165d8f5b2192c9fe143c158fa4f /source4/lib | |
parent | 99f0659f67eb59d55aeee31bd16614a7ebe282a1 (diff) | |
download | samba-60f8666ae88c5a03b0da58acb94015337442e18b.tar.gz samba-60f8666ae88c5a03b0da58acb94015337442e18b.tar.bz2 samba-60f8666ae88c5a03b0da58acb94015337442e18b.zip |
r13255: New CIFS dd client for use in performance testing. The guts of this is
in client/cifsdd*, which implements a minimal implementation of dd. The
IO path is careful to always perform IO at the requested block size.
There is a very basic test suite in script/tests/test_cifsdd.sh which
covers local and remote IO at a variety of block sizes.
Added to lib/util_str.c is a small set of conv_str_*() functions to
convert strings to the corresponding type.
smbcli_parse_unc is modified to insert NULL terminators after its
hostname and sharename parameters. This allows it to correctly parse a
path of the form //foo/share/path/file.
(This used to be commit cd2f94a65817bfae20ac21b730a2c42d8e581ab3)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/util_str.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/source4/lib/util_str.c b/source4/lib/util_str.c index 311f81eaf3..6da0063c50 100644 --- a/source4/lib/util_str.c +++ b/source4/lib/util_str.c @@ -5,6 +5,7 @@ Copyright (C) Andrew Tridgell 1992-2001 Copyright (C) Simo Sorce 2001-2002 Copyright (C) Martin Pool 2003 + Copyright (C) James Peach 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1136,3 +1137,73 @@ BOOL set_boolean(const char *boolean_string, BOOL *boolean) return False; } +BOOL conv_str_bool(const char * str, BOOL * val) +{ + char * end = NULL; + long lval; + + if (str == NULL || *str == '\0') { + return False; + } + + lval = strtol(str, &end, 10 /* base */); + if (end == NULL || *end != '\0' || end == str) { + return set_boolean(str, val); + } + + *val = (lval) ? True : False; + return True; +} + +/* Convert a size specification like 16K into an integral number of bytes. */ +BOOL conv_str_size(const char * str, uint64_t * val) +{ + char * end = NULL; + unsigned long long lval; + + if (str == NULL || *str == '\0') { + return False; + } + + lval = strtoull(str, &end, 10 /* base */); + if (end == NULL || end == str) { + return False; + } + + if (*end) { + if (strwicmp(end, "K") == 0) { + lval *= 1024ULL; + } else if (strwicmp(end, "M") == 0) { + lval *= (1024ULL * 1024ULL); + } else if (strwicmp(end, "G") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL); + } else if (strwicmp(end, "T") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL); + } else if (strwicmp(end, "P") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL); + } else { + return False; + } + } + + *val = (uint64_t)lval; + return True; +} + +BOOL conv_str_u64(const char * str, uint64_t * val) +{ + char * end = NULL; + unsigned long long lval; + + if (str == NULL || *str == '\0') { + return False; + } + + lval = strtoull(str, &end, 10 /* base */); + if (end == NULL || *end != '\0' || end == str) { + return False; + } + + *val = (uint64_t)lval; + return True; +} |