aboutsummaryrefslogtreecommitdiff
path: root/libbutl/openssl.txx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-05-29 20:05:54 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-05-30 19:04:13 +0300
commit95ff8f359cfc2189bd4d7e02e15373027d2bda32 (patch)
tree2b22d991886c0a5c2678ea0fb5f565f90d57df25 /libbutl/openssl.txx
parent1b57e247b8d1a7a41a8ee45d6d524c71edd63a81 (diff)
Implement openssl process
Diffstat (limited to 'libbutl/openssl.txx')
-rw-r--r--libbutl/openssl.txx56
1 files changed, 56 insertions, 0 deletions
diff --git a/libbutl/openssl.txx b/libbutl/openssl.txx
new file mode 100644
index 0000000..aaaa239
--- /dev/null
+++ b/libbutl/openssl.txx
@@ -0,0 +1,56 @@
+// file : libbutl/openssl.txx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <utility> // move(), forward()
+
+namespace butl
+{
+ template <typename I>
+ typename std::enable_if<openssl::is_other<I>::value, I>::type openssl::
+ map_in (I&& in, io_data&)
+ {
+ return std::forward<I> (in);
+ }
+
+ template <typename O>
+ typename std::enable_if<openssl::is_other<O>::value, O>::type openssl::
+ map_out (O&& out, io_data&)
+ {
+ return std::forward<O> (out);
+ }
+
+ template <typename C,
+ typename I,
+ typename O,
+ typename E,
+ typename P,
+ typename... A>
+ openssl::
+ openssl (const C& cmdc,
+ I&& in,
+ O&& out,
+ E&& err,
+ const P& program,
+ const std::string& command,
+ A&&... options)
+ {
+ io_data in_data;
+ io_data out_data;
+
+ process& p (*this);
+ p = process_start (
+ cmdc,
+ map_in (std::forward<I> (in), in_data),
+ map_out (std::forward<O> (out), out_data),
+ std::forward<E> (err),
+ dir_path (),
+ program,
+ command,
+ in_data.options,
+ out_data.options,
+ std::forward<A> (options)...);
+
+ // Note: leaving this scope closes any open ends of the pipes in io_data.
+ }
+}