svn commit: samba r11130 - in branches/SAMBA_3_0: .
examples/libsmbclient
derrell at samba.org
derrell at samba.org
Mon Oct 17 19:29:11 GMT 2005
Author: derrell
Date: 2005-10-17 19:29:11 +0000 (Mon, 17 Oct 2005)
New Revision: 11130
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11130
Log:
r10092 at cabra: derrell | 2005-10-17 15:29:03 -0400
let's now actually add the new test file
Added:
branches/SAMBA_3_0/examples/libsmbclient/testread.c
Modified:
branches/SAMBA_3_0/
Changeset:
Property changes on: branches/SAMBA_3_0
___________________________________________________________________
Name: svk:merge
- 3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba3:10090
+ 3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba3:10092
Added: branches/SAMBA_3_0/examples/libsmbclient/testread.c
===================================================================
--- branches/SAMBA_3_0/examples/libsmbclient/testread.c 2005-10-17 19:27:19 UTC (rev 11129)
+++ branches/SAMBA_3_0/examples/libsmbclient/testread.c 2005-10-17 19:29:11 UTC (rev 11130)
@@ -0,0 +1,74 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <libsmbclient.h>
+#include "get_auth_data_fn.h"
+
+
+int main(int argc, char * argv[])
+{
+ int fd;
+ int ret;
+ int debug = 0;
+ int mode = 0666;
+ int savedErrno;
+ char buffer[2048];
+ char * pSmbPath = NULL;
+ time_t t0;
+ time_t t1;
+ struct stat st;
+
+ if (argc == 1)
+ {
+ pSmbPath = "smb://RANDOM/Public/bigfile";
+ }
+ else if (argc == 2)
+ {
+ pSmbPath = argv[1];
+ }
+ else
+ {
+ printf("usage: "
+ "%s [ smb://path/to/file ]\n",
+ argv[0]);
+ return 1;
+ }
+
+ smbc_init(get_auth_data_fn, debug);
+
+ printf("Open file %s\n", pSmbPath);
+
+ t0 = time(NULL);
+
+ if ((fd = smbc_open(pSmbPath, O_RDONLY, 0)) < 0)
+ {
+ perror("smbc_open");
+ return 1;
+ }
+
+ printf("Beginning read loop.\n");
+
+ do
+ {
+ ret = smbc_read(fd, buffer, sizeof(buffer));
+ savedErrno = errno;
+ } while (ret > 0);
+
+ smbc_close(fd);
+
+ if (ret < 0)
+ {
+ errno = savedErrno;
+ perror("read");
+ return 1;
+ }
+
+ t1 = time(NULL);
+
+ printf("Elapsed time: %d seconds\n", t1 - t0);
+
+ return 0;
+}
More information about the samba-cvs
mailing list