utils/smbw_sample.c

説明を見る。
00001 #include <stdio.h>
00002 #include <unistd.h>
00003 #include <stdlib.h>
00004 #include <dirent.h>
00005 #include <sys/stat.h>
00006 
00007 static void usage(void)
00008 {
00009         printf("
00010 smbw_sample - a sample program that uses smbw
00011 
00012 smbw_sample <options> path
00013 
00014   options:
00015      -W workgroup
00016      -l logfile
00017      -P prefix
00018      -d debuglevel
00019      -U username%%password
00020      -R resolve order
00021 
00022 note that path must start with /smb/
00023 ");
00024 }
00025 
00026 int main(int argc, char *argv[])
00027 {
00028         DIR *dir;
00029         struct dirent *dent;
00030         int opt;
00031         char *p;
00032         extern char *optarg;
00033         extern int optind;
00034         char *path;
00035 
00036         lp_load(dyn_CONFIGFILE,1,0,0,1);
00037         smbw_setup_shared();
00038 
00039         while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
00040                 switch (opt) {
00041                 case 'W':
00042                         smbw_setshared("WORKGROUP", optarg);
00043                         break;
00044                 case 'l':
00045                         smbw_setshared("LOGFILE", optarg);
00046                         break;
00047                 case 'P':
00048                         smbw_setshared("PREFIX", optarg);
00049                         break;
00050                 case 'd':
00051                         smbw_setshared("DEBUG", optarg);
00052                         break;
00053                 case 'U':
00054                         p = strchr_m(optarg,'%');
00055                         if (p) {
00056                                 *p=0;
00057                                 smbw_setshared("PASSWORD",p+1);
00058                         }
00059                         smbw_setshared("USER", optarg);
00060                         break;
00061                 case 'R':
00062                         smbw_setshared("RESOLVE_ORDER",optarg);
00063                         break;
00064                 case 'h':
00065                 default:
00066                         usage();
00067                         exit(1);
00068                 }
00069         }
00070 
00071         argc -= optind;
00072         argv += optind;
00073 
00074         if (argc < 1) {
00075                 usage();
00076                 exit(1);
00077         }
00078 
00079         path = argv[0];
00080 
00081         smbw_init();
00082 
00083         dir = smbw_opendir(path);
00084         if (!dir) {
00085                 printf("failed to open %s\n", path);
00086                 exit(1);
00087         }
00088         
00089         while ((dent = smbw_readdir(dir))) {
00090                 printf("%s\n", dent->d_name);
00091         }
00092         smbw_closedir(dir);
00093         return 0;
00094 }

Sambaに対してSat Aug 29 21:23:30 2009に生成されました。  doxygen 1.4.7