Return full info in pdb_ads_search_users()
[Samba.git] / examples / libsmbclient / testread.c
blob3f948848957151badf4ad95f7560bbc26eeca194
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <time.h>
6 #include <errno.h>
7 #include <libsmbclient.h>
8 #include "get_auth_data_fn.h"
11 int main(int argc, char * argv[])
13 int i;
14 int fd;
15 int ret;
16 int debug = 0;
17 int mode = 0666;
18 int savedErrno;
19 char buffer[2048];
20 char path[2048];
21 char * p;
22 time_t t0;
23 time_t t1;
24 struct stat st;
26 smbc_init(get_auth_data_fn, debug);
28 for (;;)
30 fprintf(stdout, "Path: ");
31 *path = '\0';
32 fgets(path, sizeof(path) - 1, stdin);
33 if (strlen(path) == 0)
35 return 0;
38 p = path + strlen(path) - 1;
39 if (*p == '\n')
41 *p = '\0';
44 if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
46 perror("smbc_open");
47 continue;
52 ret = smbc_read(fd, buffer, sizeof(buffer));
53 savedErrno = errno;
54 if (ret > 0) fwrite(buffer, 1, ret, stdout);
55 } while (ret > 0);
57 smbc_close(fd);
59 if (ret < 0)
61 errno = savedErrno;
62 perror("read");
66 return 0;