[206] | 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 | 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;
|
---|
| 19 |
|
---|
| 20 | if (argc == 1)
|
---|
| 21 | {
|
---|
| 22 | pSmbPath = "smb://RANDOM/Public/small";
|
---|
| 23 | pLocalPath = "/random/home/samba/small";
|
---|
| 24 | }
|
---|
| 25 | else if (argc == 2)
|
---|
| 26 | {
|
---|
| 27 | pSmbPath = argv[1];
|
---|
| 28 | pLocalPath = NULL;
|
---|
| 29 | }
|
---|
| 30 | else if (argc == 3)
|
---|
| 31 | {
|
---|
| 32 | pSmbPath = argv[1];
|
---|
| 33 | pLocalPath = argv[2];
|
---|
| 34 | }
|
---|
| 35 | else
|
---|
| 36 | {
|
---|
| 37 | printf("usage: "
|
---|
| 38 | "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
|
---|
| 39 | argv[0]);
|
---|
| 40 | return 1;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | smbc_init(get_auth_data_fn, debug);
|
---|
| 44 |
|
---|
| 45 | if (smbc_stat(pSmbPath, &st) < 0)
|
---|
| 46 | {
|
---|
| 47 | perror("smbc_stat");
|
---|
| 48 | return 1;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 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));
|
---|
| 55 |
|
---|
| 56 | if (pLocalPath != NULL)
|
---|
| 57 | {
|
---|
| 58 | if (stat(pLocalPath, &st) < 0)
|
---|
| 59 | {
|
---|
| 60 | perror("stat");
|
---|
| 61 | return 1;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 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));
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | return 0;
|
---|
| 71 | }
|
---|