WHATSNEW: Finish release notes for Samba 3.6.9.
[Samba.git] / examples / libsmbclient / teststat3.c
blob26348b335c197b100d1fedf68aa607f9e3b1fe21
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 mtime[32];
21 char ctime[32];
22 char atime[32];
23 char * pUrl = argv[1];
25 if(argc != 2)
27 printf("usage: %s <file_url>\n", argv[0]);
28 return 1;
32 smbc_init(get_auth_data_fn, 0);
34 if (smbc_stat(pUrl, &st1) < 0)
36 perror("smbc_stat");
37 return 1;
40 if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
42 perror("smbc_open");
43 return 1;
46 if (smbc_fstat(fd, &st2) < 0)
48 perror("smbc_fstat");
49 return 1;
52 smbc_close(fd);
54 #define COMPARE(name, field) \
55 if (st1.field != st2.field) \
56 { \
57 printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
58 (unsigned long) st1.field, \
59 (unsigned long) st2.field); \
62 COMPARE("st_dev", st_dev);
63 COMPARE("st_ino", st_ino);
64 COMPARE("st_mode", st_mode);
65 COMPARE("st_nlink", st_nlink);
66 COMPARE("st_uid", st_uid);
67 COMPARE("st_gid", st_gid);
68 COMPARE("st_rdev", st_rdev);
69 COMPARE("st_size", st_size);
70 COMPARE("st_blksize", st_blksize);
71 COMPARE("st_blocks", st_blocks);
72 COMPARE("st_atime", st_atime);
73 COMPARE("st_mtime", st_mtime);
74 COMPARE("st_ctime", st_ctime);
76 return 0;