diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-24 02:27:47 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-26 11:43:54 -0500 |
commit | 621d9e5c413e561293d7484b93882d985b3fe15f (patch) | |
tree | 638f3d75761c121d9a8fb50b52a12a6686c5ac5c /pki/base/symkey/src/com/netscape/symkey/Buffer.cpp | |
parent | 40d3643b8d91886bf210aa27f711731c81a11e49 (diff) | |
download | pki-621d9e5c413e561293d7484b93882d985b3fe15f.tar.gz pki-621d9e5c413e561293d7484b93882d985b3fe15f.tar.xz pki-621d9e5c413e561293d7484b93882d985b3fe15f.zip |
Removed unnecessary pki folder.
Previously the source code was located inside a pki folder.
This folder was created during svn migration and is no longer
needed. This folder has now been removed and the contents have
been moved up one level.
Ticket #131
Diffstat (limited to 'pki/base/symkey/src/com/netscape/symkey/Buffer.cpp')
-rw-r--r-- | pki/base/symkey/src/com/netscape/symkey/Buffer.cpp | 183 |
1 files changed, 0 insertions, 183 deletions
diff --git a/pki/base/symkey/src/com/netscape/symkey/Buffer.cpp b/pki/base/symkey/src/com/netscape/symkey/Buffer.cpp deleted file mode 100644 index 5c687c5f5..000000000 --- a/pki/base/symkey/src/com/netscape/symkey/Buffer.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// 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; version 2 of the License. -// -// 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., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -#include <memory.h> -#include <assert.h> -#include <stdio.h> -#include <cstdarg> -#include <string> - -#include "Buffer.h" - -Buffer::Buffer(const BYTE *buf_, unsigned int len_) : len(len_), res(len_) -{ - buf = new BYTE[len]; - memcpy(buf, buf_, len); -} - -Buffer::Buffer(const Buffer& cpy) -{ - buf = 0; - *this = cpy; -} - -Buffer::Buffer(unsigned int len_) : len(len_), res(len_) -{ - buf = new BYTE[res]; - memset(buf, 0, len_); -} - -Buffer::Buffer(unsigned int len_, BYTE b) : len(len_), res(len_) -{ - buf = new BYTE[res]; - memset(buf, b, len); -} - -Buffer::~Buffer() -{ - delete [] buf; -} - -bool -Buffer::operator==(const Buffer& cmp) const -{ - if( len != cmp.len ) return false; - for( unsigned int i=0; i < len; ++i ) { - if( buf[i] != cmp.buf[i] ) { - return false; - } - } - return true; -} - -Buffer& -Buffer::operator=(const Buffer& cpy) -{ - if( this == &cpy ) return *this; - len = cpy.len; - delete [] buf; - buf = new BYTE[len]; - memcpy(buf, cpy.buf, len); - res = len; - - return *this; -} - -void -Buffer::zeroize() -{ - if( len > 0 ) { - memset( buf, 0, len ); - } -} - -Buffer -Buffer::operator+(const Buffer& addend) const -{ - Buffer result(len + addend.len); - memcpy(result.buf, buf, len); - memcpy(result.buf+len, addend.buf, addend.len); - return result; -} - -Buffer& -Buffer::operator+=(const Buffer& addend) -{ - unsigned int oldLen = len; - resize(len + addend.len); - memcpy(buf+oldLen, addend.buf, addend.len); - return *this; -} - -Buffer& -Buffer::operator+=(BYTE b) -{ - resize(len+1); - buf[len-1] = b; - return *this; -} - -void -Buffer::reserve(unsigned int n) -{ - if( n > res ) { - BYTE *newBuf = new BYTE[n]; - memcpy(newBuf, buf, len); - delete [] buf; - buf = newBuf; - res = n; - } -} - -void -Buffer::resize(unsigned int newLen) -{ - if( newLen == len ) { - return; - } else if( newLen < len ) { - len = newLen; - } else if( newLen <= res ) { - assert( newLen > len ); - memset(buf+len, 0, newLen-len); - len = newLen; - } else { - assert( newLen > len && newLen > res ); - BYTE *newBuf = new BYTE[newLen]; - memcpy(newBuf, buf, len); - memset(newBuf+len, 0, newLen-len); - delete [] buf; - buf = newBuf; - len = newLen; - res = newLen; - } -} - -Buffer -Buffer::substr(unsigned int i, unsigned int n) const -{ - assert( i < len && (i+n) <= len ); - return Buffer( buf+i, n ); -} - -void -Buffer::replace(unsigned int i, const BYTE* cpy, unsigned int n) -{ - if (len > i+n) { - resize( len); - }else { - resize( i+n ); - } - memcpy(buf+i, cpy, n); -} - -void -Buffer::dump() const -{ - unsigned int i; - - for( i=0; i < len; ++i ) { - printf("%02x ", buf[i]); - if( i % 16 == 15 ) printf("\n"); - } - printf("\n"); -} - -static const char hextbl[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' -}; |