source: vendor/current/examples/libsmbclient/teststat2.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.8 KB
Line 
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"
7
8/*
9 * This test is intended to ensure that the timestamps returned by
10 * libsmbclient are the same as timestamps returned by the local system. To
11 * test this, we assume a working Samba environment, and access the same
12 * file via SMB and locally (or NFS).
13 *
14 */
15
16
17static int gettime(const char * pUrl,
18 const char * pLocalPath);
19
20
21int main(int argc, char* argv[])
22{
23 if(argc != 3)
24 {
25 printf("usage: %s <file_url> <file_localpath>\n", argv[0]);
26 return 1;
27 }
28
29 gettime(argv[1], argv[2]);
30 return 0;
31}
32
33
34static int gettime(const char * pUrl,
35 const char * pLocalPath)
36{
37 struct stat st;
38 char m_time[32];
39 char c_time[32];
40 char a_time[32];
41
42 smbc_init(get_auth_data_fn, 0);
43
44 if (smbc_stat(pUrl, &st) < 0)
45 {
46 perror("smbc_stat");
47 return 1;
48 }
49
50 printf("SAMBA\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
56 /* check the stat on this file */
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.