The branch, v3-2-test has been updated
via aebecd7462733b56457540423354ba249fd52808 (commit)
via 9d75ea577b407ccab59196760d376831062a3ab5 (commit)
via 296a6783fbc03460e87ac4136a0a9e6d2743b2ff (commit)
via 01f6a4cca7a91ae41ff393263418216324502f84 (commit)
from 4db26c803de52d3efccc940efc55f14131a057f5 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit aebecd7462733b56457540423354ba249fd52808
Merge: 9d75ea577b407ccab59196760d376831062a3ab5
4db26c803de52d3efccc940efc55f14131a057f5
Author: Derrell Lipman <[EMAIL PROTECTED]>
Date: Wed Jan 16 14:41:43 2008 +0000
Merge branch 'v3-2-test' of git://git.samba.org/samba into v3-2-test
commit 9d75ea577b407ccab59196760d376831062a3ab5
Author: Derrell Lipman <[EMAIL PROTECTED]>
Date: Wed Jan 16 14:41:11 2008 +0000
Modify testread example to loop using same context.
There's been a problem seen where open/read/close a number of times causes
open failures eventually. This program has been modified to create the
context once and then loop requesting file names to open/read/close.
This program also demonstrates the current error in cli_read() where it
returns an error instead of length 0 upon end of file.
Derrell
commit 296a6783fbc03460e87ac4136a0a9e6d2743b2ff
Author: Derrell Lipman <[EMAIL PROTECTED]>
Date: Wed Jan 16 14:37:40 2008 +0000
Replace GetTimeOfDay() with gettimeofday() in example program.
GetTimeOfDay() seems to no longer be exported. For the smbsh example, just
use the native gettimeofday() for now.
commit 01f6a4cca7a91ae41ff393263418216324502f84
Author: Derrell Lipman <[EMAIL PROTECTED]>
Date: Wed Jan 16 14:35:44 2008 +0000
Add a (very!) trivial cache to the example authentication callback.
-----------------------------------------------------------------------
Summary of changes:
examples/libsmbclient/get_auth_data_fn.h | 22 ++++++++-
examples/libsmbclient/smbwrapper/select.c | 5 +-
examples/libsmbclient/testread.c | 76 +++++++++++++----------------
3 files changed, 57 insertions(+), 46 deletions(-)
Changeset truncated at 500 lines:
diff --git a/examples/libsmbclient/get_auth_data_fn.h
b/examples/libsmbclient/get_auth_data_fn.h
index eb49388..b1d36c8 100644
--- a/examples/libsmbclient/get_auth_data_fn.h
+++ b/examples/libsmbclient/get_auth_data_fn.h
@@ -8,7 +8,23 @@ get_auth_data_fn(const char * pServer,
char * pPassword,
int maxLenPassword)
{
- char temp[128];
+ char temp[128];
+ char server[256] = { '\0' };
+ char share[256] = { '\0' };
+ char workgroup[256] = { '\0' };
+ char username[256] = { '\0' };
+ char password[256] = { '\0' };
+
+ if (strcmp(server, pServer) == 0 &&
+ strcmp(share, pShare) == 0 &&
+ *workgroup != '\0' &&
+ *username != '\0')
+ {
+ strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
+ strncpy(pUsername, username, maxLenUsername - 1);
+ strncpy(pPassword, password, maxLenPassword - 1);
+ return;
+ }
fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
@@ -48,4 +64,8 @@ get_auth_data_fn(const char * pServer,
{
strncpy(pPassword, temp, maxLenPassword - 1);
}
+
+ strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
+ strncpy(username, pUsername, sizeof(username) - 1);
+ strncpy(password, pPassword, sizeof(password) - 1);
}
diff --git a/examples/libsmbclient/smbwrapper/select.c
b/examples/libsmbclient/smbwrapper/select.c
index 4e87a2e..bb7a25f 100644
--- a/examples/libsmbclient/smbwrapper/select.c
+++ b/examples/libsmbclient/smbwrapper/select.c
@@ -72,13 +72,12 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set
*writefds, fd_set *errorf
int ret;
fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2,
errorfds_buf;
struct timeval tval2, *ptval, end_time, now_time;
- extern void GetTimeOfDay(struct timeval *tval);
readfds2 = (readfds ? &readfds_buf : NULL);
writefds2 = (writefds ? &writefds_buf : NULL);
errorfds2 = (errorfds ? &errorfds_buf : NULL);
if (tval) {
- GetTimeOfDay(&end_time);
+ gettimeofday(&end_time, NULL);
end_time.tv_sec += tval->tv_sec;
end_time.tv_usec += tval->tv_usec;
end_time.tv_sec += end_time.tv_usec / 1000000;
@@ -96,7 +95,7 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set
*writefds, fd_set *errorf
if (errorfds)
errorfds_buf = *errorfds;
if (tval) {
- GetTimeOfDay(&now_time);
+ gettimeofday(&now_time, NULL);
tval2.tv_sec = end_time.tv_sec - now_time.tv_sec;
tval2.tv_usec = end_time.tv_usec - now_time.tv_usec;
if ((signed long) tval2.tv_usec < 0) {
diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testread.c
index d59fc70..3f94884 100644
--- a/examples/libsmbclient/testread.c
+++ b/examples/libsmbclient/testread.c
@@ -10,66 +10,58 @@
int main(int argc, char * argv[])
{
+ int i;
int fd;
int ret;
int debug = 0;
int mode = 0666;
int savedErrno;
char buffer[2048];
- char * pSmbPath = NULL;
+ char path[2048];
+ char * p;
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)
+ for (;;)
{
- perror("smbc_open");
- return 1;
- }
+ fprintf(stdout, "Path: ");
+ *path = '\0';
+ fgets(path, sizeof(path) - 1, stdin);
+ if (strlen(path) == 0)
+ {
+ return 0;
+ }
- printf("Beginning read loop.\n");
+ p = path + strlen(path) - 1;
+ if (*p == '\n')
+ {
+ *p = '\0';
+ }
+
+ if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+ {
+ perror("smbc_open");
+ continue;
+ }
- do
- {
- ret = smbc_read(fd, buffer, sizeof(buffer));
- savedErrno = errno;
- if (ret > 0) fwrite(buffer, 1, ret, stdout);
- } while (ret > 0);
+ do
+ {
+ ret = smbc_read(fd, buffer, sizeof(buffer));
+ savedErrno = errno;
+ if (ret > 0) fwrite(buffer, 1, ret, stdout);
+ } while (ret > 0);
- smbc_close(fd);
+ smbc_close(fd);
- if (ret < 0)
- {
- errno = savedErrno;
- perror("read");
- return 1;
+ if (ret < 0)
+ {
+ errno = savedErrno;
+ perror("read");
+ }
}
- t1 = time(NULL);
-
- printf("Elapsed time: %d seconds\n", t1 - t0);
-
return 0;
}
--
Samba Shared Repository