5 #include <libsmbclient.h>
7 #include "get_auth_data_fn.h"
9 static const char *filetypestr(mode_t mode
)
12 return "regular file";
21 return "symbolic link";
27 return "character special file";
30 return "block special file";
32 return "unknown file type";
35 int main(int argc
, char * argv
[])
42 const char * pSmbPath
= NULL
;
43 const char * pLocalPath
= NULL
;
48 pSmbPath
= "smb://RANDOM/Public/small";
49 pLocalPath
= "/random/home/samba/small";
59 printf("usage: %s [ smb://path/to/file "
60 "[ /nfs/or/local/path/to/file ] ]\n",
65 ctx
= smbc_new_context();
67 perror("smbc_new_context failed");
71 smbc_setOptionDebugToStderr(ctx
, 1);
72 smbc_setDebug(ctx
, debug
);
73 smbc_init_context(ctx
);
74 smbc_setFunctionAuthData(ctx
, get_auth_data_fn
);
75 smbc_setOptionPosixExtensions(ctx
, true);
77 ret
= smbc_getFunctionStat(ctx
)(ctx
, pSmbPath
, &st
);
83 printf("\nSAMBA\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s %s\n",
84 (intmax_t)st
.st_mtime
,
85 ctime_r(&st
.st_mtime
, m_time
),
86 (intmax_t)st
.st_ctime
,
87 ctime_r(&st
.st_ctime
, c_time
),
88 (intmax_t)st
.st_atime
,
89 ctime_r(&st
.st_atime
, a_time
),
90 filetypestr(st
.st_mode
));
92 if (pLocalPath
!= NULL
) {
93 ret
= stat(pLocalPath
, &st
);
99 printf("LOCAL\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s %s\n",
100 (intmax_t)st
.st_mtime
,
101 ctime_r(&st
.st_mtime
, m_time
),
102 (intmax_t)st
.st_ctime
,
103 ctime_r(&st
.st_ctime
, c_time
),
104 (intmax_t)st
.st_atime
,
105 ctime_r(&st
.st_atime
, a_time
),
106 filetypestr(st
.st_mode
));