summaryrefslogtreecommitdiff
path: root/source3/client/testsmbc.c
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2001-01-12 05:10:45 +0000
committerRichard Sharpe <sharpe@samba.org>2001-01-12 05:10:45 +0000
commitfb4013444677629af4b663a61da3b575bba49195 (patch)
tree7651b05326ecf23a1ccfafbdb988b44f0502df6f /source3/client/testsmbc.c
parent78b2616049f19f7dad7c259bf04b0fb8645de218 (diff)
downloadsamba-fb4013444677629af4b663a61da3b575bba49195.tar.gz
samba-fb4013444677629af4b663a61da3b575bba49195.tar.bz2
samba-fb4013444677629af4b663a61da3b575bba49195.zip
Many bug fixes to the libsmbclient.c code plus
- an implementation of smbc_readdir - extensions to tree.c to show files in a second window - changes to auth_fn to provide buffers for username, password, etc from caller rather than callee (This used to be commit 7f559c1a7307b91218d5984f48f65e7dc0ab66b9)
Diffstat (limited to 'source3/client/testsmbc.c')
-rw-r--r--source3/client/testsmbc.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/source3/client/testsmbc.c b/source3/client/testsmbc.c
index 0dbd5b3c2d..49d9692176 100644
--- a/source3/client/testsmbc.c
+++ b/source3/client/testsmbc.c
@@ -26,30 +26,36 @@
#include <libsmbclient.h>
void auth_fn(char *server, char *share,
- char **workgroup, char **username, char **password)
+ char *workgroup, int wgmaxlen, char *username, int unmaxlen,
+ char *password, int pwmaxlen)
{
- static char wg[128], un[128], pw[128];
- /* DO nothing for now ... change later */
+ char temp[128];
- fprintf(stdout, "Enter workgroup: ");
- fgets(wg, sizeof(wg), stdin);
+ fprintf(stdout, "Need password for //%s/%s\n", server, share);
- if (wg[strlen(wg) - 1] == 0x0a) /* A new line? */
- wg[strlen(wg) - 1] = 0x00;
+ fprintf(stdout, "Enter workgroup: [%s] ", workgroup);
+ fgets(temp, sizeof(temp), stdin);
- fprintf(stdout, "Enter username: ");
- fgets(un, sizeof(un), stdin);
+ if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
+ temp[strlen(temp) - 1] = 0x00;
- if (un[strlen(un) - 1] == 0x0a) /* A new line? */
- un[strlen(un) - 1] = 0x00;
+ if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);
- fprintf(stdout, "Enter password: ");
- fgets(pw, sizeof(pw), stdin);
+ fprintf(stdout, "Enter username: [%s] ", username);
+ fgets(temp, sizeof(temp), stdin);
- if (pw[strlen(pw) - 1] == 0x0a) /* A new line? */
- pw[strlen(pw) - 1] = 0x00;
+ if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
+ temp[strlen(temp) - 1] = 0x00;
- *workgroup = wg; *password = pw; *username = un;
+ if (temp[0]) strncpy(username, temp, unmaxlen - 1);
+
+ fprintf(stdout, "Enter password: [%s] ", password);
+ fgets(temp, sizeof(temp), stdin);
+
+ if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
+ temp[strlen(temp) - 1] = 0x00;
+
+ if (temp[0]) strncpy(password, temp, pwmaxlen - 1);
}
@@ -122,7 +128,7 @@ int main(int argc, char *argv[])
while (dirc > 0) {
- dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1;
+ dsize = dirp->dirlen;
fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n",
dirp->smbc_type, dirp->name, dirp->comment);
@@ -148,7 +154,7 @@ int main(int argc, char *argv[])
while (dirc > 0) {
- dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1;
+ dsize = dirp->dirlen;
fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n",
dirp->smbc_type, dirp->name, dirp->comment);
@@ -174,7 +180,7 @@ int main(int argc, char *argv[])
while (dirc > 0) {
- dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1;
+ dsize = dirp->dirlen;
fprintf(stdout, "\nDir Ent, Type: %u, Name: %s, Comment: %s\n",
dirp->smbc_type, dirp->name, dirp->comment);
@@ -330,7 +336,9 @@ int main(int argc, char *argv[])
fprintf(stdout, "Stat'ed file: %s. Size = %d, mode = %04X\n", file2,
st2.st_size, st2.st_mode);
+ fprintf(stdout, " time: %s\n", ctime(&st2.st_atime));
fprintf(stdout, "Earlier stat: %s, Size = %d, mode = %04X\n", file,
st1.st_size, st1.st_mode);
+ fprintf(stdout, " time: %s\n", ctime(&st1.st_atime));
}