From 024c7fb409dc9b0c921a41a89a411496a17b0f70 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 1 Apr 2014 14:58:49 +0000 Subject: CryptoPP: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@8813 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CryptoPP/src/base16.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'plugins/CryptoPP/src/base16.cpp') diff --git a/plugins/CryptoPP/src/base16.cpp b/plugins/CryptoPP/src/base16.cpp index d28daf99a3..689d54c88a 100644 --- a/plugins/CryptoPP/src/base16.cpp +++ b/plugins/CryptoPP/src/base16.cpp @@ -1,15 +1,14 @@ #include "commonheaders.h" - -char *base16encode(const char *inBuffer, int count) { - - char *outBuffer = (char *) malloc(count*2+1); +char *base16encode(const char *inBuffer, int count) +{ + char *outBuffer = (char *)malloc(count * 2 + 1); char *outBufferPtr = outBuffer; - BYTE *inBufferPtr = (BYTE *) inBuffer; + BYTE *inBufferPtr = (BYTE *)inBuffer; - while(count){ - *outBufferPtr++ = encode16(((*inBufferPtr)>>4)&0x0F); - *outBufferPtr++ = encode16((*inBufferPtr++)&0x0F); + while (count) { + *outBufferPtr++ = encode16(((*inBufferPtr) >> 4) & 0x0F); + *outBufferPtr++ = encode16((*inBufferPtr++) & 0x0F); count--; } *outBufferPtr = '\0'; @@ -17,20 +16,19 @@ char *base16encode(const char *inBuffer, int count) { return outBuffer; } - -char *base16decode(const char *inBuffer, unsigned int *count) { - +char *base16decode(const char *inBuffer, unsigned int *count) +{ char *outBuffer = (char *)mir_alloc(*count); BYTE *outBufferPtr = (BYTE *)outBuffer; bool big_endian = false; - if (*inBuffer == '0' && *(inBuffer+1) == 'x') { + if (*inBuffer == '0' && *(inBuffer + 1) == 'x') { inBuffer += *count; big_endian = true; *count -= 2; } - while(*count>1){ - BYTE c0,c1; + while (*count > 1) { + BYTE c0, c1; if (big_endian) { c1 = decode16(*--inBuffer); c0 = decode16(*--inBuffer); @@ -44,21 +42,17 @@ char *base16decode(const char *inBuffer, unsigned int *count) { *count = 0; return(NULL); } - *outBufferPtr++ = (c0<<4) | c1; + *outBufferPtr++ = (c0 << 4) | c1; *count -= 2; } *outBufferPtr = '\0'; - *count = (int)(outBufferPtr-(BYTE *)outBuffer); + *count = (int)(outBufferPtr - (BYTE *)outBuffer); return outBuffer; } - char *base16decode(const char *inBuffer) { unsigned count = (unsigned)strlen(inBuffer); return base16decode(inBuffer, &count); } - - -// EOF -- cgit v1.2.3