summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-01-31 06:09:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:39 -0500
commit60f8666ae88c5a03b0da58acb94015337442e18b (patch)
tree685a293456b72165d8f5b2192c9fe143c158fa4f /source4/libcli
parent99f0659f67eb59d55aeee31bd16614a7ebe282a1 (diff)
downloadsamba-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/libcli')
-rw-r--r--source4/libcli/cliconnect.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index fe0ad9c9f5..9a5236a661 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -4,6 +4,7 @@
client connect/disconnect routines
Copyright (C) Andrew Tridgell 2003-2005
+ 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
@@ -175,11 +176,33 @@ struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx)
return talloc_zero(mem_ctx, struct smbcli_state);
}
+/* Insert a NULL at the first separator of the given path and return a pointer
+ * to the location it was inserted at.
+ */
+static char *
+terminate_path_at_separator(char * path)
+{
+ char * p;
+
+ if ((p = strchr_m(path, '/'))) {
+ *p = '\0';
+ return(p);
+ }
+
+ if ((p = strchr_m(path, '\\'))) {
+ *p = '\0';
+ return(p);
+ }
+
+ /* No terminator. Return pointer to the last byte. */
+ return(p + strlen(path));
+}
+
/*
parse a //server/share type UNC name
*/
BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
- const char **hostname, const char **sharename)
+ char **hostname, char **sharename)
{
char *p;
@@ -189,13 +212,10 @@ BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
}
*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
- p = strchr_m(&(*hostname)[2],'/');
- if (!p) {
- p = strchr_m(&(*hostname)[2],'\\');
- if (!p) return False;
- }
- *p = 0;
+ p = terminate_path_at_separator(*hostname);
+
*sharename = talloc_strdup(mem_ctx, p+1);
+ p = terminate_path_at_separator(*sharename);
return True;
}