changeset 176:ac6e22c8a9cf

build separate libpst, libpst-libs, libpst-devel rpms. remove many functions from the interface by making them static.
author Carl Byington <carl@five-ten-sg.com>
date Wed, 08 Apr 2009 14:13:06 -0700
parents 03dbd449290f
children 59bd93d02feb
files ChangeLog NEWS libpst.spec.in regression/regression-tests.bash src/Makefile.am src/debug.c src/define.h src/libpst.c src/libpst.h src/vbuf.c src/vbuf.h
diffstat 11 files changed, 229 insertions(+), 189 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 07 13:48:25 2009 -0700
+++ b/ChangeLog	Wed Apr 08 14:13:06 2009 -0700
@@ -1,4 +1,4 @@
-LibPST 0.6.35 (2009-xx-xx)
+LibPST 0.6.35 (2009-04-08)
 ===============================
     * fix bug where we failed to pickup the last extended attribute.
     * patch from Emmanuel Andry to fix potential security bug in
@@ -8,6 +8,8 @@
     * prefix all external symbols in the shared library with pst_ to
       avoid symbol clashes with other shared libraries.
     * new debianization from hggdh.
+    * build separate libpst, libpst-libs, libpst-devel rpms.
+    * remove many functions from the interface by making them static.
 
 LibPST 0.6.34 (2009-03-19)
 ===============================
--- a/NEWS	Tue Apr 07 13:48:25 2009 -0700
+++ b/NEWS	Wed Apr 08 14:13:06 2009 -0700
@@ -1,3 +1,4 @@
+0.6.35  2009-04-08 properly add trailing mime boundary in all modes, build separate rpms with libpst.so shared.
 0.6.34  2009-03-19 avoid putting mixed item types into the same output folder
 0.6.33  2009-03-17 fix utf-7 conversions, don't produce empty attachment files in separate mode
 0.6.32  2009-03-14 fix ppc64 compile error
--- a/libpst.spec.in	Tue Apr 07 13:48:25 2009 -0700
+++ b/libpst.spec.in	Wed Apr 08 14:13:06 2009 -0700
@@ -8,9 +8,9 @@
 BuildRoot:          %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 URL:                http://www.five-ten-sg.com/%{name}/
 Requires:           ImageMagick
+Requires:           %{name}-libs = %{version}-%{release}
 BuildRequires:      ImageMagick freetype-devel gd-devel libjpeg-devel zlib-devel
 
-
 %description
 The Libpst utilities include readpst which can convert email messages
 to both mbox and MH mailbox formats, pst2ldif which can convert the
@@ -19,24 +19,54 @@
 Summation.
 
 
+%package libs
+Summary:            Shared library used by the pst utilities
+Group:              Development/Libraries
+
+%description libs
+libpst-libs contains the shared library used by the pst utilities.
+
+
+%package devel
+Summary:            Library links and header files for libpst application development
+Group:              Development/Libraries
+Requires:           pkgconfig freetype-devel gd-devel libjpeg-devel zlib-devel
+Requires:           %{name}-libs = %{version}-%{release}
+
+%description devel
+libpst-devel contains the library links and header fles you'll
+need to develop applications using the libpst shared library.
+You do not need to install it if you just want to use the libpst
+utilities.
+
+
+
 %prep
 %setup -q
 
 
 %build
-%configure
+%configure --enable-libpst-shared
 make %{?_smp_mflags}
 
 
 %install
 rm -rf $RPM_BUILD_ROOT
 make DESTDIR=$RPM_BUILD_ROOT install
+rm $RPM_BUILD_ROOT%{_libdir}/libpst.la
+rm $RPM_BUILD_ROOT%{_libdir}/libpst.a
 
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 
+%post libs -p /sbin/ldconfig
+
+
+%postun libs -p /sbin/ldconfig
+
+
 %files
 %defattr(-,root,root,-)
 %{_bindir}/*
@@ -46,7 +76,22 @@
 %{_datadir}/doc/%{name}-%{version}
 
 
+%files libs
+%{_libdir}/libpst.so.*
+
+
+%files devel
+%{_libdir}/libpst.so
+%dir %{_includedir}/%{name}-@LIBPST_SO_MAJOR@
+%{_includedir}/%{name}-@LIBPST_SO_MAJOR@/*
+%{_libdir}/pkgconfig/libpst.pc
+
+
 %changelog
+* Wed Apr 08 2009 Carl Byington <carl@five-ten-sg.com> - 0.6.35-1
+- properly add trailing mime boundary in all modes.
+- build separate libpst, libpst-libs, libpst-devel rpms.
+
 * Thu Mar 19 2009 Carl Byington <carl@five-ten-sg.com> - 0.6.34-1
 - avoid putting mixed item types into the same output folder.
 
--- a/regression/regression-tests.bash	Tue Apr 07 13:48:25 2009 -0700
+++ b/regression/regression-tests.bash	Wed Apr 08 14:13:06 2009 -0700
@@ -1,6 +1,21 @@
 #!/bin/bash
 
 
+function consistency()
+{
+    # check source and xml documentation for consistency
+    (
+        cd ..   # back to top level of project
+        f1=/tmp/f1$$
+        f2=/tmp/f2$$
+        grep 'case 0x' src/libpst.c   | awk '{print $2}' | tr A-Z a-z | sed -e 's/://g'             | sort >$f1
+        grep '^0x'     xml/libpst.in  | awk '{print $1}' | (for i in {1..19}; do read a; done; cat) | sort >$f2
+        diff $f1 $f2
+        less $f1
+        rm -f $f1 $f2
+    )
+}
+
 function dodii()
 {
     n="$1"
--- a/src/Makefile.am	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/Makefile.am	Wed Apr 08 14:13:06 2009 -0700
@@ -22,7 +22,7 @@
                 libpst.c        \
                 libstrfunc.c    \
                 lzfu.c          \
-                timeconv.c      \
+                timeconv.c		\
                 vbuf.c
 
 
--- a/src/debug.c	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/debug.c	Wed Apr 08 14:13:06 2009 -0700
@@ -20,11 +20,13 @@
 static struct pst_debug_func *func_head=NULL, *func_ptr=NULL;
 
 
-void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size);
-void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col);
-void * pst_malloc(size_t size);
+static void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size);
+static void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col);
+static void pst_debug_write();
 
-size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) {
+
+static size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream);
+static size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) {
     return fwrite(ptr, size, nitems, stream);
 }
 
@@ -250,7 +252,7 @@
 }
 
 
-void pst_debug_write() {
+static void pst_debug_write() {
     size_t size, ptr, funcname, filename, text, end;
     char *buf = NULL, rec_type;
     if (!debug_fp) return;  // no file
@@ -334,7 +336,7 @@
 }
 
 
-void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) {
+static void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) {
     struct pst_debug_file_rec_l lfile_rec;
     struct pst_debug_file_rec_m mfile_rec;
     unsigned char rec_type;
--- a/src/define.h	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/define.h	Wed Apr 08 14:13:06 2009 -0700
@@ -141,20 +141,17 @@
 #endif
 
 
-void pst_debug(const char *fmt, ...);
-void pst_debug_hexdumper(FILE* out, char* buf, size_t size, int col, int delta);
-void pst_debug_hexprint(char *data, int size);
-
-void pst_debug_init(const char *fname);
-void pst_debug_msg_info (int line, const char *file, int type);
-void pst_debug_msg_text(const char* fmt, ...);
-void pst_debug_hexdump(char *x, size_t y, int cols, int delta);
-void pst_debug_func(const char *function);
-void pst_debug_func_ret();
-void pst_debug_close(void);
-void pst_debug_write();
-size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream);
-void*  pst_malloc(size_t size);
+void  pst_debug(const char *fmt, ...);
+void  pst_debug_hexdumper(FILE* out, char* buf, size_t size, int col, int delta);
+void  pst_debug_hexprint(char *data, int size);
+void  pst_debug_init(const char *fname);
+void  pst_debug_msg_info (int line, const char *file, int type);
+void  pst_debug_msg_text(const char* fmt, ...);
+void  pst_debug_hexdump(char *x, size_t y, int cols, int delta);
+void  pst_debug_func(const char *function);
+void  pst_debug_func_ret();
+void  pst_debug_close(void);
+void* pst_malloc(size_t size);
 
 #define MESSAGEPRINT(x,y) {pst_debug_msg_info(__LINE__,__FILE__,y);\
                            pst_debug_msg_text x;}
--- a/src/libpst.c	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/libpst.c	Wed Apr 08 14:13:06 2009 -0700
@@ -168,6 +168,37 @@
     0x61, 0xe0, 0xc6, 0xc1, 0x59, 0xab, 0xbb, 0x58, 0xde, 0x5f, 0xdf, 0x60, 0x79, 0x7e, 0xb2, 0x8a
 };
 
+static int              pst_build_desc_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
+static pst_id2_ll*      pst_build_id2(pst_file *pf, pst_index_ll* list);
+static int              pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
+static int              pst_chr_count(char *str, char x);
+static size_t           pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size);
+static size_t           pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf);
+static size_t           pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h);
+static void             pst_free_attach(pst_item_attach *attach);
+static void             pst_free_desc (pst_desc_ll *head);
+static void             pst_free_id2(pst_id2_ll * head);
+static void             pst_free_id (pst_index_ll *head);
+static void             pst_free_list(pst_mapi_object *list);
+static void             pst_free_xattrib(pst_x_attrib_ll *x);
+static size_t           pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size);
+static int              pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p);
+static int              pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p);
+static pst_id2_ll*      pst_getID2(pst_id2_ll * ptr, uint64_t id);
+static pst_desc_ll*     pst_getDptr(pst_file *pf, uint64_t d_id);
+static uint64_t         pst_getIntAt(pst_file *pf, char *buf);
+static uint64_t         pst_getIntAtPos(pst_file *pf, int64_t pos);
+static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head);
+static void             pst_printDptr(pst_file *pf, pst_desc_ll *ptr);
+static void             pst_printIDptr(pst_file* pf);
+static void             pst_printID2ptr(pst_id2_ll *ptr);
+static int              pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach);
+static size_t           pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf);
+static int              pst_stricmp(char *a, char *b);
+static int              pst_strincmp(char *a, char *b, size_t x);
+static char*            pst_wide_to_single(char *wt, size_t size);
+
+
 
 int pst_open(pst_file *pf, char *name) {
     int32_t sig;
@@ -404,28 +435,6 @@
 }
 
 
-size_t pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b){
-    size_t size=0;
-    pst_index_ll *ptr;
-    pst_holder h = {b, NULL, 0};
-    DEBUG_ENT("pst_attach_to_mem");
-    if (attach->i_id != (uint64_t)-1) {
-        ptr = pst_getID(pf, attach->i_id);
-        if (ptr) {
-            size = pst_ff_getID2data(pf, ptr, &h);
-        } else {
-            DEBUG_WARN(("Couldn't find ID pointer. Cannot handle attachment\n"));
-            size = 0;
-        }
-        attach->data.size = size;
-    } else {
-        size = attach->data.size;
-    }
-    DEBUG_RET();
-    return size;
-}
-
-
 size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp) {
     pst_index_ll *ptr;
     pst_holder h = {NULL, fp, 0};
@@ -831,7 +840,7 @@
  *  (offset and size) of lower level objects (0xbcec descriptor
  *  blocks, etc) in the pst file.
  */
-int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) {
+static int pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) {
     struct pst_table_ptr_structn table, table2;
     pst_index_ll *i_ptr=NULL;
     pst_index index;
@@ -948,7 +957,7 @@
  *  pf->d_head tree from it. This tree holds descriptions of the
  *  higher level objects (email, contact, etc) in the pst file.
  */
-int pst_build_desc_ptr (pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) {
+static int pst_build_desc_ptr (pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val) {
     struct pst_table_ptr_structn table, table2;
     pst_descn desc_rec;
     int32_t item_count;
@@ -1252,7 +1261,7 @@
  *
  *  @return list of MAPI objects
  */
-pst_mapi_object * pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head) {
+static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head) {
     pst_mapi_object *mo_head = NULL;
     char  *buf       = NULL;
     size_t read_size = 0;
@@ -1971,7 +1980,7 @@
  *
  * @return 0 for ok, -1 for error.
  */
-int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) {
+static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) {
     DEBUG_ENT("pst_process");
     if (!item) {
         DEBUG_EMAIL(("item cannot be NULL.\n"));
@@ -2993,7 +3002,7 @@
 }
 
 
-void pst_free_list(pst_mapi_object *list) {
+static void pst_free_list(pst_mapi_object *list) {
     pst_mapi_object *l;
     DEBUG_ENT("pst_free_list");
     while (list) {
@@ -3015,7 +3024,7 @@
 }
 
 
-void pst_free_id2(pst_id2_ll * head) {
+static void pst_free_id2(pst_id2_ll * head) {
     pst_id2_ll *t;
     DEBUG_ENT("pst_free_id2");
     while (head) {
@@ -3028,7 +3037,7 @@
 }
 
 
-void pst_free_id (pst_index_ll *head) {
+static void pst_free_id (pst_index_ll *head) {
     pst_index_ll *t;
     DEBUG_ENT("pst_free_id");
     while (head) {
@@ -3040,7 +3049,7 @@
 }
 
 
-void pst_free_desc (pst_desc_ll *head) {
+static void pst_free_desc (pst_desc_ll *head) {
     pst_desc_ll *t;
     DEBUG_ENT("pst_free_desc");
     while (head) {
@@ -3064,7 +3073,7 @@
 }
 
 
-void pst_free_xattrib(pst_x_attrib_ll *x) {
+static void pst_free_xattrib(pst_x_attrib_ll *x) {
     pst_x_attrib_ll *t;
     DEBUG_ENT("pst_free_xattrib");
     while (x) {
@@ -3077,7 +3086,7 @@
 }
 
 
-pst_id2_ll * pst_build_id2(pst_file *pf, pst_index_ll* list) {
+static pst_id2_ll * pst_build_id2(pst_file *pf, pst_index_ll* list) {
     pst_block_header block_head;
     pst_id2_ll *head = NULL, *tail = NULL;
     uint16_t x = 0;
@@ -3146,7 +3155,7 @@
 }
 
 
-void pst_free_attach(pst_item_attach *attach) {
+static void pst_free_attach(pst_item_attach *attach) {
     while (attach) {
         pst_item_attach *t;
         SAFE_FREE_STR(attach->filename1);
@@ -3372,7 +3381,7 @@
   * Otherwise, the high order 16 bits of offset is the index into the subblocks, and
   * the (low order 16 bits of offset)>>4 is an index into the table of offsets in the subblock.
 */
-int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p) {
+static int pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p) {
     size_t size;
     pst_block_offset block_offset;
     DEBUG_ENT("pst_getBlockOffsetPointer");
@@ -3419,7 +3428,7 @@
 }
 
 
-int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p) {
+static int pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p) {
     uint32_t low = offset & 0xf;
     uint32_t of1 = offset >> 4;
     DEBUG_ENT("pst_getBlockOffset");
@@ -3467,7 +3476,7 @@
 }
 
 
-pst_id2_ll *pst_getID2(pst_id2_ll *head, uint64_t id2) {
+static pst_id2_ll *pst_getID2(pst_id2_ll *head, uint64_t id2) {
     DEBUG_ENT("pst_getID2");
     DEBUG_INDEX(("looking for id2 = %#"PRIx64"\n", id2));
     pst_id2_ll *ptr = head;
@@ -3501,7 +3510,7 @@
  *
  * @return pointer to the pst_desc_ll node in the descriptor tree
 */
-pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t d_id) {
+static pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t d_id) {
     pst_desc_ll *ptr = pf->d_head;
     DEBUG_ENT("pst_getDptr");
     while (ptr && (ptr->d_id != d_id)) {
@@ -3520,7 +3529,7 @@
 }
 
 
-void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) {
+static void pst_printDptr(pst_file *pf, pst_desc_ll *ptr) {
     DEBUG_ENT("pst_printDptr");
     while (ptr) {
         DEBUG_INDEX(("%#"PRIx64" [%i] desc=%#"PRIx64", assoc tree=%#"PRIx64"\n", ptr->d_id, ptr->no_child,
@@ -3535,7 +3544,7 @@
 }
 
 
-void pst_printIDptr(pst_file* pf) {
+static void pst_printIDptr(pst_file* pf) {
     pst_index_ll *ptr = pf->i_head;
     DEBUG_ENT("pst_printIDptr");
     while (ptr) {
@@ -3546,7 +3555,7 @@
 }
 
 
-void pst_printID2ptr(pst_id2_ll *ptr) {
+static void pst_printID2ptr(pst_id2_ll *ptr) {
     DEBUG_ENT("pst_printID2ptr");
     while (ptr) {
         DEBUG_INDEX(("%#"PRIx64" id=%#"PRIx64"\n", ptr->id2, (ptr->id ? ptr->id->i_id : (uint64_t)0)));
@@ -3566,7 +3575,7 @@
                  is non-NULL, it will first be free()d
  * @return       size of block read into memory
  */
-size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) {
+static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf) {
     size_t rsize;
     DEBUG_ENT("pst_read_block_size");
     DEBUG_READ(("Reading block from %#"PRIx64", %x bytes\n", offset, size));
@@ -3642,7 +3651,7 @@
 }
 
 
-uint64_t pst_getIntAt(pst_file *pf, char *buf) {
+static uint64_t pst_getIntAt(pst_file *pf, char *buf) {
     uint64_t buf64;
     uint32_t buf32;
     if (pf->do_read64) {
@@ -3658,7 +3667,7 @@
 }
 
 
-uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos ) {
+static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos ) {
     uint64_t buf64;
     uint32_t buf32;
     if (pf->do_read64) {
@@ -3682,8 +3691,7 @@
  * @param size size of the buffer and the amount of data to be read
  * @return     actual read size, 0 if seek error
  */
-
-size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size) {
+static size_t pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size) {
     size_t rc;
     DEBUG_ENT("pst_getAtPos");
 //  pst_block_recorder **t = &pf->block_head;
@@ -3767,7 +3775,7 @@
 }
 
 
-size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf) {
+static size_t pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf) {
     size_t ret;
     pst_id2_ll* ptr;
     pst_holder h = {buf, NULL, 0};
@@ -3785,7 +3793,7 @@
 }
 
 
-size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) {
+static size_t pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h) {
     size_t ret;
     char *b = NULL, *t;
     DEBUG_ENT("pst_ff_getID2data");
@@ -3817,7 +3825,7 @@
 }
 
 
-size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size) {
+static size_t pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size) {
     size_t z, a;
     uint16_t count, y;
     char *buf3 = NULL, *buf2 = NULL, *t;
@@ -3964,7 +3972,7 @@
 
 #endif //_WIN32
 
-int pst_stricmp(char *a, char *b) {
+static int pst_stricmp(char *a, char *b) {
     // compare strings case-insensitive.
     // returns -1 if a < b, 0 if a==b, 1 if a > b
     while(*a != '\0' && *b != '\0' && toupper(*a)==toupper(*b)) {
@@ -3979,7 +3987,7 @@
 }
 
 
-int pst_strincmp(char *a, char *b, size_t x) {
+static int pst_strincmp(char *a, char *b, size_t x) {
     // compare upto x chars in string a and b case-insensitively
     // returns -1 if a < b, 0 if a==b, 1 if a > b
     size_t y = 0;
@@ -4010,7 +4018,7 @@
 }
 
 
-char * pst_wide_to_single(char *wt, size_t size) {
+static char* pst_wide_to_single(char *wt, size_t size) {
     // returns the first byte of each wide char. the size is the number of bytes in source
     char *x, *y;
     DEBUG_ENT("pst_wide_to_single");
@@ -4086,7 +4094,7 @@
 }
 
 
-int pst_chr_count(char *str, char x) {
+static int pst_chr_count(char *str, char x) {
     int r = 0;
     while (*str) {
         if (*str == x) r++;
--- a/src/libpst.h	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/libpst.h	Wed Apr 08 14:13:06 2009 -0700
@@ -612,55 +612,23 @@
 int            pst_open(pst_file *pf, char *name);
 int            pst_close(pst_file *pf);
 pst_desc_ll *  pst_getTopOfFolders(pst_file *pf, pst_item *root);
-size_t         pst_attach_to_mem(pst_file *pf, pst_item_attach *attach, char **b);
 size_t         pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE* fp);
 size_t         pst_attach_to_file_base64(pst_file *pf, pst_item_attach *attach, FILE* fp);
 int            pst_load_index (pst_file *pf);
 pst_desc_ll*   pst_getNextDptr(pst_desc_ll* d);
 int            pst_load_extended_attributes(pst_file *pf);
-
-int            pst_build_id_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
-int            pst_build_desc_ptr(pst_file *pf, int64_t offset, int32_t depth, uint64_t linku1, uint64_t start_val, uint64_t end_val);
 pst_item*      pst_getItem(pst_file *pf, pst_desc_ll *d_ptr);
 pst_item*      pst_parse_item (pst_file *pf, pst_desc_ll *d_ptr, pst_id2_ll *m_head);
-pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_ll *i2_head);
-int            pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach);
-void           pst_free_list(pst_mapi_object *list);
 void           pst_freeItem(pst_item *item);
-void           pst_free_id2(pst_id2_ll * head);
-void           pst_free_id (pst_index_ll *head);
-void           pst_free_desc (pst_desc_ll *head);
-void           pst_free_xattrib(pst_x_attrib_ll *x);
-int            pst_getBlockOffsetPointer(pst_file *pf, pst_id2_ll *i2_head, pst_subblocks *subblocks, uint32_t offset, pst_block_offset_pointer *p);
-int            pst_getBlockOffset(char *buf, size_t read_size, uint32_t i_offset, uint32_t offset, pst_block_offset *p);
-pst_id2_ll* pst_build_id2(pst_file *pf, pst_index_ll* list);
 pst_index_ll*  pst_getID(pst_file* pf, uint64_t i_id);
-pst_id2_ll* pst_getID2(pst_id2_ll * ptr, uint64_t id);
-pst_desc_ll*   pst_getDptr(pst_file *pf, uint64_t d_id);
-size_t         pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf);
 int            pst_decrypt(uint64_t id, char *buf, size_t size, unsigned char type);
-uint64_t       pst_getIntAt(pst_file *pf, char *buf);
-uint64_t       pst_getIntAtPos(pst_file *pf, int64_t pos);
-size_t         pst_getAtPos(pst_file *pf, int64_t pos, void* buf, size_t size);
 size_t         pst_ff_getIDblock_dec(pst_file *pf, uint64_t id, char **b);
 size_t         pst_ff_getIDblock(pst_file *pf, uint64_t id, char** b);
-size_t         pst_ff_getID2block(pst_file *pf, uint64_t id2, pst_id2_ll *id2_head, char** buf);
-size_t         pst_ff_getID2data(pst_file *pf, pst_index_ll *ptr, pst_holder *h);
-size_t         pst_ff_compile_ID(pst_file *pf, uint64_t id, pst_holder *h, size_t size);
-
-int            pst_strincmp(char *a, char *b, size_t x);
-int            pst_stricmp(char *a, char *b);
 size_t         pst_fwrite(const void*ptr, size_t size, size_t nmemb, FILE*stream);
-char *         pst_wide_to_single(char *wt, size_t size);
-
 char *         pst_rfc2426_escape(char *str);
-int            pst_chr_count(char *str, char x);
 char *         pst_rfc2425_datetime_format(FILETIME *ft);
 char *         pst_rfc2445_datetime_format(FILETIME *ft);
 
-void           pst_printDptr(pst_file *pf, pst_desc_ll *ptr);
-void           pst_printIDptr(pst_file* pf);
-void           pst_printID2ptr(pst_id2_ll *ptr);
 
 const char*    pst_codepage(int cp);
 const char*    pst_default_charset(pst_item *item);
--- a/src/vbuf.c	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/vbuf.c	Wed Apr 08 14:13:06 2009 -0700
@@ -1,11 +1,54 @@
 
 #include "define.h"
 
+static int    pst_skip_nl(char *s);         // returns the width of the newline at s[0]
+static int    pst_find_nl(vstr *vs);        // find newline of type type in b
+
+// vbuf functions
+static void   pst_vbfree(vbuf *vb);
+static void   pst_vbclear(vbuf *vb);        // ditch the data, keep the buffer
+static void   pst_vbresize(vbuf *vb, size_t len);
+static size_t pst_vbavail(vbuf *vb);
+static void   pst_vbdump(vbuf *vb);
+static void   pst_vbskipws(vbuf *vb);
+static void   pst_vbskip(vbuf *vb, size_t skip);
+static void   pst_vboverwrite(vbuf *vbdest, vbuf *vbsrc);
+
+// vstr functions
+static vstr  *pst_vsalloc(size_t len);
+static char  *pst_vsb(vstr *vs);
+static size_t pst_vslen(vstr *vs);                      //strlen
+static void   pst_vsfree(vstr *vs);
+static void   pst_vsset(vstr *vs, char *s);             // Store string s in vb
+static void   pst_vsnset(vstr *vs, char *s, size_t n);  // Store string s in vb
+static void   pst_vsgrow(vstr *vs, size_t len);         // grow buffer by len bytes, data are preserved
+static size_t pst_vsavail(vstr *vs);
+static void   pst_vscat(vstr *vs, char *str);
+static void   pst_vsncat(vstr *vs, char *str, size_t len);
+static void   pst_vsnprepend(vstr *vs, char *str, size_t len) ;
+static void   pst_vsskip(vstr *vs, size_t len);
+static int    pst_vscmp(vstr *vs, char *str);
+static void   pst_vsskipws(vstr *vs);
+static void   pst_vs_printf(vstr *vs, char *fmt, ...);
+static void   pst_vs_printfa(vstr *vs, char *fmt, ...);
+static void   pst_vshexdump(vstr *vs, const char *b, size_t start, size_t stop, int ascii);
+static int    pst_vscatprintf(vstr *vs, char *fmt, ...);
+static void   pst_vsvprintf(vstr *vs, char *fmt, va_list ap);
+static void   pst_vstrunc(vstr *vs, size_t off);    // Drop chars [off..dlen]
+static int    pst_vslast(vstr *vs);                 // returns the last character stored in a vstr string
+static void   pst_vscharcat(vstr *vs, int ch);
+
+static void   pst_unicode_close();
+
+static int    pst_vb_skipline(vbuf *vb);   // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
+
+
+
 
 #define ASSERT(x,...) { if( !(x) ) DIE(( __VA_ARGS__)); }
 
 
-int pst_skip_nl(char *s)
+static int pst_skip_nl(char *s)
 {
     if (s[0] == '\n')
         return 1;
@@ -17,7 +60,7 @@
 }
 
 
-int pst_find_nl(vstr * vs)
+static int pst_find_nl(vstr * vs)
 {
     char *nextr, *nextn;
 
@@ -61,7 +104,7 @@
 }
 
 
-void pst_unicode_close()
+static void pst_unicode_close()
 {
     iconv_close(i16to8);
     if (target_open_from) iconv_close(i8totarget);
@@ -199,7 +242,7 @@
 
 vbuf *pst_vballoc(size_t len)
 {
-    struct varbuf *result = malloc(sizeof(struct varbuf));
+    vbuf *result = malloc(sizeof(vbuf));
     if (result) {
         result->dlen = 0;
         result->blen = 0;
@@ -211,7 +254,7 @@
 }
 
 
-void pst_vbcheck(vbuf * vb)
+static void pst_vbcheck(vbuf * vb)
 {
     ASSERT(vb->b >= vb->buf, "vbcheck(): data not inside buffer");
     ASSERT((size_t)(vb->b - vb->buf) <= vb->blen, "vbcheck(): vb->b outside of buffer range.");
@@ -220,20 +263,20 @@
 }
 
 
-void pst_vbfree(vbuf * vb)
+static void pst_vbfree(vbuf * vb)
 {
     free(vb->buf);
     free(vb);
 }
 
 
-void pst_vbclear(struct varbuf *vb) // ditch the data, keep the buffer
+static void pst_vbclear(vbuf *vb) // ditch the data, keep the buffer
 {
     pst_vbresize(vb, 0);
 }
 
 
-void pst_vbresize(struct varbuf *vb, size_t len)    // DESTRUCTIVELY grow or shrink buffer
+static void pst_vbresize(vbuf *vb, size_t len)    // DESTRUCTIVELY grow or shrink buffer
 {
     vb->dlen = 0;
 
@@ -248,13 +291,13 @@
 }
 
 
-size_t pst_vbavail(vbuf * vb)
+static size_t pst_vbavail(vbuf * vb)
 {
     return vb->blen  - vb->dlen - (size_t)(vb->b - vb->buf);
 }
 
 
-void pst_vbgrow(struct varbuf *vb, size_t len)      // out: vbavail(vb) >= len, data are preserved
+void pst_vbgrow(vbuf *vb, size_t len)      // out: vbavail(vb) >= len, data are preserved
 {
     if (0 == len)
         return;
@@ -294,7 +337,7 @@
 }
 
 
-void pst_vsskipws(vstr * vs)
+static void pst_vsskipws(vstr * vs)
 {
     char *p = vs->b;
     while ((size_t)(p - vs->b) < vs->dlen && isspace(p[0]))
@@ -305,7 +348,7 @@
 
 
 // append len bytes of b to vbuf, resize if necessary
-void pst_vbappend(struct varbuf *vb, void *b, size_t len)
+void pst_vbappend(vbuf *vb, void *b, size_t len)
 {
     if (0 == vb->dlen) {
         pst_vbset(vb, b, len);
@@ -318,7 +361,7 @@
 
 
 // dumps the first skip bytes from vbuf
-void pst_vbskip(struct varbuf *vb, size_t skip)
+static void pst_vbskip(vbuf *vb, size_t skip)
 {
     ASSERT(skip <= vb->dlen, "vbskip(): Attempt to seek past end of buffer.");
     vb->b += skip;
@@ -327,7 +370,7 @@
 
 
 // overwrite vbdest with vbsrc
-void pst_vboverwrite(struct varbuf *vbdest, struct varbuf *vbsrc)
+static void pst_vboverwrite(vbuf *vbdest, vbuf *vbsrc)
 {
     pst_vbresize(vbdest, vbsrc->blen);
     memcpy(vbdest->b, vbsrc->b, vbsrc->dlen);
@@ -336,7 +379,7 @@
 }
 
 
-vstr *pst_vsalloc(size_t len)
+static vstr *pst_vsalloc(size_t len)
 {
     vstr *result = (vstr *) pst_vballoc(len + 1);
     pst_vsset(result, "");
@@ -351,19 +394,19 @@
 }
 
 
-size_t pst_vslen(vstr * vs)
+static size_t pst_vslen(vstr * vs)
 {
     return strlen(pst_vsstr(vs));
 }
 
 
-void pst_vsfree(vstr * vs)
+static void pst_vsfree(vstr * vs)
 {
     pst_vbfree((vbuf *) vs);
 }
 
 
-void pst_vscharcat(vstr * vb, int ch)
+static void pst_vscharcat(vstr * vb, int ch)
 {
     pst_vbgrow((vbuf *) vb, 1);
     vb->b[vb->dlen - 1] = ch;
@@ -373,7 +416,7 @@
 
 
 // prependappend string str to vbuf, vbuf must already contain a valid string
-void pst_vsnprepend(vstr * vb, char *str, size_t len)
+static void pst_vsnprepend(vstr * vb, char *str, size_t len)
 {
     ASSERT(vb->b[vb->dlen - 1] == '\0', "vsncat(): attempt to append string to non-string.");
     size_t sl = strlen(str);
@@ -387,7 +430,7 @@
 
 
 // len < dlen-1 -> skip len chars, else DIE
-void pst_vsskip(vstr * vs, size_t len)
+static void pst_vsskip(vstr * vs, size_t len)
 {
     ASSERT(len < vs->dlen - 1, "Attempt to skip past end of string");
     pst_vbskip((vbuf *) vs, len);
@@ -395,7 +438,7 @@
 
 
 // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
-int pst_vsskipline(vstr * vs)
+static int pst_vsskipline(vstr * vs)
 {
     int nloff = pst_find_nl(vs);
     int nll   = pst_skip_nl(vs->b + nloff);
@@ -419,7 +462,7 @@
 }
 
 
-int pst_vscatprintf(vstr * vs, char *fmt, ...)
+static int pst_vscatprintf(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
@@ -451,7 +494,7 @@
 
 
 //  returns the last character stored in a vstr
-int pst_vslast(vstr * vs)
+static int pst_vslast(vstr * vs)
 {
     if (vs->dlen < 1)
         return -1;
@@ -464,7 +507,7 @@
 
 
 //  print over vb
-void pst_vs_printf(vstr * vs, char *fmt, ...)
+static void pst_vs_printf(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
@@ -493,7 +536,7 @@
 
 
 // printf append to vs
-void pst_vs_printfa(vstr * vs, char *fmt, ...)
+static void pst_vs_printfa(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
@@ -521,7 +564,7 @@
 }
 
 
-void pst_vshexdump(vstr * vs, const char *b, size_t start, size_t stop, int ascii)
+static void pst_vshexdump(vstr * vs, const char *b, size_t start, size_t stop, int ascii)
 {
     char c;
     int diff, i;
@@ -552,13 +595,13 @@
 }
 
 
-void pst_vsset(vstr * vs, char *s)  // Store string s in vs
+static void pst_vsset(vstr * vs, char *s)  // Store string s in vs
 {
     pst_vsnset(vs, s, strlen(s));
 }
 
 
-void pst_vsnset(vstr * vs, char *s, size_t n)       // Store string s in vs
+static void pst_vsnset(vstr * vs, char *s, size_t n)       // Store string s in vs
 {
     pst_vbresize((vbuf *) vs, n + 1);
     memcpy(vs->b, s, n);
@@ -567,19 +610,19 @@
 }
 
 
-void pst_vsgrow(vstr * vs, size_t len)      // grow buffer by len bytes, data are preserved
+static void pst_vsgrow(vstr * vs, size_t len)      // grow buffer by len bytes, data are preserved
 {
     pst_vbgrow((vbuf *) vs, len);
 }
 
 
-size_t pst_vsavail(vstr * vs)
+static size_t pst_vsavail(vstr * vs)
 {
     return pst_vbavail((vbuf *) vs);
 }
 
 
-void pst_vsnset16(vstr * vs, char *s, size_t len)   // Like vbstrnset, but for UTF16
+static void pst_vsnset16(vstr * vs, char *s, size_t len)   // Like vbstrnset, but for UTF16
 {
     pst_vbresize((vbuf *) vs, len + 1);
     memcpy(vs->b, s, len);
@@ -590,19 +633,19 @@
 }
 
 
-void pst_vscat(vstr * vs, char *str)
+static void pst_vscat(vstr * vs, char *str)
 {
     pst_vsncat(vs, str, strlen(str));
 }
 
 
-int pst_vscmp(vstr * vs, char *str)
+static int pst_vscmp(vstr * vs, char *str)
 {
     return strcmp(vs->b, str);
 }
 
 
-void pst_vsncat(vstr * vs, char *str, size_t len)   // append string str to vstr, vstr must already contain a valid string
+static void pst_vsncat(vstr * vs, char *str, size_t len)   // append string str to vstr, vstr must already contain a valid string
 {
     ASSERT(vs->b[vs->dlen - 1] == '\0', "vsncat(): attempt to append string to non-string.");
     size_t sl = strlen(str);
@@ -615,7 +658,7 @@
 }
 
 
-void pst_vstrunc(vstr * v, size_t off) // Drop chars [off..dlen]
+static void pst_vstrunc(vstr * v, size_t off) // Drop chars [off..dlen]
 {
     if (off >= v->dlen - 1)
         return;                 //nothing to do
--- a/src/vbuf.h	Tue Apr 07 13:48:25 2009 -0700
+++ b/src/vbuf.h	Wed Apr 08 14:13:06 2009 -0700
@@ -42,55 +42,14 @@
 #define VBUF_STATIC(x,y) static vbuf *x = NULL; if(!x) x = pst_vballoc(y);
 #define VSTR_STATIC(x,y) static vstr *x = NULL; if(!x) x = pst_vsalloc(y);
 
-int pst_skip_nl( char *s );  // returns the width of the newline at s[0]
-int pst_find_nl( vstr *vs ); // find newline of type type in b
-
-// vbuf functions
-vbuf *pst_vballoc(    size_t len );
-void pst_vbfree(      vbuf *vb );
-void pst_vbclear(     vbuf *vb ); //ditch the data, keep the buffer
-void pst_vbresize(    vbuf *vb, size_t len );
-size_t pst_vbavail(   vbuf *vb );
-void pst_vbdump(      vbuf *vb );
-void pst_vbgrow(      vbuf *vb, size_t len ); // grow buffer by len bytes, data are preserved
-void pst_vbset(       vbuf *vb, void *data, size_t len );
-void pst_vbskipws(    vbuf *vb );
-void pst_vbappend(    vbuf *vb, void *data, size_t length );
-void pst_vbskip(      vbuf *vb, size_t skip );
-void pst_vboverwrite( vbuf *vbdest, vbuf *vbsrc );
-
-// vstr functions
-vstr *pst_vsalloc( size_t len );
-char *pst_vsb(      vstr *vs );
-size_t pst_vslen(     vstr *vs ); //strlen
-void pst_vsfree(      vstr *vs );
-void pst_vsset(       vstr *vs, char *s ); // Store string s in vb
-void pst_vsnset(      vstr *vs, char *s, size_t n ); // Store string s in vb
-void pst_vsgrow(      vstr *vs, size_t len ); // grow buffer by len bytes, data are preserved
-size_t pst_vsavail(   vstr *vs );
-void pst_vscat(       vstr *vs, char *str );
-void pst_vsncat(      vstr *vs, char *str, size_t len );
-void pst_vsnprepend(  vstr *vs, char *str, size_t len ) ;
-void pst_vsskip(      vstr *vs, size_t len );
-int  pst_vscmp(       vstr *vs, char *str );
-void pst_vsskipws(    vstr *vs );
-void pst_vs_printf(   vstr *vs, char *fmt, ... );
-void pst_vs_printfa(  vstr *vs, char *fmt, ... );
-void pst_vshexdump(   vstr *vs, const char *b, size_t start, size_t stop, int ascii );
-int  pst_vscatprintf( vstr *vs, char *fmt, ... );
-void pst_vsvprintf(   vstr *vs, char *fmt, va_list ap );
-void pst_vstrunc(     vstr *vs, size_t off ); // Drop chars [off..dlen]
-int  pst_vslast(      vstr *vs ); // returns the last character stored in a vstr string
-void pst_vscharcat(   vstr *vs, int ch );
-
-
-void pst_unicode_init();
-void pst_unicode_close();
+vbuf  *pst_vballoc(size_t len);
+void   pst_vbgrow(vbuf *vb, size_t len);    // grow buffer by len bytes, data are preserved
+void   pst_vbset(vbuf *vb, void *data, size_t len);
+void   pst_vbappend(vbuf *vb, void *data, size_t length);
+void   pst_unicode_init();
 size_t pst_vb_utf16to8(vbuf *dest, const char *inbuf, int iblen);
 size_t pst_vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset);
 size_t pst_vb_8bit2utf8(vbuf *dest, const char *inbuf, int iblen, const char* charset);
 
-int pst_vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
-
 
 #endif // VBUF_H