Added globbing support for all searchpaths! (can now search /media/*/pandora/apps...
authorskeezix <skeezix@flotsam-vm.(none)>
Sat, 7 Mar 2009 03:22:56 +0000 (22:22 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Sat, 7 Mar 2009 03:22:56 +0000 (22:22 -0500)
Altered Makefile to create media/mmcblk0p1 type dirs in the deployment directory; makes pndnotifyd life easier
Changed configs to allow for wildcards
Added second testdata appdir, to prove ./testdata/app? will pick up both dirs

Makefile
deployment/etc/pandora/conf/apps
lib/pnd_pathiter.h
testdata/app2/sampleapp4/PXML.xml [new file with mode: 0644]
testdata/app2/sampleapp4/program.exe [new file with mode: 0644]
testdata/app2/sampleapp4/zeldaicon.png [new file with mode: 0644]
testdata/conf/apps

index 77a13ce..bbb0402 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,7 @@ all: ${SOLIB} ${LIB} conftest discotest notifytest locatetest pndnotifyd
 
 clean:
        ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest bin/notifytest notifytest.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd
+       ${RM} -rf deployment/media
        find . -name "*~*" -exec rm {} \; -print
 
 # component targets
@@ -60,6 +61,9 @@ deploy:
        mkdir -p deployment/usr/pandora/apps
        mkdir -p deployment/usr/pandora/scripts
        mkdir -p deployment/etc/init.d/
+       # premake the directories that SD's mount onto; makes pndnotifyd life easier
+       mkdir -p deployment/media/mmcblk0p1
+       mkdir -p deployment/media/mmcblk1p1
        # copy in goodies
        cp libpnd* deployment/usr/lib
        cp bin/pndnotifyd deployment/usr/bin
index 80ab306..6cc8aa0 100644 (file)
@@ -3,7 +3,7 @@
 # Application configuration
 
 [autodiscovery]
-searchpath     /media:/usr/pandora/apps        # path to depth-search for PXMLs
+searchpath     /media:/media/*:/usr/pandora/apps       # path to depth-search for PXMLs
 
 # PXMLs may be overridden .. ie: overrides are a subset of PXML, where the values are copied over the full PXML
 [overrides]
@@ -11,5 +11,5 @@ searchpath    ~/pxml-overrides
 
 # [pnd] defines where to locate the pnd support scripts, so the user may override pnd_run.sh without clobbering built in
 [pnd]
-searchpath     /media/mmcblk0p1/pandora/scripts:/media/mmcblk1p1/pandora/scripts:/usr/pandora/scripts
+searchpath     /media/*/pandora/scripts:/usr/pandora/scripts
 runscript      pnd_run.sh
index 4611e99..e91a408 100644 (file)
@@ -1,15 +1,84 @@
 
 #ifndef h_pnd_pathiter_h
-#define h_png_pathiter_h
+#define h_pnd_pathiter_h
 
 // man don'y you wish it was python, perl or c++ right about now?
 // perl: foreach i ( split ( ':', path ) ) would be sauce right now
 
+// for wordexp(); nice thign to have bundled into libc!
+#include <stdio.h>
+#include <stdlib.h>
+#include <wordexp.h>
+// for stat()
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
 // this really should be replaced by a function pair .. one to
 // start a new search and one to go to next, bailing when done. Maybe
 // a state struct. Like we have time. OR perhaps just a single
 // func with a callback. Whatever.
 
+
+#if 1 // globbing is performed
+
+#define SEARCHPATH_PRE                            \
+  char *end, *colon;                              \
+  char *head = searchpath;                        \
+  char chunk [ FILENAME_MAX ];                    \
+                                                  \
+  /*fprintf ( stderr, "sp %s\n", searchpath );*/  \
+                                                  \
+  while ( 1 ) {                                   \
+    colon = strchr ( head, ':' );                 \
+    end = strchr ( head, '\0' );                  \
+                                                  \
+    if ( colon && colon < end ) {                 \
+      memset ( chunk, '\0', FILENAME_MAX );       \
+      strncpy ( chunk, head, colon - head );      \
+    } else {                                      \
+      strncpy ( chunk, head, FILENAME_MAX - 1 );  \
+    }                                             \
+                                                  \
+    /*fprintf ( stderr, "-> %s\n", chunk ); */    \
+                                                  \
+    struct stat statbuf;                          \
+    wordexp_t _p;                                 \
+    char **_w;                                    \
+    int _i;                                       \
+    char buffer [ FILENAME_MAX ];                 \
+                                                  \
+    if ( wordexp ( chunk, &_p, 0 ) != 0 ) {       \
+      /* ignore this chunk I guess.. */           \
+    } else {                                      \
+      _w = _p.we_wordv;                           \
+                                                  \
+      for ( _i=0; _i < _p.we_wordc; _i++ ) {      \
+        strcpy ( buffer, _w [ _i ] );             \
+       /*fprintf ( stderr, "glob %s\n", buffer );*/    \
+       if ( ( stat ( buffer, &statbuf ) == 0 )   \
+         && ( S_ISDIR(statbuf.st_mode) ) )       \
+        { /* user code */
+
+#define SEARCHPATH_POST                           \
+        } /* user code */                         \
+      } /* for each glob result */               \
+      wordfree ( &_p );                           \
+    } /* if wordexp succeeds */                          \
+    /* next search path */                       \
+    if ( colon && colon < end ) {                 \
+      head = colon + 1;                           \
+    } else {                                      \
+      break; /* done! */                          \
+    }                                             \
+                                                  \
+  } // while
+
+#endif // globbing is done
+
+
+#if 0 // deprecated simple (no globbing/expansion)
+
 #define SEARCHPATH_PRE                            \
   char *end, *colon;                              \
   char *head = searchpath;                        \
                                                   \
   } // while
 
-#endif
+#endif // deprecated simple
+
+
+#endif // #ifndef
diff --git a/testdata/app2/sampleapp4/PXML.xml b/testdata/app2/sampleapp4/PXML.xml
new file mode 100644 (file)
index 0000000..bbc7afb
--- /dev/null
@@ -0,0 +1,86 @@
+<PXML>
+<title>
+       <en>sample 4</en>
+       <de>Program Title in German Language</de>
+       <fr>Program Title in French Language</fr>
+       <it>Program Title in Italian Language</it>
+</title>
+
+<unique_id>345jaloo</unique_id>
+
+<standalone>Yes</standalone>
+
+<icon>zeldaicon.png</icon>
+
+<description>
+       <en>This is the [b]English Description[/b] of the file.
+            Can use [i]multiple lines[/i] and BBCode.</en>
+       <de>The German Description</de>
+       <it>The Italian Description</it>
+       <fr>The French Description</fr>
+</description>
+
+<previewpic>
+       <pic1>./preview/pic1.jpg</pic1>
+       <pic2>./preview/pic2.jpg</pic2>
+</previewpic>
+
+<author>
+       <name>EvilDragon</name>
+       <website>http://www.openpandora.org</website>
+</author>
+
+<version>
+       <major>1</major>
+       <minor>1</minor>
+       <release>1</release>
+       <build>2</build>
+</version>
+
+<exec>program.exe</exec>
+
+<category>
+       <main>Main category</main>
+       <subcategory1>Subcategory 1</subcategory1>
+       <subcategory2>Subcategory 2</subcategory2>
+</category>
+
+<altcategory>
+       <main>Alternate category</main>
+       <subcategory1>Alternate Subcategory 1</subcategory1>
+       <subcategory2>Alternate Subcategory 2</subcategory2>
+</altcategory>
+
+<osversion> 
+       <major>1</major>
+       <minor>1</minor>
+       <release>1</release>
+       <build>2</build>
+</osversion>
+
+<associationitem1>
+       <name>View this Picture</name>
+       <filetype>jpg,bmp,gif</filetype>
+       <parameter>­view</parameter>
+</associationitem1>
+
+<associationitem2>
+       <name>Convert this Picture</name>
+       <filetype>jpg,bmp,gif</filetype>
+       <parameter>­convert</parameter>
+</associationitem2>
+
+<associationitem3>
+       <name>Watch This Movie</name>
+       <filetype>mpg,avi,wmv</filetype>
+       <parameter>­convert</parameter>
+</associationitem3>
+
+<clockspeed>600</clockspeed>
+
+<background>Yes</background>
+
+<startdir>../differentdir</startdir>
+
+</PXML>
+
diff --git a/testdata/app2/sampleapp4/program.exe b/testdata/app2/sampleapp4/program.exe
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testdata/app2/sampleapp4/zeldaicon.png b/testdata/app2/sampleapp4/zeldaicon.png
new file mode 100644 (file)
index 0000000..140a393
Binary files /dev/null and b/testdata/app2/sampleapp4/zeldaicon.png differ
index ed63b52..3257bd3 100644 (file)
@@ -3,7 +3,7 @@
 # Application configuration
 
 [autodiscovery]
-searchpath     /mnt/sd1/pandora/apps:/mnt/sd2/pandora/apps:./testdata/apps     # path to depth-search for PXMLs
+searchpath     /mnt/sd?/pandora/apps:./testdata/app?   # path to depth-search for PXMLs
 
 # PXMLs may be overridden .. ie: overrides are a subset of PXML, where the values are copied over the full PXML
 [overrides]
@@ -11,5 +11,5 @@ searchpath    ~/pxml-overrides:./testdata/apps-override
 
 # [pnd] defines where to locate the pnd support scripts, so the user may override pnd_run.sh without clobbering built in
 [pnd]
-searchpath     /mnt/sd1/pandora/scripts:/mnt/sd2/pandora/scripts:./testdata/scripts
+searchpath     /mnt/sd?/pandora/scripts:./testdata/scripts
 runscript      pnd_run.sh