From a40ccbb5ba271641134586898e69df4855a7f687 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 5 Mar 2013 00:04:28 +0200 Subject: merged with miranda_ng main repo --- src/gpg_wrapper.cpp | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/gpg_wrapper.cpp') diff --git a/src/gpg_wrapper.cpp b/src/gpg_wrapper.cpp index 5f9df7d..112d860 100755 --- a/src/gpg_wrapper.cpp +++ b/src/gpg_wrapper.cpp @@ -70,21 +70,22 @@ pxResult pxExecute(std::vector &aargv, string *aoutput, LPDWORD ae pipe pout = create_pipe(); + pipe perr = create_pipe(); + child *c = nullptr; { file_descriptor_sink sout(pout.sink, close_handle); + file_descriptor_sink serr(perr.sink, close_handle); char *mir_path = new char [MAX_PATH]; - CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"\\", (LPARAM)mir_path); + PathToAbsolute("\\", mir_path); - child c = execute(set_args(argv), bind_stdout(sout), /*bind_stdin(sin),*/ show_window(SW_HIDE), hide_console(), inherit_env(), set_env(env), start_in_dir(toUTF16(mir_path))); - _child = &c; + c = new child(execute(set_args(argv), bind_stdout(sout), bind_stderr(serr), close_stdin(),/*bind_stdin(sin),*/ show_window(SW_HIDE), hide_console(), inherit_env(), set_env(env), start_in_dir(toUTF16(mir_path)))); + _child = c; delete [] mir_path; - auto ec = wait_for_exit(*_child); - *aexitcode = ec; - _child = nullptr; } - + + file_descriptor_source source(pout.source, close_handle); stream is(source); @@ -102,11 +103,35 @@ pxResult pxExecute(std::vector &aargv, string *aoutput, LPDWORD ae if(bDebugLog) debuglog< is2(source2); + + try{ + std::string s; + while(std::getline(is2, s)) + { + aoutput->append(s); + aoutput->append("\n"); + } + } + catch(const std::exception &e) + { + if(bDebugLog) + debuglog< &aargv, string *aoutp // file_descriptor_source sin(pin.source, close_handle); char *mir_path = new char [MAX_PATH]; - CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"\\", (LPARAM)mir_path); + PathToAbsolute("\\", mir_path); //execute(set_args(argv), bind_stdout(sout), bind_stdin(sin), show_window(SW_HIDE), hide_console(), inherit_env(), set_env(env), start_in_dir(toUTF16(mir_path))); child c = execute(set_args(argv), /*bind_stdin(sin), */inherit_env(), set_env(env), start_in_dir(toUTF16(mir_path))); @@ -230,7 +255,7 @@ pxResult pxExecute_passwd_change(std::vector &aargv, string *aoutp ctx.environment["LC_ALL"] = "English"; char *mir_path = new char [MAX_PATH]; - CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"\\", (LPARAM)mir_path); + PathToAbsolute("\\", mir_path); ctx.work_directory = mir_path; delete [] mir_path; -- cgit v1.2.3