diff --git a/Makefile.am b/Makefile.am index f004cc6..7e8c026 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,11 @@ -SUBDIRS = src man html info debian src/libpst +SUBDIRS = src man html info debian htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@ html_DATA = AUTHORS COPYING ChangeLog NEWS README CLEANFILES = xml/libpst xml/Makefile EXTRA_DIST = Doxyfile libpst.html.tar.gz libpst.spec $(wildcard xml/M*) $(wildcard xml/h*) $(wildcard xml/lib*) if !STATIC_TOOLS pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libpst.pc endif diff --git a/configure.in b/configure.in index ecd5c53..7d47555 100644 --- a/configure.in +++ b/configure.in @@ -1,269 +1,268 @@ AC_PREREQ(2.59) AC_INIT(libpst,0.6.26,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([src/libpst.c]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE AC_CANONICAL_HOST # Check for win32 which needs iconv library specified on the link line AC_MSG_CHECKING([for Win32]) case "$host" in *-mingw*) os_win32=yes ;; *) os_win32=no ;; esac AC_MSG_RESULT($os_win32) AM_CONDITIONAL(OS_WIN32, [test "$os_win32" = "yes"]) # Check for Win32 platform AC_MSG_CHECKING([for Win32 platform in general]) case "$host" in *-cygwin*) platform_win32=yes ;; *) platform_win32=$os_win32 ;; esac AC_MSG_RESULT($platform_win32) AM_CONDITIONAL(PLATFORM_WIN32, [test "$platform_win32" = "yes"]) # Checks for programs. # The following lines adds the --enable-dii option to configure: # # Give the user the choice to enter one of these: # --enable-dii # --enable-dii=yes # --enable-dii=no # AC_MSG_CHECKING([whether we are enabling dii utility]) AC_ARG_ENABLE(dii, AC_HELP_STRING([--enable-dii], [enable dii utility]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-dii) ;; esac ], # default if not specified enable_dii=yes ) AC_MSG_RESULT([$enable_dii]) AC_PATH_PROG(CONVERT, convert) if test "x$CONVERT" = "x" ; then if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([convert program not found. pst2dii disabled]) fi else if test "x`$CONVERT --version 2>&1 | grep -i imagemagick >/dev/null ; echo $?`" != "x0"; then if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([wrong convert program found. pst2dii disabled]) fi fi fi AC_CHECK_HEADER([gd.h], [ AC_DEFINE([HAVE_GD_H], [1], [Define to 1 if you have the header file.]) ], [ if test "$enable_dii" = "yes"; then enable_dii=no AC_MSG_WARN([gd.h not found. pst2dii disabled]) fi ]) AM_CONDITIONAL(BUILD_DII, [test "$enable_dii" = "yes"]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_LIBTOOL AC_PROG_MAKE_SET AC_PROG_RANLIB # make sure we get large file support AC_SYS_LARGEFILE AC_CHECK_SIZEOF(off_t) # Checks for header files. AC_CHECK_HEADER([unistd.h], AM_CONDITIONAL(NEED_XGETOPT, [test yes = no]), AM_CONDITIONAL(NEED_XGETOPT, [test yes = yes]) ) AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h iconv.h inttypes.h limits.h regex.h signal.h stdarg.h stdint.h stdio.h stdlib.h string.h sys/param.h sys/stat.h sys/types.h time.h unistd.h wchar.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_STRUCT_TM # Checks for library functions. AC_FUNC_FSEEKO AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK if test "$cross_compiling" != "yes"; then AC_FUNC_MALLOC AC_FUNC_MKTIME AC_FUNC_REALLOC fi AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_CHECK_FUNCS([memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol]) # iconv on mac is a library SAVELIBS="$LIBS" AC_SEARCH_LIBS([iconv_open], [iconv]) if test "$SAVELIBS" != "$LIBS"; then all_libraries="-L/usr/lib $all_libraries" AC_SUBST(all_libraries) AC_MSG_WARN([This should be building on Mac OSX, adding /usr/lib to the library path]) fi AC_MSG_CHECKING([if iconv uses const arguments]) AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([ #include #include int main(int argc, char* const* argv) { size_t inlen = 100; char buffer[[inlen]]; char *p = buffer; size_t utf8_len = 2 * inlen + 1; char utf8_buffer[[utf8_len]]; char *utf8_p = utf8_buffer; iconv_t cd = 0; iconv(cd, (const char**)&p, &inlen, &utf8_p, &utf8_len); } ], [AC_DEFINE(ICONV_CONST,const,[do we have const headers]) AC_MSG_RESULT([yes]) ], [AC_DEFINE(ICONV_CONST,,[do we have const headers]) AC_MSG_RESULT([no]) ]) AC_LANG_POP([C++]) # The following lines adds the --enable-pst-debug option to configure: # # Give the user the choice to enter one of these: # --enable-pst-debug # --enable-pst-debug=yes # --enable-pst-debug=no # AC_MSG_CHECKING([whether we are forcing debug dump file creation]) AC_ARG_ENABLE(pst-debug, AC_HELP_STRING([--enable-pst-debug], [force debug dump file creation]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-pst-debug) ;; esac ], # default if not specified enable_pst_debug=no ) AC_MSG_RESULT([$enable_pst_debug]) if test "$enable_pst_debug" = "yes"; then AC_DEFINE(DEBUG_ALL, 1, Define to 1 to force debug dump file creation) fi # The following lines adds the --enable-libpst-shared option to configure: # # Give the user the choice to enter one of these: # --enable-libpst-shared # --enable-libpst-shared=yes # --enable-libpst-shared=no # AC_MSG_CHECKING([whether we are building libpst shared object]) AC_ARG_ENABLE(libpst-shared, AC_HELP_STRING([--enable-libpst-shared], [build libpst shared object]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-libpst-shared) ;; esac ], # default if not specified enable_libpst_shared=no ) AC_MSG_RESULT([$enable_libpst_shared]) enable_static_tools=yes if test "$enable_libpst_shared" = "yes"; then enable_shared=yes enable_static_tools=no fi # needed by STATIC_TOOLS in src/Makefile.am AC_SUBST(PST_OBJDIR, [$objdir]) # The following lines adds the --enable-static-tools option to configure: # # Give the user the choice to enter one of these: # --enable-static-tools # --enable-static-tools=yes # --enable-static-tools=no # AC_MSG_CHECKING([whether to link command line tools with libpst statically]) AC_ARG_ENABLE([static-tools], AC_HELP_STRING([--enable-static-tools], [link command line tools with libpst statically]), [ case "${enableval}" in yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${enableval} for --static-tools) ;; esac ], [ enable_static_tools=no ]) AC_MSG_RESULT([$enable_static_tools]) AM_CONDITIONAL(STATIC_TOOLS, [test "$enable_static_tools" = "yes"]) if test "$enable_static_tools" = "yes"; then enable_static="yes" fi AC_OUTPUT( \ Makefile \ debian/Makefile \ debian/changelog \ html/Makefile \ info/Makefile \ libpst.pc \ libpst.spec \ man/Makefile \ src/Makefile \ - src/libpst/Makefile \ src/pst2dii.cpp \ xml/Makefile \ xml/libpst \ ) diff --git a/src/Makefile.am b/src/Makefile.am index 1b31295..120b3f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,92 +1,104 @@ if PLATFORM_WIN32 ICONVLIB = -liconv NO_UNDEFINED = -no-undefined else ICONVLIB = NO_UNDEFINED = endif if STATIC_TOOLS PSTLIB = @PST_OBJDIR@/libpst.a else PSTLIB = libpst.la endif common_header = common.h \ define.h \ libpst.h \ libstrfunc.h \ lzfu.h \ timeconv.h \ vbuf.h common_source = debug.c \ libpst.c \ libstrfunc.c \ lzfu.c \ timeconv.c \ vbuf.c + if NEED_XGETOPT common_source += XGetopt.c common_header += XGetopt.h endif noinst_PROGRAMS = deltasearch dumpblocks getidblock bin_PROGRAMS = lspst readpst readpstlog pst2ldif if BUILD_DII bin_PROGRAMS += pst2dii endif -lspst_SOURCES = lspst.c $(common_header) -readpst_SOURCES = readpst.c $(common_header) -readpstlog_SOURCES = readpstlog.c $(common_header) -pst2ldif_SOURCES = pst2ldif.cpp $(common_header) -pst2dii_SOURCES = pst2dii.cpp $(common_header) -deltasearch_SOURCES = deltasearch.cpp $(common_header) -dumpblocks_SOURCES = dumpblocks.c $(common_header) -getidblock_SOURCES = getidblock.c $(common_header) +lspst_SOURCES = lspst.c $(common_header) +readpst_SOURCES = readpst.c $(common_header) +readpstlog_SOURCES = readpstlog.c $(common_header) +pst2ldif_SOURCES = pst2ldif.cpp $(common_header) +pst2dii_SOURCES = pst2dii.cpp $(common_header) +deltasearch_SOURCES = deltasearch.cpp $(common_header) +dumpblocks_SOURCES = dumpblocks.c $(common_header) +getidblock_SOURCES = getidblock.c $(common_header) lspst_CFLAGS = $(AM_CFLAGS) readpst_CFLAGS = $(AM_CFLAGS) readpstlog_CFLAGS = $(AM_CFLAGS) pst2ldif_CFLAGS = $(AM_CFLAGS) pst2dii_CFLAGS = $(AM_CFLAGS) deltasearch_CFLAGS = $(AM_CFLAGS) dumpblocks_CFLAGS = $(AM_CFLAGS) getidblock_CFLAGS = $(AM_CFLAGS) +lspst_DEPENDENCIES = libpst.la +readpst_DEPENDENCIES = libpst.la +readpstlog_DEPENDENCIES = libpst.la +pst2ldif_DEPENDENCIES = libpst.la +pst2dii_DEPENDENCIES = libpst.la +deltasearch_DEPENDENCIES = libpst.la +dumpblocks_DEPENDENCIES = libpst.la +getidblock_DEPENDENCIES = libpst.la + if STATIC_TOOLS noinst_LTLIBRARIES = libpst.la else lib_LTLIBRARIES = libpst.la libpstincludedir = $(includedir)/libpst libpstinclude_HEADERS = \ common.h \ libpst.h \ libstrfunc.h\ timeconv.h \ vbuf.h libpst_la_LDFLAGS = $(NO_UNDEFINED) -version-info 1:0:0 endif libpst_la_SOURCES = $(common_source) $(common_header) libpst_la_LIBADD = $(ICONVLIB) EXTRA_DIST = testdebug.c if !NEED_XGETOPT EXTRA_DIST += XGetopt.c XGetopt.h endif # set the include path found by configure INCLUDES= -I$(srcdir)/.. $(all_includes) # the library search path. lspst_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) readpst_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) readpstlog_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) pst2ldif_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) pst2dii_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) -lgd dumpblocks_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) getidblock_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(ICONVLIB) + + diff --git a/src/libpst.h b/src/libpst.h index 30cd6c5..a0bda55 100644 --- a/src/libpst.h +++ b/src/libpst.h @@ -1,592 +1,592 @@ /*** * libpst.h * Part of LibPST project * Written by David Smith * dave.s@earthcorp.com */ // LibPST - Library for Accessing Outlook .pst files // Dave Smith - davesmith@users.sourceforge.net #ifndef LIBPST_H #define LIBPST_H -#include +#include "common.h" // switch to maximal packing for all structures in the libpst interface // this is reverted at the end of this file #ifdef _MSC_VER #pragma pack(push, 1) #endif #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) #pragma pack(1) #endif #define PST_TYPE_NOTE 1 #define PST_TYPE_APPOINTMENT 8 #define PST_TYPE_CONTACT 9 #define PST_TYPE_JOURNAL 10 #define PST_TYPE_STICKYNOTE 11 #define PST_TYPE_TASK 12 #define PST_TYPE_OTHER 13 #define PST_TYPE_REPORT 14 // defines whether decryption is done on this bit of data #define PST_NO_ENC 0 #define PST_ENC 1 // defines types of possible encryption #define PST_NO_ENCRYPT 0 #define PST_COMP_ENCRYPT 1 #define PST_ENCRYPT 2 // defines different types of mappings #define PST_MAP_ATTRIB (uint32_t)1 #define PST_MAP_HEADER (uint32_t)2 // define my custom email attributes. #define PST_ATTRIB_HEADER -1 // defines types of free/busy values for appointment->showas #define PST_FREEBUSY_FREE 0 #define PST_FREEBUSY_TENTATIVE 1 #define PST_FREEBUSY_BUSY 2 #define PST_FREEBUSY_OUT_OF_OFFICE 3 // defines labels for appointment->label #define PST_APP_LABEL_NONE 0 // None #define PST_APP_LABEL_IMPORTANT 1 // Important #define PST_APP_LABEL_BUSINESS 2 // Business #define PST_APP_LABEL_PERSONAL 3 // Personal #define PST_APP_LABEL_VACATION 4 // Vacation #define PST_APP_LABEL_MUST_ATTEND 5 // Must Attend #define PST_APP_LABEL_TRAVEL_REQ 6 // Travel Required #define PST_APP_LABEL_NEEDS_PREP 7 // Needs Preparation #define PST_APP_LABEL_BIRTHDAY 8 // Birthday #define PST_APP_LABEL_ANNIVERSARY 9 // Anniversary #define PST_APP_LABEL_PHONE_CALL 10// Phone Call // define type of reccuring event #define PST_APP_RECUR_NONE 0 #define PST_APP_RECUR_DAILY 1 #define PST_APP_RECUR_WEEKLY 2 #define PST_APP_RECUR_MONTHLY 3 #define PST_APP_RECUR_YEARLY 4 typedef struct pst_misc_6_struct { int32_t i1; int32_t i2; int32_t i3; int32_t i4; int32_t i5; int32_t i6; } pst_misc_6; typedef struct pst_entryid_struct { int32_t u1; char entryid[16]; uint32_t id; } pst_entryid; typedef struct pst_desc_struct32 { uint32_t d_id; uint32_t desc_id; uint32_t list_id; uint32_t parent_id; } pst_desc32; typedef struct pst_desc_structn { uint64_t d_id; uint64_t desc_id; uint64_t list_id; uint32_t parent_id; // not 64 bit ?? uint32_t u1; // padding } pst_descn; typedef struct pst_index_struct32 { uint32_t id; uint32_t offset; uint16_t size; int16_t u1; } pst_index32; typedef struct pst_index_struct { uint64_t id; uint64_t offset; uint16_t size; int16_t u0; int32_t u1; } pst_index; typedef struct pst_index_tree32 { uint32_t id; uint32_t offset; uint32_t size; int32_t u1; struct pst_index_tree * next; } pst_index_ll32; typedef struct pst_index_tree { uint64_t id; uint64_t offset; uint64_t size; int64_t u1; struct pst_index_tree * next; } pst_index_ll; typedef struct pst_index2_tree { uint64_t id2; pst_index_ll *id; struct pst_index2_tree * next; } pst_index2_ll; typedef struct pst_desc_tree { uint64_t id; uint64_t parent_id; pst_index_ll * list_index; pst_index_ll * desc; int32_t no_child; struct pst_desc_tree * prev; struct pst_desc_tree * next; struct pst_desc_tree * parent; struct pst_desc_tree * child; struct pst_desc_tree * child_tail; } pst_desc_ll; typedef struct pst_item_email_subject { int off1; int off2; char *subj; } pst_item_email_subject; typedef struct pst_item_email { FILETIME *arrival_date; int autoforward; // 1 = true, 0 = not set, -1 = false char *body; char *body_charset; // null if not specified char *cc_address; char *bcc_address; char *common_name; int32_t conv_index; int conversion_prohib; // 1 = true, 0 = false int delete_after_submit; // 1 = true, 0 = false int delivery_report; // 1 = true, 0 = false char *encrypted_body; size_t encrypted_body_size; char *encrypted_htmlbody; size_t encrypted_htmlbody_size; int32_t flag; char *header; char *htmlbody; int32_t importance; char *in_reply_to; int message_cc_me; // 1 = true, 0 = false int message_recip_me; // 1 = true, 0 = false int message_to_me; // 1 = true, 0 = false char *messageid; int32_t orig_sensitivity; char *original_bcc; char *original_cc; char *original_to; char *outlook_recipient; char *outlook_recipient_name; char *outlook_recipient2; char *outlook_sender; char *outlook_sender_name; char *outlook_sender2; int32_t priority; char *proc_subject; int read_receipt; // 1 = true, 0 = false char *recip_access; char *recip_address; char *recip2_access; char *recip2_address; int reply_requested; // 1 = true, 0 = false char *reply_to; char *return_path_address; int32_t rtf_body_char_count; int32_t rtf_body_crc; char *rtf_body_tag; char *rtf_compressed; uint32_t rtf_compressed_size; int rtf_in_sync; // 1 = true, 0 = doesn't exist, -1 = false int32_t rtf_ws_prefix_count; int32_t rtf_ws_trailing_count; char *sender_access; char *sender_address; char *sender2_access; char *sender2_address; int32_t sensitivity; FILETIME *sent_date; pst_entryid *sentmail_folder; char *sentto_address; pst_item_email_subject *subject; } pst_item_email; typedef struct pst_item_folder { int32_t email_count; int32_t unseen_email_count; int32_t assoc_count; int subfolder; // 1 = true, 0 = false } pst_item_folder; typedef struct pst_item_message_store { pst_entryid *top_of_personal_folder; // 0x35e0 pst_entryid *default_outbox_folder; // 0x35e2 pst_entryid *deleted_items_folder; // 0x35e3 pst_entryid *sent_items_folder; // 0x35e4 pst_entryid *user_views_folder; // 0x35e5 pst_entryid *common_view_folder; // 0x35e6 pst_entryid *search_root_folder; // 0x35e7 pst_entryid *top_of_folder; // 0x7c07 int32_t valid_mask; // 0x35df // what folders the message store contains int32_t pwd_chksum; // 0x76ff } pst_item_message_store; typedef struct pst_item_contact { char *access_method; char *account_name; char *address1; char *address1a; char *address1_desc; char *address1_transport; char *address2; char *address2a; char *address2_desc; char *address2_transport; char *address3; char *address3a; char *address3_desc; char *address3_transport; char *assistant_name; char *assistant_phone; char *billing_information; FILETIME *birthday; char *business_address; // 0x801b char *business_city; char *business_country; char *business_fax; char *business_homepage; char *business_phone; char *business_phone2; char *business_po_box; char *business_postal_code; char *business_state; char *business_street; char *callback_phone; char *car_phone; char *company_main_phone; char *company_name; char *computer_name; char *customer_id; char *def_postal_address; char *department; char *display_name_prefix; char *first_name; char *followup; char *free_busy_address; char *ftp_site; char *fullname; int16_t gender; char *gov_id; char *hobbies; char *home_address; // 0x801a char *home_city; char *home_country; char *home_fax; char *home_phone; char *home_phone2; char *home_po_box; char *home_postal_code; char *home_state; char *home_street; char *initials; char *isdn_phone; char *job_title; char *keyword; char *language; char *location; int mail_permission; // 1 = true, 0 = false char *manager_name; char *middle_name; char *mileage; char *mobile_phone; char *nickname; char *office_loc; char *org_id; char *other_address; // 0x801c char *other_city; char *other_country; char *other_phone; char *other_po_box; char *other_postal_code; char *other_state; char *other_street; char *pager_phone; char *personal_homepage; char *pref_name; char *primary_fax; char *primary_phone; char *profession; char *radio_phone; int rich_text; // 1 = true, 0 = false char *spouse_name; char *suffix; char *surname; char *telex; char *transmittable_display_name; char *ttytdd_phone; FILETIME *wedding_anniversary; char *work_address_street; // 0x8045 char *work_address_city; // 0x8046 char *work_address_state; // 0x8047 char *work_address_postalcode; // 0x8048 char *work_address_country; // 0x8049 char *work_address_postofficebox; // 0x804a } pst_item_contact; typedef struct pst_item_attach { char *filename1; char *filename2; char *mimetype; char *data; size_t size; uint64_t id2_val; uint64_t id_val; // calculated from id2_val during creation of record int32_t method; int32_t position; int32_t sequence; struct pst_item_attach *next; } pst_item_attach; typedef struct pst_item_extra_field { char *field_name; char *value; struct pst_item_extra_field *next; } pst_item_extra_field; typedef struct pst_item_journal { FILETIME *end; FILETIME *start; char *type; } pst_item_journal; typedef struct pst_item_appointment { FILETIME *end; char *location; int alarm; // 1 = true, 0 = false FILETIME *reminder; int32_t alarm_minutes; char *alarm_filename; FILETIME *start; char *timezonestring; int32_t showas; int32_t label; int all_day; // 1 = true, 0 = false char *recurrence; int32_t recurrence_type; FILETIME *recurrence_start; FILETIME *recurrence_end; } pst_item_appointment; typedef struct pst_item { struct pst_item_email *email; // data reffering to email struct pst_item_folder *folder; // data reffering to folder struct pst_item_contact *contact; // data reffering to contact struct pst_item_attach *attach; // linked list of attachments struct pst_item_message_store *message_store; // data referring to the message store struct pst_item_extra_field *extra_fields; // linked list of extra headers and such struct pst_item_journal *journal; // data reffering to a journal entry struct pst_item_appointment *appointment; // data reffering to a calendar entry int type; char *ascii_type; char *file_as; char *comment; int32_t message_size; char *outlook_version; char *record_key; // probably 16 bytes long. size_t record_key_size; int response_requested; // 1 = true, 0 = false FILETIME *create_date; FILETIME *modify_date; int private_member; // 1 = true, 0 = false } pst_item; typedef struct pst_x_attrib_ll { uint32_t type; uint32_t mytype; uint32_t map; void *data; struct pst_x_attrib_ll *next; } pst_x_attrib_ll; typedef struct pst_block_recorder { struct pst_block_recorder *next; int64_t offset; size_t size; int readcount; } pst_block_recorder; typedef struct pst_file { pst_index_ll *i_head, *i_tail; pst_desc_ll *d_head, *d_tail; pst_x_attrib_ll *x_head; pst_block_recorder *block_head; //set this to 0 to read 32-bit pst files (pre Outlook 2003) //set this to 1 to read 64-bit pst files (Outlook 2003 and later) int do_read64; uint64_t index1; uint64_t index1_back; uint64_t index2; uint64_t index2_back; FILE * fp; // file pointer to opened PST file uint64_t size; // pst file size unsigned char encryption; // pst encryption setting unsigned char ind_type; // pst index type } pst_file; typedef struct pst_block_offset { int16_t from; int16_t to; } pst_block_offset; typedef struct pst_block_offset_pointer { char *from; char *to; int needfree; } pst_block_offset_pointer; typedef struct pst_num_item { uint32_t id; // not an id1 or id2, this is actually some sort of type code char *data; uint32_t type; size_t size; char *extra; } pst_num_item; typedef struct pst_num_array { int32_t count_item; int32_t orig_count; int32_t count_array; struct pst_num_item ** items; struct pst_num_array *next; } pst_num_array; typedef struct pst_holder { char **buf; FILE *fp; int base64; } pst_holder; typedef struct pst_subblock { char *buf; size_t read_size; size_t i_offset; } pst_subblock; typedef struct pst_subblocks { size_t subblock_count; pst_subblock *subs; } pst_subblocks; // prototypes 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_num_array* pst_parse_block(pst_file *pf, uint64_t block_id, pst_index2_ll *i2_head, pst_num_array *na_head); int pst_process(pst_num_array *list, pst_item *item, pst_item_attach *attach); void pst_free_list(pst_num_array *list); void pst_freeItem(pst_item *item); void pst_free_id2(pst_index2_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_index2_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_index2_ll* pst_build_id2(pst_file *pf, pst_index_ll* list, pst_index2_ll* head_ptr); pst_index_ll* pst_getID(pst_file* pf, uint64_t id); pst_index_ll* pst_getID2(pst_index2_ll * ptr, uint64_t id); pst_desc_ll* pst_getDptr(pst_file *pf, uint64_t 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_index2_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_index2_ll *ptr); // switch from maximal packing back to default packing // undo the packing from the beginning of this file #ifdef _MSC_VER #pragma pack(pop) #endif #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) #pragma pack() #endif #endif // defined LIBPST_H diff --git a/src/libpst/Makefile.am b/src/libpst/Makefile.am deleted file mode 100644 index 50a0d2b..0000000 --- a/src/libpst/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = common.h diff --git a/src/libpst/common.h b/src/libpst/common.h deleted file mode 100644 index 1898d06..0000000 --- a/src/libpst/common.h +++ /dev/null @@ -1 +0,0 @@ -#include "../common.h" diff --git a/src/libstrfunc.h b/src/libstrfunc.h index 3a96ea3..10049f6 100644 --- a/src/libstrfunc.h +++ b/src/libstrfunc.h @@ -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); diff --git a/src/timeconv.h b/src/timeconv.h index 1b509aa..e28d93b 100644 --- a/src/timeconv.h +++ b/src/timeconv.h @@ -1,17 +1,16 @@ #ifndef __TIMECONV_H #define __TIMECONV_H +#include "common.h" + #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 fileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder ); + char * fileTimeToAscii (const FILETIME *filetime); + struct tm * fileTimeToStructTM (const FILETIME *filetime); #ifdef __cplusplus } #endif #endif diff --git a/src/vbuf.h b/src/vbuf.h index 98a706e..2a109b9 100644 --- a/src/vbuf.h +++ b/src/vbuf.h @@ -1,92 +1,95 @@ /* vbuf.h - variable length buffer functions * * Functions that try to make dealing with buffers easier. * * vbuf * * vstr * - should always contain a valid string * */ #ifndef VBUF_H #define VBUF_H + +#include "common.h" + #define SZ_MAX 4096 /***************************************************/ // Variable-length buffers struct varbuf { size_t dlen; //length of data stored in buffer size_t blen; //length of buffer char *buf; //buffer char *b; //start of stored data }; // The exact same thing as a varbuf but should always contain at least '\0' struct varstr { size_t dlen; //length of data stored in buffer size_t blen; //length of buffer char *buf; //buffer char *b; //start of stored data }; 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); 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 // 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 ); // 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 ); 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); int vb_skipline( struct varbuf *vb ); // in: vb->b == "stuff\nmore_stuff"; out: vb->b == "more_stuff" #endif // VBUF_H