source: vendor/current/examples/libsmbclient/teststat.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.7 KB
Line 
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
9int main(int argc, char * argv[])
10{
11 int debug = 0;
12 char m_time[32];
13 char c_time[32];
14 char a_time[32];
15 const char * pSmbPath = NULL;
16 const char * pLocalPath = NULL;
17 struct stat st;
18
19 if (argc == 1)
20 {
21 pSmbPath = "smb://RANDOM/Public/small";
22 pLocalPath = "/random/home/samba/small";
23 }
24 else if (argc == 2)
25 {
26 pSmbPath = argv[1];
27 pLocalPath = NULL;
28 }
29 else if (argc == 3)
30 {
31 pSmbPath = argv[1];
32 pLocalPath = argv[2];
33 }
34 else
35 {
36 printf("usage: "
37 "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
38 argv[0]);
39 return 1;
40 }
41
42 smbc_init(get_auth_data_fn, debug);
43
44 if (smbc_stat(pSmbPath, &st) < 0)
45 {
46 perror("smbc_stat");
47 return 1;
48 }
49
50 printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
51 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
52 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
53 (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
54
55 if (pLocalPath != NULL)
56 {
57 if (stat(pLocalPath, &st) < 0)
58 {
59 perror("stat");
60 return 1;
61 }
62
63 printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
64 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
65 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
66 (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
67 }
68
69 return 0;
70}
Note: See TracBrowser for help on using the repository browser.