r6149: Fixes bugs #2498 and 2484.
[tprouty/samba.git] / examples / libsmbclient / teststat.c
1 #include <stdio.h> 
2 #include <unistd.h>
3 #include <string.h> 
4 #include <time.h> 
5 #include <libsmbclient.h> 
6 #include "get_auth_data_fn.h"
7
8
9 int main(int argc, char * argv[]) 
10
11     char            buffer[16384]; 
12     char *          pSmbPath = NULL;
13     char *          pLocalPath = NULL;
14     struct stat     st; 
15     
16     if (argc == 1)
17     {
18         pSmbPath = "smb://RANDOM/Public/small";
19         pLocalPath = "/random/home/samba/small";
20     }
21     else if (argc == 2)
22     {
23         pSmbPath = argv[1];
24         pLocalPath = NULL;
25     }
26     else if (argc == 3)
27     {
28         pSmbPath = argv[1];
29         pLocalPath = argv[2];
30     }
31     else
32     {
33         printf("usage: "
34                "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
35                argv[0]);
36         return 1;
37     }
38
39     smbc_init(get_auth_data_fn, 0); 
40     
41     int ret = smbc_stat(pSmbPath, &st); 
42     
43     printf("SAMBA\nret=%d,\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", ret, 
44            st.st_mtime, ctime(&st.st_mtime),
45            st.st_ctime, ctime(&st.st_ctime),
46            st.st_atime, ctime(&st.st_atime)); 
47     
48     if (pLocalPath != NULL)
49     {
50         ret = stat(pLocalPath, &st); 
51         
52         printf("LOCAL\nret=%d,\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", ret, 
53                st.st_mtime, ctime(&st.st_mtime),
54                st.st_ctime, ctime(&st.st_ctime),
55                st.st_atime, ctime(&st.st_atime));
56     }
57
58     return 0; 
59 }