From e1562961c0bf87daa98417f2a660fbf8ebd04a35 Mon Sep 17 00:00:00 2001 From: Colin Fletcher Date: Thu, 10 Oct 2013 19:50:21 +0100 Subject: Add command-line parsing constructor to SystemExec Add a new constructor to SystemExec which takes a complete command-line and a map of substitutions for %, and parses the command line, taking account of some simple escape sequences and quoting. --- libs/pbd/pbd/system_exec.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libs/pbd/pbd/system_exec.h') diff --git a/libs/pbd/pbd/system_exec.h b/libs/pbd/pbd/system_exec.h index cf8518f547..dc17ced2f6 100644 --- a/libs/pbd/pbd/system_exec.h +++ b/libs/pbd/pbd/system_exec.h @@ -33,6 +33,8 @@ #include #include #include +#include + #ifdef NOPBD /* outside ardour */ #include #include @@ -83,8 +85,26 @@ class SystemExec * */ SystemExec (std::string c, char ** a); + + /** similar to \ref SystemExec but expects a whole command line, and + * handles some simple escape sequences. + * + * @param command complete command-line to be executed + * @param subs a map of listing the % substitutions to + * be made. + * + * creates an argv array from the given command string, splitting into + * parameters at spaces. + * "\ " is non-splitting space, "\\" (and "\" at end of command) as "\", + * for "%", is looked up in subs and the corresponding string + * substituted. "%%" (and "%" at end of command) + * returns an argv array suitable for creating a new SystemExec with + */ + SystemExec (std::string command, const std::map subs); + virtual ~SystemExec (); + /** fork and execute the given program * * @param stderr_mode select what to do with program's standard error @@ -171,6 +191,7 @@ class SystemExec int nicelevel; ///< process nice level - defaults to 0 void make_argp(std::string); + void make_argp_escaped(std::string command, const std::map subs); void make_envp(); char **argp; @@ -187,6 +208,7 @@ class SystemExec #else pid_t pid; #endif + void init (); pthread_mutex_t write_lock; int fdin; ///< file-descriptor for writing to child's STDIN. This variable is identical to pin[1] but also used as status check if the stdin pipe is open: <0 means closed. -- cgit v1.2.3