#include <stdio.h>
#include <errno.h>
#include <sys/time.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <libsmbclient.h>
static void
auth_fn(const char * pServer,
const char * pShare,
char * pWorkgroup,
int workgroup_len,
char * pUsername,
int username_len,
char * pPassword,
int password_len)
{
strncpy(pUsername, "anonymous", username_len);
strncpy(pPassword, "password", password_len);
}
int
main(int argc, char * argv[])
{
int debug = 4;
int opt;
char * p;
char buf[1024];
int dir;
struct smbc_dirent * dirent;
char ** ppUrl;
char * urlList[] =
{
"smb://",
"smb://?mb=.any",
"smb://?mb=.all",
"smb://?mb=xx",
NULL
};
if (smbc_init(auth_fn, debug) != 0)
{
printf("Could not initialize smbc_ library\n");
return 1;
}
for (ppUrl = urlList; *ppUrl != NULL; ppUrl++)
{
printf("Opening (%s)...\n", *ppUrl);
if ((dir = smbc_opendir(*ppUrl)) < 0)
{
printf("Could not open [%s] (%d:%s)\n",
*ppUrl, errno, strerror(errno));
continue;
}
while ((dirent = smbc_readdir(dir)) != NULL)
{
printf("%s\n", dirent->name);
}
smbc_closedir(dir);
}
exit(0);
}