Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
[samba.git] / examples / libsmbclient / teststat.c
index bea34cfc098e0800a83b7846818f970411187b06..86c69e4e2cd82e046c88fcde49d8b80f97569e85 100644 (file)
@@ -8,7 +8,11 @@
 
 int main(int argc, char * argv[]) 
 { 
+    int             debug = 0;
     char            buffer[16384]; 
+    char            mtime[32];
+    char            ctime[32];
+    char            atime[32];
     char *          pSmbPath = NULL;
     char *          pLocalPath = NULL;
     struct stat     st; 
@@ -36,23 +40,31 @@ int main(int argc, char * argv[])
         return 1;
     }
 
-    smbc_init(get_auth_data_fn, 0); 
+    smbc_init(get_auth_data_fn, debug); 
     
-    int ret = smbc_stat(pSmbPath, &st); 
+    if (smbc_stat(pSmbPath, &st) < 0)
+    {
+        perror("smbc_stat");
+        return 1;
+    }
     
-    printf("SAMBA\nret=%d,\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", ret, 
-           st.st_mtime, ctime(&st.st_mtime),
-           st.st_ctime, ctime(&st.st_ctime),
-           st.st_atime, ctime(&st.st_atime)); 
+    printf("\nSAMBA\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n",
+           st.st_mtime, ctime_r(&st.st_mtime, mtime),
+           st.st_ctime, ctime_r(&st.st_ctime, ctime),
+           st.st_atime, ctime_r(&st.st_atime, atime)); 
     
     if (pLocalPath != NULL)
     {
-        ret = stat(pLocalPath, &st); 
+        if (stat(pLocalPath, &st) < 0)
+        {
+            perror("stat");
+            return 1;
+        }
         
-        printf("LOCAL\nret=%d,\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", ret, 
-               st.st_mtime, ctime(&st.st_mtime),
-               st.st_ctime, ctime(&st.st_ctime),
-               st.st_atime, ctime(&st.st_atime));
+        printf("LOCAL\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n",
+               st.st_mtime, ctime_r(&st.st_mtime, mtime),
+               st.st_ctime, ctime_r(&st.st_ctime, ctime),
+               st.st_atime, ctime_r(&st.st_atime, atime)); 
     }
 
     return 0;