From 78c0815c4118fe24ab78cce2dc48a6232dcd824a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 2 Jun 2012 20:55:18 +0000 Subject: - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CryptoPP/GPGw/gpg.c | 26 +++++++++++++------------- plugins/CryptoPP/GPGw/main.c | 40 ++++++++++++++++++++-------------------- plugins/CryptoPP/GPGw/pipeexec.c | 12 ++++++------ plugins/CryptoPP/GPGw/tools.c | 2 +- 4 files changed, 40 insertions(+), 40 deletions(-) (limited to 'plugins/CryptoPP/GPGw') diff --git a/plugins/CryptoPP/GPGw/gpg.c b/plugins/CryptoPP/GPGw/gpg.c index 354e455a94..8ec3a57b11 100644 --- a/plugins/CryptoPP/GPGw/gpg.c +++ b/plugins/CryptoPP/GPGw/gpg.c @@ -126,7 +126,7 @@ gpgResult gpgListPublicKeys(char *aresult) replace(commandline, txthome, gpgHomeDirectory); pxresult=pxExecute(commandline, "", &output, &exitcode); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) { free(output); return gpgExecuteFailed; @@ -153,7 +153,7 @@ gpgResult gpgListSecretKeys(char *aresult) replace(commandline, txthome, gpgHomeDirectory); pxresult=pxExecute(commandline, "", &output, &exitcode); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) { free(output); return gpgExecuteFailed; @@ -175,7 +175,7 @@ gpgResult gpgImportPublicKey(const char *akey) char *output; LogMessage(">>> ", "import public key", "\n"); - if(! writeToFile(filename, akey)) return gpgWriteToFileFailed; + if (! writeToFile(filename, akey)) return gpgWriteToFileFailed; output=(char *)malloc(1); strcpy(output, ""); @@ -186,7 +186,7 @@ gpgResult gpgImportPublicKey(const char *akey) remove(filename); free(output); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) return gpgExecuteFailed; return gpgSuccess; @@ -208,7 +208,7 @@ gpgResult gpgExportPublicKey(char *aresult, const char *auserid) replace(commandline, txthome, gpgHomeDirectory); pxresult=pxExecute(commandline, "", &output, &exitcode); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) { strcpy(aresult, ""); free(output); @@ -237,7 +237,7 @@ gpgResult gpgDetectUserID(char *aresult, const char *aciphertext) LogMessage(">>> ", "detect user id", "\n"); strcpy(aresult, ""); - if(! writeToFile(filename, aciphertext)) + if (! writeToFile(filename, aciphertext)) return gpgWriteToFileFailed; output=(char *)malloc(1); @@ -248,7 +248,7 @@ gpgResult gpgDetectUserID(char *aresult, const char *aciphertext) pxresult=pxExecute(commandline, "", &output, &exitcode); remove(filename); - if((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid)) + if ((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid)) { free(output); return gpgExecuteFailed; @@ -287,7 +287,7 @@ gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext) LogMessage(">>> ", "encrypt", "\n"); strcpy(aresult, ""); - if(! writeToFile(plainfile, aplaintext)) + if (! writeToFile(plainfile, aplaintext)) return gpgWriteToFileFailed; output=(char *)malloc(1); @@ -302,13 +302,13 @@ gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext) remove(plainfile); free(output); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) { remove(cipherfile); return gpgExecuteFailed; } - if(! readFromFile(aresult, cipherfile)) + if (! readFromFile(aresult, cipherfile)) { remove(cipherfile); return gpgReadFromFileFailed; @@ -332,7 +332,7 @@ gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassph LogMessage(">>> ", "decrypt", "\n"); strcpy(aresult, ""); - if(! writeToFile(cipherfile, aciphertext)) + if (! writeToFile(cipherfile, aciphertext)) return gpgWriteToFileFailed; output=(char *)malloc(1); @@ -348,13 +348,13 @@ gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassph remove(cipherfile); free(output); - if((pxresult!=pxSuccess)||(exitcode!=0)) + if ((pxresult!=pxSuccess)||(exitcode!=0)) { remove(plainfile); return gpgExecuteFailed; } - if(! readFromFile(aresult, plainfile)) + if (! readFromFile(aresult, plainfile)) { remove(plainfile); return gpgReadFromFileFailed; diff --git a/plugins/CryptoPP/GPGw/main.c b/plugins/CryptoPP/GPGw/main.c index 766d491704..fc23b24262 100644 --- a/plugins/CryptoPP/GPGw/main.c +++ b/plugins/CryptoPP/GPGw/main.c @@ -27,13 +27,13 @@ int __cdecl _gpg_done() int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath) { - if( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) { + if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) { return 0; } - if( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) { + if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) { return 0; } - if( !existsFile(ExecPath) ) { + if ( !existsFile(ExecPath) ) { // ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions); return 0; } @@ -84,9 +84,9 @@ LPSTR __cdecl _gpg_get_passphrases() // encrypt for(i=0; i2 ) { + if ( b[i]>2 ) { x = b[i] ^ ( (i&0x7f) ^ 13); - if( x>2 ) b[i]=x; + if ( x>2 ) b[i]=x; } return b; @@ -97,16 +97,16 @@ void __cdecl _gpg_set_passphrases(LPCSTR buffer) { size_t i, l = strlen(buffer); char *t, *p, *b, x; - if( !l ) return; + if ( !l ) return; b = (char *) LocalAlloc(LPTR,l+1); strcpy(b, buffer); // decrypt for(i=0; i2 ) { + if ( b[i]>2 ) { x = b[i] ^ ( (i&0x7f) ^ 13); - if( x>2 ) b[i]=x; + if ( x>2 ) b[i]=x; } while(*b) { @@ -167,7 +167,7 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message) begin=strstr(message, txtbeginpgpmessage); end=strstr(message, txtendpgpmessage); - if((begin!=NULL)&&(end!=NULL)) + if ((begin!=NULL)&&(end!=NULL)) { strcpy(buffer, ""); strncat(buffer, begin, end-begin+strlen(txtendpgpmessage)); @@ -218,7 +218,7 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message) strcpy(buffer, plaintext); } - if( gpgresult==gpgSuccess && useridvalid==TRUE) + if ( gpgresult==gpgSuccess && useridvalid==TRUE) addPassphrase(keyuserid, passphrase); ZeroMemory(passphrase, sizeof(passphrase)); @@ -255,7 +255,7 @@ int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid) void noBackslash(LPSTR path) { LPSTR ptr; ptr = path + strlen(path) - 1; - if( *ptr=='\\' ) *ptr = '\0'; + if ( *ptr=='\\' ) *ptr = '\0'; } @@ -267,7 +267,7 @@ LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){ LPSTR ret=0; RegOpenKey(hKey,szPath,&hKey); - if( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ){ + if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) { noBackslash((LPSTR)&buf); ret = (LPSTR)&buf; } @@ -280,7 +280,7 @@ LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){ LPSTR GetEnvValue(LPCSTR szName){ LPSTR ret=0; - if( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) { + if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) { noBackslash((LPSTR)&buf); ret = (LPSTR)&buf; } @@ -295,14 +295,14 @@ BOOL ShowSelectExecDlg(LPSTR path) ZeroMemory(&ofn,sizeof(ofn)); ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram"); - if( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) { + if ( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) { strcpy(path, ofn.lpstrFile); return TRUE; } ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE,"Software\\GNU\\GnuPG","Install Directory"); - if( ofn.lpstrFile ) { + if ( ofn.lpstrFile ) { strcat(ofn.lpstrFile,"\\gpg.exe"); - if( existsFile(ofn.lpstrFile) ) { + if ( existsFile(ofn.lpstrFile) ) { strcpy(path, ofn.lpstrFile); return TRUE; } @@ -327,19 +327,19 @@ BOOL ShowSelectHomeDlg(LPSTR path) OPENFILENAME ofn; ofn.lpstrFile = GetEnvValue("GNUPGHOME"); - if( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) { + if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) { strcpy(path, ofn.lpstrFile); return TRUE; } ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","HomeDir"); - if( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) { + if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) { strcpy(path, ofn.lpstrFile); return TRUE; } ofn.lpstrFile = GetEnvValue("APPDATA"); - if( ofn.lpstrFile ) { + if ( ofn.lpstrFile ) { strcat(ofn.lpstrFile,"\\gnupg"); - if( existsPath(ofn.lpstrFile) ) { + if ( existsPath(ofn.lpstrFile) ) { strcpy(path, ofn.lpstrFile); return TRUE; } diff --git a/plugins/CryptoPP/GPGw/pipeexec.c b/plugins/CryptoPP/GPGw/pipeexec.c index 871dfbe3b4..ea54f85d1a 100644 --- a/plugins/CryptoPP/GPGw/pipeexec.c +++ b/plugins/CryptoPP/GPGw/pipeexec.c @@ -32,7 +32,7 @@ void storeOutput(HANDLE ahandle, char **aoutput) success=ReadFile(ahandle, readbuffer, sizeof(readbuffer), &transfered, NULL); - if((success)&&(transfered!=0)) + if ((success)&&(transfered!=0)) appendText(aoutput, readbuffer, transfered); } while(available>0); @@ -66,14 +66,14 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex else securityattributes.lpSecurityDescriptor=NULL; success=CreatePipe(&newstdin, &writestdin ,&securityattributes ,0); - if(! success) + if (! success) { LogMessage("--- ", "create pipe failed", "\n"); return pxCreatePipeFailed; } success=CreatePipe(&readstdout, &newstdout, &securityattributes, 0); - if(! success) + if (! success) { LogMessage("--- ", "create pipe failed", "\n"); CloseHandle(newstdin); @@ -90,7 +90,7 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex success=CreateProcess(NULL, acommandline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupinfo, &processinformation); - if(! success) + if (! success) { LogMessage("--- ", "create process failed", "\n"); CloseHandle(newstdin); @@ -105,11 +105,11 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex while(TRUE) { success=GetExitCodeProcess(processinformation.hProcess, aexitcode); - if((success)&&(*aexitcode!=STILL_ACTIVE)) break; + if ((success)&&(*aexitcode!=STILL_ACTIVE)) break; storeOutput(readstdout, aoutput); - if(*inputpos!='\0') size=1; + if (*inputpos!='\0') size=1; else size=0; success=WriteFile(writestdin, inputpos, size, &transfered, NULL); diff --git a/plugins/CryptoPP/GPGw/tools.c b/plugins/CryptoPP/GPGw/tools.c index ee7adde761..002f18824d 100644 --- a/plugins/CryptoPP/GPGw/tools.c +++ b/plugins/CryptoPP/GPGw/tools.c @@ -78,7 +78,7 @@ void appendText(char **abuffer, const char *atext, int atextsize) { int size; - if(*abuffer==NULL) size=0; + if (*abuffer==NULL) size=0; else size=strlen(*abuffer); size++; // abschliessende 0 if(atextsize==0) atextsize=strlen(atext); -- cgit v1.2.3