diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-03-05 00:04:28 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-03-05 00:04:28 +0200 |
commit | a40ccbb5ba271641134586898e69df4855a7f687 (patch) | |
tree | 0a79ef1a59582b4367c9be65426ec88b343c500c /src/gpg_wrapper.cpp | |
parent | 418736c65c97cdc6ca4910e1e8650e474cb12849 (diff) |
merged with miranda_ng main reponew_gpg_miranda_ng
Diffstat (limited to 'src/gpg_wrapper.cpp')
-rwxr-xr-x | src/gpg_wrapper.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
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<std::wstring> &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<file_descriptor_source> is(source); @@ -102,11 +103,35 @@ pxResult pxExecute(std::vector<std::wstring> &aargv, string *aoutput, LPDWORD ae if(bDebugLog) debuglog<<std::string(time_str()+": failed to read from stream with error: " + e.what() + "\n\tSuccesfully read : " + *aoutput); } + + file_descriptor_source source2(perr.source, close_handle); + + stream<file_descriptor_source> 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<<std::string(time_str()+": failed to read from stream with error: " + e.what() + "\n\tSuccesfully read : " + *aoutput); + } + fix_line_term(*aoutput); if(bDebugLog) debuglog<<std::string(time_str()+": gpg out: "+*aoutput); + auto ec = wait_for_exit(*c); + delete c; + *aexitcode = ec; + _child = nullptr; + if(*aexitcode) { @@ -185,7 +210,7 @@ pxResult pxExecute_passwd_change(std::vector<std::wstring> &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<std::wstring> &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; |