Update of /cvsroot/gtkpod/libgpod/tests
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv25356/tests

Modified Files:
        test-ls.c 
Added Files:
        get-timezone.c 
Log Message:
        * src/itdb_itunesdb (itdb_parse_internal): fixed compile warning
          (thanks to Daniele Forsi).

        * tests/test-ls.c (display_recently_played): fixed compile warning
          (thanks to Daniele Forsi).

        * tests/get-timezone.c: added to CVS (thanks to Daniele Forsi).



--- NEW FILE: get-timezone.c ---
/*
 * Compile with:
 * gcc $(pkg-config --cflags --libs libgpod-1.0) -o tz ./get-timezone.c
 *
 * then run:
 * ./tz <ipod-mountpoint>
 *
 * This should output something like:
 * Timezone: UTC+1 DST
 *
 * which means I'm living in an UTC+1 timezone with DST which adds a 1 hour
 * shift, ie my local time is UTC+2. DST won't be shown if not active.
 *
 */

#include <errno.h>
#include <stdio.h>
#include <itdb.h>

int main (int argc, char **argv)
{
    char *mountpoint;
    char *device_dir;
    char *prefs_filename;
    FILE *f;
    int result;
    gint32 timezone;
    const int GMT_OFFSET = 0x19;

    if (argc >= 2) {
        mountpoint = argv[1];
    } else {
        g_print ("Usage: %s <mountpoint>\n\n", g_basename(argv[0]));
        return -1;
    }

    device_dir = itdb_get_device_dir (mountpoint);
    if (device_dir == NULL) {
        g_print ("No iPod mounted at %s\n", mountpoint);
        return -1;
    }
    prefs_filename = itdb_get_path (device_dir, "Preferences");
    g_free (device_dir);

    f = fopen (prefs_filename, "r");
    if (f == NULL) {
        g_print ("Couldn't open %s: %s\n", prefs_filename, g_strerror (errno));
        g_free (prefs_filename);
        return -1;
    }

    result = fseek (f, 0xB10, SEEK_SET);
    if (result != 0) {
        g_print ("Couldn't seek in %s: %s\n", prefs_filename,
                 g_strerror (errno));
        fclose (f);
        g_free (prefs_filename);
        return -1;
    }

    result = fread (&timezone, sizeof (timezone), 1, f);
    if (result != 1) {
        g_print ("Couldn't read from %s: %s\n", prefs_filename,
                 g_strerror (errno));
        fclose (f);
        g_free (prefs_filename);
    }

    fclose (f);
    g_free (prefs_filename);

    timezone = GINT32_FROM_LE (timezone);
    timezone -= GMT_OFFSET;

    g_print ("Timezone: UTC%+d", timezone >> 1);
    if (timezone & 1) {
        g_print (" DST");
    }
    g_print ("\n");

    return 0;
}

Index: test-ls.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/tests/test-ls.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-ls.c   27 Apr 2007 14:09:59 -0000      1.3
+++ test-ls.c   30 Apr 2007 00:40:55 -0000      1.4
@@ -52,10 +52,10 @@
 
             g_print ("%s - %s - %s:\n",
                      track->artist, track->album, track->title);
-            strftime (date, sizeof (date), "%D %H:%M:%S",
+            strftime (date, sizeof (date), "%F %H:%M:%S",
                       gmtime (&track_time));
             g_print ("\tUTC: %s\n", date);
-            strftime (date, sizeof (date), "%D %H:%M:%S",
+            strftime (date, sizeof (date), "%F %H:%M:%S",
                       localtime (&track_time));
             g_print ("\tlocal: %s\n", date);
             g_print ("track: %ld ", track_time);


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to