Revision: 2293
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2293&view=rev
Author:   teuf
Date:     2009-03-26 22:12:48 +0000 (Thu, 26 Mar 2009)

Log Message:
-----------
Rework sync_time API

Modified Paths:
--------------
    libgpod/trunk/tools/ipod-scsi.c
    libgpod/trunk/tools/ipod-time-sync.c

Modified: libgpod/trunk/tools/ipod-scsi.c
===================================================================
--- libgpod/trunk/tools/ipod-scsi.c     2009-03-26 22:12:36 UTC (rev 2292)
+++ libgpod/trunk/tools/ipod-scsi.c     2009-03-26 22:12:48 UTC (rev 2293)
@@ -39,7 +39,7 @@
 
 #include <glib.h>
 
-extern void sync_time (const char *device, time_t current_time, gint timezone);
+extern void sync_time (const char *device, struct tm *tm);
 extern char *read_sysinfo_extended (const char *device);
 /* do_sg_inquiry and read_sysinfo_extended were heavily
  * inspired from libipoddevice
@@ -127,7 +127,7 @@
     close(fd);
 }
 
-G_GNUC_INTERNAL void sync_time (const char *device, time_t current_time, gint 
timezone)
+G_GNUC_INTERNAL void sync_time (const char *device, struct tm *tm)
 {
     struct iPodTime {
        guint16 year;
@@ -140,9 +140,12 @@
        guchar padding[3];
     } __attribute__((__packed__));
     struct iPodTime ipod_time;
-    struct tm *tm;
 
-    tm = localtime (&current_time);
+    if (tm == NULL) {
+       time_t current_time;
+       current_time = time (NULL);
+       tm = localtime (&current_time);
+    }
 
     ipod_time.year = GUINT16_TO_BE (1900+tm->tm_year);
     ipod_time.days = GUINT16_TO_BE (tm->tm_yday);

Modified: libgpod/trunk/tools/ipod-time-sync.c
===================================================================
--- libgpod/trunk/tools/ipod-time-sync.c        2009-03-26 22:12:36 UTC (rev 
2292)
+++ libgpod/trunk/tools/ipod-time-sync.c        2009-03-26 22:12:48 UTC (rev 
2293)
@@ -28,7 +28,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 
-extern void sync_time (const char *device, time_t current_time, gint timezone);
+extern void sync_time (const char *dev, struct tm *tm);
 
 int
 main (int argc, char **argv)
@@ -38,11 +38,7 @@
        return 1;
     }
 
-    if (argc < 3) {
-        sync_time (argv[1], time (NULL), 0);
-    } else {
-        sync_time (argv[1], time (NULL), atoi (argv[2]));
-    }
+    sync_time (argv[1], NULL);
 
     return 0;
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to