From 400788f4e057fe24a58bf9923ca7cc04acb9c1e4 Mon Sep 17 00:00:00 2001 From: skeezix Date: Mon, 23 Feb 2009 16:20:38 -0500 Subject: [PATCH] Fixed up exec and icon paths --- include/pnd_discovery.h | 1 + lib/pnd_discovery.c | 10 +++++++--- lib/pnd_tinyxml.cpp | 9 ++++++++- test/discotest.c | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index 0943fae..76ae900 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -42,6 +42,7 @@ typedef struct char *exec; char *main_category; char *clockspeed; + char *startdir; } pnd_disco_t; void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index 860af1f..53bd608 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -127,7 +127,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, // check for validity and add to resultset if it looks executable if ( pnd_is_pxml_valid_app ( pxmlh ) ) { - char b [ 1024 ]; // TBD: also lame + //char b [ 1024 ]; // TBD: also lame pnd_disco_t *p; p = pnd_box_allocinsert ( disco_box, (char*) fpath, sizeof(pnd_disco_t) ); @@ -138,8 +138,9 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, p -> icon = strdup ( pnd_pxml_get_icon ( pxmlh ) ); } if ( pnd_pxml_get_exec ( pxmlh ) ) { - snprintf ( b, 1024, "pnd_run_magic %s", pnd_pxml_get_exec ( pxmlh ) ); - p -> exec = strdup ( b ); + p -> exec = strdup ( pnd_pxml_get_exec ( pxmlh ) ); + //snprintf ( b, 1024, "pnd_run_magic %s", pnd_pxml_get_exec ( pxmlh ) ); + //p -> exec = strdup ( b ); } if ( pnd_pxml_get_unique_id ( pxmlh ) ) { p -> unique_id = strdup ( pnd_pxml_get_unique_id ( pxmlh ) ); @@ -150,6 +151,9 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_pxml_get_clockspeed ( pxmlh ) ) { p -> clockspeed = strdup ( pnd_pxml_get_clockspeed ( pxmlh ) ); } + if ( pnd_pxml_get_startdir ( pxmlh ) ) { + p -> startdir = strdup ( pnd_pxml_get_startdir ( pxmlh ) ); + } } else { //printf ( "Invalid PXML; skipping.\n" ); diff --git a/lib/pnd_tinyxml.cpp b/lib/pnd_tinyxml.cpp index 5b2822e..e0f2daa 100644 --- a/lib/pnd_tinyxml.cpp +++ b/lib/pnd_tinyxml.cpp @@ -90,6 +90,7 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int pElem=hRoot.FirstChild("icon").Element(); if (pElem) { +#if 0 char anotherbuffer [ FILENAME_MAX ]; strcpy ( anotherbuffer, pFilename ); char *s = strstr ( anotherbuffer, PXML_FILENAME ); @@ -99,8 +100,10 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int } else if ( ( s = strrchr ( anotherbuffer, '/' ) ) ) { s += 1; strcpy ( s, strdup(pElem->GetText())); - app->exec = strdup(anotherbuffer); + app->icon = strdup(anotherbuffer); } +#endif + app->icon = strdup ( pElem->GetText() ); } pElem = hRoot.FirstChild( "description" ).FirstChildElement("en").Element(); @@ -178,9 +181,11 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int pElem=hRoot.FirstChild("exec").Element(); if (pElem) { +#if 0 char anotherbuffer [ FILENAME_MAX ]; strcpy ( anotherbuffer, pFilename ); char *s = strstr ( anotherbuffer, PXML_FILENAME ); + printf ( "exec %s\n", pElem->GetText() ); if ( s ) { strcpy ( s, strdup(pElem->GetText())); app->exec = strdup(anotherbuffer); @@ -189,6 +194,8 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int strcpy ( s, strdup(pElem->GetText())); app->exec = strdup(anotherbuffer); } +#endif + app->exec = strdup ( pElem->GetText() ); } pElem = hRoot.FirstChild( "category" ).FirstChildElement("main").Element(); diff --git a/test/discotest.c b/test/discotest.c index 0dd0432..af31896 100644 --- a/test/discotest.c +++ b/test/discotest.c @@ -78,6 +78,9 @@ int main ( void) { if ( d -> exec ) { printf ( " Executable: %s\n", d -> exec ); } + if ( d -> startdir ) { + printf ( " Start dir: %s\n", d -> startdir ); + } if ( d -> clockspeed ) { printf ( " Clockspeed: %s\n", d -> clockspeed ); } -- 2.39.2