docs: Remove distinction between server and domain accounts
[Samba/bjacke.git] / source3 / utils / smbw_sample.c
blob2c4a20fab7b3794e47e9e2917626318787fa6a97
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <dirent.h>
5 #include <sys/stat.h>
7 static void usage(void)
9 printf("
10 smbw_sample - a sample program that uses smbw
12 smbw_sample <options> path
14 options:
15 -W workgroup
16 -l logfile
17 -P prefix
18 -d debuglevel
19 -U username%%password
20 -R resolve order
22 note that path must start with /smb/
23 ");
26 int main(int argc, char *argv[])
28 DIR *dir;
29 struct dirent *dent;
30 int opt;
31 char *p;
32 extern char *optarg;
33 extern int optind;
34 char *path;
35 TALLOC_CTX *frame = talloc_stackframe();
37 lp_load_global(get_dyn_CONFIGFILE());
38 smbw_setup_shared();
40 while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
41 switch (opt) {
42 case 'W':
43 smbw_setshared("WORKGROUP", optarg);
44 break;
45 case 'l':
46 smbw_setshared("LOGFILE", optarg);
47 break;
48 case 'P':
49 smbw_setshared("PREFIX", optarg);
50 break;
51 case 'd':
52 smbw_setshared("DEBUG", optarg);
53 break;
54 case 'U':
55 p = strchr_m(optarg,'%');
56 if (p) {
57 *p=0;
58 smbw_setshared("PASSWORD",p+1);
60 smbw_setshared("USER", optarg);
61 break;
62 case 'R':
63 smbw_setshared("RESOLVE_ORDER",optarg);
64 break;
65 case 'h':
66 default:
67 usage();
68 exit(1);
72 argc -= optind;
73 argv += optind;
75 if (argc < 1) {
76 usage();
77 exit(1);
80 path = argv[0];
82 smbw_init();
84 dir = smbw_opendir(path);
85 if (!dir) {
86 printf("failed to open %s\n", path);
87 exit(1);
90 while ((dent = smbw_readdir(dir))) {
91 printf("%s\n", dent->d_name);
93 smbw_closedir(dir);
94 TALLOC_FREE(frame);
95 return 0;