From: skeezix Date: Sat, 7 Mar 2009 03:22:56 +0000 (-0500) Subject: Added globbing support for all searchpaths! (can now search /media/*/pandora/apps... X-Git-Tag: Release-2010-05/1~191 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=commitdiff_plain;h=29847dbecdfd3887a750191bb37f61c81412b3c9 Added globbing support for all searchpaths! (can now search /media/*/pandora/apps say) 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 --- diff --git a/Makefile b/Makefile index 77a13ce..bbb0402 100644 --- 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 diff --git a/deployment/etc/pandora/conf/apps b/deployment/etc/pandora/conf/apps index 80ab306..6cc8aa0 100644 --- a/deployment/etc/pandora/conf/apps +++ b/deployment/etc/pandora/conf/apps @@ -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 diff --git a/lib/pnd_pathiter.h b/lib/pnd_pathiter.h index 4611e99..e91a408 100644 --- a/lib/pnd_pathiter.h +++ b/lib/pnd_pathiter.h @@ -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 +#include +#include +// for stat() +#include +#include +#include + // 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; \ @@ -38,4 +107,7 @@ \ } // 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 index 0000000..bbc7afb --- /dev/null +++ b/testdata/app2/sampleapp4/PXML.xml @@ -0,0 +1,86 @@ + + + <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> + + +345jaloo + +Yes + +zeldaicon.png + + + This is the [b]English Description[/b] of the file. + Can use [i]multiple lines[/i] and BBCode. + The German Description + The Italian Description + The French Description + + + + ./preview/pic1.jpg + ./preview/pic2.jpg + + + + EvilDragon + http://www.openpandora.org + + + + 1 + 1 + 1 + 2 + + +program.exe + + +
Main category
+ Subcategory 1 + Subcategory 2 +
+ + +
Alternate category
+ Alternate Subcategory 1 + Alternate Subcategory 2 +
+ + + 1 + 1 + 1 + 2 + + + + View this Picture + jpg,bmp,gif + ­view + + + + Convert this Picture + jpg,bmp,gif + ­convert + + + + Watch This Movie + mpg,avi,wmv + ­convert + + +600 + +Yes + +../differentdir + +
+ diff --git a/testdata/app2/sampleapp4/program.exe b/testdata/app2/sampleapp4/program.exe new file mode 100644 index 0000000..e69de29 diff --git a/testdata/app2/sampleapp4/zeldaicon.png b/testdata/app2/sampleapp4/zeldaicon.png new file mode 100644 index 0000000..140a393 Binary files /dev/null and b/testdata/app2/sampleapp4/zeldaicon.png differ diff --git a/testdata/conf/apps b/testdata/conf/apps index ed63b52..3257bd3 100644 --- a/testdata/conf/apps +++ b/testdata/conf/apps @@ -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