From 60f8666ae88c5a03b0da58acb94015337442e18b Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 31 Jan 2006 06:09:18 +0000 Subject: 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) --- source4/lib/util_str.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source4/lib/util_str.c') 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; +} -- cgit