From e9fad677d785fea2d471eafb54d6aba0a49bd1f5 Mon Sep 17 00:00:00 2001 From: Jorg Schuler Date: Mon, 21 Aug 2006 15:08:28 +0000 Subject: * tests/test-ls.c: added option to list contents of local repository and specified playlist. Thanks to Richard Hyde for the patch. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1310 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- ChangeLog | 12 ++++++++++++ tests/test-ls.c | 27 ++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1277713..cbfec8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-08-21 Jorg Schuler + + * tests/test-ls.c: added option to list contents of local + repository and specified playlist. Thanks to Richard Hyde for + the patch. + +2006-08-18 Jorg Schuler + + * src/db-artwork-writer.c (ipod_buffer_grow_file): printf(3) type + warnings caused compile error with FreeBSD 6.0-stable/GCC + 3.4.4. Thanks to Mike Heffner for the patch. + 2006-07-08 Jorg Schuler * src/itdb_itunesdb.c (itdb_write): don't crash if error == diff --git a/tests/test-ls.c b/tests/test-ls.c index b1376bd..f37bc43 100644 --- a/tests/test-ls.c +++ b/tests/test-ls.c @@ -28,11 +28,14 @@ #include #include +#include #include #include #include "itdb.h" +#define LOCALDB "/.gtkpod/local_0.itdb" + static void display_track (Itdb_Track *track, const char *prefix) { @@ -71,20 +74,32 @@ int main (int argc, char *argv[]) { GError *error=NULL; + const gchar *homeenv="HOME"; Itdb_iTunesDB *itdb; - gchar *mountpoint = NULL; + gchar *mountpoint = NULL, *playlistname = NULL; if (argc >= 2) mountpoint = argv[1]; + if (argc >= 3) + playlistname = argv[2]; + if (mountpoint == NULL) { - g_print ("Usage: %s \n", g_basename(argv[0])); + g_print ("Usage: %s |-l []\n\n" + "-l - List from the local repository (~" LOCALDB ")\n" + " - name of the playlist to list (optional)\n", + g_basename(argv[0])); exit (0); } - itdb = itdb_parse (mountpoint, &error); - + if (strcmp(mountpoint, "-l") == 0) { + mountpoint = g_build_filename(g_getenv(homeenv), LOCALDB, NULL); + itdb = itdb_parse_file (mountpoint, &error); + } + else + itdb = itdb_parse (mountpoint, &error); + if (error) { if (error->message) { @@ -103,7 +118,9 @@ main (int argc, char *argv[]) Itdb_Playlist *playlist; playlist = (Itdb_Playlist *)it->data; - display_playlist (playlist, ""); + + if (playlistname == NULL || strcmp(playlist->name, playlistname) == 0) + display_playlist (playlist, ""); } if (error) -- cgit