From fbc611f431db443c23486f768ca5e2bc4db95c24 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 29 Mar 2005 00:42:51 +0000 Subject: r6108: Added smbsh/smbwrapper for Linux to example/libsmbclient tree; provided more complete libsmbclient testbrowse utility (This used to be commit 15736b97c837a16d9c009b8bff18b31429ccbe83) --- examples/libsmbclient/smbwrapper/opendir_smbsh.c | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/libsmbclient/smbwrapper/opendir_smbsh.c (limited to 'examples/libsmbclient/smbwrapper/opendir_smbsh.c') diff --git a/examples/libsmbclient/smbwrapper/opendir_smbsh.c b/examples/libsmbclient/smbwrapper/opendir_smbsh.c new file mode 100644 index 0000000000..275b95f8ea --- /dev/null +++ b/examples/libsmbclient/smbwrapper/opendir_smbsh.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include + +int +main(int argc, char * argv[]) +{ + char * p; + char buf[1024]; + DIR * dir; + struct dirent * dirent; + + setbuf(stdout, NULL); + + for (fputs("path: ", stdout), p = fgets(buf, sizeof(buf), stdin); + p != NULL && *p != '\n' && *p != '\0'; + fputs("path: ", stdout), p = fgets(buf, sizeof(buf), stdin)) + { + if ((p = strchr(buf, '\n')) != NULL) + { + *p = '\0'; + } + + printf("Opening (%s)...\n", buf); + + if ((dir = opendir(buf)) == NULL) + { + printf("Could not open directory [%s]: \n", + buf, strerror(errno)); + continue; + } + + while ((dirent = readdir(dir)) != NULL) + { + printf("%-30s", dirent->d_name); + printf("%-30s", dirent->d_name + strlen(dirent->d_name) + 1); + printf("\n"); + } + + closedir(dir); + } + + exit(0); +} -- cgit