Add smbta-util to manage the encryption key.
[Samba/ekacnet.git] / examples / libsmbclient / teststat.c
blob86c69e4e2cd82e046c88fcde49d8b80f97569e85
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"
9 int main(int argc, char * argv[])
11 int debug = 0;
12 char buffer[16384];
13 char mtime[32];
14 char ctime[32];
15 char atime[32];
16 char * pSmbPath = NULL;
17 char * pLocalPath = NULL;
18 struct stat st;
20 if (argc == 1)
22 pSmbPath = "smb://RANDOM/Public/small";
23 pLocalPath = "/random/home/samba/small";
25 else if (argc == 2)
27 pSmbPath = argv[1];
28 pLocalPath = NULL;
30 else if (argc == 3)
32 pSmbPath = argv[1];
33 pLocalPath = argv[2];
35 else
37 printf("usage: "
38 "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
39 argv[0]);
40 return 1;
43 smbc_init(get_auth_data_fn, debug);
45 if (smbc_stat(pSmbPath, &st) < 0)
47 perror("smbc_stat");
48 return 1;
51 printf("\nSAMBA\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n",
52 st.st_mtime, ctime_r(&st.st_mtime, mtime),
53 st.st_ctime, ctime_r(&st.st_ctime, ctime),
54 st.st_atime, ctime_r(&st.st_atime, atime));
56 if (pLocalPath != NULL)
58 if (stat(pLocalPath, &st) < 0)
60 perror("stat");
61 return 1;
64 printf("LOCAL\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n",
65 st.st_mtime, ctime_r(&st.st_mtime, mtime),
66 st.st_ctime, ctime_r(&st.st_ctime, ctime),
67 st.st_atime, ctime_r(&st.st_atime, atime));
70 return 0;