9 #include <libsmbclient.h>
10 #include "get_auth_data_fn.h"
12 void error_message(char * pMessage)
14 printf("ERROR: %s\n", pMessage);
19 main(int argc, char * argv[])
28 struct smbc_dirent * dirent;
30 struct poptOption long_options[] =
34 "debug", 'd', POPT_ARG_INT, &debug,
35 0, "Set debug level", "integer"
44 pc = poptGetContext("opendir", argc, (const char **)argv, long_options, 0);
46 poptSetOtherOptionHelp(pc, "");
48 while ((opt = poptGetNextOpt(pc)) != -1) {
49 printf("Got option %d = %c\n", opt, opt);
54 if (smbc_init(get_auth_data_fn, debug) != 0)
56 printf("Could not initialize smbc_ library\n");
60 for (fputs("url: ", stdout), p = fgets(buf, sizeof(buf), stdin);
61 p != NULL && *p != '\n' && *p != '\0';
62 fputs("url: ", stdout), p = fgets(buf, sizeof(buf), stdin))
64 if ((p = strchr(buf, '\n')) != NULL)
69 printf("Opening (%s)...\n", buf);
71 if ((dir = smbc_opendir(buf)) < 0)
73 printf("Could not open directory [%s] (%d:%s)\n",
74 buf, errno, strerror(errno));
78 while ((dirent = smbc_readdir(dir)) != NULL)
80 printf("%-30s", dirent->name);
81 printf("%-30s", dirent->comment);
83 switch(dirent->smbc_type)
97 case SMBC_PRINTER_SHARE:
98 printf("PRINTER_SHARE");
101 case SMBC_COMMS_SHARE:
102 printf("COMMS_SHARE");
116 q = buf + strlen(buf);
118 strcat(q+1, dirent->name);
119 if (smbc_stat(buf, &stat) < 0)
121 printf(" unknown size (reason %d: %s)",
122 errno, strerror(errno));
126 printf(" size %lu", (unsigned long) stat.st_size);