summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2004-03-19 17:36:56 +0000
committerRichard Sharpe <sharpe@samba.org>2004-03-19 17:36:56 +0000
commit8d976560e07ccf11ac49926ee742ca41ff77c248 (patch)
tree9370640f26af94aa8ee7b6be1b6a7e59bfef484d /examples
parent14f5ea9965eb1455c25fa80a8e58e31a20ef37b6 (diff)
downloadsamba-8d976560e07ccf11ac49926ee742ca41ff77c248.tar.gz
samba-8d976560e07ccf11ac49926ee742ca41ff77c248.tar.bz2
samba-8d976560e07ccf11ac49926ee742ca41ff77c248.zip
Apply some more of Derrell Lipman's changes.
(This used to be commit a6457e1c817663cf5f3e77e4dd431ac0d9184dc7)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/Makefile6
-rw-r--r--examples/libsmbclient/testbrowse.c91
2 files changed, 96 insertions, 1 deletions
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index e7c82a3aee..fcd5ef2900 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -10,7 +10,7 @@ CFLAGS = -I$(SAMBA_INCL) $(EXTLIB_INCL)
LDFLAGS = -L/usr/lib
-all: testsmbc tree testacl
+all: testsmbc tree testacl testbrowse
testsmbc: testsmbc.o
@echo Linking testsmbc
@@ -28,5 +28,9 @@ testacl: testacl.o
@echo Linking testacl
@$(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ `gtk-config --libs` -lsmbclient -lpopt $<
+testbrowse: testbrowse.o
+ @echo Linking testbrowse
+ @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -lsmbclient -lpopt $<
+
clean:
@rm -f *.o *~
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
new file mode 100644
index 0000000000..d2472230a2
--- /dev/null
+++ b/examples/libsmbclient/testbrowse.c
@@ -0,0 +1,91 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB client library test program for browsing with different master browsers
+ Copyright (C) Derrell Lipman 2004
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <libsmbclient.h>
+
+static void
+auth_fn(const char * pServer,
+ const char * pShare,
+ char * pWorkgroup,
+ int workgroup_len,
+ char * pUsername,
+ int username_len,
+ char * pPassword,
+ int password_len)
+
+{
+ strncpy(pUsername, "anonymous", username_len); /* doesn't matter what */
+ strncpy(pPassword, "password", password_len); /* ditto */
+}
+
+
+int
+main(int argc, char * argv[])
+{
+ int debug = 4;
+ int opt;
+ char * p;
+ char buf[1024];
+ int dir;
+ struct smbc_dirent * dirent;
+ char ** ppUrl;
+ char * urlList[] =
+ {
+ "smb://",
+ "smb://?mb=.any",
+ "smb://?mb=.all",
+ "smb://?mb=xx", /* this one is suupposed to fail */
+ NULL
+ };
+
+ if (smbc_init(auth_fn, debug) != 0)
+ {
+ printf("Could not initialize smbc_ library\n");
+ return 1;
+ }
+
+ for (ppUrl = urlList; *ppUrl != NULL; ppUrl++)
+ {
+ printf("Opening (%s)...\n", *ppUrl);
+
+ if ((dir = smbc_opendir(*ppUrl)) < 0)
+ {
+ printf("Could not open [%s] (%d:%s)\n",
+ *ppUrl, errno, strerror(errno));
+ continue;
+ }
+
+ while ((dirent = smbc_readdir(dir)) != NULL)
+ {
+ printf("%s\n", dirent->name);
+ }
+
+ smbc_closedir(dir);
+ }
+
+ exit(0);
+}
+