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

Modified Files:
        test-ls.c 
Log Message:
        * tests/test-ls.c: added option to list contents of local
          repository and specified playlist. Thanks to Richard Hyde for
          the patch.



Index: test-ls.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/tests/test-ls.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test-ls.c   10 Apr 2006 18:38:10 -0000      1.1
+++ test-ls.c   21 Aug 2006 15:08:28 -0000      1.2
@@ -28,11 +28,14 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <libintl.h>
 
 #include "itdb.h"
 
+#define LOCALDB "/.gtkpod/local_0.itdb"
+
 static void
 display_track (Itdb_Track *track, const char *prefix) 
 {
@@ -71,20 +74,32 @@
 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 <mountpoint>\n",  g_basename(argv[0]));
+      g_print ("Usage: %s <mountpoint>|-l [<playlistname>]\n\n"
+               "-l - List from the local repository (~" LOCALDB ")\n"
+              "<playlistname> - 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 @@
          Itdb_Playlist *playlist;
 
          playlist = (Itdb_Playlist *)it->data;
-         display_playlist (playlist, "");
+         
+         if (playlistname == NULL || strcmp(playlist->name, playlistname) == 
0) 
+           display_playlist (playlist, "");
       }
 
       if (error)


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to