changeset 128:7f747c8c9d02

cleanup installed headers
author Carl Byington <carl@five-ten-sg.com>
date Thu, 05 Feb 2009 09:22:22 -0800
parents c2482d0cd84e
children fc11b1d1ad34
files Makefile.cvs configure.in src/define.h src/deltasearch.cpp src/libpst.c src/libpst.h src/pst2ldif.cpp
diffstat 7 files changed, 103 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.cvs	Thu Feb 05 09:20:02 2009 -0800
+++ b/Makefile.cvs	Thu Feb 05 09:22:22 2009 -0800
@@ -3,6 +3,7 @@
 HOST=$(shell hostname)
 
 all:
+	libtoolize --force --copy
 	aclocal
 	autoheader
 	automake
--- a/configure.in	Thu Feb 05 09:20:02 2009 -0800
+++ b/configure.in	Thu Feb 05 09:22:22 2009 -0800
@@ -1,8 +1,8 @@
 AC_PREREQ(2.59)
 AC_INIT(libpst,0.6.26,carl@five-ten-sg.com)
-AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_SRCDIR([src/libpst.c])
 AC_CONFIG_HEADER([config.h])
-AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
+AM_INIT_AUTOMAKE
 AC_CANONICAL_HOST
 
 
--- a/src/define.h	Thu Feb 05 09:20:02 2009 -0800
+++ b/src/define.h	Thu Feb 05 09:22:22 2009 -0800
@@ -8,6 +8,8 @@
 #ifndef DEFINEH_H
 #define DEFINEH_H
 
+#include "common.h"
+
 #ifdef HAVE_CONFIG_H
     #include "config.h"
 #endif
@@ -298,4 +300,75 @@
     unsigned int type;
 };
 
+#if BYTE_ORDER == BIG_ENDIAN
+#  define LE64_CPU(x) \
+  x = ((((x) & UINT64_C(0xff00000000000000)) >> 56) | \
+       (((x) & UINT64_C(0x00ff000000000000)) >> 40) | \
+       (((x) & UINT64_C(0x0000ff0000000000)) >> 24) | \
+       (((x) & UINT64_C(0x000000ff00000000)) >> 8 ) | \
+       (((x) & UINT64_C(0x00000000ff000000)) << 8 ) | \
+       (((x) & UINT64_C(0x0000000000ff0000)) << 24) | \
+       (((x) & UINT64_C(0x000000000000ff00)) << 40) | \
+       (((x) & UINT64_C(0x00000000000000ff)) << 56));
+#  define LE32_CPU(x) \
+  x = ((((x) & 0xff000000) >> 24) | \
+       (((x) & 0x00ff0000) >> 8 ) | \
+       (((x) & 0x0000ff00) << 8 ) | \
+       (((x) & 0x000000ff) << 24));
+#  define LE16_CPU(x) \
+  x = ((((x) & 0xff00) >> 8) | \
+       (((x) & 0x00ff) << 8));
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#  define LE64_CPU(x) {}
+#  define LE32_CPU(x) {}
+#  define LE16_CPU(x) {}
+#else
+#  error "Byte order not supported by this library"
+#endif // BYTE_ORDER
+
+
+#define PST_LE_GET_UINT64(p) \
+        (uint64_t)((((uint8_t const *)(p))[0] << 0) |    \
+                  (((uint8_t const *)(p))[1] << 8)  |    \
+                  (((uint8_t const *)(p))[2] << 16) |    \
+                  (((uint8_t const *)(p))[3] << 24) |    \
+                  (((uint8_t const *)(p))[4] << 32) |    \
+                  (((uint8_t const *)(p))[5] << 40) |    \
+                  (((uint8_t const *)(p))[6] << 48) |    \
+                  (((uint8_t const *)(p))[7] << 56))
+
+#define PST_LE_GET_INT64(p) \
+        (int64_t)((((uint8_t const *)(p))[0] << 0) |    \
+                  (((uint8_t const *)(p))[1] << 8)  |    \
+                  (((uint8_t const *)(p))[2] << 16) |    \
+                  (((uint8_t const *)(p))[3] << 24) |    \
+                  (((uint8_t const *)(p))[4] << 32) |    \
+                  (((uint8_t const *)(p))[5] << 40) |    \
+                  (((uint8_t const *)(p))[6] << 48) |    \
+                  (((uint8_t const *)(p))[7] << 56))
+
+#define PST_LE_GET_UINT32(p) \
+        (uint32_t)((((uint8_t const *)(p))[0] << 0)  |    \
+                  (((uint8_t const *)(p))[1] << 8)  |    \
+                  (((uint8_t const *)(p))[2] << 16) |    \
+                  (((uint8_t const *)(p))[3] << 24))
+
+#define PST_LE_GET_INT32(p) \
+        (int32_t)((((uint8_t const *)(p))[0] << 0)  |    \
+                  (((uint8_t const *)(p))[1] << 8)  |    \
+                  (((uint8_t const *)(p))[2] << 16) |    \
+                  (((uint8_t const *)(p))[3] << 24))
+
+#define PST_LE_GET_UINT16(p)				  \
+        (uint16_t)((((uint8_t const *)(p))[0] << 0)  |    \
+                  (((uint8_t const *)(p))[1] << 8))
+
+#define PST_LE_GET_INT16(p)				  \
+        (int16_t)((((uint8_t const *)(p))[0] << 0)  |    \
+                  (((uint8_t const *)(p))[1] << 8))
+
+#define PST_LE_GET_UINT8(p) (*(uint8_t const *)(p))
+
+#define PST_LE_GET_INT8(p) (*(int8_t const *)(p))
+
 #endif //DEFINEH_H
--- a/src/deltasearch.cpp	Thu Feb 05 09:20:02 2009 -0800
+++ b/src/deltasearch.cpp	Thu Feb 05 09:22:22 2009 -0800
@@ -1,8 +1,10 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <iostream>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <vector>
 using namespace std;
 extern "C" {
 	#include "define.h"
@@ -55,14 +57,14 @@
 		struct stat st;
 		fstat(fd, &st);
 		off_t size = st.st_size;
-		char buf[size];
-		size_t s = read(fd, buf, size);
-		pst_debug_hexdumper(stdout, buf, s, 16, 0);
+		vector <char> buf(size);
+		size_t s = read(fd, &buf[0], size);
+		pst_debug_hexdumper(stdout, &buf[0], s, 16, 0);
         printf("\n\n dump decrypted data \n");
 		for (off_t i=0; i<size; i++) {
 			buf[i] = comp_enc[(unsigned char)buf[i]];
 		}
-		pst_debug_hexdumper(stdout, buf, s, 16, 0);
+		pst_debug_hexdumper(stdout, &buf[0], s, 16, 0);
 		close(fd);
 	}
 	return 0;
--- a/src/libpst.c	Thu Feb 05 09:20:02 2009 -0800
+++ b/src/libpst.c	Thu Feb 05 09:22:22 2009 -0800
@@ -565,11 +565,9 @@
         return 0;
     }
 
-    memcpy(&xattrib, &(buffer[bptr]), sizeof(xattrib));
-    LE32_CPU(xattrib.extended);
-    LE16_CPU(xattrib.type);
-    LE16_CPU(xattrib.map);
-    bptr += sizeof(xattrib);
+	xattrib.extended=PST_LE_GET_UINT32(buffer+bptr), bptr += 4;
+	xattrib.type=PST_LE_GET_UINT16(buffer+bptr), bptr += 2;
+	xattrib.map=PST_LE_GET_UINT16(buffer+bptr),	bptr += 2;
 
     while (xattrib.type != 0 && bptr < bsize) {
         ptr = (pst_x_attrib_ll*) xmalloc(sizeof(*ptr));
--- a/src/libpst.h	Thu Feb 05 09:20:02 2009 -0800
+++ b/src/libpst.h	Thu Feb 05 09:22:22 2009 -0800
@@ -11,33 +11,6 @@
 #define LIBPST_H
 
 
-#if BYTE_ORDER == BIG_ENDIAN
-#  define LE64_CPU(x) \
-  x = ((((x) & UINT64_C(0xff00000000000000)) >> 56) | \
-       (((x) & UINT64_C(0x00ff000000000000)) >> 40) | \
-       (((x) & UINT64_C(0x0000ff0000000000)) >> 24) | \
-       (((x) & UINT64_C(0x000000ff00000000)) >> 8 ) | \
-       (((x) & UINT64_C(0x00000000ff000000)) << 8 ) | \
-       (((x) & UINT64_C(0x0000000000ff0000)) << 24) | \
-       (((x) & UINT64_C(0x000000000000ff00)) << 40) | \
-       (((x) & UINT64_C(0x00000000000000ff)) << 56));
-#  define LE32_CPU(x) \
-  x = ((((x) & 0xff000000) >> 24) | \
-       (((x) & 0x00ff0000) >> 8 ) | \
-       (((x) & 0x0000ff00) << 8 ) | \
-       (((x) & 0x000000ff) << 24));
-#  define LE16_CPU(x) \
-  x = ((((x) & 0xff00) >> 8) | \
-       (((x) & 0x00ff) << 8));
-#elif BYTE_ORDER == LITTLE_ENDIAN
-#  define LE64_CPU(x) {}
-#  define LE32_CPU(x) {}
-#  define LE16_CPU(x) {}
-#else
-#  error "Byte order not supported by this library"
-#endif // BYTE_ORDER
-
-
 #define PST_TYPE_NOTE        1
 #define PST_TYPE_APPOINTMENT 8
 #define PST_TYPE_CONTACT     9
--- a/src/pst2ldif.cpp	Thu Feb 05 09:20:02 2009 -0800
+++ b/src/pst2ldif.cpp	Thu Feb 05 09:22:22 2009 -0800
@@ -104,10 +104,10 @@
     string_set::iterator i = all_strings.find(name);
     if (i == all_strings.end()) return register_string(name);
     while (true) {
-        char n[strlen(name)+10];
-        snprintf(n, sizeof(n), "%s %d", name, unique++);
-        string_set::iterator i = all_strings.find(n);
-        if (i == all_strings.end()) return register_string(n);
+        vector<char> n(strlen(name)+10);
+        snprintf(&n[0], n.size(), "%s %d", name, unique++);
+        string_set::iterator i = all_strings.find(&n[0]);
+        if (i == all_strings.end()) return register_string(&n[0]);
     }
 }
 
@@ -327,8 +327,8 @@
     // Strip leading spaces
     while (*value == ' ') value++;
     len = strlen(value) + 1;
-    char buffer[len];
-    char *p = buffer;
+    vector<char> buffer(len);
+    char *p = &buffer[0];
 
     // See if "value" is a "SAFE STRING"
     // First check characters that are safe but not safe as initial characters
@@ -359,29 +359,29 @@
     }
     *p = 0;
     if (is_safe_string) {
-        printf("%s: %s\n", attr, buffer);
+        printf("%s: %s\n", attr, &buffer[0]);
         return;
     }
 
     if (needs_code_conversion && cd != 0) {
-        size_t inlen = p - buffer;
+        size_t inlen = p - &buffer[0];
         size_t utf8_len = 2 * inlen + 1;
-        char utf8_buffer[utf8_len];
-        char *utf8_p = utf8_buffer;
+        vector<char> utf8_buffer(utf8_len);
+        char *utf8_p = &utf8_buffer[0];
 
         iconv(cd, NULL, NULL, NULL, NULL);
-        p = buffer;
+        p = &buffer[0];
         int ret = iconv(cd, (ICONV_CONST char**)&p, &inlen, &utf8_p, &utf8_len);
 
         if (ret >= 0) {
             *utf8_p = 0;
-            p = base64_encode(utf8_buffer, utf8_p - utf8_buffer);
+            p = base64_encode(&utf8_buffer[0], utf8_p - &utf8_buffer[0]);
         }
         else
-            p = base64_encode(buffer, strlen(buffer));
+            p = base64_encode(&buffer[0], buffer.size());
     }
     else
-        p = base64_encode(buffer, strlen(buffer));
+        p = base64_encode(&buffer[0], buffer.size());
     printf("%s:: %s\n", attr, p);
     free(p);
 }
@@ -486,11 +486,11 @@
         return;
     }
 
-    char value[len1 + len2 + 2];
-    memcpy(value, value1, len1);
+    vector<char> value(len1 + len2 + 2);
+    memcpy(&value[0], value1, len1);
     value[len1] = ' ';
-    memcpy(value + len1 + 1, value2, len2 + 1);
-    print_ldif_single(attr, value);
+    memcpy(&value[0] + len1 + 1, value2, len2 + 1);
+    print_ldif_single(attr, &value[0]);
 }