[Winpt-commits] r326 - in trunk: . Src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 25 17:53:21 CEST 2009
Author: twoaday
Date: 2009-09-25 17:53:21 +0200 (Fri, 25 Sep 2009)
New Revision: 326
Added:
trunk/Src/StringBuffer.cpp
trunk/Src/StringBuffer.h
Removed:
trunk/Generic/
Modified:
trunk/Makefile.am
trunk/README
trunk/Src/Makefile.am
trunk/configure.ac
Log:
Begin update.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/Makefile.am 2009-09-25 15:53:21 UTC (rev 326)
@@ -20,7 +20,7 @@
EXTRA_DIST = autogen.sh README.SVN
-SUBDIRS = Po Gnupg PTD Src Include Generic icons m4
+SUBDIRS = Po Gnupg PTD Src Include icons m4
dist-hook:
echo "$(VERSION)" > $(distdir)/VERSION
Modified: trunk/README
===================================================================
--- trunk/README 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/README 2009-09-25 15:53:21 UTC (rev 326)
@@ -1,5 +1,5 @@
WinPT - The Windows Privacy Tray
- ================================
+ =================================
Bugs and Improvements
Modified: trunk/Src/Makefile.am
===================================================================
--- trunk/Src/Makefile.am 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/Src/Makefile.am 2009-09-25 15:53:21 UTC (rev 326)
@@ -80,6 +80,7 @@
wptSigTreeDlg.cpp
code_files = \
+ StringBuffer.cpp \
WinPT.cpp \
wptCardManager.cpp \
wptCardPCSC.cpp \
@@ -131,7 +132,7 @@
-lgnupg ../PTD/PTD.dll \
$(GPGME_LIBS) $(W32LIBS) \
-lcomctl32 -lkernel32 -luser32 -lcomdlg32 -ladvapi32 \
- -lshell32 -lgdi32 -lversion
+ -lshell32 -lgdi32 -lversion -lole32 -loleout32 -luuid
WinPT-en.o: $(resource_files)
Added: trunk/Src/StringBuffer.cpp
===================================================================
--- trunk/Src/StringBuffer.cpp 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/Src/StringBuffer.cpp 2009-09-25 15:53:21 UTC (rev 326)
@@ -0,0 +1,227 @@
+/* StringBuffer.cpp - A simple string buffer implementation.
+ Copyright (C) 2006, 2007 Timo Schulz
+ Released under the GNU General Public License, Version 2. */
+
+#include <string.h>
+#include <stdio.h>
+
+#include "StringBuffer.h"
+
+/* Add the converted data at the end of the internal buffer.
+ Allocate more memory if needed, plus some extra bytes. */
+void StringBuffer::addCharacters (const char *buffer, int bufsize)
+{
+ if (size+bufsize > alloced_size) {
+ char *save = private_contents;
+
+ alloced_size += bufsize+DEFSIZE+1;
+ private_contents = new char[alloced_size+1];
+ memset (private_contents, 0, alloced_size+1);
+ if (save != NULL) {
+ strcpy (private_contents, save);
+ delete []save;
+ }
+ }
+ strcat (private_contents, buffer);
+ size += bufsize;
+}
+
+
+/* Create an empty buffer object. */
+StringBuffer::StringBuffer ()
+{
+ alloced_size = 0;
+ size = 0;
+ private_contents = NULL;
+}
+
+
+/* Create an empty buffer object with an inital size. */
+StringBuffer::StringBuffer (int bufsize)
+{
+ alloced_size = bufsize+DEFSIZE+1;
+ private_contents = new char[alloced_size+1];
+ memset (private_contents, 0, alloced_size+1);
+ size = 0;
+}
+
+
+/* Create a buffer object with the given contents. */
+StringBuffer::StringBuffer (const char *contents)
+{
+ alloced_size = strlen (contents)+1+DEFSIZE;
+ private_contents = new char[alloced_size+1];
+ memset (private_contents, 0, alloced_size+1);
+ strcpy (private_contents, contents);
+ size = strlen (contents);
+}
+
+
+/* Destructor which fres the used memory. */
+StringBuffer::~StringBuffer ()
+{
+ if (private_contents != NULL)
+ delete []private_contents;
+ private_contents = NULL;
+ size = 0;
+ alloced_size = 0;
+}
+
+
+/* Return a copy of the buffer which must be freed after use. */
+char* StringBuffer::getBufferCopy (void)
+{
+ char *p = new char[strlen (private_contents)+1];
+ strcpy (p, private_contents);
+ return p;
+}
+
+
+/* Return a constant pointer to the 'char*' data of the buffer. */
+const char *StringBuffer::getBuffer (void)
+{
+ return private_contents;
+}
+
+
+/* Overwrite buffer contents in a safe manner. */
+void StringBuffer::wipeContents (void)
+{
+ volatile char *ptr = (volatile char*)private_contents;
+ int len = getSize ();
+
+ while (len-- > 0) {
+ *ptr = '\0';
+ *ptr++;
+ }
+}
+
+
+/* Return the size of the underlying string. */
+int StringBuffer::getSize (void)
+{
+ return size;
+}
+
+/* Reset the buffer contents. */
+void StringBuffer::reset (void)
+{
+ memset (private_contents, 0, alloced_size);
+ size = 0;
+}
+
+
+/* Add an integer to the buffer. */
+void StringBuffer::add (int val)
+{
+ char tmp[32];
+
+ _snprintf (tmp, 31, "%d", val);
+ addCharacters (tmp, strlen (tmp));
+}
+
+
+/* Add a single character to the buffer. */
+void StringBuffer::add (char val)
+{
+ char tmp[4];
+
+ _snprintf (tmp, 3, "%c", val);
+ addCharacters (tmp, strlen (tmp));
+}
+
+
+/* Add a long-integer to the buffer. */
+void StringBuffer::add (long val)
+{
+ char tmp[32];
+
+ _snprintf (tmp, 31, "%d", val);
+ addCharacters (tmp, strlen (tmp));
+}
+
+
+/* Add a string to the buffer. */
+void StringBuffer::add (const char *val)
+{
+ addCharacters (val, strlen (val));
+}
+
+
+/* Add an unsigned integer to the buffer. */
+void StringBuffer::add (unsigned long val)
+{
+ char tmp[32];
+
+ _snprintf (tmp, 31, "%lu", val);
+ addCharacters (tmp, strlen (tmp));
+}
+
+
+/* Add an unsigned integer in hex format to the buffer. */
+void StringBuffer::addHex (unsigned long val)
+{
+ char tmp[32];
+
+ _snprintf (tmp, 31, "%08lx", val);
+ addCharacters (tmp, strlen (tmp));
+}
+
+
+/* Overloaded operators to provide an easier interface
+ for manipulating the underlying buffer. */
+StringBuffer& StringBuffer::operator +(int val)
+{
+ add (val);
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +(unsigned long val)
+{
+ add (val);
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +(const char *val)
+{
+ addCharacters (val, strlen (val));
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +=(int val)
+{
+ add (val);
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +=(unsigned long val)
+{
+ add (val);
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +=(const char *val)
+{
+ addCharacters (val, strlen (val));
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator +=(char val)
+{
+ add (val);
+ return *this;
+}
+
+
+StringBuffer& StringBuffer::operator=(const char *val)
+{
+ reset ();
+ addCharacters (val, strlen (val));
+ return *this;
+}
Added: trunk/Src/StringBuffer.h
===================================================================
--- trunk/Src/StringBuffer.h 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/Src/StringBuffer.h 2009-09-25 15:53:21 UTC (rev 326)
@@ -0,0 +1,90 @@
+#ifndef __STRING_BUFFER_H
+#define __STRING_BUFFER_H
+
+/* Copyright (C) 2006, 2007 Timo Schulz
+ Released under the GNU General Public License, Version 2. */
+
+#define DEFSIZE 128
+
+/* A simple string buffer implementation which allows to manipulate
+ the underlying buffer in a unified and easy way. The code is written
+ for clarity and simplicty, _not_ speed. */
+class StringBuffer
+{
+private:
+ char *private_contents;
+ int alloced_size;
+ int size;
+
+private:
+ /* Add the converted data at the end of the internal buffer.
+ Allocate more memory if needed, plus some extra bytes. */
+ void addCharacters (const char *buffer, int bufsize);
+
+public:
+ StringBuffer ();
+
+ /* Create an empty buffer object with an inital size. */
+ StringBuffer (int bufsize);
+
+
+ /* Create a buffer object with the given contents. */
+ StringBuffer (const char *contents);
+
+ /* Destructor which fres the used memory. */
+ ~StringBuffer ();
+
+ /* Overwrite buffer contents in a safe manner. */
+ void wipeContents (void);
+
+ /* Return a constant pointer to the 'char*' data of the buffer. */
+ const char *getBuffer (void);
+
+ /* Return a copy of the buffer which must be freed after use. */
+ char* getBufferCopy (void);
+
+ /* Return the size of the underlying string. */
+ int getSize (void);
+
+ /* Reset the buffer contents. */
+ void reset (void);
+
+ /* Add an integer to the buffer. */
+ void add (int val);
+
+ /* Add a single character to the buffer. */
+ void add (char val);
+
+ /* Add a long-integer to the buffer. */
+ void add (long val);
+
+ /* Add a string to the buffer. */
+ void add (const char *val);
+
+ /* Add an unsigned integer to the buffer. */
+ void add (unsigned long val);
+
+ /* Add an unsigned integer in hex format to the buffer. */
+ void addHex (unsigned long val);
+
+ /* Overloaded operators to provide an easier interface
+ for manipulating the underlying buffer. */
+ StringBuffer& operator +(int val);
+
+ StringBuffer& operator +(unsigned long val);
+
+ StringBuffer& operator +(const char *val);
+
+ StringBuffer& operator +=(int val);
+
+ StringBuffer& operator +=(unsigned long val);
+
+ StringBuffer& operator +=(const char *val);
+
+ StringBuffer& operator +=(char val);
+
+ StringBuffer& operator=(const char *val);
+};
+
+
+#endif /*__STRING_BUFFER_H*/
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-09-25 15:51:28 UTC (rev 325)
+++ trunk/configure.ac 2009-09-25 15:53:21 UTC (rev 326)
@@ -34,7 +34,7 @@
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_TARGET()
AM_INIT_AUTOMAKE
-AM_MKINSTALLDIRS
+#AM_MKINSTALLDIRS
AC_GNU_SOURCE
@@ -136,8 +136,8 @@
])
# Note, that autogen.sh greps for the next line.
-AM_GNU_GETTEXT_VERSION(0.12.1)
-AM_GNU_GETTEXT([external])
+#AM_GNU_GETTEXT_VERSION(0.12.1)
+#AM_GNU_GETTEXT([external])
# There is something wrong with the NLS checking here. We force using it.
USE_NLS=yes
@@ -230,7 +230,8 @@
fi
-AC_CONFIG_FILES([ Makefile
+AC_CONFIG_FILES([
+Makefile
PTD/Makefile
PTD/versioninfo.rc
Src/Makefile
@@ -239,7 +240,6 @@
icons/Makefile
m4/Makefile
Gnupg/Makefile
-Generic/Makefile
Po/Makefile.in
])
AC_OUTPUT
More information about the Winpt-commits
mailing list