#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_NORUN 8 /* don't try to run; just form the pnd_run.sh line and cache it */
-#define PND_EXEC_OPTION_FUTURE2 16
+#define PND_EXEC_OPTION_INFO 16 /* for apps_exec_disco() only; implies that 'reserved' points to pnd_apps_exec_info_t struct */
+#define PND_EXEC_OPTION_FUTURE2 32
unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
char *rel_exec, char *rel_startdir,
// - 'pndrun' is a reference to a pnd_run.sh script, to avoid seeking it out every time
unsigned char pnd_apps_exec_disco ( char *pndrun, pnd_disco_t *app, unsigned int options, void *reserved );
+// for pnd_apps_exec_disco(), when option PND_EXEC_OPTION_INFO is used
+typedef struct {
+ char *viewer; // required; viewer's executable
+ char *args; // optional; arg to viewer; ie: the file to view
+} pnd_apps_exec_info_t;
+
// 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.
argv [ f++ ] = "-p";
argv [ f++ ] = fullpath;
argv [ f++ ] = "-e";
- argv [ f++ ] = app -> exec;
+ if ( options & PND_EXEC_OPTION_INFO ) {
+ argv [ f++ ] = ((pnd_apps_exec_info_t*)reserved) -> viewer;
+ } else {
+ argv [ f++ ] = app -> exec;
+ }
if ( app -> startdir ) {
argv [ f++ ] = "-s";
argv [ f++ ] = app -> startdir;
}
- if ( app -> execargs ) {
- argv [ f++ ] = "-a";
- argv [ f++ ] = app -> execargs;
+ if ( options & PND_EXEC_OPTION_INFO ) {
+ if ( ((pnd_apps_exec_info_t*)reserved) -> args ) {
+ argv [ f++ ] = "-a";
+ argv [ f++ ] = ((pnd_apps_exec_info_t*)reserved) -> args;
+ }
+ } else {
+ if ( app -> execargs ) {
+ argv [ f++ ] = "-a";
+ argv [ f++ ] = app -> execargs;
+ }
}
if ( app -> appdata_dirname ) {
argv [ f++ ] = "-b";
if ( quotenext ) {
quotenext = 0;
} else {
+ // deprecated; need to handle spaces in some additional args
+ // if ( strcmp ( argv [ i ], "-a" ) == 0 ) {
// if this is for -a, we need to wrap with quotes
- if ( strcmp ( argv [ i ], "-a" ) == 0 ) {
+ // ivanovic:
+ // to allow spaces in filenames we have to add quotes around most terms!
+ // terms with quotes:
+ // -a additional arguments
+ // -p fullpath to pnd
+ // -e name of execuatable inside the pnd
+ // -s startdir
+ // -b name for the appdir
+
+ if ( ( strcmp ( argv [ i ], "-a" ) == 0 ) ||
+ ( strcmp ( argv [ i ], "-p" ) == 0 ) ||
+ ( strcmp ( argv [ i ], "-e" ) == 0 ) ||
+ ( strcmp ( argv [ i ], "-s" ) == 0 ) ||
+ ( strcmp ( argv [ i ], "-b" ) == 0 ) )
+ {
quotenext = 1;
}
+
}
} // for
// basics
if ( p -> object_type == pnd_object_type_directory ) {
- snprintf ( buffer, 1020, "Exec=%s%s -p %s -e %s -b %s",
+ snprintf ( buffer, 1020, "Exec=%s%s -p \"%s\" -e \"%s\" -b \"%s\"",
nohup, pndrun, p -> object_path, p -> exec,
p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id );
} else if ( p -> object_type == pnd_object_type_pnd ) {
- snprintf ( buffer, 1020, "Exec=%s%s -p %s/%s -e %s -b %s",
+ snprintf ( buffer, 1020, "Exec=%s%s -p \"%s/%s\" -e \"%s\" -b \"%s\"",
nohup, pndrun, p -> object_path, p -> object_filename, p -> exec,
p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id );
}
pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename );
} else {
pargs = NULL;
+ // WARNING: This might not be quite right; if no viewer-args, shouldn't we still append the info-filename? likewise,
+ // even if we do have view-args, shouldn't we check if filename is present?
}
char pndfile [ 1024 ];
snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename );
}
- if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs,
- p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) )
- {
+ pnd_apps_exec_info_t info;
+ info.viewer = viewer;
+ info.args = pargs;
+
+ if ( ! pnd_apps_exec_disco ( pndrun, p, PND_EXEC_OPTION_NORUN | PND_EXEC_OPTION_INFO, &info ) ) {
return ( 0 );
}