diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-30 01:04:08 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-30 01:04:08 +0300 |
commit | ab9762aa4e52af06bff46965b2cbace0aa81d7ac (patch) | |
tree | a844c1783b2ab0206790e75358a113599100180c /gpg_wrapper.cpp | |
parent | 9b2fde9ceedab2249f0f8bccba9afb2f48479994 (diff) |
modified: gpg_wrapper.cpp
modified: log.cpp
modified: log.h
new file: new_gpg.vcxproj
Diffstat (limited to 'gpg_wrapper.cpp')
-rw-r--r-- | gpg_wrapper.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp index 14f0c74..04f3512 100644 --- a/gpg_wrapper.cpp +++ b/gpg_wrapper.cpp @@ -1,15 +1,15 @@ // Copyright © 2010 sss -// +// // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -36,20 +36,20 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD int size; wstring commandline; - + sattrs.nLength=sizeof(SECURITY_ATTRIBUTES); sattrs.bInheritHandle=TRUE; InitializeSecurityDescriptor(&sdesc,SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sdesc,TRUE,NULL,FALSE); sattrs.lpSecurityDescriptor=&sdesc; - + success=CreatePipe(&newstdin,&writestdin,&sattrs,0); if (!success) { *result = pxCreatePipeFailed; return pxCreatePipeFailed; } - + success=CreatePipe(&readstdout,&newstdout,&sattrs,0); if (!success) { @@ -58,7 +58,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD *result = pxCreatePipeFailed; return pxCreatePipeFailed; } - + GetStartupInfo(&sinfo); sinfo.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; sinfo.wShowWindow=SW_HIDE; @@ -79,7 +79,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD { mir_free(bin_path); *result = pxNotFound; - return pxNotFound; + return pxNotFound; } } } @@ -96,12 +96,12 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD delete [] bin_path; //hmm delete [] home_dir; } - + debuglog<<"gpg in: "<<commandline<<"\n"; - success = CreateProcess(NULL, (TCHAR*)commandline.c_str(), NULL, NULL, TRUE, CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, _T("LANGUAGE=en@quot\0LC_ALL=English\0"), NULL, &sinfo, &pri); - + success = CreateProcess(NULL, (TCHAR*)commandline.c_str(), NULL, NULL, TRUE, CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, (void*)_T("LANGUAGE=en@quot\0LC_ALL=English\0"), NULL, &sinfo, &pri); + if (!success) { CloseHandle(newstdin); @@ -112,32 +112,32 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD *result = pxCreateProcessFailed; return pxCreateProcessFailed; } - + inputpos=ainput; - + while (TRUE) { success=GetExitCodeProcess(pri.hProcess,aexitcode); if (success && *aexitcode!=STILL_ACTIVE) break; - + storeOutput(readstdout,aoutput); - + if (*inputpos!='\0') size=1; else size=0; - + success=WriteFile(writestdin,inputpos,size,&transfered,NULL); inputpos+=transfered; Sleep(200); } gpg_mutex.unlock(); - + storeOutput(readstdout,aoutput); debuglog<<"gpg out: "<<aoutput->c_str()<<"\n"; WaitForSingleObject(pri.hProcess,INFINITE); - + CloseHandle(pri.hThread); CloseHandle(pri.hProcess); CloseHandle(newstdin); @@ -145,7 +145,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD CloseHandle(readstdout); CloseHandle(writestdin); - *result = pxSuccess; + *result = pxSuccess; return pxSuccess; } @@ -157,4 +157,4 @@ void pxEexcute_thread(void *param) { MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); } -}
\ No newline at end of file +}
|