s4-torture: add smb2 ioctl test suite
[Samba/gebeck_regimport.git] / examples / libsmbclient / smbwrapper / opendir_smbsh.c
blob275b95f8ea19cfd9ec09877aadadb1d1af563eab
1 #include <sys/types.h>
2 #include <dirent.h>
3 #include <errno.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <libsmbclient.h>
8 int
9 main(int argc, char * argv[])
11 char * p;
12 char buf[1024];
13 DIR * dir;
14 struct dirent * dirent;
16 setbuf(stdout, NULL);
18 for (fputs("path: ", stdout), p = fgets(buf, sizeof(buf), stdin);
19 p != NULL && *p != '\n' && *p != '\0';
20 fputs("path: ", stdout), p = fgets(buf, sizeof(buf), stdin))
22 if ((p = strchr(buf, '\n')) != NULL)
24 *p = '\0';
27 printf("Opening (%s)...\n", buf);
29 if ((dir = opendir(buf)) == NULL)
31 printf("Could not open directory [%s]: \n",
32 buf, strerror(errno));
33 continue;
36 while ((dirent = readdir(dir)) != NULL)
38 printf("%-30s", dirent->d_name);
39 printf("%-30s", dirent->d_name + strlen(dirent->d_name) + 1);
40 printf("\n");
43 closedir(dir);
46 exit(0);