source: vendor/current/examples/libsmbclient/testread.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.2 KB
Line 
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"
9
10
11int main(int argc, char * argv[])
12{
13 int fd;
14 int ret;
15 int debug = 0;
16 int savedErrno;
17 char buffer[2048];
18 char path[2048];
19 char * p;
20
21 smbc_init(get_auth_data_fn, debug);
22
23 for (;;)
24 {
25 fprintf(stdout, "Path: ");
26 *path = '\0';
27 fgets(path, sizeof(path) - 1, stdin);
28 if (strlen(path) == 0)
29 {
30 return 0;
31 }
32
33 p = path + strlen(path) - 1;
34 if (*p == '\n')
35 {
36 *p = '\0';
37 }
38
39 if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
40 {
41 perror("smbc_open");
42 continue;
43 }
44
45 do
46 {
47 ret = smbc_read(fd, buffer, sizeof(buffer));
48 savedErrno = errno;
49 if (ret > 0) fwrite(buffer, 1, ret, stdout);
50 } while (ret > 0);
51
52 smbc_close(fd);
53
54 if (ret < 0)
55 {
56 errno = savedErrno;
57 perror("read");
58 }
59 }
60
61 return 0;
62}
Note: See TracBrowser for help on using the repository browser.