Last change
on this file since 101 was 1, checked in by Paul Smedley, 18 years ago |
Initial code import
|
File size:
1.5 KB
|
Line | |
---|
1 | #include <stdio.h>
|
---|
2 | #include <unistd.h>
|
---|
3 | #include <stdlib.h>
|
---|
4 | #include <dirent.h>
|
---|
5 | #include <sys/stat.h>
|
---|
6 |
|
---|
7 | static void usage(void)
|
---|
8 | {
|
---|
9 | printf("
|
---|
10 | smbw_sample - a sample program that uses smbw
|
---|
11 |
|
---|
12 | smbw_sample <options> path
|
---|
13 |
|
---|
14 | options:
|
---|
15 | -W workgroup
|
---|
16 | -l logfile
|
---|
17 | -P prefix
|
---|
18 | -d debuglevel
|
---|
19 | -U username%%password
|
---|
20 | -R resolve order
|
---|
21 |
|
---|
22 | note that path must start with /smb/
|
---|
23 | ");
|
---|
24 | }
|
---|
25 |
|
---|
26 | int main(int argc, char *argv[])
|
---|
27 | {
|
---|
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 |
|
---|
36 | lp_load(dyn_CONFIGFILE,1,0,0,1);
|
---|
37 | smbw_setup_shared();
|
---|
38 |
|
---|
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);
|
---|
58 | }
|
---|
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);
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | argc -= optind;
|
---|
72 | argv += optind;
|
---|
73 |
|
---|
74 | if (argc < 1) {
|
---|
75 | usage();
|
---|
76 | exit(1);
|
---|
77 | }
|
---|
78 |
|
---|
79 | path = argv[0];
|
---|
80 |
|
---|
81 | smbw_init();
|
---|
82 |
|
---|
83 | dir = smbw_opendir(path);
|
---|
84 | if (!dir) {
|
---|
85 | printf("failed to open %s\n", path);
|
---|
86 | exit(1);
|
---|
87 | }
|
---|
88 |
|
---|
89 | while ((dent = smbw_readdir(dir))) {
|
---|
90 | printf("%s\n", dent->d_name);
|
---|
91 | }
|
---|
92 | smbw_closedir(dir);
|
---|
93 | return 0;
|
---|
94 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.