diff options
author | Richard Sharpe <sharpe@samba.org> | 2001-01-05 13:43:19 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@samba.org> | 2001-01-05 13:43:19 +0000 |
commit | b6e811b90bf8cc6ca440ffedd210e5b16df555b2 (patch) | |
tree | 07860050ac28bb93ebdb340f318703129e1d5fe2 /source3/client | |
parent | dca808cbc4b52e38701f814f7aac043ddd1ca1c1 (diff) | |
download | samba-b6e811b90bf8cc6ca440ffedd210e5b16df555b2.tar.gz samba-b6e811b90bf8cc6ca440ffedd210e5b16df555b2.tar.bz2 samba-b6e811b90bf8cc6ca440ffedd210e5b16df555b2.zip |
The latest changes to libsmbclient ...
It can now do a directory listing for workgroups, servers, and shares, and,
with a bit more effort, it will be able to list directories and files.
I also does not request a username and password for the IPC$ share, but it
should if the first attempt to connect fails.
(This used to be commit 38ff91c5059a32c7ad2fd6074697c7c7f68a878c)
Diffstat (limited to 'source3/client')
-rw-r--r-- | source3/client/testsmbc.c | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/source3/client/testsmbc.c b/source3/client/testsmbc.c index 919b31e76b..0dbd5b3c2d 100644 --- a/source3/client/testsmbc.c +++ b/source3/client/testsmbc.c @@ -55,11 +55,13 @@ void auth_fn(char *server, char *share, int main(int argc, char *argv[]) { - int err, fd; + int err, fd, dh1, dh2, dh3, dsize, dirc; const char *file = "smb://samba/public/testfile.txt"; const char *file2 = "smb://samba/public/testfile2.txt"; const char *workgroup = "sambanet"; char buff[256]; + char dirbuf[512]; + struct smbc_dirent *dirp; struct stat st1, st2; err = smbc_init(auth_fn, workgroup, 10); /* Initialize things */ @@ -70,6 +72,121 @@ int main(int argc, char *argv[]) } + if (argc > 1) { + + if ((dh1 = smbc_opendir("smb://"))<1) { + + fprintf(stderr, "Could not open directory: smb://: %s\n", + strerror(errno)); + + exit(1); + + } + + if ((dh2 = smbc_opendir("smb://sambanet")) < 0) { + + fprintf(stderr, "Could not open directory: smb://sambanet: %s\n", + strerror(errno)); + + exit(1); + + } + + if ((dh3 = smbc_opendir("smb://samba")) < 0) { + + fprintf(stderr, "Could not open directory: smb://samba: %s\n", + strerror(errno)); + + exit(1); + + } + + fprintf(stdout, "Directory handles: %u, %u, %u\n", dh1, dh2, dh3); + + /* Now, list those directories, but in funny ways ... */ + + dirp = (struct smbc_dirent *)dirbuf; + + if ((dirc = smbc_getdents(dh1, dirp, sizeof(dirbuf))) < 0) { + + fprintf(stderr, "Problems getting directory entries: %s\n", + strerror(errno)); + + exit(1); + + } + + /* Now, process the list of names ... */ + + fprintf(stdout, "Directory listing, size = %u\n", dirc); + + while (dirc > 0) { + + dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1; + fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n", + dirp->smbc_type, dirp->name, dirp->comment); + + (char *)dirp += dsize; + (char *)dirc -= dsize; + + } + + dirp = (struct smbc_dirent *)dirbuf; + + if ((dirc = smbc_getdents(dh2, dirp, sizeof(dirbuf))) < 0) { + + fprintf(stderr, "Problems getting directory entries: %s\n", + strerror(errno)); + + exit(1); + + } + + /* Now, process the list of names ... */ + + fprintf(stdout, "\nDirectory listing, size = %u\n", dirc); + + while (dirc > 0) { + + dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1; + fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n", + dirp->smbc_type, dirp->name, dirp->comment); + + (char *)dirp += dsize; + (char *)dirc -= dsize; + + } + + dirp = (struct smbc_dirent *)dirbuf; + + if ((dirc = smbc_getdents(dh3, dirp, sizeof(dirbuf))) < 0) { + + fprintf(stderr, "Problems getting directory entries: %s\n", + strerror(errno)); + + exit(1); + + } + + /* Now, process the list of names ... */ + + fprintf(stdout, "Directory listing, size = %u\n", dirc); + + while (dirc > 0) { + + dsize = sizeof(struct smbc_dirent) + dirp->namelen + dirp->commentlen + 1; + fprintf(stdout, "\nDir Ent, Type: %u, Name: %s, Comment: %s\n", + dirp->smbc_type, dirp->name, dirp->comment); + + (char *)dirp += dsize; + (char *)dirc -= dsize; + + } + + exit(1); + + } + /* For now, open a file on a server that is hard coded ... later will * read from the command line ... */ |