From: skeezix Date: Tue, 2 Mar 2010 03:38:35 +0000 (-0500) Subject: Adding argument support to PXML; pnd_run.sh already had it, but PXML did not. X-Git-Tag: Release-2010-05/1~89 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb607f8312d117aa5827925a9602ff2363eabf1;p=pandora-libraries.git Adding argument support to PXML; pnd_run.sh already had it, but PXML did not. In the Exec tag you can now specify args to pass, save you making sh-scripts in the pnd a lot of the time --- diff --git a/apps/pnd_run.c b/apps/pnd_run.c index 5baabd4..29caf35 100644 --- a/apps/pnd_run.c +++ b/apps/pnd_run.c @@ -172,6 +172,7 @@ int main ( int argc, char *argv[] ) { pnd_pxml_get_unique_id ( h ), pnd_pxml_get_exec ( h ), pnd_pxml_get_startdir ( h ), + NULL /* args */, clock, options ) ) diff --git a/include/pnd_apps.h b/include/pnd_apps.h index 9e56333..bea31a4 100644 --- a/include/pnd_apps.h +++ b/include/pnd_apps.h @@ -62,6 +62,7 @@ extern "C" { unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, + char *args, unsigned int clockspeed, unsigned int options ); // should you wish to know where an app will get mounted, call this function to obtain a guess. The diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index b8aaa2b..f8123d7 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -56,6 +56,7 @@ typedef struct { char *unique_id; char *icon; char *exec; + char *execargs; char *clockspeed; char *startdir; char *option_no_x11; diff --git a/include/pnd_pxml.h b/include/pnd_pxml.h index 2ef0e80..f381dde 100644 --- a/include/pnd_pxml.h +++ b/include/pnd_pxml.h @@ -62,6 +62,7 @@ char *pnd_pxml_get_version_minor ( pnd_pxml_handle h ); char *pnd_pxml_get_version_release ( pnd_pxml_handle h ); char *pnd_pxml_get_version_build ( pnd_pxml_handle h ); char *pnd_pxml_get_exec ( pnd_pxml_handle h ); +char *pnd_pxml_get_execargs ( pnd_pxml_handle h ); char *pnd_pxml_get_exec_option_no_x11 ( pnd_pxml_handle h ); char *pnd_pxml_get_main_category ( pnd_pxml_handle h ); char *pnd_pxml_get_subcategory1 ( pnd_pxml_handle h ); @@ -122,6 +123,7 @@ typedef struct char *version_release; char *version_build; char *exec; + char *execargs; char *main_category; char *subcategory1; char *subcategory2; diff --git a/include/pnd_pxml_names.h b/include/pnd_pxml_names.h index c476c21..9432314 100644 --- a/include/pnd_pxml_names.h +++ b/include/pnd_pxml_names.h @@ -24,6 +24,7 @@ extern "C" { #define PND_PXML_ATTRNAME_EXECBG "background" #define PND_PXML_ATTRNAME_EXECSTAL "standalone" #define PND_PXML_ATTRNAME_EXECCMD "command" +#define PND_PXML_ATTRNAME_EXECARGS "arguments" #define PND_PXML_ATTRNAME_EXECWD "startdir" #define PND_PXML_ATTRNAME_EXECNOX11 "no_x11" diff --git a/lib/pnd_apps.c b/lib/pnd_apps.c index 63f1450..e446c34 100644 --- a/lib/pnd_apps.c +++ b/lib/pnd_apps.c @@ -13,6 +13,7 @@ unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, + char *args, unsigned int clockspeed, unsigned int options ) { char *argv [ 60 ]; @@ -58,6 +59,10 @@ unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, argv [ f++ ] = "-s"; argv [ f++ ] = rel_startdir; } + if ( args ) { + argv [ f++ ] = "-a"; + argv [ f++ ] = args; + } argv [ f++ ] = "-b"; argv [ f++ ] = unique_id; if ( clockspeed ) { diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index d3efb4f..427622a 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -116,6 +116,12 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t strncat ( buffer, p -> startdir, 1020 ); } + // args + if ( p -> execargs ) { + strncat ( buffer, " -a ", 1020 ); + strncat ( buffer, p -> execargs, 1020 ); + } + // clockspeed if ( p -> clockspeed && atoi ( p -> clockspeed ) != 0 ) { strncat ( buffer, " -c ", 1020 ); diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index 88a1126..d32a591 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -28,6 +28,7 @@ void pnd_disco_destroy ( pnd_disco_t *p ) { if ( p -> unique_id ) { free ( p -> unique_id ); } if ( p -> icon ) { free ( p -> icon ); } if ( p -> exec ) { free ( p -> exec ); } + if ( p -> execargs ) { free ( p -> execargs ); } if ( p -> clockspeed ) { free ( p -> clockspeed ); } if ( p -> startdir ) { free ( p -> startdir ); } if ( p -> option_no_x11 ) { free ( p -> option_no_x11 ); } @@ -219,6 +220,9 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_pxml_get_exec ( pxmlh ) ) { p -> exec = strdup ( pnd_pxml_get_exec ( pxmlh ) ); } + if ( pnd_pxml_get_execargs ( pxmlh ) ) { + p -> execargs = strdup ( pnd_pxml_get_execargs ( pxmlh ) ); + } if ( pnd_pxml_get_exec_option_no_x11 ( pxmlh ) ) { p -> option_no_x11 = strdup ( pnd_pxml_get_exec_option_no_x11 ( pxmlh ) ); } diff --git a/lib/pnd_pxml.c b/lib/pnd_pxml.c index 09a7fb6..836a970 100644 --- a/lib/pnd_pxml.c +++ b/lib/pnd_pxml.c @@ -405,6 +405,11 @@ char *pnd_pxml_get_exec ( pnd_pxml_handle h ) { return ( p -> exec ); } +char *pnd_pxml_get_execargs ( pnd_pxml_handle h ) { + pnd_pxml_t *p = (pnd_pxml_t*) h; + return ( p -> execargs ); +} + char *pnd_pxml_get_exec_option_no_x11 ( pnd_pxml_handle h ) { pnd_pxml_t *p = (pnd_pxml_t*) h; return ( p -> exec_no_x11 ); diff --git a/lib/pnd_tinyxml.cpp b/lib/pnd_tinyxml.cpp index 59f7e4d..0e05ad0 100644 --- a/lib/pnd_tinyxml.cpp +++ b/lib/pnd_tinyxml.cpp @@ -177,6 +177,7 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int app->exec = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECCMD); app->startdir = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECWD); app->exec_no_x11 = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECNOX11); + app->execargs = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECARGS); } //The app icon: diff --git a/test/discotest.c b/test/discotest.c index cbe1040..f6584b0 100644 --- a/test/discotest.c +++ b/test/discotest.c @@ -224,7 +224,7 @@ int main ( int argc, char *argv[] ) { } printf ( "Trying to exec '%s'\n", fullpath ); - pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ), PND_EXEC_OPTION_BLOCK ); + pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, NULL, atoi ( d -> clockspeed ), PND_EXEC_OPTION_BLOCK ); } }