changeset 172:6954d315aaa8

move version-info into main configure.in, and set it properly. prefix all external symbols in the shared library with pst_ to avoid symbol clashes with other shared libraries.
author Carl Byington <carl@five-ten-sg.com>
date Sat, 04 Apr 2009 16:00:48 -0700
parents 6c1e75bc4cac
children d9393349ab29
files ChangeLog configure.in src/Makefile.am src/debug.c src/define.h src/dumpblocks.c src/getidblock.c src/libpst.c src/libstrfunc.c src/libstrfunc.h src/lspst.c src/lzfu.c src/lzfu.h src/pst2dii.cpp.in src/pst2ldif.cpp src/readpst.c src/readpstlog.c src/testdebug.c src/timeconv.c src/timeconv.h src/vbuf.c src/vbuf.h
diffstat 22 files changed, 288 insertions(+), 265 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 29 08:51:13 2009 -0700
+++ b/ChangeLog	Sat Apr 04 16:00:48 2009 -0700
@@ -3,7 +3,10 @@
     * fix bug where we failed to pickup the last extended attribute.
     * patch from Emmanuel Andry to fix potential security bug in
       pst2dii with printf(err).
-    * properly add trailing mime boundary in all modes.	
+    * properly add trailing mime boundary in all modes.
+    * move version-info into main configure.in, and set it properly
+    * prefix all external symbols in the shared library with pst_ to
+      avoid symbol clashes with other shared libraries.
 
 LibPST 0.6.34 (2009-03-19)
 ===============================
--- a/configure.in	Sun Mar 29 08:51:13 2009 -0700
+++ b/configure.in	Sat Apr 04 16:00:48 2009 -0700
@@ -5,6 +5,23 @@
 AM_INIT_AUTOMAKE
 AC_CANONICAL_HOST
 
+#
+#  1. Remember that version-info is current:revision:age, and age <= current.
+#  2. If the source code has changed at all since the last public release,
+#     then increment revision (`c:r:a' becomes `c:r+1:a').
+#  3. If any interfaces have been added, removed, or changed since the last
+#     update, increment current, and set revision to 0.
+#  4. If any interfaces have been added since the last public release, then
+#     increment age, since we should be backward compatible with the previous
+#     version.
+#  5. If any interfaces have been removed or changed since the last public
+#     release, then set age to 0, since we are not backward compatible.
+#  6. libtool will build libpst.so.x.y.z where the SONAME is libpst.so.x
+#     and x=current-age, y=age, z=revision
+
+libpst_version_info='2:0:0'
+AC_SUBST(LIBPST_VERSION_INFO, [$libpst_version_info])
+
 
 # Check for win32
 AC_MSG_CHECKING([for Win32])
@@ -196,7 +213,6 @@
     enable_static_tools=no
 fi
 
-
 # needed by STATIC_TOOLS in src/Makefile.am
 AC_SUBST(PST_OBJDIR, [$objdir])
 
--- a/src/Makefile.am	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/Makefile.am	Sat Apr 04 16:00:48 2009 -0700
@@ -74,7 +74,7 @@
         libstrfunc.h\
         timeconv.h  \
         vbuf.h
-    libpst_la_LDFLAGS     = $(NO_UNDEFINED) -version-info 1:3:0
+    libpst_la_LDFLAGS     = $(NO_UNDEFINED) -version-info @LIBPST_VERSION_INFO@
 endif
 
 libpst_la_SOURCES     = $(common_source) $(common_header)
--- a/src/debug.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/debug.c	Sat Apr 04 16:00:48 2009 -0700
@@ -7,18 +7,22 @@
     char * file;
     char * text;
     struct pst_debug_item *next;
-} *item_head=NULL, *item_tail=NULL, *item_ptr=NULL, *info_ptr=NULL, *temp_list=NULL;
+};
+
+static struct pst_debug_item *item_head=NULL, *item_tail=NULL, *item_ptr=NULL, *info_ptr=NULL, *temp_list=NULL;
 
 
 struct pst_debug_func {
     char * name;
     struct pst_debug_func *next;
-} *func_head=NULL, *func_ptr=NULL;
+};
+
+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 * xmalloc(size_t size);
+void * pst_malloc(size_t size);
 
 size_t pst_debug_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) {
     return fwrite(ptr, size, nitems, stream);
@@ -74,8 +78,8 @@
 }
 
 
-FILE *debug_fp = NULL;
-unsigned int max_items=DEBUG_MAX_ITEMS, curr_items=0;
+static FILE *debug_fp = NULL;
+static unsigned int max_items=DEBUG_MAX_ITEMS, curr_items=0;
 
 
 void pst_debug_init(const char* fname) {
@@ -97,14 +101,14 @@
 void pst_debug_msg_info(int line, const char* file, int type) {
     char *x;
     if (!debug_fp) return;  // no file
-    info_ptr = (struct pst_debug_item*) xmalloc(sizeof(struct pst_debug_item));
+    info_ptr = (struct pst_debug_item*) pst_malloc(sizeof(struct pst_debug_item));
     info_ptr->type = type;
     info_ptr->line = line;
     x = (func_head==NULL?"No Function":func_head->name);
-    info_ptr->function = (char*) xmalloc(strlen(x)+1);
+    info_ptr->function = (char*) pst_malloc(strlen(x)+1);
     strcpy(info_ptr->function, x);
 
-    info_ptr->file = (char*) xmalloc(strlen(file)+1);
+    info_ptr->file = (char*) pst_malloc(strlen(file)+1);
     strcpy(info_ptr->file, file);
 
     //put the current record on a temp linked list
@@ -152,7 +156,7 @@
     #endif
 
     if (f > 0 && f < MAX_MESSAGE_SIZE) {
-        info_ptr->text = (char*) xmalloc(f+1);
+        info_ptr->text = (char*) pst_malloc(f+1);
         va_start(ap, fmt);
         if ((g = vsnprintf(info_ptr->text, f, fmt, ap)) == -1) {
             fprintf(stderr, "_debug_msg: Dying! vsnprintf returned -1 for format \"%s\"\n", fmt);
@@ -212,8 +216,8 @@
 
 
 void pst_debug_func(const char *function) {
-    func_ptr = xmalloc (sizeof(struct pst_debug_func));
-    func_ptr->name = xmalloc(strlen(function)+1);
+    func_ptr = pst_malloc (sizeof(struct pst_debug_func));
+    func_ptr->name = pst_malloc(strlen(function)+1);
     strcpy(func_ptr->name, function);
     func_ptr->next = func_head;
     func_head = func_ptr;
@@ -262,7 +266,7 @@
 
     if (curr_items == 0) return;    // no items to write.
 
-    index = (int64_t*)xmalloc(index_size);
+    index = (int64_t*)pst_malloc(index_size);
     memset(index, 0, index_size);   // valgrind, avoid writing uninitialized data
     file_pos += index_size;
     // write the index first, we will re-write it later, but
@@ -278,7 +282,7 @@
                strlen(item_ptr->file)     +
                strlen(item_ptr->text)     + 3; //for the three \0s
         if (buf) free(buf);
-        buf = xmalloc(size+1);
+        buf = pst_malloc(size+1);
         ptr = 0;
         funcname=ptr;
         ptr += sprintf(&(buf[ptr]), "%s", item_ptr->function)+1;
@@ -435,10 +439,10 @@
 }
 
 
-void *xmalloc(size_t size) {
+void *pst_malloc(size_t size) {
     void *mem = malloc(size);
     if (!mem) {
-        fprintf(stderr, "xMalloc: Out Of memory [req: %ld]\n", (long)size);
+        fprintf(stderr, "pst_malloc: Out Of memory [req: %ld]\n", (long)size);
         exit(1);
     }
     return mem;
--- a/src/define.h	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/define.h	Sat Apr 04 16:00:48 2009 -0700
@@ -154,8 +154,7 @@
 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 * xmalloc(size_t size);
+void*  pst_malloc(size_t size);
 
 #define MESSAGEPRINT(x,y) {pst_debug_msg_info(__LINE__,__FILE__,y);\
                            pst_debug_msg_text x;}
--- a/src/dumpblocks.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/dumpblocks.c	Sat Apr 04 16:00:48 2009 -0700
@@ -52,7 +52,7 @@
         }
 
     ptr = pstfile.i_head;
-    outname = (char *) xmalloc(OUT_BUF);
+    outname = (char *) pst_malloc(OUT_BUF);
     printf("Saving blocks\n");
     while (ptr != NULL) {
         /*    if (pstfile.encryption == PST_ENC) {
--- a/src/getidblock.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/getidblock.c	Sat Apr 04 16:00:48 2009 -0700
@@ -52,7 +52,7 @@
             ptr = pst_getNextDptr(ptr);
         }
         if (!ptr) {
-            ptr = (pst_desc_ll *) xmalloc(sizeof(pst_desc_ll));
+            ptr = (pst_desc_ll *) pst_malloc(sizeof(pst_desc_ll));
             memset(ptr, 0, sizeof(pst_desc_ll));
             ptr->desc = pst_getID(&pstfile, i_id);
         }
--- a/src/libpst.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/libpst.c	Sat Apr 04 16:00:48 2009 -0700
@@ -172,7 +172,7 @@
 int pst_open(pst_file *pf, char *name) {
     int32_t sig;
 
-    unicode_init();
+    pst_unicode_init();
 
     DEBUG_ENT("pst_open");
 
@@ -363,7 +363,7 @@
 static pst_id2_ll* deep_copy(pst_id2_ll *head)
 {
     if (!head) return NULL;
-    pst_id2_ll* me = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll));
+    pst_id2_ll* me = (pst_id2_ll*) pst_malloc(sizeof(pst_id2_ll));
     me->id2 = head->id2;
     me->id  = head->id;
     me->child = deep_copy(head->child);
@@ -392,7 +392,7 @@
     topnode = pst_getDptr(pf, (uint64_t)topid);
     if (!topnode) {
         // add dummy top record to pickup orphan children
-        topnode              = (pst_desc_ll*) xmalloc(sizeof(pst_desc_ll));
+        topnode              = (pst_desc_ll*) pst_malloc(sizeof(pst_desc_ll));
         topnode->d_id        = topid;
         topnode->parent_d_id = 0;
         topnode->assoc_tree  = NULL;
@@ -464,7 +464,7 @@
         attach->data.size = size;
     } else {
         // encode the attachment to the file
-        char *c = base64_encode(attach->data.data, attach->data.size);
+        char *c = pst_base64_encode(attach->data.data, attach->data.size);
         if (c) {
             (void)pst_fwrite(c, (size_t)1, strlen(c), fp);
             free(c);    // caught by valgrind
@@ -590,7 +590,7 @@
         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;
-        ptr = (pst_x_attrib_ll*) xmalloc(sizeof(*ptr));
+        ptr = (pst_x_attrib_ll*) pst_malloc(sizeof(*ptr));
         memset(ptr, 0, sizeof(*ptr));
         ptr->type = xattrib.type;
         ptr->map  = xattrib.map+0x8000;
@@ -604,7 +604,7 @@
                 // copy the size of the header. It is 32 bit int
                 memcpy(&tint, &(headerbuffer[xattrib.extended]), sizeof(tint));
                 LE32_CPU(tint);
-                wt = (char*) xmalloc((size_t)(tint+2)); // plus 2 for a uni-code zero
+                wt = (char*) pst_malloc((size_t)(tint+2)); // plus 2 for a uni-code zero
                 memset(wt, 0, (size_t)(tint+2));
                 memcpy(wt, &(headerbuffer[xattrib.extended+sizeof(tint)]), (size_t)tint);
                 ptr->data = pst_wide_to_single(wt, (size_t)tint);
@@ -617,7 +617,7 @@
             ptr->mytype = PST_MAP_HEADER;
         } else {
             // contains the attribute code to map to.
-            ptr->data = (uint32_t*)xmalloc(sizeof(uint32_t));
+            ptr->data = (uint32_t*)pst_malloc(sizeof(uint32_t));
             memset(ptr->data, 0, sizeof(uint32_t));
             *((uint32_t*)ptr->data) = xattrib.extended;
             ptr->mytype = PST_MAP_ATTRIB;
@@ -895,7 +895,7 @@
                     return -1;
                 }
             }
-            i_ptr = (pst_index_ll*) xmalloc(sizeof(pst_index_ll));
+            i_ptr = (pst_index_ll*) pst_malloc(sizeof(pst_index_ll));
             i_ptr->i_id   = index.id;
             i_ptr->offset = index.offset;
             i_ptr->u1     = index.u1;
@@ -1011,7 +1011,7 @@
             }
             DEBUG_INDEX(("New Record %#"PRIx64" with parent %#x\n", desc_rec.d_id, desc_rec.parent_d_id));
             {
-                pst_desc_ll *d_ptr = (pst_desc_ll*) xmalloc(sizeof(pst_desc_ll));
+                pst_desc_ll *d_ptr = (pst_desc_ll*) pst_malloc(sizeof(pst_desc_ll));
                 d_ptr->d_id        = desc_rec.d_id;
                 d_ptr->parent_d_id = desc_rec.parent_d_id;
                 d_ptr->assoc_tree  = pst_getID(pf, desc_rec.tree_id);
@@ -1102,7 +1102,7 @@
         return NULL;
     }
 
-    item = (pst_item*) xmalloc(sizeof(pst_item));
+    item = (pst_item*) pst_malloc(sizeof(pst_item));
     memset(item, 0, sizeof(pst_item));
 
     if (pst_process(list, item, NULL)) {
@@ -1126,7 +1126,7 @@
             return item;
         }
         for (x=0; x < list->count_objects; x++) {
-            attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach));
+            attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
             memset(attach, 0, sizeof(pst_item_attach));
             attach->next = item->attach;
             item->attach = attach;
@@ -1152,7 +1152,7 @@
             return item;
         }
         for (x=0; x < list->count_objects; x++) {
-            attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach));
+            attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
             memset(attach, 0, sizeof(pst_item_attach));
             attach->next = item->attach;
             item->attach = attach;
@@ -1483,12 +1483,12 @@
 
     DEBUG_EMAIL(("Mallocing number of records %i\n", num_recs));
     for (count_rec=0; count_rec<num_recs; count_rec++) {
-        mo_ptr = (pst_mapi_object*) xmalloc(sizeof(pst_mapi_object));
+        mo_ptr = (pst_mapi_object*) pst_malloc(sizeof(pst_mapi_object));
         memset(mo_ptr, 0, sizeof(pst_mapi_object));
         mo_ptr->next = mo_head;
         mo_head = mo_ptr;
         // allocate an array of count num_recs to contain sizeof(pst_mapi_element)
-        mo_ptr->elements        = (pst_mapi_element**) xmalloc(sizeof(pst_mapi_element)*num_list);
+        mo_ptr->elements        = (pst_mapi_element**) pst_malloc(sizeof(pst_mapi_element)*num_list);
         mo_ptr->count_elements  = num_list;
         mo_ptr->orig_count      = num_list;
         mo_ptr->count_objects   = (int32_t)num_recs; // each record will have a record of the total number of records
@@ -1546,7 +1546,7 @@
                 x, table_rec.type, table_rec.ref_type, table_rec.value));
 
             if (!mo_ptr->elements[x]) {
-                mo_ptr->elements[x] = (pst_mapi_element*) xmalloc(sizeof(pst_mapi_element));
+                mo_ptr->elements[x] = (pst_mapi_element*) pst_malloc(sizeof(pst_mapi_element));
             }
             memset(mo_ptr->elements[x], 0, sizeof(pst_mapi_element)); //init it
 
@@ -1598,7 +1598,7 @@
                 //contains 32 bits of data
                 mo_ptr->elements[x]->size = sizeof(int32_t);
                 mo_ptr->elements[x]->type = table_rec.ref_type;
-                mo_ptr->elements[x]->data = xmalloc(sizeof(int32_t));
+                mo_ptr->elements[x]->data = pst_malloc(sizeof(int32_t));
                 memcpy(mo_ptr->elements[x]->data, &(table_rec.value), sizeof(int32_t));
                 // are we missing an LE32_CPU() call here? table_rec.value is still
                 // in the original order.
@@ -1623,7 +1623,7 @@
                     // directly stored in this block.
                     mo_ptr->elements[x]->size = value_size;
                     mo_ptr->elements[x]->type = table_rec.ref_type;
-                    mo_ptr->elements[x]->data = xmalloc(value_size);
+                    mo_ptr->elements[x]->data = pst_malloc(value_size);
                     memcpy(mo_ptr->elements[x]->data, value_pointer, value_size);
                 }
                 else if (pst_getBlockOffsetPointer(pf, i2_head, &subblocks, table_rec.value, &block_offset7)) {
@@ -1645,7 +1645,7 @@
                     value_size = (size_t)(block_offset7.to - block_offset7.from);
                     mo_ptr->elements[x]->size = value_size;
                     mo_ptr->elements[x]->type = table_rec.ref_type;
-                    mo_ptr->elements[x]->data = xmalloc(value_size+1);
+                    mo_ptr->elements[x]->data = pst_malloc(value_size+1);
                     memcpy(mo_ptr->elements[x]->data, block_offset7.from, value_size);
                     mo_ptr->elements[x]->data[value_size] = '\0';  // it might be a string, null terminate it.
                 }
@@ -1666,26 +1666,26 @@
                     size_t rc;
                     static vbuf *utf16buf = NULL;
                     static vbuf *utf8buf  = NULL;
-                    if (!utf16buf) utf16buf = vballoc((size_t)1024);
-                    if (!utf8buf)  utf8buf  = vballoc((size_t)1024);
+                    if (!utf16buf) utf16buf = pst_vballoc((size_t)1024);
+                    if (!utf8buf)  utf8buf  = pst_vballoc((size_t)1024);
 
                     // splint barfed on the following lines
                     //VBUF_STATIC(utf16buf, 1024);
                     //VBUF_STATIC(utf8buf, 1024);
 
                     //need UTF-16 zero-termination
-                    vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size);
-                    vbappend(utf16buf, "\0\0", (size_t)2);
+                    pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size);
+                    pst_vbappend(utf16buf, "\0\0", (size_t)2);
                     DEBUG_INDEX(("Iconv in:\n"));
                     DEBUG_HEXDUMPC(utf16buf->b, utf16buf->dlen, 0x10);
-                    rc = vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen);
+                    rc = pst_vb_utf16to8(utf8buf, utf16buf->b, utf16buf->dlen);
                     if (rc == (size_t)-1) {
                         DEBUG_EMAIL(("Failed to convert utf-16 to utf-8\n"));
                     }
                     else {
                         free(mo_ptr->elements[x]->data);
                         mo_ptr->elements[x]->size = utf8buf->dlen;
-                        mo_ptr->elements[x]->data = xmalloc(utf8buf->dlen);
+                        mo_ptr->elements[x]->data = pst_malloc(utf8buf->dlen);
                         memcpy(mo_ptr->elements[x]->data, utf8buf->b, utf8buf->dlen);
                     }
                     DEBUG_INDEX(("Iconv out:\n"));
@@ -1716,12 +1716,12 @@
 #define SAFE_FREE_BIN(x) SAFE_FREE(x.data)
 
 // check if item->email is NULL, and init if so
-#define MALLOC_EMAIL(x)        { if (!x->email)         { x->email         = (pst_item_email*)         xmalloc(sizeof(pst_item_email));         memset(x->email,         0, sizeof(pst_item_email)        );} }
-#define MALLOC_FOLDER(x)       { if (!x->folder)        { x->folder        = (pst_item_folder*)        xmalloc(sizeof(pst_item_folder));        memset(x->folder,        0, sizeof(pst_item_folder)       );} }
-#define MALLOC_CONTACT(x)      { if (!x->contact)       { x->contact       = (pst_item_contact*)       xmalloc(sizeof(pst_item_contact));       memset(x->contact,       0, sizeof(pst_item_contact)      );} }
-#define MALLOC_MESSAGESTORE(x) { if (!x->message_store) { x->message_store = (pst_item_message_store*) xmalloc(sizeof(pst_item_message_store)); memset(x->message_store, 0, sizeof(pst_item_message_store));} }
-#define MALLOC_JOURNAL(x)      { if (!x->journal)       { x->journal       = (pst_item_journal*)       xmalloc(sizeof(pst_item_journal));       memset(x->journal,       0, sizeof(pst_item_journal)      );} }
-#define MALLOC_APPOINTMENT(x)  { if (!x->appointment)   { x->appointment   = (pst_item_appointment*)   xmalloc(sizeof(pst_item_appointment));   memset(x->appointment,   0, sizeof(pst_item_appointment)  );} }
+#define MALLOC_EMAIL(x)        { if (!x->email)         { x->email         = (pst_item_email*)         pst_malloc(sizeof(pst_item_email));         memset(x->email,         0, sizeof(pst_item_email)        );} }
+#define MALLOC_FOLDER(x)       { if (!x->folder)        { x->folder        = (pst_item_folder*)        pst_malloc(sizeof(pst_item_folder));        memset(x->folder,        0, sizeof(pst_item_folder)       );} }
+#define MALLOC_CONTACT(x)      { if (!x->contact)       { x->contact       = (pst_item_contact*)       pst_malloc(sizeof(pst_item_contact));       memset(x->contact,       0, sizeof(pst_item_contact)      );} }
+#define MALLOC_MESSAGESTORE(x) { if (!x->message_store) { x->message_store = (pst_item_message_store*) pst_malloc(sizeof(pst_item_message_store)); memset(x->message_store, 0, sizeof(pst_item_message_store));} }
+#define MALLOC_JOURNAL(x)      { if (!x->journal)       { x->journal       = (pst_item_journal*)       pst_malloc(sizeof(pst_item_journal));       memset(x->journal,       0, sizeof(pst_item_journal)      );} }
+#define MALLOC_APPOINTMENT(x)  { if (!x->appointment)   { x->appointment   = (pst_item_appointment*)   pst_malloc(sizeof(pst_item_appointment));   memset(x->appointment,   0, sizeof(pst_item_appointment)  );} }
 
 // malloc space and copy the current item's data null terminated
 #define LIST_COPY(targ, type) {                                    \
@@ -1912,7 +1912,7 @@
     memcpy(targ, list->elements[x]->data, list->elements[x]->size);         \
     LE32_CPU(targ->dwLowDateTime);                                          \
     LE32_CPU(targ->dwHighDateTime);                                         \
-    DEBUG_EMAIL((label" - %s", fileTimeToAscii(targ)));                     \
+    DEBUG_EMAIL((label" - %s", pst_fileTimeToAscii(targ)));                     \
 }
 
 #define LIST_COPY_EMAIL_TIME(label, targ) {                     \
@@ -1988,7 +1988,7 @@
             switch (list->elements[x]->mapi_id) {
                 case PST_ATTRIB_HEADER: // CUSTOM attribute for saying the Extra Headers
                     if (list->elements[x]->extra) {
-                        pst_item_extra_field *ef = (pst_item_extra_field*) xmalloc(sizeof(pst_item_extra_field));
+                        pst_item_extra_field *ef = (pst_item_extra_field*) pst_malloc(sizeof(pst_item_extra_field));
                         memset(ef, 0, sizeof(pst_item_extra_field));
                         ef->field_name = strdup(list->elements[x]->extra);
                         LIST_COPY_CSTR(ef->value);
@@ -2842,10 +2842,10 @@
                     LIST_COPY_APPT_BOOL("Reminder alarm", item->appointment->alarm);
                     break;
                 case 0x8516: // Common start
-                    DEBUG_EMAIL(("Common Start Date - %s\n", fileTimeToAscii((FILETIME*)list->elements[x]->data)));
+                    DEBUG_EMAIL(("Common Start Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data)));
                     break;
                 case 0x8517: // Common end
-                    DEBUG_EMAIL(("Common End Date - %s\n", fileTimeToAscii((FILETIME*)list->elements[x]->data)));
+                    DEBUG_EMAIL(("Common End Date - %s\n", pst_fileTimeToAscii((FILETIME*)list->elements[x]->data)));
                     break;
                 case 0x851f: // Play reminder sound filename
                     LIST_COPY_APPT_STR("Appointment reminder sound filename", item->appointment->alarm_filename);
@@ -2936,7 +2936,7 @@
 
                     } else if (list->elements[x]->type == (uint32_t)0x0040) {
                         DEBUG_EMAIL(("Unknown type %#x Date = \"%s\"\n", list->elements[x]->mapi_id,
-                            fileTimeToAscii((FILETIME*)list->elements[x]->data)));
+                            pst_fileTimeToAscii((FILETIME*)list->elements[x]->data)));
 
                     } else if (list->elements[x]->type == (uint32_t)0x0048) {
                         DEBUG_EMAIL(("Unknown type %#x OLE GUID [size = %#x]\n", list->elements[x]->mapi_id,
@@ -3121,7 +3121,7 @@
             DEBUG_INDEX(("%#"PRIx64" - Offset %#"PRIx64", u1 %#"PRIx64", Size %"PRIi64"(%#"PRIx64")\n",
                          i_ptr->i_id, i_ptr->offset, i_ptr->u1, i_ptr->size, i_ptr->size));
             // add it to the tree
-            i2_ptr = (pst_id2_ll*) xmalloc(sizeof(pst_id2_ll));
+            i2_ptr = (pst_id2_ll*) pst_malloc(sizeof(pst_id2_ll));
             i2_ptr->id2   = id2_rec.id2;
             i2_ptr->id    = i_ptr;
             i2_ptr->child = NULL;
@@ -3575,7 +3575,7 @@
         DEBUG_READ(("Freeing old memory\n"));
         free(*buf);
     }
-    *buf = (char*) xmalloc(size);
+    *buf = (char*) pst_malloc(size);
 
     rsize = pst_getAtPos(pf, offset, *buf, size);
     if (rsize != size) {
@@ -3698,7 +3698,7 @@
 //  } else {
 //      // add a new block
 //      pst_block_recorder *tail = *t;
-//      p = (pst_block_recorder*)xmalloc(sizeof(*p));
+//      p = (pst_block_recorder*)pst_malloc(sizeof(*p));
 //      *t = p;
 //      p->next      = tail;
 //      p->offset    = pos;
@@ -3794,7 +3794,7 @@
         if (h->buf) {
             *(h->buf) = b;
         } else if ((h->base64 == 1) && h->fp) {
-            t = base64_encode(b, ret);
+            t = pst_base64_encode(b, ret);
             if (t) {
                 (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp);
                 free(t);    // caught by valgrind
@@ -3848,7 +3848,7 @@
         if (h->buf)
             *(h->buf) = buf3;
         else if (h->base64 == 1 && h->fp) {
-            t = base64_encode(buf3, a);
+            t = pst_base64_encode(buf3, a);
             if (t) {
                 (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp);
                 free(t);    // caught by valgrind
@@ -3897,7 +3897,7 @@
             }
 
             // encode this chunk
-            t = base64_encode_multiple(buf2, z, &line_count);
+            t = pst_base64_encode_multiple(buf2, z, &line_count);
             if (t) {
                 DEBUG_READ(("writing %i bytes to file as base64 [%i]. Currently %i\n", z, strlen(t), size));
                 (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp);
@@ -3913,7 +3913,7 @@
     }
     if ((h->base64 == 1) && h->fp && base64_extra) {
         // need to encode any bytes left over
-        t = base64_encode_multiple(base64_extra_chars, (size_t)base64_extra, &line_count);
+        t = pst_base64_encode_multiple(base64_extra_chars, (size_t)base64_extra, &line_count);
         if (t) {
             (void)pst_fwrite(t, (size_t)1, strlen(t), h->fp);
             free(t);    // caught by valgrind
@@ -3927,10 +3927,10 @@
 
 
 #ifdef _WIN32
-char * fileTimeToAscii(const FILETIME* filetime) {
+char * pst_fileTimeToAscii(const FILETIME* filetime) {
     time_t t;
-    DEBUG_ENT("fileTimeToAscii");
-    t = fileTimeToUnixTime(filetime, 0);
+    DEBUG_ENT("pst_fileTimeToAscii");
+    t = pst_fileTimeToUnixTime(filetime, 0);
     if (t == -1)
         DEBUG_WARN(("ERROR time_t varible that was produced, is -1\n"));
     DEBUG_RET();
@@ -3938,10 +3938,10 @@
 }
 
 
-time_t fileTimeToUnixTime(const FILETIME* filetime, DWORD *x) {
+time_t pst_fileTimeToUnixTime(const FILETIME* filetime, DWORD *x) {
     SYSTEMTIME s;
     struct tm t;
-    DEBUG_ENT("fileTimeToUnixTime");
+    DEBUG_ENT("pst_fileTimeToUnixTime");
     memset (&t, 0, sizeof(struct tm));
     FileTimeToSystemTime(filetime, &s);
     t.tm_year = s.wYear-1900; // this is what is required
@@ -3955,9 +3955,9 @@
 }
 
 
-struct tm * fileTimeToStructTM (const FILETIME *filetime) {
+struct tm * pst_fileTimeToStructTM (const FILETIME *filetime) {
     time_t t1;
-    t1 = fileTimeToUnixTime(filetime, 0);
+    t1 = pst_fileTimeToUnixTime(filetime, 0);
     return gmtime(&t1);
 }
 
@@ -4014,7 +4014,7 @@
     // 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");
-    x = xmalloc((size/2)+1);
+    x = pst_malloc((size/2)+1);
     y = x;
     while (size != 0 && *wt != '\0') {
         *y = *wt;
@@ -4100,7 +4100,7 @@
     static char buffer[30];
     struct tm *stm = NULL;
     DEBUG_ENT("rfc2425_datetime_format");
-    stm = fileTimeToStructTM(ft);
+    stm = pst_fileTimeToStructTM(ft);
     if (strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", stm)==0) {
         DEBUG_INFO(("Problem occured formatting date\n"));
     }
@@ -4113,7 +4113,7 @@
     static char buffer[30];
     struct tm *stm = NULL;
     DEBUG_ENT("rfc2445_datetime_format");
-    stm = fileTimeToStructTM(ft);
+    stm = pst_fileTimeToStructTM(ft);
     if (strftime(buffer, sizeof(buffer), "%Y%m%dT%H%M%SZ", stm)==0) {
         DEBUG_INFO(("Problem occured formatting date\n"));
     }
@@ -4207,8 +4207,8 @@
     const char *charset = pst_default_charset(item);
     if (!strcasecmp("utf-8", charset)) return;  // already utf8
     DEBUG_ENT("pst_convert_utf8");
-    vbuf *newer = vballoc(2);
-    size_t rc = vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset);
+    vbuf *newer = pst_vballoc(2);
+    size_t rc = pst_vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset);
     if (rc == (size_t)-1) {
         free(newer->b);
         DEBUG_EMAIL(("Failed to convert %s to utf-8 - %s\n", charset, str->str));
--- a/src/libstrfunc.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/libstrfunc.c	Sat Apr 04 16:00:48 2009 -0700
@@ -6,7 +6,8 @@
 
 static char base64_code_chars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/==";
 
-void base64_append(char **ou, int *line_count, char data)
+static void base64_append(char **ou, int *line_count, char data);
+static void base64_append(char **ou, int *line_count, char data)
 {
     if (*line_count == 76) {
         *(*ou)++ = '\n';
@@ -17,14 +18,14 @@
 }
 
 
-char *base64_encode(void *data, size_t size)
+char *pst_base64_encode(void *data, size_t size)
 {
     int line_count = 0;
-    return base64_encode_multiple(data, size, &line_count);
+    return pst_base64_encode_multiple(data, size, &line_count);
 }
 
 
-char *base64_encode_multiple(void *data, size_t size, int *line_count)
+char *pst_base64_encode_multiple(void *data, size_t size, int *line_count)
 {
     char *output;
     char *ou;
--- a/src/libstrfunc.h	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/libstrfunc.h	Sat Apr 04 16:00:48 2009 -0700
@@ -1,4 +1,4 @@
 #include "common.h"
-char * base64_encode(void *data, size_t size);
-char * base64_encode_multiple(void *data, size_t size, int *line_count);
-void hexdump(char *hbuf, int start, int stop, int ascii);
+char *pst_base64_encode(void *data, size_t size);
+char *pst_base64_encode_multiple(void *data, size_t size, int *line_count);
+void  pst_hexdump(char *hbuf, int start, int stop, int ascii);
--- a/src/lspst.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/lspst.c	Sat Apr 04 16:00:48 2009 -0700
@@ -33,8 +33,7 @@
     f->skip_count   = 0;
     f->type         = item->type;
     f->stored_count = (item->folder) ? item->folder->item_count : 0;
-    f->dname        = (char*) xmalloc(strlen(item->file_as.str)+1);
-    strcpy(f->dname, item->file_as.str);
+    f->dname        = strdup(item->file_as.str);
 }
 
 
@@ -232,8 +231,7 @@
                 temp++; // get past the "\\"
         else
             temp++; // get past the "/"
-        item->file_as.str = (char*)xmalloc(strlen(temp)+1);
-        strcpy(item->file_as.str, temp);
+        item->file_as.str = strdup(temp);
         item->file_as.is_utf8 = 1;
     }
     WARN(("item->file_as = '%s'.\n", item->file_as.str));
--- a/src/lzfu.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/lzfu.c	Sat Apr 04 16:00:48 2009 -0700
@@ -35,7 +35,7 @@
 } lzfuheader;
 
 
-char* lzfu_decompress(char* rtfcomp, uint32_t compsize, size_t *size) {
+char* pst_lzfu_decompress(char* rtfcomp, uint32_t compsize, size_t *size) {
 	unsigned char dict[4096];       // the dictionary buffer
 	unsigned int dict_length = 0;   // the dictionary pointer
 	lzfuheader lzfuhdr;             // the header of the lzfu block
@@ -63,7 +63,7 @@
 	//printf("CRC       : %#x\n", lzfuhdr.dwCRC);
 	//printf("\n");
 	out_size = lzfuhdr.cbRawSize;
-	out_buf  = (char*)xmalloc(out_size);
+	out_buf  = (char*)pst_malloc(out_size);
 	in_ptr	 = sizeof(lzfuhdr);
 	// Make sure to correct lzfuhdr.cbSize with 4 bytes before comparing
 	// to compsize
--- a/src/lzfu.h	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/lzfu.h	Sat Apr 04 16:00:48 2009 -0700
@@ -1,6 +1,6 @@
 #ifndef LZFU_H
 #define LZFU_H
 
-char* lzfu_decompress (char* rtfcomp, uint32_t compsize, size_t *size);
+char* pst_lzfu_decompress (char* rtfcomp, uint32_t compsize, size_t *size);
 
 #endif
--- a/src/pst2dii.cpp.in	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/pst2dii.cpp.in	Sat Apr 04 16:00:48 2009 -0700
@@ -184,11 +184,11 @@
     int len = strlen(output_directory) + 1 + strlen(f_name) + 15;
     if (!attach_filename) {
         // generate our own (dummy) filename for the attachement
-        temp = (char*)xmalloc(len);
+        temp = (char*)pst_malloc(len);
         sprintf(temp, "%s/%s_attach%i", output_directory, f_name, attach_num);
     } else {
         // have an attachment name, make sure it's unique
-        temp = (char*)xmalloc(len+strlen(attach_filename));
+        temp = (char*)pst_malloc(len+strlen(attach_filename));
         do {
             if (fp) fclose(fp);
             if (x == 0)
@@ -480,7 +480,7 @@
     if (mybcc.empty())  write_simple("BCC",  item->email->bcc_address.str);
     else                write_simple("BCC", mybcc);
     if (item->email->sent_date) {
-        time_t t = fileTimeToUnixTime(item->email->sent_date, NULL);
+        time_t t = pst_fileTimeToUnixTime(item->email->sent_date, NULL);
         char c_time[C_TIME_SIZE];
         strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t));
         write_simple("DATESENT", c_time);
@@ -488,7 +488,7 @@
         write_simple("TIMESENT", c_time);
     }
     if (item->email->arrival_date) {
-        time_t t = fileTimeToUnixTime(item->email->arrival_date, NULL);
+        time_t t = pst_fileTimeToUnixTime(item->email->arrival_date, NULL);
         char c_time[C_TIME_SIZE];
         strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t));
         write_simple("DATERCVD", c_time);
@@ -540,7 +540,7 @@
         }
 
         if (item->email->sent_date) {
-            time_t em_time = fileTimeToUnixTime(item->email->sent_date, 0);
+            time_t em_time = pst_fileTimeToUnixTime(item->email->sent_date, 0);
             char c_time[C_TIME_SIZE];
             strftime(c_time, C_TIME_SIZE, "%a, %d %b %Y %H:%M:%S %z", gmtime(&em_time));
             snprintf(line, sizeof(line), "Date: %s\n", c_time);
--- a/src/pst2ldif.cpp	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/pst2ldif.cpp	Sat Apr 04 16:00:48 2009 -0700
@@ -406,7 +406,7 @@
         printf("%s: %s\n", attr, &buffer[0]);
     }
     else {
-        p = base64_encode(&buffer[0], buffer.size());
+        p = pst_base64_encode(&buffer[0], buffer.size());
         printf("%s:: %s\n", attr, p);
         free(p);
     }
--- a/src/readpst.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/readpst.c	Sat Apr 04 16:00:48 2009 -0700
@@ -406,7 +406,7 @@
                 temp++; // get past the "\\"
         else
             temp++; // get past the "/"
-        item->file_as.str = (char*)xmalloc(strlen(temp)+1);
+        item->file_as.str = (char*)pst_malloc(strlen(temp)+1);
         strcpy(item->file_as.str, temp);
         item->file_as.is_utf8 = 1;
         DEBUG_MAIN(("file_as was blank, so am using %s\n", item->file_as.str));
@@ -766,11 +766,11 @@
     check_filename(f_name);
     if (!attach_filename) {
         // generate our own (dummy) filename for the attachement
-        temp = xmalloc(strlen(f_name)+15);
+        temp = pst_malloc(strlen(f_name)+15);
         sprintf(temp, "%s-attach%i", f_name, attach_num);
     } else {
         // have an attachment name, make sure it's unique
-        temp = xmalloc(strlen(f_name)+strlen(attach_filename)+15);
+        temp = pst_malloc(strlen(f_name)+strlen(attach_filename)+15);
         do {
             if (fp) fclose(fp);
             if (x == 0)
@@ -833,7 +833,7 @@
     DEBUG_ENT("write_inline_attachment");
     DEBUG_EMAIL(("Attachment Size is %"PRIu64", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->i_id));
     if (attach->data.data) {
-        enc = base64_encode (attach->data.data, attach->data.size);
+        enc = pst_base64_encode (attach->data.data, attach->data.size);
         if (!enc) {
             DEBUG_EMAIL(("ERROR base64_encode returned NULL. Must have failed\n"));
             DEBUG_RET();
@@ -1054,8 +1054,8 @@
         // and is now in utf-8.
         size_t rc;
         DEBUG_EMAIL(("Convert %s utf-8 to %s\n", mime, charset));
-        vbuf *newer = vballoc(2);
-        rc = vb_utf8to8bit(newer, body->str, strlen(body->str), charset);
+        vbuf *newer = pst_vballoc(2);
+        rc = pst_vb_utf8to8bit(newer, body->str, strlen(body->str), charset);
         if (rc == (size_t)-1) {
             // unable to convert, change the charset to utf8
             free(newer->b);
@@ -1064,7 +1064,7 @@
         }
         else {
             // null terminate the output string
-            vbgrow(newer, 1);
+            pst_vbgrow(newer, 1);
             newer->b[newer->dlen] = '\0';
             free(body->str);
             body->str = newer->b;
@@ -1078,7 +1078,7 @@
     if (base64) fprintf(f_output, "Content-Transfer-Encoding: base64\n");
     fprintf(f_output, "\n");
     if (base64) {
-        char *enc = base64_encode(body->str, strlen(body->str));
+        char *enc = pst_base64_encode(body->str, strlen(body->str));
         if (enc) {
             write_email_body(f_output, enc);
             fprintf(f_output, "\n");
@@ -1130,7 +1130,7 @@
 
     // convert the sent date if it exists, or set it to a fixed date
     if (item->email->sent_date) {
-        em_time = fileTimeToUnixTime(item->email->sent_date, 0);
+        em_time = pst_fileTimeToUnixTime(item->email->sent_date, 0);
         c_time = ctime(&em_time);
         if (c_time)
             c_time[strlen(c_time)-1] = '\0'; //remove end \n
@@ -1304,12 +1304,12 @@
     }
 
     if (item->email->rtf_compressed.data && save_rtf) {
-        pst_item_attach* attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach));
+        pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach));
         DEBUG_EMAIL(("Adding RTF body as attachment\n"));
         memset(attach, 0, sizeof(pst_item_attach));
         attach->next = item->attach;
         item->attach = attach;
-        attach->data.data         = lzfu_decompress(item->email->rtf_compressed.data, item->email->rtf_compressed.size, &attach->data.size);
+        attach->data.data         = pst_lzfu_decompress(item->email->rtf_compressed.data, item->email->rtf_compressed.size, &attach->data.size);
         attach->filename2.str     = strdup(RTF_ATTACH_NAME);
         attach->filename2.is_utf8 = 1;
         attach->mimetype.str      = strdup(RTF_ATTACH_TYPE);
@@ -1319,9 +1319,9 @@
     if (item->email->encrypted_body.data || item->email->encrypted_htmlbody.data) {
         // if either the body or htmlbody is encrypted, add them as attachments
         if (item->email->encrypted_body.data) {
-            pst_item_attach* attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach));
+            pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach));
             DEBUG_EMAIL(("Adding Encrypted Body as attachment\n"));
-            attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach));
+            attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
             memset(attach, 0, sizeof(pst_item_attach));
             attach->next = item->attach;
             item->attach = attach;
@@ -1331,9 +1331,9 @@
         }
 
         if (item->email->encrypted_htmlbody.data) {
-            pst_item_attach* attach = (pst_item_attach*)xmalloc(sizeof(pst_item_attach));
+            pst_item_attach* attach = (pst_item_attach*)pst_malloc(sizeof(pst_item_attach));
             DEBUG_EMAIL(("Adding encrypted HTML body as attachment\n"));
-            attach = (pst_item_attach*) xmalloc(sizeof(pst_item_attach));
+            attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
             memset(attach, 0, sizeof(pst_item_attach));
             attach->next = item->attach;
             item->attach = attach;
@@ -1614,19 +1614,19 @@
     else if (mode == MODE_SEPARATE) {
         // do similar stuff to recurse here.
         mk_separate_dir(item->file_as.str);
-        f->name = (char*) xmalloc(10);
+        f->name = (char*) pst_malloc(10);
         memset(f->name, 0, 10);
     } else {
-        f->name = (char*) xmalloc(strlen(item->file_as.str)+strlen(OUTPUT_TEMPLATE)+1);
+        f->name = (char*) pst_malloc(strlen(item->file_as.str)+strlen(OUTPUT_TEMPLATE)+1);
         sprintf(f->name, OUTPUT_TEMPLATE, item->file_as.str);
     }
 
-    f->dname = (char*) xmalloc(strlen(item->file_as.str)+1);
+    f->dname = (char*) pst_malloc(strlen(item->file_as.str)+1);
     strcpy(f->dname, item->file_as.str);
 
     if (overwrite != 1) {
         int x = 0;
-        char *temp = (char*) xmalloc (strlen(f->name)+10); //enough room for 10 digits
+        char *temp = (char*) pst_malloc (strlen(f->name)+10); //enough room for 10 digits
 
         sprintf(temp, "%s", f->name);
         check_filename(temp);
--- a/src/readpstlog.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/readpstlog.c	Sat Apr 04 16:00:48 2009 -0700
@@ -63,7 +63,7 @@
         return 4;
     }
 
-    buf = (char*) xmalloc(BUF_SIZE);
+    buf = (char*) pst_malloc(BUF_SIZE);
 
     while (!stop) {
         int64_t temp;
@@ -213,7 +213,7 @@
     while ((tmp = strchr(tmp, ',')) != NULL) {
         tmp++; count++;
     }
-    *targ = (int*)xmalloc(count * sizeof(int));
+    *targ = (int*)pst_malloc(count * sizeof(int));
     i = *targ; // for convienience
     tmp = args;
     z = 0;
--- a/src/testdebug.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/testdebug.c	Sat Apr 04 16:00:48 2009 -0700
@@ -3,7 +3,7 @@
 #define BUF_SIZE 100000
 
 int main(int argc, const char** argv) {
-  char *x = xmalloc(BUF_SIZE); // 10k
+  char *x = pst_malloc(BUF_SIZE); // 10k
   memset(x, '.', BUF_SIZE-1);
   x[BUF_SIZE-2]='P';
   x[BUF_SIZE-1]='\0';
--- a/src/timeconv.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/timeconv.c	Sat Apr 04 16:00:48 2009 -0700
@@ -15,17 +15,17 @@
 
 #include "define.h"
 
-char * fileTimeToAscii (const FILETIME *filetime) {
-  time_t t1;
+char * pst_fileTimeToAscii (const FILETIME *filetime) {
+    time_t t1;
 
-  t1 = fileTimeToUnixTime(filetime, NULL);
-  return ctime(&t1);
+    t1 = pst_fileTimeToUnixTime(filetime, NULL);
+    return ctime(&t1);
 }
 
-struct tm * fileTimeToStructTM (const FILETIME *filetime) {
-  time_t t1;
-  t1 = fileTimeToUnixTime(filetime, NULL);
-  return gmtime(&t1);
+struct tm * pst_fileTimeToStructTM (const FILETIME *filetime) {
+    time_t t1;
+    t1 = pst_fileTimeToUnixTime(filetime, NULL);
+    return gmtime(&t1);
 }
 
 /***********************************************************************
@@ -35,7 +35,7 @@
  * If not NULL, 'remainder' contains the fractional part of the filetime,
  * in the range of [0..9999999] (even if time_t is negative).
  */
-time_t fileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder )
+time_t pst_fileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder )
 {
     /* Read the comment in the function DOSFS_UnixTimeToFileTime. */
 #if USE_LONG_LONG
--- a/src/timeconv.h	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/timeconv.h	Sat Apr 04 16:00:48 2009 -0700
@@ -6,9 +6,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-    time_t fileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
-    char * fileTimeToAscii (const FILETIME *filetime);
-    struct tm * fileTimeToStructTM (const FILETIME *filetime);
+    time_t pst_fileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
+    char * pst_fileTimeToAscii (const FILETIME *filetime);
+    struct tm * pst_fileTimeToStructTM (const FILETIME *filetime);
 #ifdef __cplusplus
 }
 #endif
--- a/src/vbuf.c	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/vbuf.c	Sat Apr 04 16:00:48 2009 -0700
@@ -5,7 +5,7 @@
 #define ASSERT(x,...) { if( !(x) ) DIE(( __VA_ARGS__)); }
 
 
-int skip_nl(char *s)
+int pst_skip_nl(char *s)
 {
     if (s[0] == '\n')
         return 1;
@@ -17,7 +17,7 @@
 }
 
 
-int find_nl(vstr * vs)
+int pst_find_nl(vstr * vs)
 {
     char *nextr, *nextn;
 
@@ -49,9 +49,9 @@
 static iconv_t     target2i8  = (iconv_t)-1;
 
 
-void unicode_init()
+void pst_unicode_init()
 {
-    if (unicode_up) unicode_close();
+    if (unicode_up) pst_unicode_close();
     i16to8 = iconv_open("utf-8", "utf-16le");
     if (i16to8 == (iconv_t)-1) {
         WARN(("Couldn't open iconv descriptor for utf-16le to utf-8.\n"));
@@ -61,7 +61,7 @@
 }
 
 
-void unicode_close()
+void pst_unicode_close()
 {
     iconv_close(i16to8);
     if (target_open_from) iconv_close(i8totarget);
@@ -74,7 +74,8 @@
 }
 
 
-int utf16_is_terminated(const char *str, int length)
+static int utf16_is_terminated(const char *str, int length);
+static int utf16_is_terminated(const char *str, int length)
 {
     VSTR_STATIC(errbuf, 100);
     int len = -1;
@@ -86,7 +87,7 @@
     }
 
     if (-1 == len) {
-        vshexdump(errbuf, str, 0, length, 1);
+        pst_vshexdump(errbuf, str, 0, length, 1);
         DEBUG_WARN(("String is not zero terminated (probably broken data from registry) %s.\n", errbuf->b));
     }
 
@@ -94,7 +95,7 @@
 }
 
 
-size_t vb_utf16to8(vbuf *dest, const char *inbuf, int iblen)
+size_t pst_vb_utf16to8(vbuf *dest, const char *inbuf, int iblen)
 {
     size_t inbytesleft  = iblen;
     size_t icresult     = (size_t)-1;
@@ -103,7 +104,7 @@
     int   myerrno;
 
     ASSERT(unicode_up, "vb_utf16to8() called before unicode started.");
-    vbresize(dest, iblen);
+    pst_vbresize(dest, iblen);
 
     //Bad Things can happen if a non-zero-terminated utf16 string comes through here
     if (!utf16_is_terminated(inbuf, iblen))
@@ -115,12 +116,12 @@
         icresult = iconv(i16to8, (ICONV_CONST char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
         myerrno  = errno;
         dest->dlen = outbuf - dest->b;
-        if (inbytesleft) vbgrow(dest, inbytesleft);
+        if (inbytesleft) pst_vbgrow(dest, inbytesleft);
     } while ((size_t)-1 == icresult && E2BIG == myerrno);
 
     if (icresult == (size_t)-1) {
         DEBUG_WARN(("iconv failure: %s\n", strerror(myerrno)));
-        unicode_init();
+        pst_unicode_init();
         return (size_t)-1;
     }
     return (icresult) ? (size_t)-1 : 0;
@@ -160,7 +161,7 @@
     char *outbuf        = NULL;
     int   myerrno;
 
-    vbresize(dest, 2*iblen);
+    pst_vbresize(dest, 2*iblen);
 
     do {
         outbytesleft = dest->blen - dest->dlen;
@@ -168,19 +169,19 @@
         icresult = iconv(conversion, (ICONV_CONST char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
         myerrno  = errno;
         dest->dlen = outbuf - dest->b;
-        if (inbytesleft) vbgrow(dest, 2*inbytesleft);
+        if (inbytesleft) pst_vbgrow(dest, 2*inbytesleft);
     } while ((size_t)-1 == icresult && E2BIG == myerrno);
 
     if (icresult == (size_t)-1) {
         DEBUG_WARN(("iconv failure: %s\n", strerror(myerrno)));
-        unicode_init();
+        pst_unicode_init();
         return (size_t)-1;
     }
     return (icresult) ? (size_t)-1 : 0;
 }
 
 
-size_t vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset)
+size_t pst_vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset)
 {
     open_targets(charset);
     if (!target_open_from) return (size_t)-1;   // failure to open the target
@@ -188,7 +189,7 @@
 }
 
 
-size_t vb_8bit2utf8(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)
 {
     open_targets(charset);
     if (!target_open_to) return (size_t)-1;     // failure to open the target
@@ -196,21 +197,21 @@
 }
 
 
-vbuf *vballoc(size_t len)
+vbuf *pst_vballoc(size_t len)
 {
     struct varbuf *result = malloc(sizeof(struct varbuf));
     if (result) {
         result->dlen = 0;
         result->blen = 0;
         result->buf = NULL;
-        vbresize(result, len);
+        pst_vbresize(result, len);
     }
     else DIE(("malloc() failure"));
     return result;
 }
 
 
-void vbcheck(vbuf * vb)
+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.");
@@ -219,20 +220,20 @@
 }
 
 
-void vbfree(vbuf * vb)
+void pst_vbfree(vbuf * vb)
 {
     free(vb->buf);
     free(vb);
 }
 
 
-void vbclear(struct varbuf *vb) // ditch the data, keep the buffer
+void pst_vbclear(struct varbuf *vb) // ditch the data, keep the buffer
 {
-    vbresize(vb, 0);
+    pst_vbresize(vb, 0);
 }
 
 
-void vbresize(struct varbuf *vb, size_t len)    // DESTRUCTIVELY grow or shrink buffer
+void pst_vbresize(struct varbuf *vb, size_t len)    // DESTRUCTIVELY grow or shrink buffer
 {
     vb->dlen = 0;
 
@@ -247,26 +248,26 @@
 }
 
 
-size_t vbavail(vbuf * vb)
+size_t pst_vbavail(vbuf * vb)
 {
     return vb->blen  - vb->dlen - (size_t)(vb->b - vb->buf);
 }
 
 
-void vbgrow(struct varbuf *vb, size_t len)      // out: vbavail(vb) >= len, data are preserved
+void pst_vbgrow(struct varbuf *vb, size_t len)      // out: vbavail(vb) >= len, data are preserved
 {
     if (0 == len)
         return;
 
     if (0 == vb->blen) {
-        vbresize(vb, len);
+        pst_vbresize(vb, len);
         return;
     }
 
     if (vb->dlen + len > vb->blen) {
         if (vb->dlen + len < vb->blen * 1.5)
             len = vb->blen * 1.5;
-        char *nb = malloc(vb->blen + len);
+        char *nb = pst_malloc(vb->blen + len);
         if (!nb) DIE(("malloc() failure"));
         vb->blen = vb->blen + len;
         memcpy(nb, vb->b, vb->dlen);
@@ -281,43 +282,43 @@
 
     vb->b = vb->buf;
 
-    ASSERT(vbavail(vb) >= len, "vbgrow(): I have failed in my mission.");
+    ASSERT(pst_vbavail(vb) >= len, "vbgrow(): I have failed in my mission.");
 }
 
 
-void vbset(vbuf * vb, void *b, size_t len)      // set vbuf b size=len, resize if necessary, relen = how much to over-allocate
+void pst_vbset(vbuf * vb, void *b, size_t len)      // set vbuf b size=len, resize if necessary, relen = how much to over-allocate
 {
-    vbresize(vb, len);
+    pst_vbresize(vb, len);
     memcpy(vb->b, b, len);
     vb->dlen = len;
 }
 
 
-void vsskipws(vstr * vs)
+void pst_vsskipws(vstr * vs)
 {
     char *p = vs->b;
     while ((size_t)(p - vs->b) < vs->dlen && isspace(p[0]))
         p++;
 
-    vbskip((vbuf *) vs, p - vs->b);
+    pst_vbskip((vbuf *) vs, p - vs->b);
 }
 
 
 // append len bytes of b to vbuf, resize if necessary
-void vbappend(struct varbuf *vb, void *b, size_t len)
+void pst_vbappend(struct varbuf *vb, void *b, size_t len)
 {
     if (0 == vb->dlen) {
-        vbset(vb, b, len);
+        pst_vbset(vb, b, len);
         return;
     }
-    vbgrow(vb, len);
+    pst_vbgrow(vb, len);
     memcpy(vb->b + vb->dlen, b, len);
     vb->dlen += len;
 }
 
 
 // dumps the first skip bytes from vbuf
-void vbskip(struct varbuf *vb, size_t skip)
+void pst_vbskip(struct varbuf *vb, size_t skip)
 {
     ASSERT(skip <= vb->dlen, "vbskip(): Attempt to seek past end of buffer.");
     vb->b += skip;
@@ -326,44 +327,45 @@
 
 
 // overwrite vbdest with vbsrc
-void vboverwrite(struct varbuf *vbdest, struct varbuf *vbsrc)
+void pst_vboverwrite(struct varbuf *vbdest, struct varbuf *vbsrc)
 {
-    vbresize(vbdest, vbsrc->blen);
+    pst_vbresize(vbdest, vbsrc->blen);
     memcpy(vbdest->b, vbsrc->b, vbsrc->dlen);
     vbdest->blen = vbsrc->blen;
     vbdest->dlen = vbsrc->dlen;
 }
 
 
-vstr *vsalloc(size_t len)
+vstr *pst_vsalloc(size_t len)
 {
-    vstr *result = (vstr *) vballoc(len + 1);
-    vsset(result, "");
+    vstr *result = (vstr *) pst_vballoc(len + 1);
+    pst_vsset(result, "");
     return result;
 }
 
 
-char *vsstr(vstr * vs)
+static char *pst_vsstr(vstr * vs);
+static char *pst_vsstr(vstr * vs)
 {
     return vs->b;
 }
 
 
-size_t vslen(vstr * vs)
+size_t pst_vslen(vstr * vs)
 {
-    return strlen(vsstr(vs));
+    return strlen(pst_vsstr(vs));
 }
 
 
-void vsfree(vstr * vs)
+void pst_vsfree(vstr * vs)
 {
-    vbfree((vbuf *) vs);
+    pst_vbfree((vbuf *) vs);
 }
 
 
-void vscharcat(vstr * vb, int ch)
+void pst_vscharcat(vstr * vb, int ch)
 {
-    vbgrow((vbuf *) vb, 1);
+    pst_vbgrow((vbuf *) vb, 1);
     vb->b[vb->dlen - 1] = ch;
     vb->b[vb->dlen] = '\0';
     vb->dlen++;
@@ -371,12 +373,12 @@
 
 
 // prependappend string str to vbuf, vbuf must already contain a valid string
-void vsnprepend(vstr * vb, char *str, size_t len)
+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);
     size_t n = (sl < len) ? sl : len;
-    vbgrow((vbuf *) vb, n + 1);
+    pst_vbgrow((vbuf *) vb, n + 1);
     memmove(vb->b + n, vb->b, vb->dlen - 1);
     memcpy(vb->b, str, n);
     vb->dlen += n;
@@ -385,18 +387,18 @@
 
 
 // len < dlen-1 -> skip len chars, else DIE
-void vsskip(vstr * vs, size_t len)
+void pst_vsskip(vstr * vs, size_t len)
 {
     ASSERT(len < vs->dlen - 1, "Attempt to skip past end of string");
-    vbskip((vbuf *) vs, len);
+    pst_vbskip((vbuf *) vs, len);
 }
 
 
 // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
-int vsskipline(vstr * vs)
+int pst_vsskipline(vstr * vs)
 {
-    int nloff = find_nl(vs);
-    int nll   = skip_nl(vs->b + nloff);
+    int nloff = pst_find_nl(vs);
+    int nll   = pst_skip_nl(vs->b + nloff);
 
     if (nloff < 0) {
         //TODO: error
@@ -417,7 +419,7 @@
 }
 
 
-int vscatprintf(vstr * vs, char *fmt, ...)
+int pst_vscatprintf(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
@@ -425,7 +427,7 @@
     /* Guess we need no more than 100 bytes. */
     //vsresize( vb, 100 );
     if (!vs->b || vs->dlen == 0) {
-        vsset(vs, "");
+        pst_vsset(vs, "");
     }
 
     while (1) {
@@ -441,15 +443,15 @@
         }
         /* Else try again with more space. */
         if (size >= 0)          /* glibc 2.1 */
-            vbgrow((vbuf *) vs, size + 1);      /* precisely what is needed */
+            pst_vbgrow((vbuf *) vs, size + 1);      /* precisely what is needed */
         else                    /* glibc 2.0 */
-            vbgrow((vbuf *) vs, vs->blen);
+            pst_vbgrow((vbuf *) vs, vs->blen);
     }
 }
 
 
 //  returns the last character stored in a vstr
-int vslast(vstr * vs)
+int pst_vslast(vstr * vs)
 {
     if (vs->dlen < 1)
         return -1;
@@ -462,13 +464,13 @@
 
 
 //  print over vb
-void vs_printf(vstr * vs, char *fmt, ...)
+void pst_vs_printf(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
 
     /* Guess we need no more than 100 bytes. */
-    vbresize((vbuf *) vs, 100);
+    pst_vbresize((vbuf *) vs, 100);
 
     while (1) {
         /* Try to print in the allocated space. */
@@ -483,21 +485,21 @@
         }
         /* Else try again with more space. */
         if (size >= 0)          /* glibc 2.1 */
-            vbresize((vbuf *) vs, size + 1);    /* precisely what is needed */
+            pst_vbresize((vbuf *) vs, size + 1);    /* precisely what is needed */
         else                    /* glibc 2.0 */
-            vbresize((vbuf *) vs, vs->blen * 2);
+            pst_vbresize((vbuf *) vs, vs->blen * 2);
     }
 }
 
 
 // printf append to vs
-void vs_printfa(vstr * vs, char *fmt, ...)
+void pst_vs_printfa(vstr * vs, char *fmt, ...)
 {
     int size;
     va_list ap;
 
     if (vs->blen - vs->dlen < 50)
-        vbgrow((vbuf *) vs, 100);
+        pst_vbgrow((vbuf *) vs, 100);
 
     while (1) {
         /* Try to print in the allocated space. */
@@ -512,14 +514,14 @@
         }
         /* Else try again with more space. */
         if (size >= 0)          /* glibc 2.1 */
-            vbgrow((vbuf *) vs, size + 1 - vs->dlen);   /* precisely what is needed */
+            pst_vbgrow((vbuf *) vs, size + 1 - vs->dlen);   /* precisely what is needed */
         else                    /* glibc 2.0 */
-            vbgrow((vbuf *) vs, size);
+            pst_vbgrow((vbuf *) vs, size);
     }
 }
 
 
-void vshexdump(vstr * vs, const char *b, size_t start, size_t stop, int ascii)
+void pst_vshexdump(vstr * vs, const char *b, size_t start, size_t stop, int ascii)
 {
     char c;
     int diff, i;
@@ -529,57 +531,57 @@
         if (diff > 16)
             diff = 16;
 
-        vs_printfa(vs, ":%08X  ", start);
+        pst_vs_printfa(vs, ":%08X  ", start);
 
         for (i = 0; i < diff; i++) {
             if (8 == i)
-                vs_printfa(vs, " ");
-            vs_printfa(vs, "%02X ", (unsigned char) *(b + start + i));
+                pst_vs_printfa(vs, " ");
+            pst_vs_printfa(vs, "%02X ", (unsigned char) *(b + start + i));
         }
         if (ascii) {
             for (i = diff; i < 16; i++)
-                vs_printfa(vs, "   ");
+                pst_vs_printfa(vs, "   ");
             for (i = 0; i < diff; i++) {
                 c = *(b + start + i);
-                vs_printfa(vs, "%c", isprint(c) ? c : '.');
+                pst_vs_printfa(vs, "%c", isprint(c) ? c : '.');
             }
         }
-        vs_printfa(vs, "\n");
+        pst_vs_printfa(vs, "\n");
         start += 16;
     }
 }
 
 
-void vsset(vstr * vs, char *s)  // Store string s in vs
+void pst_vsset(vstr * vs, char *s)  // Store string s in vs
 {
-    vsnset(vs, s, strlen(s));
+    pst_vsnset(vs, s, strlen(s));
 }
 
 
-void vsnset(vstr * vs, char *s, size_t n)       // Store string s in vs
+void pst_vsnset(vstr * vs, char *s, size_t n)       // Store string s in vs
 {
-    vbresize((vbuf *) vs, n + 1);
+    pst_vbresize((vbuf *) vs, n + 1);
     memcpy(vs->b, s, n);
     vs->b[n] = '\0';
     vs->dlen = n + 1;
 }
 
 
-void vsgrow(vstr * vs, size_t len)      // grow buffer by len bytes, data are preserved
+void pst_vsgrow(vstr * vs, size_t len)      // grow buffer by len bytes, data are preserved
 {
-    vbgrow((vbuf *) vs, len);
+    pst_vbgrow((vbuf *) vs, len);
 }
 
 
-size_t vsavail(vstr * vs)
+size_t pst_vsavail(vstr * vs)
 {
-    return vbavail((vbuf *) vs);
+    return pst_vbavail((vbuf *) vs);
 }
 
 
-void vsnset16(vstr * vs, char *s, size_t len)   // Like vbstrnset, but for UTF16
+void pst_vsnset16(vstr * vs, char *s, size_t len)   // Like vbstrnset, but for UTF16
 {
-    vbresize((vbuf *) vs, len + 1);
+    pst_vbresize((vbuf *) vs, len + 1);
     memcpy(vs->b, s, len);
 
     vs->b[len] = '\0';
@@ -588,32 +590,32 @@
 }
 
 
-void vscat(vstr * vs, char *str)
+void pst_vscat(vstr * vs, char *str)
 {
-    vsncat(vs, str, strlen(str));
+    pst_vsncat(vs, str, strlen(str));
 }
 
 
-int vscmp(vstr * vs, char *str)
+int pst_vscmp(vstr * vs, char *str)
 {
     return strcmp(vs->b, str);
 }
 
 
-void vsncat(vstr * vs, char *str, size_t len)   // append string str to vstr, vstr must already contain a valid string
+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);
     size_t n = (sl < len) ? sl : len;
     //string append
-    vbgrow((vbuf *) vs, n + 1);
+    pst_vbgrow((vbuf *) vs, n + 1);
     memcpy(vs->b + vs->dlen - 1, str, n);
     vs->dlen += n;
     vs->b[vs->dlen - 1] = '\0';
 }
 
 
-void vstrunc(vstr * v, size_t off) // Drop chars [off..dlen]
+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	Sun Mar 29 08:51:13 2009 -0700
+++ b/src/vbuf.h	Sat Apr 04 16:00:48 2009 -0700
@@ -39,58 +39,58 @@
 typedef struct varbuf vbuf;
 typedef struct varstr vstr;
 
-#define VBUF_STATIC(x,y) static vbuf *x = NULL; if(!x) x = vballoc(y);
-#define VSTR_STATIC(x,y) static vstr *x = NULL; if(!x) x = vsalloc(y);
+#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 skip_nl( char *s );  // returns the width of the newline at s[0]
-int find_nl( vstr *vs ); // find newline of type type in b
+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
-struct varbuf *vballoc( size_t len );
-void vbfree(      vbuf *vb );
-void vbclear(     vbuf *vb ); //ditch the data, keep the buffer
-void vbresize(    vbuf *vb, size_t len );
-size_t vbavail(   vbuf *vb );
-void vbdump(      vbuf *vb );
-void vbgrow(      vbuf *vb, size_t len ); // grow buffer by len bytes, data are preserved
-void vbset(       vbuf *vb, void *data, size_t len );
-void vbskipws(    vbuf *vb );
-void vbappend(    vbuf *vb, void *data, size_t length );
-void vbskip(      vbuf *vb, size_t skip );
-void vboverwrite( vbuf *vbdest, vbuf *vbsrc );
+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 *vsalloc( size_t len );
-char *vsb(      vstr *vs );
-size_t vslen(     vstr *vs ); //strlen
-void vsfree(      vstr *vs );
-void vsset(       vstr *vs, char *s ); // Store string s in vb
-void vsnset(      vstr *vs, char *s, size_t n ); // Store string s in vb
-void vsgrow(      vstr *vs, size_t len ); // grow buffer by len bytes, data are preserved
-size_t vsavail(   vstr *vs );
-void vscat(       vstr *vs, char *str );
-void vsncat(      vstr *vs, char *str, size_t len );
-void vsnprepend(  vstr *vs, char *str, size_t len ) ;
-void vsskip(      vstr *vs, size_t len );
-int  vscmp(       vstr *vs, char *str );
-void vsskipws(    vstr *vs );
-void vs_printf(   vstr *vs, char *fmt, ... );
-void vs_printfa(  vstr *vs, char *fmt, ... );
-void vshexdump(   vstr *vs, const char *b, size_t start, size_t stop, int ascii );
-int  vscatprintf( vstr *vs, char *fmt, ... );
-void vsvprintf(   vstr *vs, char *fmt, va_list ap );
-void vstrunc(     vstr *vs, size_t off ); // Drop chars [off..dlen]
-int  vslast(      vstr *vs ); // returns the last character stored in a vstr string
-void vscharcat(   vstr *vs, int ch );
+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 unicode_init();
-void unicode_close();
-size_t vb_utf16to8(vbuf *dest, const char *inbuf, int iblen);
-size_t vb_utf8to8bit(vbuf *dest, const char *inbuf, int iblen, const char* charset);
-size_t vb_8bit2utf8(vbuf *dest, const char *inbuf, int iblen, const char* charset);
+void pst_unicode_init();
+void pst_unicode_close();
+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 vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
+int pst_vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff"
 
 
 #endif // VBUF_H