allow path lookup for pipestream
[libi2ncommon] / src / pipestream.hxx
index 4b645ef..f53f474 100644 (file)
@@ -29,6 +29,7 @@ on this file might be covered by the GNU General Public License.
 
 #include <stdio.h>
 
+#include <cstring>
 #include <string>
 #include <streambuf>
 #include <istream>
@@ -69,9 +70,11 @@ typedef struct ExecResult ExecResult;
 
 std::string capture_exec(const std::string& command, ExecResult &rescode);
 std::string capture_exec(const char *const *command, ExecResult &rescode,
-                         const bool out=true, const bool err=false);
+                         const bool out=true, const bool err=false,
+                         const bool path=false);
 std::string capture_exec(const std::vector<std::string>& command, ExecResult &rescode,
-                         const bool out=true, const bool err=false);
+                         const bool out=true, const bool err=false,
+                         const bool path=false);
 
 inline std::string capture_exec (const std::string &command)
 {
@@ -114,11 +117,11 @@ protected:
 
 public:
     inpipebuf(const std::string& command,
-              const bool out, const bool err);
+              const bool out, const bool err, const bool path);
     inpipebuf(const char *const *command,
-              const bool out, const bool err);
+              const bool out, const bool err, const bool path);
     inpipebuf(const std::vector<std::string> &command,
-              const bool out, const bool err);
+              const bool out, const bool err, const bool path);
 
     ~inpipebuf();
 
@@ -130,7 +133,8 @@ protected:
 private:
     std::pair <pid_t, FILE *>
     init_without_shell (const char *const *argv,
-                        const bool out, const bool err) const;
+                        const bool out, const bool err,
+                        const bool path) const;
 };
 
 /** @brief stream around inpipebuf -- see comment there */
@@ -141,18 +145,21 @@ protected:
 
 public:
     inpipestream(const std::string& command,
-                 const bool out=true, const bool err=false)
-            : std::istream(&buf), buf(command, out, err)
+                 const bool out=true, const bool err=false,
+                 const bool path=false)
+            : std::istream(&buf), buf(command, out, err, path)
     {}
 
     inpipestream(const char *const command[],
-                 const bool out=true, const bool err=false)
-            : std::istream(&buf), buf(command, out, err)
+                 const bool out=true, const bool err=false,
+                 const bool path=false)
+            : std::istream(&buf), buf(command, out, err, path)
     {}
 
     inpipestream(const std::vector<std::string> &command,
-                 const bool out=true, const bool err=false)
-            : std::istream(&buf), buf(command, out, err)
+                 const bool out=true, const bool err=false,
+                 const bool path=false)
+            : std::istream(&buf), buf(command, out, err, path)
     {}
 
     void store_exit_status(bool *_status_set, int *_exit_status)