s3:libsmb: Check return code of cli_credentials_guess()
[Samba.git] / examples / libsmbclient / teststat3.c
blob3efe51dffa7b381b0ee99c5bd8c4b1a63a60571e
1 #include <libsmbclient.h>
2 #include <sys/stat.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <time.h>
6 #include "get_auth_data_fn.h"
8 /*
9 * This test is intended to ensure that the timestamps returned by
10 * libsmbclient using smbc_stat() are the same as those returned by
11 * smbc_fstat().
15 int main(int argc, char* argv[])
17 int fd;
18 struct stat st1;
19 struct stat st2;
20 char * pUrl = argv[1];
22 if(argc != 2)
24 printf("usage: %s <file_url>\n", argv[0]);
25 return 1;
29 smbc_init(get_auth_data_fn, 0);
31 if (smbc_stat(pUrl, &st1) < 0)
33 perror("smbc_stat");
34 return 1;
37 if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
39 perror("smbc_open");
40 return 1;
43 if (smbc_fstat(fd, &st2) < 0)
45 perror("smbc_fstat");
46 return 1;
49 smbc_close(fd);
51 #define COMPARE(name, field) \
52 if (st1.field != st2.field) \
53 { \
54 printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
55 (unsigned long) st1.field, \
56 (unsigned long) st2.field); \
59 COMPARE("st_dev", st_dev);
60 COMPARE("st_ino", st_ino);
61 COMPARE("st_mode", st_mode);
62 COMPARE("st_nlink", st_nlink);
63 COMPARE("st_uid", st_uid);
64 COMPARE("st_gid", st_gid);
65 COMPARE("st_rdev", st_rdev);
66 COMPARE("st_size", st_size);
67 COMPARE("st_blksize", st_blksize);
68 COMPARE("st_blocks", st_blocks);
69 COMPARE("st_atime", st_atime);
70 COMPARE("st_mtime", st_mtime);
71 COMPARE("st_ctime", st_ctime);
73 return 0;