Real fix for Coverity 1372362.
[claws.git] / src / plugins / tnef_parse / ytnef.h
1 /*
2 *    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 *    Copyright (C) 2004-2014 Colin Leroy and the Claws Mail team
4 *
5 *    Yerase's TNEF Stream Reader Library
6 *    Copyright (C) 2003  Randall E. Hand
7 *
8 *    This program is free software; you can redistribute it and/or modify
9 *    it under the terms of the GNU General Public License as published by
10 *    the Free Software Foundation; either version 3 of the License, or
11 *    (at your option) any later version.
12 *
13 *    This program is distributed in the hope that it will be useful,
14 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *    GNU General Public License for more details.
17 *
18 *    You should have received a copy of the GNU General Public License
19 *    along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 *    You can contact me at randall.hand@gmail.com for questions or assistance
22 */
23 #ifndef _TNEF_PROCS_H_
24 #define _TNEF_PROCS_H_
25
26 #include "tnef-types.h"
27 #include "mapi.h"
28 #include "mapidefs.h"
29 #define STD_ARGLIST (TNEFStruct *TNEF, int id, unsigned char *data, int size)
30 DWORD SwapDWord(BYTE *p);
31 WORD SwapWord(BYTE *p);
32
33
34 void TNEFInitMapi(MAPIProps *p);
35 void TNEFInitAttachment(Attachment *p);
36 void TNEFInitialize(TNEFStruct *TNEF);
37 void TNEFFree(TNEFStruct *TNEF);
38 void TNEFFreeAttachment(Attachment *p);
39 void TNEFFreeMapiProps(MAPIProps *p);
40 int TNEFCheckForSignature(DWORD sig);
41 int TNEFParseMemory(BYTE *memory, long size, TNEFStruct *TNEF);
42 int TNEFParseFile(char *filename, TNEFStruct *TNEF);
43 int TNEFParse(TNEFStruct *TNEF);
44 variableLength *MAPIFindUserProp(MAPIProps *p, unsigned int ID);
45 variableLength *MAPIFindProperty(MAPIProps *p, unsigned int ID);
46 int MAPISysTimetoDTR(BYTE *data, dtr *thedate);
47 void MAPIPrint(MAPIProps *p);
48 char* to_utf8(int len, char* buf);
49 WORD SwapWord(BYTE *p);
50 DWORD SwapDWord(BYTE *p);
51 DDWORD SwapDDWord(BYTE *p);
52 variableLength *MAPIFindUserProp(MAPIProps *p, unsigned int ID);
53 variableLength *MAPIFindProperty(MAPIProps *p, unsigned int ID);
54 unsigned char * DecompressRTF(variableLength *p, int *size);
55
56 /* ------------------------------------- */ 
57 /* TNEF Down-level Attributes/Properties */
58 /* ------------------------------------- */
59
60 #define atpTriples      ((WORD) 0x0000)
61 #define atpString       ((WORD) 0x0001)
62 #define atpText         ((WORD) 0x0002)
63 #define atpDate         ((WORD) 0x0003)
64 #define atpShort        ((WORD) 0x0004)
65 #define atpLong         ((WORD) 0x0005)
66 #define atpByte         ((WORD) 0x0006)
67 #define atpWord         ((WORD) 0x0007)
68 #define atpDword        ((WORD) 0x0008)
69 #define atpMax          ((WORD) 0x0009)
70
71 #define LVL_MESSAGE     ((BYTE) 0x01)
72 #define LVL_ATTACHMENT  ((BYTE) 0x02)
73
74 #define ATT_ID(_att)                ((WORD) ((_att) & 0x0000FFFF))
75 #define ATT_TYPE(_att)              ((WORD) (((_att) >> 16) & 0x0000FFFF))
76 #define ATT(_atp, _id)              ((((DWORD) (_atp)) << 16) | ((WORD) (_id)))
77
78 #define attNull                     ATT( 0,             0x0000)
79 #define attFrom                     ATT( atpTriples,    0x8000) /* PR_ORIGINATOR_RETURN_ADDRESS */
80 #define attSubject                  ATT( atpString,     0x8004) /* PR_SUBJECT */
81 #define attDateSent                 ATT( atpDate,       0x8005) /* PR_CLIENT_SUBMIT_TIME */
82 #define attDateRecd                 ATT( atpDate,       0x8006) /* PR_MESSAGE_DELIVERY_TIME */
83 #define attMessageStatus            ATT( atpByte,       0x8007) /* PR_MESSAGE_FLAGS */
84 #define attMessageClass             ATT( atpWord,       0x8008) /* PR_MESSAGE_CLASS */
85 #define attMessageID                ATT( atpString,     0x8009) /* PR_MESSAGE_ID */
86 #define attParentID                 ATT( atpString,     0x800A) /* PR_PARENT_ID */
87 #define attConversationID           ATT( atpString,     0x800B) /* PR_CONVERSATION_ID */
88 #define attBody                     ATT( atpText,       0x800C) /* PR_BODY */
89 #define attPriority                 ATT( atpShort,      0x800D) /* PR_IMPORTANCE */
90 #define attAttachData               ATT( atpByte,       0x800F) /* PR_ATTACH_DATA_xxx */
91 #define attAttachTitle              ATT( atpString,     0x8010) /* PR_ATTACH_FILENAME */
92 #define attAttachMetaFile           ATT( atpByte,       0x8011) /* PR_ATTACH_RENDERING */
93 #define attAttachCreateDate         ATT( atpDate,       0x8012) /* PR_CREATION_TIME */
94 #define attAttachModifyDate         ATT( atpDate,       0x8013) /* PR_LAST_MODIFICATION_TIME */
95 #define attDateModified             ATT( atpDate,       0x8020) /* PR_LAST_MODIFICATION_TIME */
96 #define attAttachTransportFilename  ATT( atpByte,       0x9001) /* PR_ATTACH_TRANSPORT_NAME */
97 #define attAttachRenddata           ATT( atpByte,       0x9002)
98 #define attMAPIProps                ATT( atpByte,       0x9003)
99 #define attRecipTable               ATT( atpByte,       0x9004) /* PR_MESSAGE_RECIPIENTS */
100 #define attAttachment               ATT( atpByte,       0x9005)
101 #define attTnefVersion              ATT( atpDword,      0x9006)
102 #define attOemCodepage              ATT( atpByte,       0x9007)
103 #define attOriginalMessageClass     ATT( atpWord,       0x0006) /* PR_ORIG_MESSAGE_CLASS */
104
105 #define attOwner                    ATT( atpByte,       0x0000) /* PR_RCVD_REPRESENTING_xxx  or
106                                                                                                                                       PR_SENT_REPRESENTING_xxx */
107 #define attSentFor                  ATT( atpByte,       0x0001) /* PR_SENT_REPRESENTING_xxx */
108 #define attDelegate                 ATT( atpByte,       0x0002) /* PR_RCVD_REPRESENTING_xxx */
109 #define attDateStart                ATT( atpDate,       0x0006) /* PR_DATE_START */
110 #define attDateEnd                  ATT( atpDate,       0x0007) /* PR_DATE_END */
111 #define attAidOwner                 ATT( atpLong,       0x0008) /* PR_OWNER_APPT_ID */
112 #define attRequestRes               ATT( atpShort,      0x0009) /* PR_RESPONSE_REQUESTED */
113
114 typedef struct {
115     DWORD id;
116     char name[40];
117     int (*handler) STD_ARGLIST;
118 } TNEFHandler;
119
120
121 #endif