Added NORUN option to pnd_apps_exec, which goes as far as pnd_run but then skips...
authorskeezix <skeezix@flotsam-vm.(none)>
Sat, 6 Mar 2010 04:32:07 +0000 (23:32 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Sat, 6 Mar 2010 04:32:07 +0000 (23:32 -0500)
line to a buffer, which can then be retrieved. Thus, an app can find out how to run an app without depending on
pnd_apps_exec to actually run it.

include/pnd_apps.h
lib/pnd_apps.c

index bea31a4..5db22a3 100644 (file)
@@ -58,12 +58,14 @@ extern "C" {
 #define PND_EXEC_OPTION_BLOCK      1 /* wait till children complete; note, children might fork on their own.. */
 #define PND_EXEC_OPTION_NOUNION    2 /* request pnd_run not use a union, just do the mount/run */
 #define PND_EXEC_OPTION_NOX11      4 /* request pnd_run to kill x11 and restart it after */
-#define PND_EXEC_OPTION_FUTURE2    8
+#define PND_EXEC_OPTION_NORUN      8 /* don't try to run; just form the pnd_run.sh line and cache it */
+#define PND_EXEC_OPTION_FUTURE2   16
 
 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 *pnd_apps_exec_runline ( void ); // returns the cached pnd_run.sh line from last PND_EXEC_OPTION_NORUN
 
 // should you wish to know where an app will get mounted, call this function to obtain a guess. The
 // logic is wrapped up in pnd_run.sh, but in theory should be easily determined.
index e1b7eb1..eed07f3 100644 (file)
 #include "pnd_container.h"
 #include "pnd_pxml.h"
 #include "pnd_apps.h"
+#include "pnd_logger.h"
+
+static char apps_exec_runline [ 1024 ];
+
+char *pnd_apps_exec_runline ( void ) {
+  return ( apps_exec_runline );
+}
 
 unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
                              char *rel_exec, char *rel_startdir,
@@ -84,6 +91,35 @@ unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
   // finish
   argv [ f++ ] = NULL; // for execv
 
+  // stop here?
+  if ( options & PND_EXEC_OPTION_NORUN ) {
+    unsigned char i;
+    bzero ( apps_exec_runline, 1024 );
+    //pnd_log ( PND_LOG_DEFAULT, "Norun %u\n", f );
+    for ( i = 0; i < ( f - 1 ); i++ ) {
+      //pnd_log ( PND_LOG_DEFAULT, "Norun %u: %s\n", i, argv [ i ] );
+
+      // add spacing between args
+      if ( i > 0 ) {
+       strncat ( apps_exec_runline, " ", 1000 );
+      }
+
+      // if this is for -a, we need to wrap with quotes
+      if ( i > 0 && strcmp ( argv [ i - 1 ], "-a" ) == 0 ) {
+       strncat ( apps_exec_runline, "\"", 1000 );
+      }
+
+      strncat ( apps_exec_runline, argv [ i ], 1000 );
+
+      // if this is for -a, we need to wrap with quotes
+      if ( i > 0 && strcmp ( argv [ i - 1 ], "-a" ) == 0 ) {
+       strncat ( apps_exec_runline, "\"", 1000 );
+      }
+
+    }
+    return ( 1 );
+  }
+
   // debug
 #if 0
   int i;