summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2005-12-29 16:26:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:59 -0500
commite13d0cb3ec89d83db8893341ca7ae24c07aad1fb (patch)
treed99483ec3e0f3cf2514b184eed2f7199fd05f1af /examples
parent7919fd0ec80e680d848dd6157b6a5d14fc42e9b6 (diff)
downloadsamba-e13d0cb3ec89d83db8893341ca7ae24c07aad1fb.tar.gz
samba-e13d0cb3ec89d83db8893341ca7ae24c07aad1fb.tar.bz2
samba-e13d0cb3ec89d83db8893341ca7ae24c07aad1fb.zip
r12576: r12115@cabra: derrell | 2005-12-29 11:16:03 -0500
bug (enhancement) #2651: add option to log debug messages to stderr instead of stdout (This used to be commit 4182eb99af5b343291a661a87d08edd91fd09a7a)
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/testbrowse.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
index 6fa70eab41..eba6fff4eb 100644
--- a/examples/libsmbclient/testbrowse.c
+++ b/examples/libsmbclient/testbrowse.c
@@ -29,6 +29,7 @@ int
main(int argc, char * argv[])
{
int debug = 0;
+ int debug_stderr = 0;
int scan = 0;
int iterations = -1;
int again;
@@ -37,6 +38,7 @@ main(int argc, char * argv[])
char * q;
char buf[1024];
poptContext pc;
+ SMBCCTX * context;
struct poptOption long_options[] =
{
POPT_AUTOHELP
@@ -45,6 +47,10 @@ main(int argc, char * argv[])
0, "Set debug level", "integer"
},
{
+ "stderr", 'e', POPT_ARG_NONE, &debug_stderr,
+ 0, "Debug log to stderr instead of stdout", "integer"
+ },
+ {
"scan", 's', POPT_ARG_NONE, &scan,
0, "Scan for servers and shares", "integer"
},
@@ -69,14 +75,36 @@ main(int argc, char * argv[])
}
}
+ /* Allocate a new context */
+ context = smbc_new_context();
+ if (!context) {
+ printf("Could not allocate new smbc context\n");
+ return 1;
+ }
+
+ /* Set mandatory options (is that a contradiction in terms?) */
+ context->debug = debug;
+ context->callbacks.auth_fn = (scan ? no_auth_data_fn : get_auth_data_fn);
+
+ /* If we've been asked to log to stderr instead of stdout... */
+ if (debug_stderr) {
+ /* ... then set the option to do so */
+ smbc_option_set(context, "debug_stderr", NULL);
+ }
+
+ /* Initialize the context using the previously specified options */
+ if (!smbc_init_context(context)) {
+ smbc_free_context(context, 0);
+ printf("Could not initialize smbc context\n");
+ return 1;
+ }
+
+ /* Tell the compatibility layer to use this context */
+ smbc_set_context(context);
+
+
if (scan)
{
- if (smbc_init(no_auth_data_fn, debug) != 0)
- {
- printf("Could not initialize smbc_ library\n");
- return 1;
- }
-
for (;
iterations == -1 || iterations > 0;
iterations = (iterations == -1 ? iterations : --iterations))
@@ -87,12 +115,6 @@ main(int argc, char * argv[])
}
else
{
- if (smbc_init(get_auth_data_fn, debug) != 0)
- {
- printf("Could not initialize smbc_ library\n");
- return 1;
- }
-
for (;
iterations == -1 || iterations > 0;
iterations = (iterations == -1 ? iterations : --iterations))