From c1254449a2d6fb17655829bc1db02b918b6a2798 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jul 2000 03:54:07 +0000 Subject: the smbw sample prog (This used to be commit 0afcc0d3368472ed4b49167dc4b7d907b0ccdc25) --- source3/utils/smbw_sample.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 source3/utils/smbw_sample.c (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c new file mode 100644 index 0000000000..d98d5cbe22 --- /dev/null +++ b/source3/utils/smbw_sample.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include +#include + +static void usage(void) +{ + printf(" +smbw_sample - a sample program that uses smbw + +smbw_sample path + + options: + -W workgroup + -l logfile + -P prefix + -d debuglevel + -U username%password + -R resolve order + +note that path must start with /smb/ +"); +} + +int main(int argc, char *argv[]) +{ + DIR *dir; + struct dirent *dent; + int opt; + char *p; + extern char *optarg; + extern int optind; + char *path; + + charset_initialise(); + smbw_setup_shared(); + + while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { + switch (opt) { + case 'W': + smbw_setshared("WORKGROUP", optarg); + break; + case 'l': + smbw_setshared("LOGFILE", optarg); + break; + case 'P': + smbw_setshared("PREFIX", optarg); + break; + case 'd': + smbw_setshared("DEBUG", optarg); + break; + case 'U': + p = strchr(optarg,'%'); + if (p) { + *p=0; + smbw_setshared("PASSWORD",p+1); + } + smbw_setshared("USER", optarg); + break; + case 'R': + smbw_setshared("RESOLVE_ORDER",optarg); + break; + case 'h': + default: + usage(); + } + } + + argc -= optind; + argv += optind; + + if (argc < 1) { + usage(); + exit(1); + } + + path = argv[0]; + + smbw_init(); + + dir = smbw_opendir(path); + if (!dir) { + printf("failed to open %s\n", path); + exit(1); + } + + while ((dent = smbw_readdir(dir))) { + printf("%s\n", dent->d_name); + } + smbw_closedir(dir); + return 0; +} -- cgit From 0d7df3ee013bbad33a4fa230e0941c5021af0a71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Aug 2000 00:11:01 +0000 Subject: fixed help string (This used to be commit 16afa46797a4cdaa6e3b668caf6d910c08bec9b4) --- source3/utils/smbw_sample.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index d98d5cbe22..999dcaef47 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -16,7 +16,7 @@ smbw_sample path -l logfile -P prefix -d debuglevel - -U username%password + -U username%%password -R resolve order note that path must start with /smb/ @@ -64,6 +64,7 @@ int main(int argc, char *argv[]) case 'h': default: usage(); + exit(1); } } -- cgit From 6022747b5bbc3197d3a0e246c57caf1b7ad04b2d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Feb 2001 06:24:28 +0000 Subject: fixed character set init in smbw_sample (This used to be commit c43593ad069670fb47b8e98248254c739bb7ab18) --- source3/utils/smbw_sample.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index 999dcaef47..db92af9510 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -34,6 +34,8 @@ int main(int argc, char *argv[]) char *path; charset_initialise(); + lp_load(CONFIGFILE,1,0,0); + codepage_initialise(lp_client_code_page()); smbw_setup_shared(); while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/utils/smbw_sample.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index db92af9510..7d6eb7f353 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -33,9 +33,7 @@ int main(int argc, char *argv[]) extern int optind; char *path; - charset_initialise(); lp_load(CONFIGFILE,1,0,0); - codepage_initialise(lp_client_code_page()); smbw_setup_shared(); while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { -- cgit From 527e824293ee934ca5da0ef5424efe5ab7757248 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:36:09 +0000 Subject: strchr and strrchr are macros when compiling with optimisation in gcc, so we can't redefine them. damn. (This used to be commit c41fc06376d1a2b83690612304e85010b5e5f3cf) --- source3/utils/smbw_sample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index 7d6eb7f353..6a8fbf116b 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) smbw_setshared("DEBUG", optarg); break; case 'U': - p = strchr(optarg,'%'); + p = strchr_m(optarg,'%'); if (p) { *p=0; smbw_setshared("PASSWORD",p+1); -- cgit From f741f656737f4ec46cd318e986b6bf412ed309d2 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 02:49:53 +0000 Subject: Store some path names in global variables initialized to configure default, rather than in preprocessor macros. (This used to be commit 79ec88f0da40faebe1e587f1b3e87b5f2b184f58) --- source3/utils/smbw_sample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index 6a8fbf116b..5cd792df7a 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) extern int optind; char *path; - lp_load(CONFIGFILE,1,0,0); + lp_load(dyn_CONFIGFILE,1,0,0); smbw_setup_shared(); while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { -- cgit From 9c15bd311db76885b27f30ba92d885833f668550 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 28 Jan 2006 22:53:04 +0000 Subject: r13212: r12414@cabra: derrell | 2006-01-28 17:52:17 -0500 lp_load() could not be called multiple times to modify parameter settings based on reading from multiple configuration settings. Each time, it initialized all of the settings back to their defaults before reading the specified configuration file. This patch adds a parameter to lp_load() specifying whether the settings should be initialized. It does, however, still force the settings to be initialized the first time, even if the request was to not initialize them. (Not doing so could wreak havoc due to uninitialized values.) (This used to be commit f2a24de769d1b2266e576597c57a8e3b1e2a2b51) --- source3/utils/smbw_sample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index 5cd792df7a..ba78eb22fc 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) extern int optind; char *path; - lp_load(dyn_CONFIGFILE,1,0,0); + lp_load(dyn_CONFIGFILE,1,0,0,1); smbw_setup_shared(); while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { -- cgit From 7faee02d0d351c5c039e8f1be7e82ce3a93cbe96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 11:30:37 -0800 Subject: Remove the char[1024] strings from dynconfig. Replace them with malloc'ing accessor functions. Should save a lot of static space :-). Jeremy. (This used to be commit 52dc5eaef2106015b3a8b659e818bdb15ad94b05) --- source3/utils/smbw_sample.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/utils/smbw_sample.c') diff --git a/source3/utils/smbw_sample.c b/source3/utils/smbw_sample.c index ba78eb22fc..eface2fc46 100644 --- a/source3/utils/smbw_sample.c +++ b/source3/utils/smbw_sample.c @@ -32,8 +32,9 @@ int main(int argc, char *argv[]) extern char *optarg; extern int optind; char *path; + TALLOC_CTX *frame = talloc_stackframe(); - lp_load(dyn_CONFIGFILE,1,0,0,1); + lp_load(get_dyn_CONFIGFILE(),1,0,0,1); smbw_setup_shared(); while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) { @@ -90,5 +91,6 @@ int main(int argc, char *argv[]) printf("%s\n", dent->d_name); } smbw_closedir(dir); + TALLOC_FREE(frame); return 0; } -- cgit