[Commits] .cvsignore NONE 1.1.2.1 Makefile.am NONE 1.1.2.1 claws.def NONE 1.1.2.1 mapi.h NONE 1.1.2.1 mapidefs.h NONE 1.1.2.1 mapitags.h NONE 1.1.2.1 placeholder.txt 1.1.2.1 NONE plugin.def NONE 1.1.2.1 tnef-errors.h NONE 1.1.2.1 tnef-types.h NONE 1.1.2.1 tnef_dump.c NONE 1.1.2.1 tnef_dump.h NONE 1.1.2.1 tnef_parse.c NONE 1.1.2.1 version.rc NONE 1.1.2.1 ytnef.c NONE 1.1.2.1 ytnef.h NONE 1.1.2.1

colin at claws-mail.org colin at claws-mail.org
Wed Feb 20 09:46:01 CET 2013


Update of /home/claws-mail/claws/src/plugins/tnef_parse
In directory srv:/tmp/cvs-serv23253/src/plugins/tnef_parse

Added Files:
      Tag: gtk2
	.cvsignore Makefile.am claws.def mapi.h mapidefs.h mapitags.h 
	plugin.def tnef-errors.h tnef-types.h tnef_dump.c tnef_dump.h 
	tnef_parse.c version.rc ytnef.c ytnef.h 
Removed Files:
      Tag: gtk2
	placeholder.txt 
Log Message:
2013-02-20 [colin]	3.9.0cvs83

	* configure.ac
	* src/plugins/Makefile.am
	* src/plugins/spam_report/.cvsignore
	* src/plugins/spam_report/Makefile.am
	* src/plugins/spam_report/placeholder.txt
	* src/plugins/spam_report/spam_report.c
	* src/plugins/spam_report/spam_report_prefs.c
	* src/plugins/spam_report/spam_report_prefs.h
	* src/plugins/tnef_parse/.cvsignore
	* src/plugins/tnef_parse/Makefile.am
	* src/plugins/tnef_parse/claws.def
	* src/plugins/tnef_parse/mapi.h
	* src/plugins/tnef_parse/mapidefs.h
	* src/plugins/tnef_parse/mapitags.h
	* src/plugins/tnef_parse/placeholder.txt
	* src/plugins/tnef_parse/plugin.def
	* src/plugins/tnef_parse/tnef-errors.h
	* src/plugins/tnef_parse/tnef-types.h
	* src/plugins/tnef_parse/tnef_dump.c
	* src/plugins/tnef_parse/tnef_dump.h
	* src/plugins/tnef_parse/tnef_parse.c
	* src/plugins/tnef_parse/version.rc
	* src/plugins/tnef_parse/ytnef.c
	* src/plugins/tnef_parse/ytnef.h
		Add tnef_parse and spam_report

--- NEW FILE: .cvsignore ---
.deps
.libs
Makefile
Makefile.in
*.la
*.lo
*.o

--- NEW FILE: Makefile.am ---
EXTRA_DIST = claws.def plugin.def version.rc

if OS_WIN32

LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RC) \
     `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
     sed -e 's/-I/--include-dir /g;s/-D/--define /g'`

%.lo : %.rc
	$(LTRCCOMPILE) -i $< -o $@

plugin_res = version.lo
plugin_res_ldflag = -Wl,.libs/version.o

export_symbols = -export-symbols $(srcdir)/plugin.def

plugin_deps = libclaws.a $(plugin_res) plugin.def

libclaws.a: claws.def
	$(DLLTOOL) --output-lib $@ --def $<

plugin_ldadd = -L. -lclaws

else
plugin_res =
plugin_res_ldflag =
export_symbols =
plugin_deps =
plugin_ldadd =
endif

if PLATFORM_WIN32
no_undefined = -no-undefined
else
no_undefined =
endif

if CYGWIN
cygwin_export_lib = -L$(top_builddir)/src -lclaws-mail
else
cygwin_export_lib = 
endif

plugindir = $(pkglibdir)/plugins

plugin_LTLIBRARIES = tnef_parse.la

tnef_parse_la_SOURCES = \
         tnef_parse.c \
         tnef_dump.c \
         tnef_dump.h \
	 ytnef.c \
	 gettext.h

tnef_parse_la_LDFLAGS = \
	$(plugin_res_ldflag) $(no_undefined) $(export_symbols) \
	-avoid-version -module \
	$(GTK_LIBS)

tnef_parse_la_DEPENDENCIES = $(plugin_deps)

tnef_parse_la_LIBADD = $(plugin_ldadd) $(cygwin_export_lib) \
	$(GTK_LIBS)

noinst_HEADERS = \
	mapidefs.h \
	mapi.h \
	mapitags.h \
	tnef_dump.h \
	tnef-errors.h \
	tnef-types.h \
	ytnef.h

INCLUDES = \
	-I$(top_srcdir)/src \
	-I$(top_srcdir)/src/common \
	-I$(top_builddir)/src/common \
	-I$(top_srcdir)/src/gtk

AM_CPPFLAGS = \
	-Wall \
	$(CLAWS_MAIL_CFLAGS) \
	$(GLIB_CFLAGS) \
	$(GTK_CFLAGS) \
	-DLOCALEDIR=\""$(localedir)"\"

--- NEW FILE: version.rc ---
1 VERSIONINFO
 FILEVERSION 0, 0, 0, 0
 PRODUCTVERSION 0, 0, 0, 0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "000004b0"
        BEGIN
            VALUE "FileDescription", "TNEF Parser Plugin\0"
            VALUE "FileVersion", "0.0.0.0\0"
            VALUE "ProductVersion", "0.0.0.0 Win32\0"
            VALUE "LegalCopyright", "GPL / © 1999-2008 Hiroyuki Yamamoto & The Claws Mail Team\0"
            VALUE "CompanyName", "GNU / Free Software Foundation\0"
            VALUE "ProductName", "Claws Mail\0"
//            VALUE "Comments", "\0"
//            VALUE "InternalName", "\0"
//            VALUE "LegalTrademarks", "\0"
//            VALUE "OriginalFilename", "\0"
//            VALUE "PrivateBuild", "\0"
//            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200
    END
END

--- NEW FILE: claws.def ---
LIBRARY CLAWS-MAIL.EXE
EXPORTS
get_locale_dir
check_plugin_version
claws_unlink
debug_get_mode
debug_print_real
debug_srcname
get_mime_tmp_dir
get_tmpfile_in_dir
procmime_decode_content
procmime_get_media_type
procmime_get_mime_type
procmime_mimeinfo_free_all
procmime_mimeinfo_new
procmime_mimeparser_register
procmime_mimeparser_unregister

--- NEW FILE: ytnef.h ---
#ifndef _TNEF_PROCS_H_
#define _TNEF_PROCS_H_

#include "tnef-types.h"
#include "mapi.h"
#include "mapidefs.h"
#define STD_ARGLIST (TNEFStruct *TNEF, int id, unsigned char *data, int size)
DWORD SwapDWord(BYTE *p);
WORD SwapWord(BYTE *p);


void TNEFInitMapi(MAPIProps *p);
void TNEFInitAttachment(Attachment *p);
void TNEFInitialize(TNEFStruct *TNEF);
void TNEFFree(TNEFStruct *TNEF);
void TNEFFreeAttachment(Attachment *p);
void TNEFFreeMapiProps(MAPIProps *p);
int TNEFCheckForSignature(DWORD sig);
int TNEFParseMemory(BYTE *memory, long size, TNEFStruct *TNEF);
int TNEFParseFile(char *filename, TNEFStruct *TNEF);
int TNEFParse(TNEFStruct *TNEF);
variableLength *MAPIFindUserProp(MAPIProps *p, unsigned int ID);
variableLength *MAPIFindProperty(MAPIProps *p, unsigned int ID);
int MAPISysTimetoDTR(BYTE *data, dtr *thedate);
void MAPIPrint(MAPIProps *p);
char* to_utf8(int len, char* buf);
WORD SwapWord(BYTE *p);
DWORD SwapDWord(BYTE *p);
DDWORD SwapDDWord(BYTE *p);
variableLength *MAPIFindUserProp(MAPIProps *p, unsigned int ID);
variableLength *MAPIFindProperty(MAPIProps *p, unsigned int ID);
unsigned char * DecompressRTF(variableLength *p, int *size);

/* ------------------------------------- */ 
/* TNEF Down-level Attributes/Properties */
/* ------------------------------------- */

#define atpTriples      ((WORD) 0x0000)
#define atpString       ((WORD) 0x0001)
#define atpText         ((WORD) 0x0002)
#define atpDate         ((WORD) 0x0003)
#define atpShort        ((WORD) 0x0004)
#define atpLong         ((WORD) 0x0005)
#define atpByte         ((WORD) 0x0006)
#define atpWord         ((WORD) 0x0007)
#define atpDword        ((WORD) 0x0008)
#define atpMax          ((WORD) 0x0009)

#define LVL_MESSAGE     ((BYTE) 0x01)
#define LVL_ATTACHMENT  ((BYTE) 0x02)

#define ATT_ID(_att)                ((WORD) ((_att) & 0x0000FFFF))
#define ATT_TYPE(_att)              ((WORD) (((_att) >> 16) & 0x0000FFFF))
#define ATT(_atp, _id)              ((((DWORD) (_atp)) << 16) | ((WORD) (_id)))

#define attNull                     ATT( 0,             0x0000)
#define attFrom                     ATT( atpTriples,    0x8000) /* PR_ORIGINATOR_RETURN_ADDRESS */
#define attSubject                  ATT( atpString,     0x8004) /* PR_SUBJECT */
#define attDateSent                 ATT( atpDate,       0x8005) /* PR_CLIENT_SUBMIT_TIME */
#define attDateRecd                 ATT( atpDate,       0x8006) /* PR_MESSAGE_DELIVERY_TIME */
#define attMessageStatus            ATT( atpByte,       0x8007) /* PR_MESSAGE_FLAGS */
#define attMessageClass             ATT( atpWord,       0x8008) /* PR_MESSAGE_CLASS */
#define attMessageID                ATT( atpString,     0x8009) /* PR_MESSAGE_ID */
#define attParentID                 ATT( atpString,     0x800A) /* PR_PARENT_ID */
#define attConversationID           ATT( atpString,     0x800B) /* PR_CONVERSATION_ID */
#define attBody                     ATT( atpText,       0x800C) /* PR_BODY */
#define attPriority                 ATT( atpShort,      0x800D) /* PR_IMPORTANCE */
#define attAttachData               ATT( atpByte,       0x800F) /* PR_ATTACH_DATA_xxx */
#define attAttachTitle              ATT( atpString,     0x8010) /* PR_ATTACH_FILENAME */
#define attAttachMetaFile           ATT( atpByte,       0x8011) /* PR_ATTACH_RENDERING */
#define attAttachCreateDate         ATT( atpDate,       0x8012) /* PR_CREATION_TIME */
#define attAttachModifyDate         ATT( atpDate,       0x8013) /* PR_LAST_MODIFICATION_TIME */
#define attDateModified             ATT( atpDate,       0x8020) /* PR_LAST_MODIFICATION_TIME */
#define attAttachTransportFilename  ATT( atpByte,       0x9001) /* PR_ATTACH_TRANSPORT_NAME */
#define attAttachRenddata           ATT( atpByte,       0x9002)
#define attMAPIProps                ATT( atpByte,       0x9003)
#define attRecipTable               ATT( atpByte,       0x9004) /* PR_MESSAGE_RECIPIENTS */
#define attAttachment               ATT( atpByte,       0x9005)
#define attTnefVersion              ATT( atpDword,      0x9006)
#define attOemCodepage              ATT( atpByte,       0x9007)
#define attOriginalMessageClass     ATT( atpWord,       0x0006) /* PR_ORIG_MESSAGE_CLASS */

#define attOwner                    ATT( atpByte,       0x0000) /* PR_RCVD_REPRESENTING_xxx  or
                                                                                                                                      PR_SENT_REPRESENTING_xxx */
#define attSentFor                  ATT( atpByte,       0x0001) /* PR_SENT_REPRESENTING_xxx */
#define attDelegate                 ATT( atpByte,       0x0002) /* PR_RCVD_REPRESENTING_xxx */
#define attDateStart                ATT( atpDate,       0x0006) /* PR_DATE_START */
#define attDateEnd                  ATT( atpDate,       0x0007) /* PR_DATE_END */
#define attAidOwner                 ATT( atpLong,       0x0008) /* PR_OWNER_APPT_ID */
#define attRequestRes               ATT( atpShort,      0x0009) /* PR_RESPONSE_REQUESTED */

typedef struct {
    DWORD id;
    char name[40];
    int (*handler) STD_ARGLIST;
} TNEFHandler;


#endif

--- NEW FILE: plugin.def ---
EXPORTS
        plugin_desc
        plugin_done
        plugin_init
        plugin_licence
        plugin_name
        plugin_type
	plugin_provides
        plugin_version


--- NEW FILE: tnef-types.h ---
#ifndef _TNEF_TYPES_H_
#define _TNEF_TYPES_H_

#define BYTE unsigned char
#define WORD unsigned short int
#define DWORD unsigned int
#define ULONG unsigned int
#define DDWORD unsigned long long
typedef struct
{
    WORD    atyp;
    ULONG   ulPosition;
    WORD    dxWidth;
    WORD    dyHeight;
    DWORD   dwFlags;
} renddata;

/* ----------------------------------- */
/* TNEF Down-level Date/Time Structure */
/* ----------------------------------- */

typedef struct 
{
    WORD    wYear;
    WORD    wMonth;
    WORD    wDay;
    WORD    wHour;
    WORD    wMinute;
    WORD    wSecond;
    WORD    wDayOfWeek;
} dtr;

typedef struct
{
    char *data;
    int size;
} variableLength;

typedef struct {
    DWORD custom;
    BYTE guid[16];
    DWORD id;
    ULONG count;
    int namedproperty;
    variableLength *propnames;
    variableLength *data;
} MAPIProperty;

typedef struct MAPIProps {
    DWORD count;
    MAPIProperty *properties;
} MAPIProps;

typedef struct Attachment
{
    dtr Date;
    variableLength Title;
    variableLength MetaFile;
    dtr CreateDate;
    dtr ModifyDate;
    variableLength TransportFilename;
    renddata RenderData;
    MAPIProps MAPI;
    struct Attachment *next;
    variableLength FileData;
    variableLength IconData;
} Attachment;

typedef struct _TNEFIOStruct
{
    int (*InitProc) (struct _TNEFIOStruct *IO);
    int (*ReadProc) (struct _TNEFIOStruct *IO, int size, int count, void *dest);
    int (*CloseProc) (struct _TNEFIOStruct *IO);
    void *data;
} TNEFIOStruct;

typedef struct 
{
    char *filename;
    FILE *fptr;
    int Debug;
} TNEFFileInfo;

typedef struct 
{
    BYTE *dataStart;
    BYTE *ptr;
    long size;
    int Debug;
} TNEFMemInfo;

typedef struct 
{
    char version[10];
    variableLength from;
    variableLength subject;
    dtr dateSent;
    dtr dateReceived;
    char messageStatus[10];
    char messageClass[50];
    char messageID[50];
    char parentID[50];
    char conversationID[50];
    variableLength body;
    char priority[10];
    Attachment starting_attach;
    dtr dateModified;
    MAPIProps MapiProperties;
    variableLength CodePage;
    variableLength OriginalMessageClass;
    variableLength Owner;
    variableLength SentFor;
    variableLength Delegate;
    dtr DateStart;
    dtr DateEnd;
    variableLength AidOwner;
    int RequestRes;
    int Debug;
    TNEFIOStruct IO;
} TNEFStruct;

#endif

--- NEW FILE: mapi.h ---
#define MV_FLAG         0x1000          /* Multi-value flag */

#define PT_UNSPECIFIED  ((ULONG)  0)    /* (Reserved for interface use) type doesn't matter to caller */
#define PT_NULL         ((ULONG)  1)    /* NULL property value */
#define PT_I2           ((ULONG)  2)    /* Signed 16-bit value */
#define PT_LONG         ((ULONG)  3)    /* Signed 32-bit value */
#define PT_R4           ((ULONG)  4)    /* 4-byte floating point */
#define PT_DOUBLE       ((ULONG)  5)    /* Floating point double */
#define PT_CURRENCY     ((ULONG)  6)    /* Signed 64-bit int (decimal w/    4 digits right of decimal pt) */
#define PT_APPTIME      ((ULONG)  7)    /* Application time */
#define PT_ERROR        ((ULONG) 10)    /* 32-bit error value */
#define PT_BOOLEAN      ((ULONG) 11)    /* 16-bit boolean (non-zero true) */
#define PT_OBJECT       ((ULONG) 13)    /* Embedded object in a property */
#define PT_I8           ((ULONG) 20)    /* 8-byte signed integer */
#define PT_STRING8      ((ULONG) 30)    /* Null terminated 8-bit character string */
#define PT_UNICODE      ((ULONG) 31)    /* Null terminated Unicode string */
#define PT_SYSTIME      ((ULONG) 64)    /* FILETIME 64-bit int w/ number of 100ns periods since Jan 1,1601 */
#define PT_CLSID        ((ULONG) 72)    /* OLE GUID */
#define PT_BINARY       ((ULONG) 258)   /* Uninterpreted (counted byte array) */

#define PROP_TYPE_MASK          ((ULONG)0x0000FFFF) /* Mask for Property type */
#define PROP_TYPE(ulPropTag)    (((ULONG)(ulPropTag))&PROP_TYPE_MASK)
#define PROP_ID(ulPropTag)      (((ULONG)(ulPropTag))>>16)
#define PROP_TAG(ulPropType,ulPropID)   ((((ULONG)(ulPropID))<<16)|((ULONG)(ulPropType)))
#define PROP_ID_NULL            0
#define PROP_ID_INVALID         0xFFFF
#define PR_NULL                 PROP_TAG( PT_NULL, PROP_ID_NULL)

#define MAPI_UNDEFINED ((variableLength*)-1)

--- NEW FILE: ytnef.c ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 2008 Colin Leroy <colin at colino.net>
 * and the Claws Mail Team
 *
 * This file Copyright (C) 2002-2007 Randall Hand <yerase at yerot.com> 
 * Thanks to him for allowing redistribution of this code as GPLv3.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
[...1395 lines suppressed...]
                // bytes can cross through the current out position.
                end = offset + length;
                while (offset < end)
	                dst[out++] = dst[offset++];
            } else { // literal
                dst[out++] = src[in++];
            }
        }
        // copy it back without the prebuffered data
        src = dst;
        dst = calloc(uncompressedSize,1);
        memcpy(dst, src + comp_Prebuf.size, uncompressedSize);
        free(src);
        *size = uncompressedSize;
        return dst;
    } else { // unknown magic number
        printf("Unknown compression type (magic number %x)\n", magic );
        return NULL;
    }
}

--- placeholder.txt DELETED ---

--- NEW FILE: mapitags.h ---
#ifndef MAPITAGS_H
#define MAPITAGS_H

#define MAPIMACRO(x) {x, #x}
typedef struct {
    unsigned int id;
    char name[128];
} MAPIPropertyTagList;


MAPIPropertyTagList MPList[] = {
        MAPIMACRO(PR_ACKNOWLEDGEMENT_MODE                     ),
        MAPIMACRO(PR_ALTERNATE_RECIPIENT_ALLOWED              ),
        MAPIMACRO(PR_AUTHORIZING_USERS                        ),
        MAPIMACRO(PR_AUTO_FORWARD_COMMENT                     ),
        MAPIMACRO(PR_AUTO_FORWARDED                           ),
        MAPIMACRO(PR_CONTENT_CONFIDENTIALITY_ALGORITHM_ID     ),
        MAPIMACRO(PR_CONTENT_CORRELATOR                       ),
        MAPIMACRO(PR_CONTENT_IDENTIFIER                       ),
        MAPIMACRO(PR_CONTENT_LENGTH                           ),
        MAPIMACRO(PR_CONTENT_RETURN_REQUESTED                 ),
        MAPIMACRO(PR_CONVERSATION_KEY                         ),
        MAPIMACRO(PR_CONVERSION_EITS                          ),
        MAPIMACRO(PR_CONVERSION_WITH_LOSS_PROHIBITED          ),
        MAPIMACRO(PR_CONVERTED_EITS                           ),
        MAPIMACRO(PR_DEFERRED_DELIVERY_TIME                   ),
        MAPIMACRO(PR_DELIVER_TIME                             ),
        MAPIMACRO(PR_DISCARD_REASON                           ),
        MAPIMACRO(PR_DISCLOSURE_OF_RECIPIENTS                 ),
        MAPIMACRO(PR_DL_EXPANSION_HISTORY                     ),
        MAPIMACRO(PR_DL_EXPANSION_PROHIBITED                  ),
        MAPIMACRO(PR_EXPIRY_TIME                              ),
        MAPIMACRO(PR_IMPLICIT_CONVERSION_PROHIBITED           ),
        MAPIMACRO(PR_IMPORTANCE                               ),
        MAPIMACRO(PR_IPM_ID                                   ),
        MAPIMACRO(PR_LATEST_DELIVERY_TIME                     ),
        MAPIMACRO(PR_MESSAGE_CLASS                            ),
        MAPIMACRO(PR_MESSAGE_DELIVERY_ID                      ),
        MAPIMACRO(PR_MESSAGE_SECURITY_LABEL                   ),
        MAPIMACRO(PR_OBSOLETED_IPMS                           ),
        MAPIMACRO(PR_ORIGINALLY_INTENDED_RECIPIENT_NAME       ),
        MAPIMACRO(PR_ORIGINAL_EITS                            ),
        MAPIMACRO(PR_ORIGINATOR_CERTIFICATE                   ),
        MAPIMACRO(PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED     ),
        MAPIMACRO(PR_ORIGINATOR_RETURN_ADDRESS                ),
        MAPIMACRO(PR_PARENT_KEY                               ),
        MAPIMACRO(PR_PRIORITY                                 ),
        MAPIMACRO(PR_ORIGIN_CHECK                             ),
        MAPIMACRO(PR_PROOF_OF_SUBMISSION_REQUESTED            ),
        MAPIMACRO(PR_READ_RECEIPT_REQUESTED                   ),
        MAPIMACRO(PR_RECEIPT_TIME                             ),
        MAPIMACRO(PR_RECIPIENT_REASSIGNMENT_PROHIBITED        ),
        MAPIMACRO(PR_REDIRECTION_HISTORY                      ),
        MAPIMACRO(PR_RELATED_IPMS                             ),
        MAPIMACRO(PR_ORIGINAL_SENSITIVITY                     ),
        MAPIMACRO(PR_LANGUAGES                                ),
        MAPIMACRO(PR_REPLY_TIME                               ),
        MAPIMACRO(PR_REPORT_TAG                               ),
        MAPIMACRO(PR_REPORT_TIME                              ),
        MAPIMACRO(PR_RETURNED_IPM                             ),
        MAPIMACRO(PR_SECURITY                                 ),
        MAPIMACRO(PR_INCOMPLETE_COPY                          ),
        MAPIMACRO(PR_SENSITIVITY                              ),
        MAPIMACRO(PR_SUBJECT                                  ),
        MAPIMACRO(PR_SUBJECT_IPM                              ),
        MAPIMACRO(PR_CLIENT_SUBMIT_TIME                       ),
        MAPIMACRO(PR_REPORT_NAME                              ),
        MAPIMACRO(PR_SENT_REPRESENTING_SEARCH_KEY             ),
        MAPIMACRO(PR_X400_CONTENT_TYPE                        ),
        MAPIMACRO(PR_SUBJECT_PREFIX                           ),
        MAPIMACRO(PR_NON_RECEIPT_REASON                       ),
        MAPIMACRO(PR_RECEIVED_BY_ENTRYID                      ),
        MAPIMACRO(PR_RECEIVED_BY_NAME                         ),
        MAPIMACRO(PR_SENT_REPRESENTING_ENTRYID                ),
        MAPIMACRO(PR_SENT_REPRESENTING_NAME                   ),
        MAPIMACRO(PR_RCVD_REPRESENTING_ENTRYID                ),
        MAPIMACRO(PR_RCVD_REPRESENTING_NAME                   ),
        MAPIMACRO(PR_REPORT_ENTRYID                           ),
        MAPIMACRO(PR_READ_RECEIPT_ENTRYID                     ),
        MAPIMACRO(PR_MESSAGE_SUBMISSION_ID                    ),
        MAPIMACRO(PR_PROVIDER_SUBMIT_TIME                     ),
        MAPIMACRO(PR_ORIGINAL_SUBJECT                         ),
        MAPIMACRO(PR_DISC_VAL                                 ),
        MAPIMACRO(PR_ORIG_MESSAGE_CLASS                       ),
        MAPIMACRO(PR_ORIGINAL_AUTHOR_ENTRYID                  ),
        MAPIMACRO(PR_ORIGINAL_AUTHOR_NAME                     ),
        MAPIMACRO(PR_ORIGINAL_SUBMIT_TIME                     ),
        MAPIMACRO(PR_REPLY_RECIPIENT_ENTRIES                  ),
        MAPIMACRO(PR_REPLY_RECIPIENT_NAMES                    ),
        MAPIMACRO(PR_RECEIVED_BY_SEARCH_KEY                   ),
        MAPIMACRO(PR_RCVD_REPRESENTING_SEARCH_KEY             ),
        MAPIMACRO(PR_READ_RECEIPT_SEARCH_KEY                  ),
        MAPIMACRO(PR_REPORT_SEARCH_KEY                        ),
        MAPIMACRO(PR_ORIGINAL_DELIVERY_TIME                   ),
        MAPIMACRO(PR_ORIGINAL_AUTHOR_SEARCH_KEY               ),
        MAPIMACRO(PR_MESSAGE_TO_ME                            ),
        MAPIMACRO(PR_MESSAGE_CC_ME                            ),
        MAPIMACRO(PR_MESSAGE_RECIP_ME                         ),
        MAPIMACRO(PR_ORIGINAL_SENDER_NAME                     ),
        MAPIMACRO(PR_ORIGINAL_SENDER_ENTRYID                  ),
        MAPIMACRO(PR_ORIGINAL_SENDER_SEARCH_KEY               ),
        MAPIMACRO(PR_ORIGINAL_SENT_REPRESENTING_NAME          ),
        MAPIMACRO(PR_ORIGINAL_SENT_REPRESENTING_ENTRYID       ),
        MAPIMACRO(PR_ORIGINAL_SENT_REPRESENTING_SEARCH_KEY    ),
        MAPIMACRO(PR_START_DATE                               ),
        MAPIMACRO(PR_END_DATE                                 ),
        MAPIMACRO(PR_OWNER_APPT_ID                            ),
        MAPIMACRO(PR_RESPONSE_REQUESTED                       ),
        MAPIMACRO(PR_SENT_REPRESENTING_ADDRTYPE               ),
        MAPIMACRO(PR_SENT_REPRESENTING_EMAIL_ADDRESS          ),
        MAPIMACRO(PR_ORIGINAL_SENDER_ADDRTYPE                 ),
        MAPIMACRO(PR_ORIGINAL_SENDER_EMAIL_ADDRESS            ),
        MAPIMACRO(PR_ORIGINAL_SENT_REPRESENTING_ADDRTYPE      ),
        MAPIMACRO(PR_ORIGINAL_SENT_REPRESENTING_EMAIL_ADDRESS ),
        MAPIMACRO(PR_CONVERSATION_TOPIC                       ),
        MAPIMACRO(PR_CONVERSATION_INDEX                       ),
        MAPIMACRO(PR_ORIGINAL_DISPLAY_BCC                     ),
        MAPIMACRO(PR_ORIGINAL_DISPLAY_CC                      ),
        MAPIMACRO(PR_ORIGINAL_DISPLAY_TO                      ),
        MAPIMACRO(PR_RECEIVED_BY_ADDRTYPE                     ),
        MAPIMACRO(PR_RECEIVED_BY_EMAIL_ADDRESS                ),
        MAPIMACRO(PR_RCVD_REPRESENTING_ADDRTYPE               ),
        MAPIMACRO(PR_RCVD_REPRESENTING_EMAIL_ADDRESS          ),
        MAPIMACRO(PR_ORIGINAL_AUTHOR_ADDRTYPE                 ),
        MAPIMACRO(PR_ORIGINAL_AUTHOR_EMAIL_ADDRESS            ),
        MAPIMACRO(PR_ORIGINALLY_INTENDED_RECIP_ADDRTYPE       ),
        MAPIMACRO(PR_ORIGINALLY_INTENDED_RECIP_EMAIL_ADDRESS  ),
        MAPIMACRO(PR_TRANSPORT_MESSAGE_HEADERS                ),
        MAPIMACRO(PR_DELEGATION                               ),
        MAPIMACRO(PR_TNEF_CORRELATION_KEY                     ),
        MAPIMACRO(PR_BODY                                     ),
        MAPIMACRO(PR_REPORT_TEXT                              ),
        MAPIMACRO(PR_ORIGINATOR_AND_DL_EXPANSION_HISTORY      ),
        MAPIMACRO(PR_REPORTING_DL_NAME                        ),
        MAPIMACRO(PR_REPORTING_MTA_CERTIFICATE                ),
        MAPIMACRO(PR_RTF_SYNC_BODY_CRC                        ),
        MAPIMACRO(PR_RTF_SYNC_BODY_COUNT                      ),
        MAPIMACRO(PR_RTF_SYNC_BODY_TAG                        ),
        MAPIMACRO(PR_RTF_COMPRESSED                           ),
        MAPIMACRO(PR_RTF_SYNC_PREFIX_COUNT                    ),
        MAPIMACRO(PR_RTF_SYNC_TRAILING_COUNT                  ),
        MAPIMACRO(PR_ORIGINALLY_INTENDED_RECIP_ENTRYID        ),
        MAPIMACRO(PR_CONTENT_INTEGRITY_CHECK                  ),
        MAPIMACRO(PR_EXPLICIT_CONVERSION                      ),
        MAPIMACRO(PR_IPM_RETURN_REQUESTED                     ),
        MAPIMACRO(PR_MESSAGE_TOKEN                            ),
        MAPIMACRO(PR_NDR_REASON_CODE                          ),
        MAPIMACRO(PR_NDR_DIAG_CODE                            ),
        MAPIMACRO(PR_NON_RECEIPT_NOTIFICATION_REQUESTED       ),
        MAPIMACRO(PR_DELIVERY_POINT                           ),
        MAPIMACRO(PR_ORIGINATOR_NON_DELIVERY_REPORT_REQUESTED ),
        MAPIMACRO(PR_ORIGINATOR_REQUESTED_ALTERNATE_RECIPIENT ),
        MAPIMACRO(PR_PHYSICAL_DELIVERY_BUREAU_FAX_DELIVERY    ),
        MAPIMACRO(PR_PHYSICAL_DELIVERY_MODE                   ),
        MAPIMACRO(PR_PHYSICAL_DELIVERY_REPORT_REQUEST         ),
        MAPIMACRO(PR_PHYSICAL_FORWARDING_ADDRESS              ),
        MAPIMACRO(PR_PHYSICAL_FORWARDING_ADDRESS_REQUESTED    ),
        MAPIMACRO(PR_PHYSICAL_FORWARDING_PROHIBITED           ),
        MAPIMACRO(PR_PHYSICAL_RENDITION_ATTRIBUTES            ),
        MAPIMACRO(PR_PROOF_OF_DELIVERY                        ),
        MAPIMACRO(PR_PROOF_OF_DELIVERY_REQUESTED              ),
        MAPIMACRO(PR_RECIPIENT_CERTIFICATE                    ),
        MAPIMACRO(PR_RECIPIENT_NUMBER_FOR_ADVICE              ),
        MAPIMACRO(PR_RECIPIENT_TYPE                           ),
        MAPIMACRO(PR_REGISTERED_MAIL_TYPE                     ),
        MAPIMACRO(PR_REPLY_REQUESTED                          ),
        MAPIMACRO(PR_REQUESTED_DELIVERY_METHOD                ),
        MAPIMACRO(PR_SENDER_ENTRYID                           ),
        MAPIMACRO(PR_SENDER_NAME                              ),
        MAPIMACRO(PR_SUPPLEMENTARY_INFO                       ),
        MAPIMACRO(PR_TYPE_OF_MTS_USER                         ),
        MAPIMACRO(PR_SENDER_SEARCH_KEY                        ),
        MAPIMACRO(PR_SENDER_ADDRTYPE                          ),
        MAPIMACRO(PR_SENDER_EMAIL_ADDRESS                     ),
        MAPIMACRO(PR_CURRENT_VERSION                          ),
        MAPIMACRO(PR_DELETE_AFTER_SUBMIT                      ),
        MAPIMACRO(PR_DISPLAY_BCC                              ),
        MAPIMACRO(PR_DISPLAY_CC                               ),
        MAPIMACRO(PR_DISPLAY_TO                               ),
        MAPIMACRO(PR_PARENT_DISPLAY                           ),
        MAPIMACRO(PR_MESSAGE_DELIVERY_TIME                    ),
        MAPIMACRO(PR_MESSAGE_FLAGS                            ),
        MAPIMACRO(PR_MESSAGE_SIZE                             ),
        MAPIMACRO(PR_PARENT_ENTRYID                           ),
        MAPIMACRO(PR_SENTMAIL_ENTRYID                         ),
        MAPIMACRO(PR_CORRELATE                                ),
        MAPIMACRO(PR_CORRELATE_MTSID                          ),
        MAPIMACRO(PR_DISCRETE_VALUES                          ),
        MAPIMACRO(PR_RESPONSIBILITY                           ),
        MAPIMACRO(PR_SPOOLER_STATUS                           ),
        MAPIMACRO(PR_TRANSPORT_STATUS                         ),
        MAPIMACRO(PR_MESSAGE_RECIPIENTS                       ),
        MAPIMACRO(PR_MESSAGE_ATTACHMENTS                      ),
        MAPIMACRO(PR_SUBMIT_FLAGS                             ),
        MAPIMACRO(PR_RECIPIENT_STATUS                         ),
        MAPIMACRO(PR_TRANSPORT_KEY                            ),
        MAPIMACRO(PR_MSG_STATUS                               ),
        MAPIMACRO(PR_MESSAGE_DOWNLOAD_TIME                    ),
        MAPIMACRO(PR_CREATION_VERSION                         ),
        MAPIMACRO(PR_MODIFY_VERSION                           ),
        MAPIMACRO(PR_HASATTACH                                ),
        MAPIMACRO(PR_BODY_CRC                                 ),
        MAPIMACRO(PR_NORMALIZED_SUBJECT                       ),
        MAPIMACRO(PR_RTF_IN_SYNC                              ),
        MAPIMACRO(PR_ATTACH_SIZE                              ),
        MAPIMACRO(PR_ATTACH_NUM                               ),
        MAPIMACRO(PR_PREPROCESS                               ),
        MAPIMACRO(PR_ORIGINATING_MTA_CERTIFICATE              ),
        MAPIMACRO(PR_PROOF_OF_SUBMISSION                      ),
        MAPIMACRO(PR_ENTRYID                                  ),
        MAPIMACRO(PR_OBJECT_TYPE                              ),
        MAPIMACRO(PR_ICON                                     ),
        MAPIMACRO(PR_MINI_ICON                                ),
        MAPIMACRO(PR_STORE_ENTRYID                            ),
        MAPIMACRO(PR_STORE_RECORD_KEY                         ),
        MAPIMACRO(PR_RECORD_KEY                               ),
        MAPIMACRO(PR_MAPPING_SIGNATURE                        ),
        MAPIMACRO(PR_ACCESS_LEVEL                             ),
        MAPIMACRO(PR_INSTANCE_KEY                             ),
        MAPIMACRO(PR_ROW_TYPE                                 ),
        MAPIMACRO(PR_ACCESS                                   ),
        MAPIMACRO(PR_ROWID                                    ),
        MAPIMACRO(PR_DISPLAY_NAME                             ),
        MAPIMACRO(PR_ADDRTYPE                                 ),
        MAPIMACRO(PR_EMAIL_ADDRESS                            ),
        MAPIMACRO(PR_COMMENT                                  ),
        MAPIMACRO(PR_DEPTH                                    ),
        MAPIMACRO(PR_PROVIDER_DISPLAY                         ),
        MAPIMACRO(PR_CREATION_TIME                            ),
        MAPIMACRO(PR_LAST_MODIFICATION_TIME                   ),
        MAPIMACRO(PR_RESOURCE_FLAGS                           ),
        MAPIMACRO(PR_PROVIDER_DLL_NAME                        ),
        MAPIMACRO(PR_SEARCH_KEY                               ),
        MAPIMACRO(PR_PROVIDER_UID                             ),
        MAPIMACRO(PR_PROVIDER_ORDINAL                         ),
        MAPIMACRO(PR_FORM_VERSION                             ),
        MAPIMACRO(PR_FORM_CLSID                               ),
        MAPIMACRO(PR_FORM_CONTACT_NAME                        ),
        MAPIMACRO(PR_FORM_CATEGORY                            ),
        MAPIMACRO(PR_FORM_CATEGORY_SUB                        ),
        MAPIMACRO(PR_FORM_HOST_MAP                            ),
        MAPIMACRO(PR_FORM_HIDDEN                              ),
        MAPIMACRO(PR_FORM_DESIGNER_NAME                       ),
        MAPIMACRO(PR_FORM_DESIGNER_GUID                       ),
        MAPIMACRO(PR_FORM_MESSAGE_BEHAVIOR                    ),
        MAPIMACRO(PR_DEFAULT_STORE                            ),
        MAPIMACRO(PR_STORE_SUPPORT_MASK                       ),
        MAPIMACRO(PR_STORE_STATE                              ),
        MAPIMACRO(PR_IPM_SUBTREE_SEARCH_KEY                   ),
        MAPIMACRO(PR_IPM_OUTBOX_SEARCH_KEY                    ),
        MAPIMACRO(PR_IPM_WASTEBASKET_SEARCH_KEY               ),
        MAPIMACRO(PR_IPM_SENTMAIL_SEARCH_KEY                  ),
        MAPIMACRO(PR_MDB_PROVIDER                             ),
        MAPIMACRO(PR_RECEIVE_FOLDER_SETTINGS                  ),
        MAPIMACRO(PR_VALID_FOLDER_MASK                        ),
        MAPIMACRO(PR_IPM_SUBTREE_ENTRYID                      ),
        MAPIMACRO(PR_IPM_OUTBOX_ENTRYID                       ),
        MAPIMACRO(PR_IPM_WASTEBASKET_ENTRYID                  ),
        MAPIMACRO(PR_IPM_SENTMAIL_ENTRYID                     ),
        MAPIMACRO(PR_VIEWS_ENTRYID                            ),
        MAPIMACRO(PR_COMMON_VIEWS_ENTRYID                     ),
        MAPIMACRO(PR_FINDER_ENTRYID                           ),
        MAPIMACRO(PR_CONTAINER_FLAGS                          ),
        MAPIMACRO(PR_FOLDER_TYPE                              ),
        MAPIMACRO(PR_CONTENT_COUNT                            ),
        MAPIMACRO(PR_CONTENT_UNREAD                           ),
        MAPIMACRO(PR_CREATE_TEMPLATES                         ),
        MAPIMACRO(PR_DETAILS_TABLE                            ),
        MAPIMACRO(PR_SEARCH                                   ),
        MAPIMACRO(PR_SELECTABLE                               ),
        MAPIMACRO(PR_SUBFOLDERS                               ),
        MAPIMACRO(PR_STATUS                                   ),
        MAPIMACRO(PR_ANR                                      ),
        MAPIMACRO(PR_CONTENTS_SORT_ORDER                      ),
        MAPIMACRO(PR_CONTAINER_HIERARCHY                      ),
        MAPIMACRO(PR_CONTAINER_CONTENTS                       ),
        MAPIMACRO(PR_FOLDER_ASSOCIATED_CONTENTS               ),
        MAPIMACRO(PR_DEF_CREATE_DL                            ),
        MAPIMACRO(PR_DEF_CREATE_MAILUSER                      ),
        MAPIMACRO(PR_CONTAINER_CLASS                          ),
        MAPIMACRO(PR_CONTAINER_MODIFY_VERSION                 ),
        MAPIMACRO(PR_AB_PROVIDER_ID                           ),
        MAPIMACRO(PR_DEFAULT_VIEW_ENTRYID                     ),
        MAPIMACRO(PR_ASSOC_CONTENT_COUNT                      ),
        MAPIMACRO(PR_ATTACHMENT_X400_PARAMETERS               ),
        MAPIMACRO(PR_ATTACH_DATA_OBJ                          ),
        MAPIMACRO(PR_ATTACH_ENCODING                          ),
        MAPIMACRO(PR_ATTACH_EXTENSION                         ),
        MAPIMACRO(PR_ATTACH_FILENAME                          ),
        MAPIMACRO(PR_ATTACH_METHOD                            ),
        MAPIMACRO(PR_ATTACH_LONG_FILENAME                     ),
        MAPIMACRO(PR_ATTACH_PATHNAME                          ),
        MAPIMACRO(PR_ATTACH_RENDERING                         ),
        MAPIMACRO(PR_ATTACH_TAG                               ),
        MAPIMACRO(PR_RENDERING_POSITION                       ),
        MAPIMACRO(PR_ATTACH_TRANSPORT_NAME                    ),
        MAPIMACRO(PR_ATTACH_LONG_PATHNAME                     ),
        MAPIMACRO(PR_ATTACH_MIME_TAG                          ),
        MAPIMACRO(PR_ATTACH_ADDITIONAL_INFO                   ),
        MAPIMACRO(PR_DISPLAY_TYPE                             ),
        MAPIMACRO(PR_TEMPLATEID                               ),
        MAPIMACRO(PR_PRIMARY_CAPABILITY                       ),
        MAPIMACRO(PR_7BIT_DISPLAY_NAME                        ),
        MAPIMACRO(PR_ACCOUNT                                  ),
        MAPIMACRO(PR_ALTERNATE_RECIPIENT                      ),
        MAPIMACRO(PR_CALLBACK_TELEPHONE_NUMBER                ),
        MAPIMACRO(PR_CONVERSION_PROHIBITED                    ),
        MAPIMACRO(PR_DISCLOSE_RECIPIENTS                      ),
        MAPIMACRO(PR_GENERATION                               ),
        MAPIMACRO(PR_GIVEN_NAME                               ),
        MAPIMACRO(PR_GOVERNMENT_ID_NUMBER                     ),
        MAPIMACRO(PR_BUSINESS_TELEPHONE_NUMBER                ),
        MAPIMACRO(PR_HOME_TELEPHONE_NUMBER                    ),
        MAPIMACRO(PR_INITIALS                                 ),
        MAPIMACRO(PR_KEYWORD                                  ),
        MAPIMACRO(PR_LANGUAGE                                 ),
        MAPIMACRO(PR_LOCATION                                 ),
        MAPIMACRO(PR_MAIL_PERMISSION                          ),
        MAPIMACRO(PR_MHS_COMMON_NAME                          ),
        MAPIMACRO(PR_ORGANIZATIONAL_ID_NUMBER                 ),
        MAPIMACRO(PR_SURNAME                                  ),
        MAPIMACRO(PR_ORIGINAL_ENTRYID                         ),
        MAPIMACRO(PR_ORIGINAL_DISPLAY_NAME                    ),
        MAPIMACRO(PR_ORIGINAL_SEARCH_KEY                      ),
        MAPIMACRO(PR_POSTAL_ADDRESS                           ),
        MAPIMACRO(PR_COMPANY_NAME                             ),
        MAPIMACRO(PR_TITLE                                    ),
        MAPIMACRO(PR_DEPARTMENT_NAME                          ),
        MAPIMACRO(PR_OFFICE_LOCATION                          ),
        MAPIMACRO(PR_PRIMARY_TELEPHONE_NUMBER                 ),
        MAPIMACRO(PR_BUSINESS2_TELEPHONE_NUMBER               ),
        MAPIMACRO(PR_MOBILE_TELEPHONE_NUMBER                  ),
        MAPIMACRO(PR_RADIO_TELEPHONE_NUMBER                   ),
        MAPIMACRO(PR_CAR_TELEPHONE_NUMBER                     ),
        MAPIMACRO(PR_OTHER_TELEPHONE_NUMBER                   ),
        MAPIMACRO(PR_TRANSMITABLE_DISPLAY_NAME                ),
        MAPIMACRO(PR_PAGER_TELEPHONE_NUMBER                   ),
        MAPIMACRO(PR_USER_CERTIFICATE                         ),
        MAPIMACRO(PR_PRIMARY_FAX_NUMBER                       ),
        MAPIMACRO(PR_BUSINESS_FAX_NUMBER                      ),
        MAPIMACRO(PR_HOME_FAX_NUMBER                          ),
        MAPIMACRO(PR_COUNTRY                                  ),
        MAPIMACRO(PR_LOCALITY                                 ),
        MAPIMACRO(PR_STATE_OR_PROVINCE                        ),
        MAPIMACRO(PR_STREET_ADDRESS                           ),
        MAPIMACRO(PR_POSTAL_CODE                              ),
        MAPIMACRO(PR_POST_OFFICE_BOX                          ),
        MAPIMACRO(PR_TELEX_NUMBER                             ),
        MAPIMACRO(PR_ISDN_NUMBER                              ),
        MAPIMACRO(PR_ASSISTANT_TELEPHONE_NUMBER               ),
        MAPIMACRO(PR_HOME2_TELEPHONE_NUMBER                   ),
        MAPIMACRO(PR_ASSISTANT                                ),
        MAPIMACRO(PR_SEND_RICH_INFO                           ),
        MAPIMACRO(PR_WEDDING_ANNIVERSARY                      ),
        MAPIMACRO(PR_BIRTHDAY                                 ),
        MAPIMACRO(PR_HOBBIES                                  ),
        MAPIMACRO(PR_MIDDLE_NAME                              ),
        MAPIMACRO(PR_DISPLAY_NAME_PREFIX                      ),
        MAPIMACRO(PR_PROFESSION                               ),
        MAPIMACRO(PR_PREFERRED_BY_NAME                        ),
        MAPIMACRO(PR_SPOUSE_NAME                              ),
        MAPIMACRO(PR_COMPUTER_NETWORK_NAME                    ),
        MAPIMACRO(PR_CUSTOMER_ID                              ),
        MAPIMACRO(PR_TTYTDD_PHONE_NUMBER                      ),
        MAPIMACRO(PR_FTP_SITE                                 ),
        MAPIMACRO(PR_GENDER                                   ),
        MAPIMACRO(PR_MANAGER_NAME                             ),
        MAPIMACRO(PR_NICKNAME                                 ),
        MAPIMACRO(PR_PERSONAL_HOME_PAGE                       ),
        MAPIMACRO(PR_BUSINESS_HOME_PAGE                       ),
        MAPIMACRO(PR_CONTACT_VERSION                          ),
        MAPIMACRO(PR_CONTACT_ENTRYIDS                         ),
        MAPIMACRO(PR_CONTACT_ADDRTYPES                        ),
        MAPIMACRO(PR_CONTACT_DEFAULT_ADDRESS_INDEX            ),
        MAPIMACRO(PR_CONTACT_EMAIL_ADDRESSES                  ),
        MAPIMACRO(PR_COMPANY_MAIN_PHONE_NUMBER                ),
        MAPIMACRO(PR_CHILDRENS_NAMES                          ),
        MAPIMACRO(PR_HOME_ADDRESS_CITY                        ),
        MAPIMACRO(PR_HOME_ADDRESS_COUNTRY                     ),
        MAPIMACRO(PR_HOME_ADDRESS_POSTAL_CODE                 ),
        MAPIMACRO(PR_HOME_ADDRESS_STATE_OR_PROVINCE           ),
        MAPIMACRO(PR_HOME_ADDRESS_STREET                      ),
        MAPIMACRO(PR_HOME_ADDRESS_POST_OFFICE_BOX             ),
        MAPIMACRO(PR_OTHER_ADDRESS_CITY                       ),
        MAPIMACRO(PR_OTHER_ADDRESS_COUNTRY                    ),
        MAPIMACRO(PR_OTHER_ADDRESS_POSTAL_CODE                ),
        MAPIMACRO(PR_OTHER_ADDRESS_STATE_OR_PROVINCE          ),
        MAPIMACRO(PR_OTHER_ADDRESS_STREET                     ),
        MAPIMACRO(PR_OTHER_ADDRESS_POST_OFFICE_BOX            ),
        MAPIMACRO(PR_STORE_PROVIDERS                          ),
        MAPIMACRO(PR_AB_PROVIDERS                             ),
        MAPIMACRO(PR_TRANSPORT_PROVIDERS                      ),
        MAPIMACRO(PR_DEFAULT_PROFILE                          ),
        MAPIMACRO(PR_AB_SEARCH_PATH                           ),
        MAPIMACRO(PR_AB_DEFAULT_DIR                           ),
        MAPIMACRO(PR_AB_DEFAULT_PAB                           ),
        MAPIMACRO(PR_FILTERING_HOOKS                          ),
        MAPIMACRO(PR_SERVICE_NAME                             ),
        MAPIMACRO(PR_SERVICE_DLL_NAME                         ),
        MAPIMACRO(PR_SERVICE_ENTRY_NAME                       ),
        MAPIMACRO(PR_SERVICE_UID                              ),
        MAPIMACRO(PR_SERVICE_EXTRA_UIDS                       ),
        MAPIMACRO(PR_SERVICES                                 ),
        MAPIMACRO(PR_SERVICE_SUPPORT_FILES                    ),
        MAPIMACRO(PR_SERVICE_DELETE_FILES                     ),
        MAPIMACRO(PR_AB_SEARCH_PATH_UPDATE                    ),
        MAPIMACRO(PR_PROFILE_NAME                             ),
        MAPIMACRO(PR_IDENTITY_DISPLAY                         ),
        MAPIMACRO(PR_IDENTITY_ENTRYID                         ),
        MAPIMACRO(PR_RESOURCE_METHODS                         ),
        MAPIMACRO(PR_RESOURCE_TYPE                            ),
        MAPIMACRO(PR_STATUS_CODE                              ),
        MAPIMACRO(PR_IDENTITY_SEARCH_KEY                      ),
        MAPIMACRO(PR_OWN_STORE_ENTRYID                        ),
        MAPIMACRO(PR_RESOURCE_PATH                            ),
        MAPIMACRO(PR_STATUS_STRING                            ),
        MAPIMACRO(PR_X400_DEFERRED_DELIVERY_CANCEL            ),
        MAPIMACRO(PR_HEADER_FOLDER_ENTRYID                    ),
        MAPIMACRO(PR_REMOTE_PROGRESS                          ),
        MAPIMACRO(PR_REMOTE_PROGRESS_TEXT                     ),
        MAPIMACRO(PR_REMOTE_VALIDATE_OK                       ),
        MAPIMACRO(PR_CONTROL_FLAGS                            ),
        MAPIMACRO(PR_CONTROL_STRUCTURE                        ),
        MAPIMACRO(PR_CONTROL_TYPE                             ),
        MAPIMACRO(PR_DELTAX                                   ),
        MAPIMACRO(PR_DELTAY                                   ),
        MAPIMACRO(PR_XPOS                                     ),
        MAPIMACRO(PR_YPOS                                     ),
        MAPIMACRO(PR_CONTROL_ID                               ),
        MAPIMACRO(PR_INITIAL_DETAILS_PANE                     )};

#endif  /* MAPITAGS_H */

--- NEW FILE: mapidefs.h ---
#ifndef MAPIDEFS_H
#define MAPIDEFS_H

#define PR_ACKNOWLEDGEMENT_MODE                     0x0001
#define PR_ALTERNATE_RECIPIENT_ALLOWED              0x0002
#define PR_AUTHORIZING_USERS                        0x0003
#define PR_AUTO_FORWARD_COMMENT                     0x0004
#define PR_AUTO_FORWARDED                           0x0005
#define PR_CONTENT_CONFIDENTIALITY_ALGORITHM_ID     0x0006
#define PR_CONTENT_CORRELATOR                       0x0007
#define PR_CONTENT_IDENTIFIER                       0x0008
#define PR_CONTENT_LENGTH                           0x0009
#define PR_CONTENT_RETURN_REQUESTED                 0x000A
#define PR_CONVERSATION_KEY                         0x000B
#define PR_CONVERSION_EITS                          0x000C
#define PR_CONVERSION_WITH_LOSS_PROHIBITED          0x000D
#define PR_CONVERTED_EITS                           0x000E
#define PR_DEFERRED_DELIVERY_TIME                   0x000F
#define PR_DELIVER_TIME                             0x0010
#define PR_DISCARD_REASON                           0x0011
#define PR_DISCLOSURE_OF_RECIPIENTS                 0x0012
#define PR_DL_EXPANSION_HISTORY                     0x0013
#define PR_DL_EXPANSION_PROHIBITED                  0x0014
#define PR_EXPIRY_TIME                              0x0015
#define PR_IMPLICIT_CONVERSION_PROHIBITED           0x0016
#define PR_IMPORTANCE                               0x0017
#define PR_IPM_ID                                   0x0018
#define PR_LATEST_DELIVERY_TIME                     0x0019
#define PR_MESSAGE_CLASS                            0x001A
#define PR_MESSAGE_DELIVERY_ID                      0x001B
#define PR_MESSAGE_SECURITY_LABEL                   0x001E
#define PR_OBSOLETED_IPMS                           0x001F
#define PR_ORIGINALLY_INTENDED_RECIPIENT_NAME       0x0020
#define PR_ORIGINAL_EITS                            0x0021
#define PR_ORIGINATOR_CERTIFICATE                   0x0022
#define PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED     0x0023
#define PR_ORIGINATOR_RETURN_ADDRESS                0x0024
#define PR_PARENT_KEY                               0x0025
#define PR_PRIORITY                                 0x0026
#define PR_ORIGIN_CHECK                             0x0027
#define PR_PROOF_OF_SUBMISSION_REQUESTED            0x0028
#define PR_READ_RECEIPT_REQUESTED                   0x0029
#define PR_RECEIPT_TIME                             0x002A
#define PR_RECIPIENT_REASSIGNMENT_PROHIBITED        0x002B
#define PR_REDIRECTION_HISTORY                      0x002C
#define PR_RELATED_IPMS                             0x002D
#define PR_ORIGINAL_SENSITIVITY                     0x002E
#define PR_LANGUAGES                                0x002F
#define PR_REPLY_TIME                               0x0030
#define PR_REPORT_TAG                               0x0031
#define PR_REPORT_TIME                              0x0032
#define PR_RETURNED_IPM                             0x0033
#define PR_SECURITY                                 0x0034
#define PR_INCOMPLETE_COPY                          0x0035
#define PR_SENSITIVITY                              0x0036
#define PR_SUBJECT                                  0x0037
#define PR_SUBJECT_IPM                              0x0038
#define PR_CLIENT_SUBMIT_TIME                       0x0039
#define PR_REPORT_NAME                              0x003A
#define PR_SENT_REPRESENTING_SEARCH_KEY             0x003B
#define PR_X400_CONTENT_TYPE                        0x003C
#define PR_SUBJECT_PREFIX                           0x003D
#define PR_NON_RECEIPT_REASON                       0x003E
#define PR_RECEIVED_BY_ENTRYID                      0x003F
#define PR_RECEIVED_BY_NAME                         0x0040
#define PR_SENT_REPRESENTING_ENTRYID                0x0041
#define PR_SENT_REPRESENTING_NAME                   0x0042
#define PR_RCVD_REPRESENTING_ENTRYID                0x0043
#define PR_RCVD_REPRESENTING_NAME                   0x0044
#define PR_REPORT_ENTRYID                           0x0045
#define PR_READ_RECEIPT_ENTRYID                     0x0046
#define PR_MESSAGE_SUBMISSION_ID                    0x0047
#define PR_PROVIDER_SUBMIT_TIME                     0x0048
#define PR_ORIGINAL_SUBJECT                         0x0049
#define PR_DISC_VAL                                 0x004A
#define PR_ORIG_MESSAGE_CLASS                       0x004B
#define PR_ORIGINAL_AUTHOR_ENTRYID                  0x004C
#define PR_ORIGINAL_AUTHOR_NAME                     0x004D
#define PR_ORIGINAL_SUBMIT_TIME                     0x004E
#define PR_REPLY_RECIPIENT_ENTRIES                  0x004F
#define PR_REPLY_RECIPIENT_NAMES                    0x0050
#define PR_RECEIVED_BY_SEARCH_KEY                   0x0051
#define PR_RCVD_REPRESENTING_SEARCH_KEY             0x0052
#define PR_READ_RECEIPT_SEARCH_KEY                  0x0053
#define PR_REPORT_SEARCH_KEY                        0x0054
#define PR_ORIGINAL_DELIVERY_TIME                   0x0055
#define PR_ORIGINAL_AUTHOR_SEARCH_KEY               0x0056
#define PR_MESSAGE_TO_ME                            0x0057
#define PR_MESSAGE_CC_ME                            0x0058
#define PR_MESSAGE_RECIP_ME                         0x0059
#define PR_ORIGINAL_SENDER_NAME                     0x005A
#define PR_ORIGINAL_SENDER_ENTRYID                  0x005B
#define PR_ORIGINAL_SENDER_SEARCH_KEY               0x005C
#define PR_ORIGINAL_SENT_REPRESENTING_NAME          0x005D
#define PR_ORIGINAL_SENT_REPRESENTING_ENTRYID       0x005E
#define PR_ORIGINAL_SENT_REPRESENTING_SEARCH_KEY    0x005F
#define PR_START_DATE                               0x0060
#define PR_END_DATE                                 0x0061
#define PR_OWNER_APPT_ID                            0x0062
#define PR_RESPONSE_REQUESTED                       0x0063
#define PR_SENT_REPRESENTING_ADDRTYPE               0x0064
#define PR_SENT_REPRESENTING_EMAIL_ADDRESS          0x0065
#define PR_ORIGINAL_SENDER_ADDRTYPE                 0x0066
#define PR_ORIGINAL_SENDER_EMAIL_ADDRESS            0x0067
#define PR_ORIGINAL_SENT_REPRESENTING_ADDRTYPE      0x0068
#define PR_ORIGINAL_SENT_REPRESENTING_EMAIL_ADDRESS 0x0069
#define PR_CONVERSATION_TOPIC                       0x0070
#define PR_CONVERSATION_INDEX                       0x0071
#define PR_ORIGINAL_DISPLAY_BCC                     0x0072
#define PR_ORIGINAL_DISPLAY_CC                      0x0073
#define PR_ORIGINAL_DISPLAY_TO                      0x0074
#define PR_RECEIVED_BY_ADDRTYPE                     0x0075
#define PR_RECEIVED_BY_EMAIL_ADDRESS                0x0076
#define PR_RCVD_REPRESENTING_ADDRTYPE               0x0077
#define PR_RCVD_REPRESENTING_EMAIL_ADDRESS          0x0078
#define PR_ORIGINAL_AUTHOR_ADDRTYPE                 0x0079
#define PR_ORIGINAL_AUTHOR_EMAIL_ADDRESS            0x007A
#define PR_ORIGINALLY_INTENDED_RECIP_ADDRTYPE       0x007B
#define PR_ORIGINALLY_INTENDED_RECIP_EMAIL_ADDRESS  0x007C
#define PR_TRANSPORT_MESSAGE_HEADERS                0x007D
#define PR_DELEGATION                               0x007E
#define PR_TNEF_CORRELATION_KEY                     0x007F
#define PR_BODY                                     0x1000
#define PR_REPORT_TEXT                              0x1001
#define PR_ORIGINATOR_AND_DL_EXPANSION_HISTORY      0x1002
#define PR_REPORTING_DL_NAME                        0x1003
#define PR_REPORTING_MTA_CERTIFICATE                0x1004
#define PR_RTF_SYNC_BODY_CRC                        0x1006
#define PR_RTF_SYNC_BODY_COUNT                      0x1007
#define PR_RTF_SYNC_BODY_TAG                        0x1008
#define PR_RTF_COMPRESSED                           0x1009
#define PR_RTF_SYNC_PREFIX_COUNT                    0x1010
#define PR_RTF_SYNC_TRAILING_COUNT                  0x1011
#define PR_ORIGINALLY_INTENDED_RECIP_ENTRYID        0x1012
#define PR_CONTENT_INTEGRITY_CHECK                  0x0C00
#define PR_EXPLICIT_CONVERSION                      0x0C01
#define PR_IPM_RETURN_REQUESTED                     0x0C02
#define PR_MESSAGE_TOKEN                            0x0C03
#define PR_NDR_REASON_CODE                          0x0C04
#define PR_NDR_DIAG_CODE                            0x0C05
#define PR_NON_RECEIPT_NOTIFICATION_REQUESTED       0x0C06
#define PR_DELIVERY_POINT                           0x0C07

#define PR_ORIGINATOR_NON_DELIVERY_REPORT_REQUESTED 0x0C08
#define PR_ORIGINATOR_REQUESTED_ALTERNATE_RECIPIENT 0x0C09
#define PR_PHYSICAL_DELIVERY_BUREAU_FAX_DELIVERY    0x0C0A
#define PR_PHYSICAL_DELIVERY_MODE                   0x0C0B
#define PR_PHYSICAL_DELIVERY_REPORT_REQUEST         0x0C0C
#define PR_PHYSICAL_FORWARDING_ADDRESS              0x0C0D
#define PR_PHYSICAL_FORWARDING_ADDRESS_REQUESTED    0x0C0E
#define PR_PHYSICAL_FORWARDING_PROHIBITED           0x0C0F
#define PR_PHYSICAL_RENDITION_ATTRIBUTES            0x0C10
#define PR_PROOF_OF_DELIVERY                        0x0C11
#define PR_PROOF_OF_DELIVERY_REQUESTED              0x0C12
#define PR_RECIPIENT_CERTIFICATE                    0x0C13
#define PR_RECIPIENT_NUMBER_FOR_ADVICE              0x0C14
#define PR_RECIPIENT_TYPE                           0x0C15
#define PR_REGISTERED_MAIL_TYPE                     0x0C16
#define PR_REPLY_REQUESTED                          0x0C17
#define PR_REQUESTED_DELIVERY_METHOD                0x0C18
#define PR_SENDER_ENTRYID                           0x0C19
#define PR_SENDER_NAME                              0x0C1A
#define PR_SUPPLEMENTARY_INFO                       0x0C1B
#define PR_TYPE_OF_MTS_USER                         0x0C1C
#define PR_SENDER_SEARCH_KEY                        0x0C1D
#define PR_SENDER_ADDRTYPE                          0x0C1E
#define PR_SENDER_EMAIL_ADDRESS                     0x0C1F
#define PR_CURRENT_VERSION                          0x0E00
#define PR_DELETE_AFTER_SUBMIT                      0x0E01
#define PR_DISPLAY_BCC                              0x0E02
#define PR_DISPLAY_CC                               0x0E03
#define PR_DISPLAY_TO                               0x0E04
#define PR_PARENT_DISPLAY                           0x0E05
#define PR_MESSAGE_DELIVERY_TIME                    0x0E06
#define PR_MESSAGE_FLAGS                            0x0E07
#define PR_MESSAGE_SIZE                             0x0E08
#define PR_PARENT_ENTRYID                           0x0E09
#define PR_SENTMAIL_ENTRYID                         0x0E0A
#define PR_CORRELATE                                0x0E0C
#define PR_CORRELATE_MTSID                          0x0E0D
#define PR_DISCRETE_VALUES                          0x0E0E
#define PR_RESPONSIBILITY                           0x0E0F
#define PR_SPOOLER_STATUS                           0x0E10
#define PR_TRANSPORT_STATUS                         0x0E11
#define PR_MESSAGE_RECIPIENTS                       0x0E12
#define PR_MESSAGE_ATTACHMENTS                      0x0E13
#define PR_SUBMIT_FLAGS                             0x0E14
#define PR_RECIPIENT_STATUS                         0x0E15
#define PR_TRANSPORT_KEY                            0x0E16
#define PR_MSG_STATUS                               0x0E17
#define PR_MESSAGE_DOWNLOAD_TIME                    0x0E18
#define PR_CREATION_VERSION                         0x0E19
#define PR_MODIFY_VERSION                           0x0E1A
#define PR_HASATTACH                                0x0E1B
#define PR_BODY_CRC                                 0x0E1C
#define PR_NORMALIZED_SUBJECT                       0x0E1D
#define PR_RTF_IN_SYNC                              0x0E1F
#define PR_ATTACH_SIZE                              0x0E20
#define PR_ATTACH_NUM                               0x0E21
#define PR_PREPROCESS                               0x0E22
#define PR_ORIGINATING_MTA_CERTIFICATE              0x0E25
#define PR_PROOF_OF_SUBMISSION                      0x0E26
#define PR_ENTRYID                                  0x0FFF
#define PR_OBJECT_TYPE                              0x0FFE
#define PR_ICON                                     0x0FFD
#define PR_MINI_ICON                                0x0FFC
#define PR_STORE_ENTRYID                            0x0FFB
#define PR_STORE_RECORD_KEY                         0x0FFA
#define PR_RECORD_KEY                               0x0FF9
#define PR_MAPPING_SIGNATURE                        0x0FF8
#define PR_ACCESS_LEVEL                             0x0FF7
#define PR_INSTANCE_KEY                             0x0FF6
#define PR_ROW_TYPE                                 0x0FF5
#define PR_ACCESS                                   0x0FF4
#define PR_ROWID                                    0x3000
#define PR_DISPLAY_NAME                             0x3001
#define PR_ADDRTYPE                                 0x3002
#define PR_EMAIL_ADDRESS                            0x3003
#define PR_COMMENT                                  0x3004
#define PR_DEPTH                                    0x3005
#define PR_PROVIDER_DISPLAY                         0x3006
#define PR_CREATION_TIME                            0x3007
#define PR_LAST_MODIFICATION_TIME                   0x3008
#define PR_RESOURCE_FLAGS                           0x3009
#define PR_PROVIDER_DLL_NAME                        0x300A
#define PR_SEARCH_KEY                               0x300B
#define PR_PROVIDER_UID                             0x300C
#define PR_PROVIDER_ORDINAL                         0x300D
#define PR_FORM_VERSION                             0x3301
#define PR_FORM_CLSID                               0x3302
#define PR_FORM_CONTACT_NAME                        0x3303
#define PR_FORM_CATEGORY                            0x3304
#define PR_FORM_CATEGORY_SUB                        0x3305
#define PR_FORM_HOST_MAP                            0x3306
#define PR_FORM_HIDDEN                              0x3307
#define PR_FORM_DESIGNER_NAME                       0x3308
#define PR_FORM_DESIGNER_GUID                       0x3309
#define PR_FORM_MESSAGE_BEHAVIOR                    0x330A
#define PR_DEFAULT_STORE                            0x3400
#define PR_STORE_SUPPORT_MASK                       0x340D
#define PR_STORE_STATE                              0x340E
#define PR_IPM_SUBTREE_SEARCH_KEY                   0x3410
#define PR_IPM_OUTBOX_SEARCH_KEY                    0x3411
#define PR_IPM_WASTEBASKET_SEARCH_KEY               0x3412
#define PR_IPM_SENTMAIL_SEARCH_KEY                  0x3413
#define PR_MDB_PROVIDER                             0x3414
#define PR_RECEIVE_FOLDER_SETTINGS                  0x3415
#define PR_VALID_FOLDER_MASK                        0x35DF
#define PR_IPM_SUBTREE_ENTRYID                      0x35E0
#define PR_IPM_OUTBOX_ENTRYID                       0x35E2
#define PR_IPM_WASTEBASKET_ENTRYID                  0x35E3
#define PR_IPM_SENTMAIL_ENTRYID                     0x35E4
#define PR_VIEWS_ENTRYID                            0x35E5
#define PR_COMMON_VIEWS_ENTRYID                     0x35E6
#define PR_FINDER_ENTRYID                           0x35E7
#define PR_CONTAINER_FLAGS                          0x3600
#define PR_FOLDER_TYPE                              0x3601
#define PR_CONTENT_COUNT                            0x3602
#define PR_CONTENT_UNREAD                           0x3603
#define PR_CREATE_TEMPLATES                         0x3604
#define PR_DETAILS_TABLE                            0x3605
#define PR_SEARCH                                   0x3607
#define PR_SELECTABLE                               0x3609
#define PR_SUBFOLDERS                               0x360A
#define PR_STATUS                                   0x360B
#define PR_ANR                                      0x360C
#define PR_CONTENTS_SORT_ORDER                      0x360D
#define PR_CONTAINER_HIERARCHY                      0x360E
#define PR_CONTAINER_CONTENTS                       0x360F
#define PR_FOLDER_ASSOCIATED_CONTENTS               0x3610
#define PR_DEF_CREATE_DL                            0x3611
#define PR_DEF_CREATE_MAILUSER                      0x3612
#define PR_CONTAINER_CLASS                          0x3613
#define PR_CONTAINER_MODIFY_VERSION                 0x3614
#define PR_AB_PROVIDER_ID                           0x3615
#define PR_DEFAULT_VIEW_ENTRYID                     0x3616
#define PR_ASSOC_CONTENT_COUNT                      0x3617
#define PR_ATTACHMENT_X400_PARAMETERS               0x3700
#define PR_ATTACH_DATA_OBJ                          0x3701
#define PR_ATTACH_ENCODING                          0x3702
#define PR_ATTACH_EXTENSION                         0x3703
#define PR_ATTACH_FILENAME                          0x3704
#define PR_ATTACH_METHOD                            0x3705
#define PR_ATTACH_LONG_FILENAME                     0x3707
#define PR_ATTACH_PATHNAME                          0x3708
#define PR_ATTACH_RENDERING                         0x3709
#define PR_ATTACH_TAG                               0x370A
#define PR_RENDERING_POSITION                       0x370B
#define PR_ATTACH_TRANSPORT_NAME                    0x370C
#define PR_ATTACH_LONG_PATHNAME                     0x370D
#define PR_ATTACH_MIME_TAG                          0x370E
#define PR_ATTACH_ADDITIONAL_INFO                   0x370F
#define PR_DISPLAY_TYPE                             0x3900
#define PR_TEMPLATEID                               0x3902
#define PR_PRIMARY_CAPABILITY                       0x3904
#define PR_7BIT_DISPLAY_NAME                        0x39FF
#define PR_ACCOUNT                                  0x3A00
#define PR_ALTERNATE_RECIPIENT                      0x3A01
#define PR_CALLBACK_TELEPHONE_NUMBER                0x3A02
#define PR_CONVERSION_PROHIBITED                    0x3A03
#define PR_DISCLOSE_RECIPIENTS                      0x3A04
#define PR_GENERATION                               0x3A05
#define PR_GIVEN_NAME                               0x3A06
#define PR_GOVERNMENT_ID_NUMBER                     0x3A07
#define PR_BUSINESS_TELEPHONE_NUMBER                0x3A08
#define PR_HOME_TELEPHONE_NUMBER                    0x3A09
#define PR_INITIALS                                 0x3A0A
#define PR_KEYWORD                                  0x3A0B
#define PR_LANGUAGE                                 0x3A0C
#define PR_LOCATION                                 0x3A0D
#define PR_MAIL_PERMISSION                          0x3A0E
#define PR_MHS_COMMON_NAME                          0x3A0F
#define PR_ORGANIZATIONAL_ID_NUMBER                 0x3A10
#define PR_SURNAME                                  0x3A11
#define PR_ORIGINAL_ENTRYID                         0x3A12
#define PR_ORIGINAL_DISPLAY_NAME                    0x3A13
#define PR_ORIGINAL_SEARCH_KEY                      0x3A14
#define PR_POSTAL_ADDRESS                           0x3A15
#define PR_COMPANY_NAME                             0x3A16
#define PR_TITLE                                    0x3A17
#define PR_DEPARTMENT_NAME                          0x3A18
#define PR_OFFICE_LOCATION                          0x3A19
#define PR_PRIMARY_TELEPHONE_NUMBER                 0x3A1A
#define PR_BUSINESS2_TELEPHONE_NUMBER               0x3A1B
#define PR_MOBILE_TELEPHONE_NUMBER                  0x3A1C
#define PR_RADIO_TELEPHONE_NUMBER                   0x3A1D
#define PR_CAR_TELEPHONE_NUMBER                     0x3A1E
#define PR_OTHER_TELEPHONE_NUMBER                   0x3A1F
#define PR_TRANSMITABLE_DISPLAY_NAME                0x3A20
#define PR_PAGER_TELEPHONE_NUMBER                   0x3A21
#define PR_USER_CERTIFICATE                         0x3A22
#define PR_PRIMARY_FAX_NUMBER                       0x3A23
#define PR_BUSINESS_FAX_NUMBER                      0x3A24
#define PR_HOME_FAX_NUMBER                          0x3A25
#define PR_COUNTRY                                  0x3A26
#define PR_LOCALITY                                 0x3A27
#define PR_STATE_OR_PROVINCE                        0x3A28
#define PR_STREET_ADDRESS                           0x3A29
#define PR_POSTAL_CODE                              0x3A2A
#define PR_POST_OFFICE_BOX                          0x3A2B
#define PR_TELEX_NUMBER                             0x3A2C
#define PR_ISDN_NUMBER                              0x3A2D
#define PR_ASSISTANT_TELEPHONE_NUMBER               0x3A2E
#define PR_HOME2_TELEPHONE_NUMBER                   0x3A2F
#define PR_ASSISTANT                                0x3A30
#define PR_SEND_RICH_INFO                           0x3A40
#define PR_WEDDING_ANNIVERSARY                      0x3A41
#define PR_BIRTHDAY                                 0x3A42
#define PR_HOBBIES                                  0x3A43
#define PR_MIDDLE_NAME                              0x3A44
#define PR_DISPLAY_NAME_PREFIX                      0x3A45
#define PR_PROFESSION                               0x3A46
#define PR_PREFERRED_BY_NAME                        0x3A47
#define PR_SPOUSE_NAME                              0x3A48
#define PR_COMPUTER_NETWORK_NAME                    0x3A49
#define PR_CUSTOMER_ID                              0x3A4A
#define PR_TTYTDD_PHONE_NUMBER                      0x3A4B
#define PR_FTP_SITE                                 0x3A4C
#define PR_GENDER                                   0x3A4D
#define PR_MANAGER_NAME                             0x3A4E
#define PR_NICKNAME                                 0x3A4F
#define PR_PERSONAL_HOME_PAGE                       0x3A50
#define PR_BUSINESS_HOME_PAGE                       0x3A51
#define PR_CONTACT_VERSION                          0x3A52
#define PR_CONTACT_ENTRYIDS                         0x3A53
#define PR_CONTACT_ADDRTYPES                        0x3A54
#define PR_CONTACT_DEFAULT_ADDRESS_INDEX            0x3A55
#define PR_CONTACT_EMAIL_ADDRESSES                  0x3A56
#define PR_COMPANY_MAIN_PHONE_NUMBER                0x3A57
#define PR_CHILDRENS_NAMES                          0x3A58
#define PR_HOME_ADDRESS_CITY                        0x3A59
#define PR_HOME_ADDRESS_COUNTRY                     0x3A5A
#define PR_HOME_ADDRESS_POSTAL_CODE                 0x3A5B
#define PR_HOME_ADDRESS_STATE_OR_PROVINCE           0x3A5C
#define PR_HOME_ADDRESS_STREET                      0x3A5D
#define PR_HOME_ADDRESS_POST_OFFICE_BOX             0x3A5E
#define PR_OTHER_ADDRESS_CITY                       0x3A5F
#define PR_OTHER_ADDRESS_COUNTRY                    0x3A60
#define PR_OTHER_ADDRESS_POSTAL_CODE                0x3A61
#define PR_OTHER_ADDRESS_STATE_OR_PROVINCE          0x3A62
#define PR_OTHER_ADDRESS_STREET                     0x3A63
#define PR_OTHER_ADDRESS_POST_OFFICE_BOX            0x3A64
#define PR_STORE_PROVIDERS                          0x3D00
#define PR_AB_PROVIDERS                             0x3D01
#define PR_TRANSPORT_PROVIDERS                      0x3D02
#define PR_DEFAULT_PROFILE                          0x3D04
#define PR_AB_SEARCH_PATH                           0x3D05
#define PR_AB_DEFAULT_DIR                           0x3D06
#define PR_AB_DEFAULT_PAB                           0x3D07
#define PR_FILTERING_HOOKS                          0x3D08
#define PR_SERVICE_NAME                             0x3D09
#define PR_SERVICE_DLL_NAME                         0x3D0A
#define PR_SERVICE_ENTRY_NAME                       0x3D0B
#define PR_SERVICE_UID                              0x3D0C
#define PR_SERVICE_EXTRA_UIDS                       0x3D0D
#define PR_SERVICES                                 0x3D0E
#define PR_SERVICE_SUPPORT_FILES                    0x3D0F
#define PR_SERVICE_DELETE_FILES                     0x3D10
#define PR_AB_SEARCH_PATH_UPDATE                    0x3D11
#define PR_PROFILE_NAME                             0x3D12
#define PR_IDENTITY_DISPLAY                         0x3E00
#define PR_IDENTITY_ENTRYID                         0x3E01
#define PR_RESOURCE_METHODS                         0x3E02
#define PR_RESOURCE_TYPE                            0x3E03
#define PR_STATUS_CODE                              0x3E04
#define PR_IDENTITY_SEARCH_KEY                      0x3E05
#define PR_OWN_STORE_ENTRYID                        0x3E06
#define PR_RESOURCE_PATH                            0x3E07
#define PR_STATUS_STRING                            0x3E08
#define PR_X400_DEFERRED_DELIVERY_CANCEL            0x3E09
#define PR_HEADER_FOLDER_ENTRYID                    0x3E0A
#define PR_REMOTE_PROGRESS                          0x3E0B
#define PR_REMOTE_PROGRESS_TEXT                     0x3E0C
#define PR_REMOTE_VALIDATE_OK                       0x3E0D
#define PR_CONTROL_FLAGS                            0x3F00
#define PR_CONTROL_STRUCTURE                        0x3F01
#define PR_CONTROL_TYPE                             0x3F02
#define PR_DELTAX                                   0x3F03
#define PR_DELTAY                                   0x3F04
#define PR_XPOS                                     0x3F05
#define PR_YPOS                                     0x3F06
#define PR_CONTROL_ID                               0x3F07
#define PR_INITIAL_DETAILS_PANE                     0x3F08

/*
 * Secure property id range
 */

#define PROP_ID_SECURE_MIN                          0x67F0
#define PROP_ID_SECURE_MAX                          0x67FF


#endif  /* MAPIDEFS_H */

--- NEW FILE: tnef_dump.c ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2007 Colin Leroy <colin at colino.net>
 * and the Claws Mail Team
 *
 * This file Copyright (C) 2002-2007 Randall Hand <yerase at yerot.com> 
 * Thanks to him for allowing redistribution of this code as GPLv3.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
#ifdef HAVE_CONFIG_H
#  include "config.h"
#include "claws-features.h"
#endif

#include <unistd.h>
#include <stdio.h>
#include <ctype.h>

#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "common/claws.h"
#include "common/version.h"
#include "main.h"
#include "plugin.h"
#include "procmime.h"
#include "utils.h"

#include <tnef-types.h>
#include <ytnef.h>
#include <mapi.h>
#include <mapidefs.h>

#include "tnef_dump.h"

#define PRODID "PRODID:-//The Gauntlet//" PACKAGE " TNEF Parser " VERSION "//EN\n"

static unsigned char GetRruleCount(unsigned char a, unsigned char b) {
    return ((a << 8) | b);
}

static unsigned char GetRruleMonthNum(unsigned char a, unsigned char b) {
    switch (a) {
        case 0x00:
            switch (b) {
                case 0x00:
                    // Jan
                    return(1);
                case 0xA3:
                    // May
                    return(5);
                case 0xAE:
                    // Nov
                    return(11);
            }
            break;
        case 0x60:
            switch (b) {
                case 0xAE:
                    // Feb
                    return(2);
                case 0x51:
                    // Jun
                    return(6);
            }
            break;
        case 0xE0:
            switch (b) {
                case 0x4B:
                    // Mar
                    return(3);
                case 0x56:
                    // Sep
                    return(9);
            }
            break;
        case 0x40:
            switch (b) {
                case 0xFA:
                    // Apr
                    return(4);
            }
            break;
        case 0x20:
            if (b == 0xFA) {
                // Jul
                return(7);
            }
            break;
        case 0x80:
            if (b == 0xA8) {
                // Aug
                return(8);
            }
            break;
        case 0xA0:
            if (b == 0xFF) {
                // Oct
                return(10);
            }
            break;
        case 0xC0:
            if (b == 0x56) {
                return(12);
            }
    }

    // Error
    return(0);
}

static char * GetRruleDayname(unsigned char a) {
    static char daystring[25];

    *daystring = 0;

    if (a & 0x01) {
        strcat(daystring, "SU,");
    }
    if (a & 0x02) {
        strcat(daystring, "MO,");
    }
    if (a & 0x04) {
        strcat(daystring, "TU,");
    }
    if (a & 0x08) {
        strcat(daystring, "WE,");
    }
    if (a & 0x10) {
        strcat(daystring, "TH,");
    }
    if (a & 0x20) {
        strcat(daystring, "FR,");
    }
    if (a & 0x40) {
        strcat(daystring, "SA,");
    }

    if (strlen(daystring)) {
        daystring[strlen(daystring) - 1] = 0;
    }

    return(daystring);
}

static void PrintRrule(FILE *fptr, char *recur_data, int size, TNEFStruct TNEF) {
    variableLength *filename;

    if (size < 0x1F) {
        return;
    }

    fprintf(fptr, "RRULE:FREQ=");

    if (recur_data[0x04] == 0x0A) {
        fprintf(fptr, "DAILY");

        if (recur_data[0x16] == 0x23 || recur_data[0x16] == 0x22 ||
                recur_data[0x16] == 0x21) {
            if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                    PROP_TAG(PT_I2, 0x0011))) != MAPI_UNDEFINED) {
                fprintf(fptr, ";INTERVAL=%d", *(filename->data));
            }
            if (recur_data[0x16] == 0x22 || recur_data[0x16] == 0x21) {
                fprintf(fptr, ";COUNT=%d",
                    GetRruleCount(recur_data[0x1B], recur_data[0x1A]));
            }
        } else if (recur_data[0x16] == 0x3E) {
            fprintf(fptr, ";BYDAY=MO,TU,WE,TH,FR");
            if (recur_data[0x1A] == 0x22 || recur_data[0x1A] == 0x21) {
                fprintf(fptr, ";COUNT=%d",
                    GetRruleCount(recur_data[0x1F], recur_data[0x1E]));
            }
        }
    } else if (recur_data[0x04] == 0x0B) {
        fprintf(fptr, "WEEKLY;INTERVAL=%d;BYDAY=%s",
            recur_data[0x0E], GetRruleDayname(recur_data[0x16]));
        if (recur_data[0x1A] == 0x22 || recur_data[0x1A] == 0x21) {
            fprintf(fptr, ";COUNT=%d",
                GetRruleCount(recur_data[0x1F], recur_data[0x1E]));
        }
    } else if (recur_data[0x04] == 0x0C) {
        fprintf(fptr, "MONTHLY");
        if (recur_data[0x06] == 0x02) {
            fprintf(fptr, ";INTERVAL=%d;BYMONTHDAY=%d", recur_data[0x0E],
                recur_data[0x16]);
            if (recur_data[0x1A] == 0x22 || recur_data[0x1A] == 0x21) {
                fprintf(fptr, ";COUNT=%d", GetRruleCount(recur_data[0x1F],
                    recur_data[0x1E]));
            }
        } else if (recur_data[0x06] == 0x03) {
            fprintf(fptr, ";BYDAY=%s;BYSETPOS=%d;INTERVAL=%d",
                GetRruleDayname(recur_data[0x16]),
                recur_data[0x1A] == 0x05 ? -1 : recur_data[0x1A],
                recur_data[0x0E]);
            if (recur_data[0x1E] == 0x22 || recur_data[0x1E] == 0x21) {
                fprintf(fptr, ";COUNT=%d", GetRruleCount(recur_data[0x23],
                    recur_data[0x22]));
            }
        }
    } else if (recur_data[0x04] == 0x0D) {
        fprintf(fptr, "YEARLY;BYMONTH=%d",
                GetRruleMonthNum(recur_data[0x0A], recur_data[0x0B]));
        if (recur_data[0x06] == 0x02) {
            fprintf(fptr, ";BYMONTHDAY=%d", recur_data[0x16]);
        } else if (recur_data[0x06] == 0x03) {
            fprintf(fptr, ";BYDAY=%s;BYSETPOS=%d",
                GetRruleDayname(recur_data[0x16]),
                recur_data[0x1A] == 0x05 ? -1 : recur_data[0x1A]);
        }
        if (recur_data[0x1E] == 0x22 || recur_data[0x1E] == 0x21) {
            fprintf(fptr, ";COUNT=%d", GetRruleCount(recur_data[0x23],
                recur_data[0x22]));
        }
    }
    fprintf(fptr, "\n");
}

static void fprintProperty(TNEFStruct TNEF, FILE *FPTR, DWORD PROPTYPE, DWORD PROPID, char TEXT[]) {
    variableLength *vl;
    if ((vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PROPTYPE, PROPID))) != MAPI_UNDEFINED) {
        if (vl->size > 0) {
            if ((vl->size == 1) && (vl->data[0] == 0)) {
            } else {
                fprintf(FPTR, TEXT, vl->data);
            }
	}
    }
}

static void fprintUserProp(TNEFStruct TNEF, FILE *FPTR, DWORD PROPTYPE, DWORD PROPID, char TEXT[]) {
    variableLength *vl;
    if ((vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PROPTYPE, PROPID))) != MAPI_UNDEFINED) {
        if (vl->size > 0) {
            if ((vl->size == 1) && (vl->data[0] == 0)) {
            } else {
                fprintf(FPTR, TEXT, vl->data);
            }
	}
    }
}

static void quotedfprint(FILE *FPTR, variableLength *VL) {
    int index;

    for (index=0;index<VL->size-1; index++) {
        if (VL->data[index] == '\n') {
            fprintf(FPTR, "=0A");
        } else if (VL->data[index] == '\r') {
        } else {
            fprintf(FPTR, "%c", VL->data[index]);
        }
    }
}

static void Cstylefprint(FILE *FPTR, variableLength *VL) {
    int index;

    for (index=0;index<VL->size-1; index++) {
        if (VL->data[index] == '\n') {
            fprintf(FPTR, "\\n");
        } else if (VL->data[index] == '\r') {
            // Print nothing.
        } else if (VL->data[index] == ';') {
            fprintf(FPTR, "\\;");
        } else if (VL->data[index] == ',') {
            fprintf(FPTR, "\\,");
        } else if (VL->data[index] == '\\') {
            fprintf(FPTR, "\\");
        } else {
            fprintf(FPTR, "%c", VL->data[index]);
        }
    }
}

static void PrintRTF(FILE *fptr, variableLength *VL) {
    int index;
    char *byte;
    int brace_ct;
    int key;

    key = 0;
    brace_ct = 0;

    for(index = 0, byte=VL->data; index < VL->size; index++, byte++) {
        if (*byte == '}') {
            brace_ct--;
            key = 0;
            continue;
        }
        if (*byte == '{') {
            brace_ct++;
            continue;
        }
        if (*byte == '\\') {
            key = 1;
        }
        if (isspace(*byte)) {
            key = 0;
        }
        if ((brace_ct == 1) && (key == 0)) {
            if (*byte == '\n') {
                fprintf(fptr, "\\n");
            } else if (*byte == '\r') {
                // Print nothing.
            } else if (*byte == ';') {
                fprintf(fptr, "\\;");
            } else if (*byte == ',') {
                fprintf(fptr, "\\,");
            } else if (*byte == '\\') {
                fprintf(fptr, "\\");
            } else {
                fprintf(fptr, "%c", *byte );
            }
        }
    }
    fprintf(fptr, "\n");
}

gboolean SaveVCalendar(FILE *fptr, TNEFStruct TNEF) {
    variableLength *filename;
    char *charptr, *charptr2;
    int index;
    DDWORD *ddword_ptr;
    DDWORD ddword_val;
    dtr thedate;

        fprintf(fptr, "BEGIN:VCALENDAR\n");
        if (TNEF.messageClass[0] != 0) {
            charptr2=TNEF.messageClass;
            charptr=charptr2;
            while (*charptr != 0) {
                if (*charptr == '.') {
                    charptr2 = charptr;
                }
                charptr++;
            }
            if (strcmp(charptr2, ".MtgCncl") == 0) {
                fprintf(fptr, "METHOD:CANCEL\n");
            } else {
                fprintf(fptr, "METHOD:REQUEST\n");
            }
        } else {
            fprintf(fptr, "METHOD:REQUEST\n");
        }
        fprintf(fptr, PRODID);
        fprintf(fptr, "VERSION:2.0\n");
        fprintf(fptr, "BEGIN:VEVENT\n");

        // UID
        // After alot of comparisons, I'm reasonably sure this is totally
        // wrong.  But it's not really necessary.
        //
        // I think it only exists to connect future modification entries to
        // this entry. so as long as it's incorrectly interpreted the same way
        // every time, it should be ok :)
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_BINARY, 0x3))) == MAPI_UNDEFINED) {
            if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                            PROP_TAG(PT_BINARY, 0x23))) == MAPI_UNDEFINED) {
                filename = NULL;
            }
        }
        if (filename!=NULL) {
            fprintf(fptr, "UID:");
            for(index=0;index<filename->size;index++) {
                fprintf(fptr,"%02X", (unsigned char)filename->data[index]);
            }
            fprintf(fptr,"\n");
        }

        // Sequence
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_LONG, 0x8201))) != MAPI_UNDEFINED) {
            ddword_ptr = (DDWORD*)filename->data;
            fprintf(fptr, "SEQUENCE:%i\n", (int) *ddword_ptr);
        }
        if ((filename=MAPIFindProperty(&(TNEF.MapiProperties),
                        PROP_TAG(PT_BINARY, PR_SENDER_SEARCH_KEY)))
                != MAPI_UNDEFINED) {
            charptr = filename->data;
            charptr2 = strstr(charptr, ":");
            if (charptr2 == NULL)
                charptr2 = charptr;
            else
                charptr2++;
            fprintf(fptr, "ORGANIZER;CN=\"%s\":MAILTO:%s\n",
                    charptr2, charptr2);
        }

        // Required Attendees
        if ((filename = MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_STRING8, 0x823b))) != MAPI_UNDEFINED) {
                // We have a list of required participants, so
                // write them out.
            if (filename->size > 1) {
                charptr = filename->data-1;
                charptr2=strstr(charptr+1, ";");
                while (charptr != NULL) {
                    charptr++;
                    charptr2 = strstr(charptr, ";");
                    if (charptr2 != NULL) {
                        *charptr2 = 0;
                    }
                    while (*charptr == ' ')
                        charptr++;
                    fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;");
                    fprintf(fptr, "ROLE=REQ-PARTICIPANT;RSVP=TRUE;");
                    fprintf(fptr, "CN=\"%s\":MAILTO:%s\n",
                                charptr, charptr);
                    charptr = charptr2;
                }
            }
            // Optional attendees
            if ((filename = MAPIFindUserProp(&(TNEF.MapiProperties),
                            PROP_TAG(PT_STRING8, 0x823c))) != MAPI_UNDEFINED) {
                    // The list of optional participants
                if (filename->size > 1) {
                    charptr = filename->data-1;
                    charptr2=strstr(charptr+1, ";");
                    while (charptr != NULL) {
                        charptr++;
                        charptr2 = strstr(charptr, ";");
                        if (charptr2 != NULL) {
                            *charptr2 = 0;
                        }
                        while (*charptr == ' ')
                            charptr++;
                        fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;");
                        fprintf(fptr, "ROLE=OPT-PARTICIPANT;RSVP=TRUE;");
                        fprintf(fptr, "CN=\"%s\":MAILTO:%s\n",
                                charptr, charptr);
                        charptr = charptr2;
                    }
                }
            }
        } else if ((filename = MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_STRING8, 0x8238))) != MAPI_UNDEFINED) {
            if (filename->size > 1) {
                charptr = filename->data-1;
                charptr2=strstr(charptr+1, ";");
                while (charptr != NULL) {
                    charptr++;
                    charptr2 = strstr(charptr, ";");
                    if (charptr2 != NULL) {
                        *charptr2 = 0;
                    }
                    while (*charptr == ' ')
                        charptr++;
                    fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;");
                    fprintf(fptr, "ROLE=REQ-PARTICIPANT;RSVP=TRUE;");
                    fprintf(fptr, "CN=\"%s\":MAILTO:%s\n",
                                charptr, charptr);
                    charptr = charptr2;
                }
            }

        }
        // Summary
        filename = NULL;
        if((filename=MAPIFindProperty(&(TNEF.MapiProperties),
                        PROP_TAG(PT_STRING8, PR_CONVERSATION_TOPIC)))
                != MAPI_UNDEFINED) {
            fprintf(fptr, "SUMMARY:");
            Cstylefprint(fptr, filename);
            fprintf(fptr, "\n");
        }

        // Description
        if ((filename=MAPIFindProperty(&(TNEF.MapiProperties),
                                PROP_TAG(PT_BINARY, PR_RTF_COMPRESSED)))
                != MAPI_UNDEFINED) {
            variableLength buf;
            if ((buf.data = DecompressRTF(filename, &(buf.size))) != NULL) {
                fprintf(fptr, "DESCRIPTION:");
                PrintRTF(fptr, &buf);
                free(buf.data);
            }

        }

        // Location
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_STRING8, 0x0002))) == MAPI_UNDEFINED) {
            if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                            PROP_TAG(PT_STRING8, 0x8208))) == MAPI_UNDEFINED) {
                filename = NULL;
            }
        }
        if (filename != NULL) {
            fprintf(fptr,"LOCATION: %s\n", filename->data);
        }
        // Date Start
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_SYSTIME, 0x820d))) == MAPI_UNDEFINED) {
            if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                            PROP_TAG(PT_SYSTIME, 0x8516))) == MAPI_UNDEFINED) {
                filename=NULL;
            }
        }
        if (filename != NULL) {
            fprintf(fptr, "DTSTART:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }
        // Date End
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_SYSTIME, 0x820e))) == MAPI_UNDEFINED) {
            if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                            PROP_TAG(PT_SYSTIME, 0x8517))) == MAPI_UNDEFINED) {
                filename=NULL;
            }
        }
        if (filename != NULL) {
            fprintf(fptr, "DTEND:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }
        // Date Stamp
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_SYSTIME, 0x8202))) != MAPI_UNDEFINED) {
            fprintf(fptr, "CREATED:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }
        // Class
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_BOOLEAN, 0x8506))) != MAPI_UNDEFINED) {
            ddword_ptr = (DDWORD*)filename->data;
            ddword_val = SwapDDWord((BYTE*)ddword_ptr);
            fprintf(fptr, "CLASS:" );
            if (*ddword_ptr == 1) {
                fprintf(fptr,"PRIVATE\n");
            } else {
                fprintf(fptr,"PUBLIC\n");
            }
        }
        // Recurrence
        filename = NULL;
        if ((filename=MAPIFindUserProp(&(TNEF.MapiProperties),
                        PROP_TAG(PT_BINARY, 0x8216))) != MAPI_UNDEFINED) {
            PrintRrule(fptr, filename->data, filename->size, TNEF);
        }

        // Wrap it up
        fprintf(fptr, "END:VEVENT\n");
        fprintf(fptr, "END:VCALENDAR\n");
	return TRUE;
}

    	

gboolean SaveVTask(FILE *fptr, TNEFStruct TNEF) {
    variableLength *filename;
    char *charptr, *charptr2;
    dtr thedate;
    DDWORD *ddword_ptr;
    DDWORD ddword_val;

        fprintf(fptr, "BEGIN:VCALENDAR\n");
        fprintf(fptr, PRODID);
        fprintf(fptr, "VERSION:2.0\n");
        fprintf(fptr, "METHOD:PUBLISH\n");
        filename = NULL;

        fprintf(fptr, "BEGIN:VTODO\n");
        if (TNEF.messageID[0] != 0) {
            fprintf(fptr,"UID:%s\n", TNEF.messageID);
        }
        filename = MAPIFindUserProp(&(TNEF.MapiProperties), \
                        PROP_TAG(PT_STRING8, 0x8122));
        if (filename != MAPI_UNDEFINED) {
            fprintf(fptr, "ORGANIZER:%s\n", filename->data);
        }


        if ((filename = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_DISPLAY_TO))) != MAPI_UNDEFINED) {
            filename = MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x811f));
        }
        if ((filename != MAPI_UNDEFINED) && (filename->size > 1)) {
            charptr = filename->data-1;
            charptr2=strstr(charptr+1, ";");
            while (charptr != NULL) {
                charptr++;
                charptr2 = strstr(charptr, ";");
                if (charptr2 != NULL) {
                    *charptr2 = 0;
                }
                while (*charptr == ' ')
                    charptr++;
                fprintf(fptr, "ATTENDEE;CN=%s;ROLE=REQ-PARTICIPANT:%s\n", charptr, charptr);
                charptr = charptr2;
            }
        }

        if (TNEF.subject.size > 0) {
            fprintf(fptr,"SUMMARY:");
            Cstylefprint(fptr,&(TNEF.subject));
            fprintf(fptr,"\n");
        }

        if (TNEF.body.size > 0) {
            fprintf(fptr,"DESCRIPTION:");
            Cstylefprint(fptr,&(TNEF.body));
            fprintf(fptr,"\n");
        }

        filename = MAPIFindProperty(&(TNEF.MapiProperties), \
                    PROP_TAG(PT_SYSTIME, PR_CREATION_TIME));
        if (filename != MAPI_UNDEFINED) {
            fprintf(fptr, "DTSTAMP:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }

        filename = MAPIFindUserProp(&(TNEF.MapiProperties), \
                    PROP_TAG(PT_SYSTIME, 0x8517));
        if (filename != MAPI_UNDEFINED) {
            fprintf(fptr, "DUE:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }
        filename = MAPIFindProperty(&(TNEF.MapiProperties), \
                    PROP_TAG(PT_SYSTIME, PR_LAST_MODIFICATION_TIME));
        if (filename != MAPI_UNDEFINED) {
            fprintf(fptr, "LAST-MODIFIED:");
            MAPISysTimetoDTR(filename->data, &thedate);
            fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n",
                    thedate.wYear, thedate.wMonth, thedate.wDay,
                    thedate.wHour, thedate.wMinute, thedate.wSecond);
        }
        // Class
        filename = MAPIFindUserProp(&(TNEF.MapiProperties), \
                        PROP_TAG(PT_BOOLEAN, 0x8506));
        if (filename != MAPI_UNDEFINED) {
            ddword_ptr = (DDWORD*)filename->data;
            ddword_val = SwapDDWord((BYTE*)ddword_ptr);
            fprintf(fptr, "CLASS:" );
            if (*ddword_ptr == 1) {
                fprintf(fptr,"PRIVATE\n");
            } else {
                fprintf(fptr,"PUBLIC\n");
            }
        }
        fprintf(fptr, "END:VTODO\n");
        fprintf(fptr, "END:VCALENDAR\n");
        fclose(fptr);
        return TRUE;
}

gboolean SaveVCard(FILE *fptr, TNEFStruct TNEF) {
    variableLength *vl;
    variableLength *pobox, *street, *city, *state, *zip, *country;
    dtr thedate;
    int boolean;

    if ((vl = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_DISPLAY_NAME))) == MAPI_UNDEFINED) {
        vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_COMPANY_NAME));
    }

        fprintf(fptr, "BEGIN:VCARD\n");
        fprintf(fptr, "VERSION:2.1\n");
        if (vl != MAPI_UNDEFINED) {
            fprintf(fptr, "FN:%s\n", vl->data);
        }
        fprintProperty(TNEF, fptr, PT_STRING8, PR_NICKNAME, "NICKNAME:%s\n");
        fprintUserProp(TNEF, fptr, PT_STRING8, 0x8554, "MAILER:Microsoft Outlook %s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_SPOUSE_NAME, "X-EVOLUTION-SPOUSE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_MANAGER_NAME, "X-EVOLUTION-MANAGER:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_ASSISTANT, "X-EVOLUTION-ASSISTANT:%s\n");

        // Organizational
        if ((vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_COMPANY_NAME))) != MAPI_UNDEFINED) {
            if (vl->size > 0) {
                if ((vl->size == 1) && (vl->data[0] == 0)) {
                } else {
                    fprintf(fptr,"ORG:%s", vl->data);
                    if ((vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_DEPARTMENT_NAME))) != MAPI_UNDEFINED) {
                        fprintf(fptr,";%s", vl->data);
                    }
                    fprintf(fptr, "\n");
                }
            }
        }

        fprintProperty(TNEF, fptr, PT_STRING8, PR_OFFICE_LOCATION, "X-EVOLUTION-OFFICE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_TITLE, "TITLE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_PROFESSION, "ROLE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_BODY, "NOTE:%s\n");
        if (TNEF.body.size > 0) {
            fprintf(fptr, "NOTE;QUOTED-PRINTABLE:");
            quotedfprint(fptr, &(TNEF.body));
            fprintf(fptr,"\n");
        }


        // Business Address
        boolean = 0;
        if ((pobox = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_POST_OFFICE_BOX))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((street = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_STREET_ADDRESS))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((city = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_LOCALITY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((state = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_STATE_OR_PROVINCE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((zip = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_POSTAL_CODE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((country = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_COUNTRY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if (boolean == 1) {
            fprintf(fptr, "ADR;QUOTED-PRINTABLE;WORK:");
            if (pobox != MAPI_UNDEFINED) {
                quotedfprint(fptr, pobox);
            }
            fprintf(fptr, ";;");
            if (street != MAPI_UNDEFINED) {
                quotedfprint(fptr, street);
            }
            fprintf(fptr, ";");
            if (city != MAPI_UNDEFINED) {
                quotedfprint(fptr, city);
            }
            fprintf(fptr, ";");
            if (state != MAPI_UNDEFINED) {
                quotedfprint(fptr, state);
            }
            fprintf(fptr, ";");
            if (zip != MAPI_UNDEFINED) {
                quotedfprint(fptr, zip);
            }
            fprintf(fptr, ";");
            if (country != MAPI_UNDEFINED) {
                quotedfprint(fptr, country);
            }
            fprintf(fptr,"\n");
            if ((vl = MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x801b))) != MAPI_UNDEFINED) {
                fprintf(fptr, "LABEL;QUOTED-PRINTABLE;WORK:");
                quotedfprint(fptr, vl);
                fprintf(fptr,"\n");
            }
        }

        // Home Address
        boolean = 0;
        if ((pobox = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_POST_OFFICE_BOX))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((street = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_STREET))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((city = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_CITY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((state = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_STATE_OR_PROVINCE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((zip = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_POSTAL_CODE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((country = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_HOME_ADDRESS_COUNTRY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if (boolean == 1) {
            fprintf(fptr, "ADR;QUOTED-PRINTABLE;HOME:");
            if (pobox != MAPI_UNDEFINED) {
                quotedfprint(fptr, pobox);
            }
            fprintf(fptr, ";;");
            if (street != MAPI_UNDEFINED) {
                quotedfprint(fptr, street);
            }
            fprintf(fptr, ";");
            if (city != MAPI_UNDEFINED) {
                quotedfprint(fptr, city);
            }
            fprintf(fptr, ";");
            if (state != MAPI_UNDEFINED) {
                quotedfprint(fptr, state);
            }
            fprintf(fptr, ";");
            if (zip != MAPI_UNDEFINED) {
                quotedfprint(fptr, zip);
            }
            fprintf(fptr, ";");
            if (country != MAPI_UNDEFINED) {
                quotedfprint(fptr, country);
            }
            fprintf(fptr,"\n");
            if ((vl = MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x801a))) != MAPI_UNDEFINED) {
                fprintf(fptr, "LABEL;QUOTED-PRINTABLE;WORK:");
                quotedfprint(fptr, vl);
                fprintf(fptr,"\n");
            }
        }

        // Other Address
        boolean = 0;
        if ((pobox = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_POST_OFFICE_BOX))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((street = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_STREET))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((city = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_CITY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((state = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_STATE_OR_PROVINCE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((zip = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_POSTAL_CODE))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if ((country = MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, PR_OTHER_ADDRESS_COUNTRY))) != MAPI_UNDEFINED) {
            boolean = 1;
        }
        if (boolean == 1) {
            fprintf(fptr, "ADR;QUOTED-PRINTABLE;OTHER:");
            if (pobox != MAPI_UNDEFINED) {
                quotedfprint(fptr, pobox);
            }
            fprintf(fptr, ";;");
            if (street != MAPI_UNDEFINED) {
                quotedfprint(fptr, street);
            }
            fprintf(fptr, ";");
            if (city != MAPI_UNDEFINED) {
                quotedfprint(fptr, city);
            }
            fprintf(fptr, ";");
            if (state != MAPI_UNDEFINED) {
                quotedfprint(fptr, state);
            }
            fprintf(fptr, ";");
            if (zip != MAPI_UNDEFINED) {
                quotedfprint(fptr, zip);
            }
            fprintf(fptr, ";");
            if (country != MAPI_UNDEFINED) {
                quotedfprint(fptr, country);
            }
            fprintf(fptr,"\n");
        }


        fprintProperty(TNEF, fptr, PT_STRING8, PR_CALLBACK_TELEPHONE_NUMBER, "TEL;X-EVOLUTION-CALLBACK:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_PRIMARY_TELEPHONE_NUMBER, "TEL;PREF:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_MOBILE_TELEPHONE_NUMBER, "TEL;CELL:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_RADIO_TELEPHONE_NUMBER, "TEL;X-EVOLUTION-RADIO:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_CAR_TELEPHONE_NUMBER, "TEL;CAR:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_OTHER_TELEPHONE_NUMBER, "TEL;VOICE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_PAGER_TELEPHONE_NUMBER, "TEL;PAGER:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_TELEX_NUMBER, "TEL;X-EVOLUTION-TELEX:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_ISDN_NUMBER, "TEL;ISDN:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_HOME2_TELEPHONE_NUMBER, "TEL;HOME:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_TTYTDD_PHONE_NUMBER, "TEL;X-EVOLUTION-TTYTDD:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_HOME_TELEPHONE_NUMBER, "TEL;HOME;VOICE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_ASSISTANT_TELEPHONE_NUMBER, "TEL;X-EVOLUTION-ASSISTANT:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_COMPANY_MAIN_PHONE_NUMBER, "TEL;WORK:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_BUSINESS_TELEPHONE_NUMBER, "TEL;WORK:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_BUSINESS2_TELEPHONE_NUMBER, "TEL;WORK;VOICE:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_PRIMARY_FAX_NUMBER, "TEL;PREF;FAX:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_BUSINESS_FAX_NUMBER, "TEL;WORK;FAX:%s\n");
        fprintProperty(TNEF, fptr, PT_STRING8, PR_HOME_FAX_NUMBER, "TEL;HOME;FAX:%s\n");


        // Email addresses
        if ((vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x8083))) == MAPI_UNDEFINED) {
            vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x8084));
        }
        if (vl != MAPI_UNDEFINED) {
            if (vl->size > 0)
                fprintf(fptr, "EMAIL:%s\n", vl->data);
        }
        if ((vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x8093))) == MAPI_UNDEFINED) {
            vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x8094));
        }
        if (vl != MAPI_UNDEFINED) {
            if (vl->size > 0)
                fprintf(fptr, "EMAIL:%s\n", vl->data);
        }
        if ((vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x80a3))) == MAPI_UNDEFINED) {
            vl=MAPIFindUserProp(&(TNEF.MapiProperties), PROP_TAG(PT_STRING8, 0x80a4));
        }
        if (vl != MAPI_UNDEFINED) {
            if (vl->size > 0)
                fprintf(fptr, "EMAIL:%s\n", vl->data);
        }

        fprintProperty(TNEF, fptr, PT_STRING8, PR_BUSINESS_HOME_PAGE, "URL:%s\n");
        fprintUserProp(TNEF, fptr, PT_STRING8, 0x80d8, "FBURL:%s\n");



        //Birthday
        if ((vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_SYSTIME, PR_BIRTHDAY))) != MAPI_UNDEFINED) {
            fprintf(fptr, "BDAY:");
            MAPISysTimetoDTR(vl->data, &thedate);
            fprintf(fptr, "%i-%02i-%02i\n", thedate.wYear, thedate.wMonth, thedate.wDay);
        }

        //Anniversary
        if ((vl=MAPIFindProperty(&(TNEF.MapiProperties), PROP_TAG(PT_SYSTIME, PR_WEDDING_ANNIVERSARY))) != MAPI_UNDEFINED) {
            fprintf(fptr, "X-EVOLUTION-ANNIVERSARY:");
            MAPISysTimetoDTR(vl->data, &thedate);
            fprintf(fptr, "%i-%02i-%02i\n", thedate.wYear, thedate.wMonth, thedate.wDay);
        }
        fprintf(fptr, "END:VCARD\n");
	return TRUE;
}

--- NEW FILE: tnef_parse.c ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2007 Colin Leroy <colin at colino.net>
 * and the Claws Mail Team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#include "claws-features.h"
#endif

#include <unistd.h>
#include <stdio.h>

#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "common/claws.h"
#include "common/version.h"
#include "main.h"
#include "plugin.h"
#include "procmime.h"
#include "utils.h"

#include <tnef-types.h>
#include <ytnef.h>
#include <mapi.h>
#include <mapidefs.h>

#include "tnef_dump.h"

static MimeParser *tnef_parser = NULL;

static MimeInfo *tnef_broken_mimeinfo(const gchar *reason)
{
	MimeInfo *sub_info = NULL;
	gchar *tmpfilename = NULL;
	FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
	struct stat statbuf;

	if (!fp) {
		g_free(tmpfilename);
		return NULL;
	}
	sub_info = procmime_mimeinfo_new();
	sub_info->content = MIMECONTENT_FILE;
	sub_info->data.filename = tmpfilename;
	sub_info->type = MIMETYPE_TEXT;
	sub_info->subtype = g_strdup("plain");
	
	fprintf(fp, _("\n"
			"Claws Mail TNEF parser:\n\n"
			"%s\n"), reason?reason:_("Unknown error"));
	
	fclose(fp);
	g_stat(tmpfilename, &statbuf);
	sub_info->tmp = TRUE;
	sub_info->length = statbuf.st_size;
	sub_info->encoding_type = ENC_BINARY;
	
	return sub_info;

}

static MimeInfo *tnef_dump_file(const gchar *filename, char *data, size_t size)
{
	MimeInfo *sub_info = NULL;
	gchar *tmpfilename = NULL;
	FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
	struct stat statbuf;
	gchar *content_type = NULL;
	if (!fp) {
		g_free(tmpfilename);
		return NULL;
	}
	sub_info = procmime_mimeinfo_new();
	sub_info->content = MIMECONTENT_FILE;
	sub_info->data.filename = tmpfilename;
	sub_info->type = MIMETYPE_APPLICATION;
	sub_info->subtype = g_strdup("octet-stream");
	
	if (filename) {
		g_hash_table_insert(sub_info->typeparameters,
				    g_strdup("filename"),
				    g_strdup(filename));
	
		content_type = procmime_get_mime_type(filename);
		if (content_type && strchr(content_type, '/')) {
			g_free(sub_info->subtype);
			sub_info->subtype = g_strdup(strchr(content_type, '/')+1);
			*(strchr(content_type, '/')) = '\0';
			sub_info->type = procmime_get_media_type(content_type);
			g_free(content_type);
		}
	} 

	if (fwrite(data, 1, size, fp) < size) {
		FILE_OP_ERROR(tmpfilename, "fwrite");
		fclose(fp);
		claws_unlink(tmpfilename);
		procmime_mimeinfo_free_all(sub_info);
		return tnef_broken_mimeinfo(_("Failed to write the part data."));
	}
	fclose(fp);
	g_stat(tmpfilename, &statbuf);
	sub_info->tmp = TRUE;
	sub_info->length = statbuf.st_size;
	sub_info->encoding_type = ENC_BINARY;
	
	return sub_info;
}

MimeInfo *tnef_parse_vcal(TNEFStruct tnef)
{
	MimeInfo *sub_info = NULL;
	gchar *tmpfilename = NULL;
	FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
	struct stat statbuf;
	gboolean result = FALSE;
	if (!fp) {
		g_free(tmpfilename);
		return NULL;
	}
	sub_info = procmime_mimeinfo_new();
	sub_info->content = MIMECONTENT_FILE;
	sub_info->data.filename = tmpfilename;
	sub_info->type = MIMETYPE_TEXT;
	sub_info->subtype = g_strdup("calendar");
	g_hash_table_insert(sub_info->typeparameters,
			    g_strdup("filename"),
			    g_strdup("calendar.ics"));
	
	result = SaveVCalendar(fp, tnef);
	
	fclose(fp);
	g_stat(tmpfilename, &statbuf);
	sub_info->tmp = TRUE;
	sub_info->length = statbuf.st_size;
	sub_info->encoding_type = ENC_BINARY;
	
	if (!result) {
		claws_unlink(tmpfilename);
		procmime_mimeinfo_free_all(sub_info);
		return tnef_broken_mimeinfo(_("Failed to parse VCalendar data."));
	}
	return sub_info;
}

MimeInfo *tnef_parse_vtask(TNEFStruct tnef)
{
	MimeInfo *sub_info = NULL;
	gchar *tmpfilename = NULL;
	FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
	struct stat statbuf;
	gboolean result = FALSE;
	if (!fp) {
		g_free(tmpfilename);
		return NULL;
	}
	sub_info = procmime_mimeinfo_new();
	sub_info->content = MIMECONTENT_FILE;
	sub_info->data.filename = tmpfilename;
	sub_info->type = MIMETYPE_TEXT;
	sub_info->subtype = g_strdup("calendar");
	g_hash_table_insert(sub_info->typeparameters,
			    g_strdup("filename"),
			    g_strdup("task.ics"));
	
	result = SaveVTask(fp, tnef);
	
	fclose(fp);
	g_stat(tmpfilename, &statbuf);
	sub_info->tmp = TRUE;
	sub_info->length = statbuf.st_size;
	sub_info->encoding_type = ENC_BINARY;
	
	if (!result) {
		claws_unlink(tmpfilename);
		procmime_mimeinfo_free_all(sub_info);
		return tnef_broken_mimeinfo(_("Failed to parse VTask data."));
	}
	return sub_info;
}

MimeInfo *tnef_parse_rtf(TNEFStruct tnef, variableLength *tmp_var)
{
	variableLength buf;
	MimeInfo *info = NULL;
	buf.data = DecompressRTF(tmp_var, &(buf.size));
	if (buf.data) {
		info = tnef_dump_file("message.rtf", buf.data, buf.size);
		free(buf.data);
		return info;
	} else {
		return NULL;
	}
}

MimeInfo *tnef_parse_vcard(TNEFStruct tnef)
{
	MimeInfo *sub_info = NULL;
	gchar *tmpfilename = NULL;
	FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
	struct stat statbuf;
	gboolean result = FALSE;
	if (!fp) {
		g_free(tmpfilename);
		return NULL;
	}
	sub_info = procmime_mimeinfo_new();
	sub_info->content = MIMECONTENT_FILE;
	sub_info->data.filename = tmpfilename;
	sub_info->type = MIMETYPE_TEXT;
	sub_info->subtype = g_strdup("x-vcard");
	g_hash_table_insert(sub_info->typeparameters,
			    g_strdup("filename"),
			    g_strdup("contact.vcf"));
	
	result = SaveVCard(fp, tnef);
	
	fclose(fp);
	g_stat(tmpfilename, &statbuf);
	sub_info->tmp = TRUE;
	sub_info->length = statbuf.st_size;
	sub_info->encoding_type = ENC_BINARY;
	
	if (!result) {
		claws_unlink(tmpfilename);
		procmime_mimeinfo_free_all(sub_info);
		return tnef_broken_mimeinfo(_("Failed to parse VCard data."));
	}
	return sub_info;
}

static gboolean tnef_parse (MimeParser *parser, MimeInfo *mimeinfo)
{
	TNEFStruct tnef;
	MimeInfo *sub_info = NULL;
	variableLength *tmp_var;
	Attachment *att;
	int parse_result = 0;
	gboolean cal_done = FALSE;

	if (!procmime_decode_content(mimeinfo)) {
		debug_print("error decoding\n");
		return FALSE;
	}
	debug_print("Tnef parser parsing part (%d).\n", mimeinfo->length);
	if (mimeinfo->content == MIMECONTENT_FILE)
		debug_print("content: %s\n", mimeinfo->data.filename);
	else 
		debug_print("contents in memory (len %zd)\n", 
			strlen(mimeinfo->data.mem));
			
	TNEFInitialize(&tnef);

	if (!debug_get_mode())
		tnef.Debug = 0;

	if (mimeinfo->content == MIMECONTENT_MEM)
		parse_result = TNEFParseMemory(mimeinfo->data.mem, mimeinfo->length, &tnef);
	else
		parse_result = TNEFParseFile(mimeinfo->data.filename, &tnef);
	
	mimeinfo->type = MIMETYPE_MULTIPART;
	mimeinfo->subtype = g_strdup("mixed");
	g_hash_table_insert(mimeinfo->typeparameters,
			    g_strdup("description"),
			    g_strdup("Parsed from MS-TNEF"));

	if (parse_result != 0) {
		g_warning("Failed to parse TNEF data.");
		TNEFFree(&tnef);
		return FALSE;
	}
	
	sub_info = NULL;
	if (tnef.messageClass != NULL && tnef.messageClass[0] != '\0') {
		if (strcmp(tnef.messageClass, "IPM.Contact") == 0)
			sub_info = tnef_parse_vcard(tnef);
		else if (strcmp(tnef.messageClass, "IPM.Task") == 0)
			sub_info = tnef_parse_vtask(tnef);
		else if (strcmp(tnef.messageClass, "IPM.Appointment") == 0) {
			sub_info = tnef_parse_vcal(tnef);
			cal_done = TRUE;
		}
	}

	if (sub_info)
		g_node_append(mimeinfo->node, sub_info->node);
	sub_info = NULL;

	if (tnef.MapiProperties.count > 0) {
		tmp_var = MAPIFindProperty (&(tnef.MapiProperties), PROP_TAG(PT_BINARY,PR_RTF_COMPRESSED));
		if (tmp_var != MAPI_UNDEFINED) {
			sub_info = tnef_parse_rtf(tnef, tmp_var);
		}
	}

	if (sub_info)
		g_node_append(mimeinfo->node, sub_info->node);
	sub_info = NULL;

	tmp_var = MAPIFindUserProp(&(tnef.MapiProperties), PROP_TAG(PT_STRING8,0x24));
	if (tmp_var != MAPI_UNDEFINED) {
		if (!cal_done && strcmp(tmp_var->data, "IPM.Appointment") == 0) {
			sub_info = tnef_parse_vcal(tnef);
		}
	}
	
	if (sub_info)
		g_node_append(mimeinfo->node, sub_info->node);
	sub_info = NULL;

	att = tnef.starting_attach.next;
	while (att) {
		gchar *filename = NULL;
		gboolean is_object = TRUE;
		DWORD signature;

		tmp_var = MAPIFindProperty(&(att->MAPI), PROP_TAG(30,0x3707));
		if (tmp_var == MAPI_UNDEFINED)
			tmp_var = MAPIFindProperty(&(att->MAPI), PROP_TAG(30,0x3001));
		if (tmp_var == MAPI_UNDEFINED)
			tmp_var = &(att->Title);

		if (tmp_var->data)
			filename = g_strdup(tmp_var->data);
		
		tmp_var = MAPIFindProperty(&(att->MAPI), PROP_TAG(PT_OBJECT, PR_ATTACH_DATA_OBJ));
		if (tmp_var == MAPI_UNDEFINED)
			tmp_var = MAPIFindProperty(&(att->MAPI), PROP_TAG(PT_BINARY, PR_ATTACH_DATA_OBJ));
		if (tmp_var == MAPI_UNDEFINED) {
			tmp_var = &(att->FileData);
			is_object = FALSE;
		}
		
		sub_info = tnef_dump_file(filename, 
			tmp_var->data + (is_object ? 16:0), 
			tmp_var->size - (is_object ? 16:0));
		
		if (sub_info)
			g_node_append(mimeinfo->node, sub_info->node);
	
		memcpy(&signature, tmp_var->data+(is_object ? 16:0), sizeof(DWORD));

		if (TNEFCheckForSignature(signature) == 0) {
			debug_print("that's TNEF stuff, process it\n");
			tnef_parse(parser, sub_info);
		}

		sub_info = NULL;
		
		att = att->next;

		g_free(filename);
	}
	
	TNEFFree(&tnef);
	return TRUE;
}

gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, _("TNEF Parser"), error))
		return -1;

	tnef_parser = g_new0(MimeParser, 1);
	tnef_parser->type = MIMETYPE_APPLICATION;
	tnef_parser->sub_type = "ms-tnef";
	tnef_parser->parse = tnef_parse;
	
	procmime_mimeparser_register(tnef_parser);

	return 0;
}

gboolean plugin_done(void)
{
	procmime_mimeparser_unregister(tnef_parser);
	g_free(tnef_parser);
	tnef_parser = NULL;

	return TRUE;
}

const gchar *plugin_name(void)
{
	return _("TNEF Parser");
}

const gchar *plugin_desc(void)
{
	return _("This Claws Mail plugin allows you to read application/ms-tnef attachments.\n\n"
		 "The plugin uses the Ytnef library, which is copyright 2002-2007 by "
		 "Randall Hand <yerase at yerot.com>");
}

const gchar *plugin_type(void)
{
	return "GTK2";
}

const gchar *plugin_licence(void)
{
	return "GPL3+";
}

const gchar *plugin_version(void)
{
	return VERSION;
}

struct PluginFeature *plugin_provides(void)
{
	static struct PluginFeature features[] = 
		{ {PLUGIN_MIMEPARSER, "application/ms-tnef"},
		  {PLUGIN_NOTHING, NULL}};
	return features;
}

--- NEW FILE: tnef-errors.h ---
#ifndef _TNEF_ERRORS_
#define _TNEF_ERRORS_


#define YTNEF_CANNOT_INIT_DATA -1
#define YTNEF_NOT_TNEF_STREAM  -2
#define YTNEF_ERROR_READING_DATA -3
#define YTNEF_NO_KEY -4
#define YTNEF_BAD_CHECKSUM -5
#define YTNEF_ERROR_IN_HANDLER -6
#define YTNEF_UNKNOWN_PROPERTY -7
#define YTNEF_INCORRECT_SETUP -8


#endif


--- NEW FILE: tnef_dump.h ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2007 Colin Leroy <colin at colino.net>
 * and the Claws Mail Team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __TNEF_DUMP__
#define __TNEF_DUMP__

gboolean SaveVCalendar(FILE *fptr, TNEFStruct TNEF);
gboolean SaveVCard(FILE *fptr, TNEFStruct TNEF);
gboolean SaveVTask(FILE *fptr, TNEFStruct TNEF);

#endif



More information about the Commits mailing list