From: skeezix Date: Thu, 19 Feb 2009 21:50:43 +0000 (-0500) Subject: Re-apply a couple fixes that got lost somewhere .. memset after malloc in pnd_pxml... X-Git-Tag: Release-2010-05/1~217 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=commitdiff_plain;h=0aa091adfd06b951e388a9c584635a2ae113041f Re-apply a couple fixes that got lost somewhere .. memset after malloc in pnd_pxml, and other things. Curious. --- diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..58ebe01 --- /dev/null +++ b/TODO.txt @@ -0,0 +1,12 @@ + +Some things to be done.. + +- review pnd_tinyxml to ensure the PXML_FILENAME is csae insensitive as needed + +apps/pndnotifyd.c:// TODO: Catch HUP and reparse config +apps/pndnotifyd.c:// TODO: Should perhaps direct all printf's through a vsprintf handler to avoid redundant "if ! g_daemon_mode" +apps/pndnotifyd.c:// TODO: During daemon mode, should perhaps syslog or log errors +apps/pndnotifyd.c:// TODO: Removing stale .desktop checks that .desktop was created by libpnd; see 'TBD' below +include/pnd_discovery.h:// TODO: Copy the icon into this directory as well, if its source is a .pnd or info is in the dico struct +include/pnd_discovery.h:// TODO: A way to release the disco-lists and reclaim RAM :) +include/pnd_discovery.h:// TODO: A way to determine the list of excess .desktop files and remove them (ie: after poo.pnd is removed, ditch the .desktop) diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index bc74aed..2bb31ea 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -88,7 +88,6 @@ void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could unsigned char pnd_emit_dotdesktop ( char *targetpath, pnd_disco_t *p ); // TODO: A way to release the disco-lists and reclaim RAM :) -// TODO: A way to determine the list of excess .desktop files and remove them (ie: after poo.pnd is removed, ditch the .desktop) #ifdef __cplusplus } /* "C" */ diff --git a/include/pnd_pndfiles.h b/include/pnd_pndfiles.h new file mode 100644 index 0000000..c603f17 --- /dev/null +++ b/include/pnd_pndfiles.h @@ -0,0 +1,15 @@ + +#ifndef h_pnd_pndfiles_h +#define h_pnd_pndfiles_h + +#ifdef __cplusplus +extern "C" { +#endif + +#define PND_PACKAGE_FILEEXT ".pnd" /* case insensitive due to SD FAT fs */ + +#ifdef __cplusplus +} /* "C" */ +#endif + +#endif diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index a034038..bfac709 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -12,11 +12,7 @@ #include "pnd_discovery.h" #include "pnd_pathiter.h" #include "pnd_apps.h" - -#warning "PND/PNZ support is not included yet; scripts need writing" -#warning " /usr/pandora/bin/pnd_valid.sh" -#warning " /usr/pandora/bin/pnd_prepare.sh" -#warning " /usr/pandora/bin/pnd_unprepare.sh" +#include "pnd_pndfiles.h" // need these 'globals' due to the way nftw and ftw work :/ static pnd_box_handle disco_box; @@ -61,15 +57,13 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, return ( 0 ); // skip directories and other non-regular files } + // PND/PNZ file and others may be valid as well .. but lets leave that for now if ( strcasecmp ( fpath + ftwbuf -> base, PXML_FILENAME ) == 0 ) { valid = 1; + } else if ( strcasecmp ( fpath + ftwbuf -> base, PND_PACKAGE_FILEEXT "\0" ) == 0 ) { + valid = 2; } - // PND file and others may be valid as well .. but lets leave that for now - // - // PND and PNZ and whatever - // - // if not a file of interest, just keep looking until we run out if ( ! valid ) { return ( 0 ); @@ -91,8 +85,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, } // look for any overrides, if requested -#warning pnd_pxml_merge_override removed by Cpasjuste ... - // pnd_pxml_merge_override ( pxmlh, disco_overrides ); + pnd_pxml_merge_override ( pxmlh, disco_overrides ); // check for validity and add to resultset if it looks executable if ( pnd_is_pxml_valid_app ( pxmlh ) ) { @@ -109,9 +102,8 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, } // ditch pxml - pnd_pxml_delete ( pxmlh ); + pnd_pxml_delete ( pxmlh ); - return 0; } else if ( valid == 2 ) { // PND ... ?? } diff --git a/lib/pnd_pndfiles.c b/lib/pnd_pndfiles.c new file mode 100644 index 0000000..1bfaa80 --- /dev/null +++ b/lib/pnd_pndfiles.c @@ -0,0 +1,9 @@ + +#include /* for FILE etc */ +#include /* for malloc */ +#include /* for making ftw.h happy */ + +#include "pnd_container.h" +#include "pnd_pxml.h" +#include "pnd_apps.h" +#include "pnd_pndfiles.h" diff --git a/lib/pnd_pxml.c b/lib/pnd_pxml.c index 2c64d42..484c418 100644 --- a/lib/pnd_pxml.c +++ b/lib/pnd_pxml.c @@ -14,11 +14,13 @@ void pnd_pxml_load(const char* pFilename, pnd_pxml_t *app); pnd_pxml_handle pnd_pxml_fetch ( char *fullpath ) { - pnd_pxml_t *p = malloc ( sizeof(pnd_pxml_t) ); + pnd_pxml_t *p = malloc ( sizeof(pnd_pxml_t) ); - pnd_pxml_load(fullpath, p); + memset ( p, '\0', sizeof(pnd_pxml_t) ); - return (p); + pnd_pxml_load ( fullpath, p ); + + return ( p ); } void pnd_pxml_delete ( pnd_pxml_handle h ) { diff --git a/testdata/apps/sampleapp2/PXML.xml~ b/testdata/apps/sampleapp2/PXML.xml~ deleted file mode 100644 index 776b9b7..0000000 --- a/testdata/apps/sampleapp2/PXML.xml~ +++ /dev/null @@ -1,86 +0,0 @@ - - - - <en>Program Title</en> - <de>Program Title in German Language</de> - <fr>Program Title in French Language</fr> - <it>Program Title in Italian Language</it> - - -123shaboo - -Yes - -program.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/apps/sampleapp3/PXML.xml~ b/testdata/apps/sampleapp3/PXML.xml~ deleted file mode 100644 index f289130..0000000 --- a/testdata/apps/sampleapp3/PXML.xml~ +++ /dev/null @@ -1,86 +0,0 @@ - - - - <en>Program Title</en> - <de>Program Title in German Language</de> - <fr>Program Title in French Language</fr> - <it>Program Title in Italian Language</it> - - -124bingle - -Yes - -program.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 - -