Clean up a comment noticed by Jonathan Shao@Panasas.com and remove an
[Samba/gebeck_regimport.git] / source3 / utils / smbw_sample.c
blob5cd792df7a2f62cde225f83247f5692e995895e6
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;
36 lp_load(dyn_CONFIGFILE,1,0,0);
37 smbw_setup_shared();
39 while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
40 switch (opt) {
41 case 'W':
42 smbw_setshared("WORKGROUP", optarg);
43 break;
44 case 'l':
45 smbw_setshared("LOGFILE", optarg);
46 break;
47 case 'P':
48 smbw_setshared("PREFIX", optarg);
49 break;
50 case 'd':
51 smbw_setshared("DEBUG", optarg);
52 break;
53 case 'U':
54 p = strchr_m(optarg,'%');
55 if (p) {
56 *p=0;
57 smbw_setshared("PASSWORD",p+1);
59 smbw_setshared("USER", optarg);
60 break;
61 case 'R':
62 smbw_setshared("RESOLVE_ORDER",optarg);
63 break;
64 case 'h':
65 default:
66 usage();
67 exit(1);
71 argc -= optind;
72 argv += optind;
74 if (argc < 1) {
75 usage();
76 exit(1);
79 path = argv[0];
81 smbw_init();
83 dir = smbw_opendir(path);
84 if (!dir) {
85 printf("failed to open %s\n", path);
86 exit(1);
89 while ((dent = smbw_readdir(dir))) {
90 printf("%s\n", dent->d_name);
92 smbw_closedir(dir);
93 return 0;