summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/system_exec.h
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2013-10-10 19:50:21 +0100
committerColin Fletcher <colin.m.fletcher@googlemail.com>2013-10-10 19:50:21 +0100
commite1562961c0bf87daa98417f2a660fbf8ebd04a35 (patch)
tree327d1b62d2b7087dd67a4e380a212fa12b9fce24 /libs/pbd/pbd/system_exec.h
parent070bb7a8abcd787958b3ea07e77043dd404d653c (diff)
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 %<char>, and parses the command line, taking account of some simple escape sequences and quoting.
Diffstat (limited to 'libs/pbd/pbd/system_exec.h')
-rw-r--r--libs/pbd/pbd/system_exec.h22
1 files changed, 22 insertions, 0 deletions
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 <string>
#include <pthread.h>
#include <signal.h>
+#include <map>
+
#ifdef NOPBD /* outside ardour */
#include <sigc++/bind.h>
#include <sigc++/signal.h>
@@ -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 <char, std::string> 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 "%<char>", <char> 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<char, std::string> 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<char, std::string> 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.