tnef 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/tnef/AUTHORS +7 -0
- data/ext/tnef/BUGS.in +5 -0
- data/ext/tnef/COPYING +340 -0
- data/ext/tnef/ChangeLog +1550 -0
- data/ext/tnef/INSTALL +234 -0
- data/ext/tnef/Makefile.am +7 -0
- data/ext/tnef/Makefile.in +699 -0
- data/ext/tnef/NEWS +177 -0
- data/ext/tnef/README +39 -0
- data/ext/tnef/THANKS +1 -0
- data/ext/tnef/TODO +7 -0
- data/ext/tnef/acinclude.m4 +47 -0
- data/ext/tnef/aclocal.m4 +1012 -0
- data/ext/tnef/configure +6815 -0
- data/ext/tnef/configure.in +67 -0
- data/ext/tnef/depcomp +584 -0
- data/ext/tnef/doc/FAQ +25 -0
- data/ext/tnef/doc/Makefile.am +6 -0
- data/ext/tnef/doc/Makefile.in +623 -0
- data/ext/tnef/doc/file-format.tex +139 -0
- data/ext/tnef/doc/tnef.1.in +183 -0
- data/ext/tnef/doc/www/Makefile.am +14 -0
- data/ext/tnef/doc/www/Makefile.in +542 -0
- data/ext/tnef/doc/www/cgi-bin/Makefile.am +14 -0
- data/ext/tnef/doc/www/cgi-bin/Makefile.in +340 -0
- data/ext/tnef/doc/www/htdocs/Makefile.am +14 -0
- data/ext/tnef/doc/www/htdocs/Makefile.in +340 -0
- data/ext/tnef/extconf.rb +3 -0
- data/ext/tnef/install-sh +507 -0
- data/ext/tnef/missing +367 -0
- data/ext/tnef/mkinstalldirs +161 -0
- data/ext/tnef/src/Makefile.am +48 -0
- data/ext/tnef/src/Makefile.in +700 -0
- data/ext/tnef/src/alloc.c +107 -0
- data/ext/tnef/src/alloc.h +54 -0
- data/ext/tnef/src/attr.c +270 -0
- data/ext/tnef/src/attr.h +74 -0
- data/ext/tnef/src/common.h +101 -0
- data/ext/tnef/src/config.h.in +111 -0
- data/ext/tnef/src/date.c +66 -0
- data/ext/tnef/src/date.h +43 -0
- data/ext/tnef/src/debug.c +45 -0
- data/ext/tnef/src/debug.h +32 -0
- data/ext/tnef/src/file.c +259 -0
- data/ext/tnef/src/file.h +48 -0
- data/ext/tnef/src/main.c +386 -0
- data/ext/tnef/src/mapi-names.data +430 -0
- data/ext/tnef/src/mapi-types.data +19 -0
- data/ext/tnef/src/mapi_attr.c +419 -0
- data/ext/tnef/src/mapi_attr.h +78 -0
- data/ext/tnef/src/mkdata.awk +100 -0
- data/ext/tnef/src/options.c +32 -0
- data/ext/tnef/src/options.h +67 -0
- data/ext/tnef/src/path.c +397 -0
- data/ext/tnef/src/path.h +34 -0
- data/ext/tnef/src/replace/Makefile.am +8 -0
- data/ext/tnef/src/replace/Makefile.in +435 -0
- data/ext/tnef/src/replace/basename.c +45 -0
- data/ext/tnef/src/replace/dummy.c +7 -0
- data/ext/tnef/src/replace/getopt_long.c +940 -0
- data/ext/tnef/src/replace/getopt_long.h +141 -0
- data/ext/tnef/src/replace/malloc.c +41 -0
- data/ext/tnef/src/replace/strdup.c +51 -0
- data/ext/tnef/src/rtf.c +362 -0
- data/ext/tnef/src/rtf.h +36 -0
- data/ext/tnef/src/tnef-names.data +34 -0
- data/ext/tnef/src/tnef-types.data +12 -0
- data/ext/tnef/src/tnef.c +396 -0
- data/ext/tnef/src/tnef.h +45 -0
- data/ext/tnef/src/util.c +112 -0
- data/ext/tnef/src/util.h +42 -0
- data/ext/tnef/src/write.c +136 -0
- data/ext/tnef/src/write.h +25 -0
- data/ext/tnef/src/xstrdup.c +41 -0
- data/ext/tnef/tests/Makefile.am +4 -0
- data/ext/tnef/tests/Makefile.in +530 -0
- data/ext/tnef/tests/cmdline/AUTHORS +8 -0
- data/ext/tnef/tests/cmdline/AUTHORS.baseline +8 -0
- data/ext/tnef/tests/cmdline/Makefile.am +33 -0
- data/ext/tnef/tests/cmdline/Makefile.in +455 -0
- data/ext/tnef/tests/cmdline/basic.baseline +4 -0
- data/ext/tnef/tests/cmdline/basic.test +39 -0
- data/ext/tnef/tests/cmdline/body-test.html.baseline +95 -0
- data/ext/tnef/tests/cmdline/body.baseline +929 -0
- data/ext/tnef/tests/cmdline/body.test +55 -0
- data/ext/tnef/tests/cmdline/debug.baseline +155 -0
- data/ext/tnef/tests/cmdline/debug.test +14 -0
- data/ext/tnef/tests/cmdline/directory.baseline +3 -0
- data/ext/tnef/tests/cmdline/directory.test +35 -0
- data/ext/tnef/tests/cmdline/help.baseline +63 -0
- data/ext/tnef/tests/cmdline/help.test +12 -0
- data/ext/tnef/tests/cmdline/interactive.test +5 -0
- data/ext/tnef/tests/cmdline/list.baseline +5 -0
- data/ext/tnef/tests/cmdline/list.test +21 -0
- data/ext/tnef/tests/cmdline/maxsize.baseline +828 -0
- data/ext/tnef/tests/cmdline/maxsize.test +43 -0
- data/ext/tnef/tests/cmdline/message.html.baseline +95 -0
- data/ext/tnef/tests/cmdline/mime-types.baseline +3 -0
- data/ext/tnef/tests/cmdline/mime-types.test +11 -0
- data/ext/tnef/tests/cmdline/overwrite.baseline +8 -0
- data/ext/tnef/tests/cmdline/overwrite.test +40 -0
- data/ext/tnef/tests/cmdline/rtf-test.rtf.baseline +0 -0
- data/ext/tnef/tests/cmdline/stdin.baseline +2 -0
- data/ext/tnef/tests/cmdline/stdin.test +18 -0
- data/ext/tnef/tests/cmdline/test.tnef +0 -0
- data/ext/tnef/tests/cmdline/triples-test-2.rtf.baseline +0 -0
- data/ext/tnef/tests/cmdline/triples-test-2.txt.baseline +0 -0
- data/ext/tnef/tests/cmdline/triples-test.txt.baseline +0 -0
- data/ext/tnef/tests/cmdline/use-path.baseline +0 -0
- data/ext/tnef/tests/cmdline/use-path.test +5 -0
- data/ext/tnef/tests/cmdline/verbose.baseline +5 -0
- data/ext/tnef/tests/cmdline/verbose.test +19 -0
- data/ext/tnef/tests/cmdline/version.baseline +17 -0
- data/ext/tnef/tests/cmdline/version.test +14 -0
- data/ext/tnef/tests/files/MAPI_ATTACH_DATA_OBJ.test +9 -0
- data/ext/tnef/tests/files/MAPI_OBJECT.test +9 -0
- data/ext/tnef/tests/files/Makefile.am +16 -0
- data/ext/tnef/tests/files/Makefile.in +636 -0
- data/ext/tnef/tests/files/baselines/AUTHORS.baseline +8 -0
- data/ext/tnef/tests/files/baselines/AUTOEXEC.BAT.baseline +0 -0
- data/ext/tnef/tests/files/baselines/CONFIG.SYS.baseline +0 -0
- data/ext/tnef/tests/files/baselines/MAPI_ATTACH_DATA_OBJ-body.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/MAPI_ATTACH_DATA_OBJ.baseline +229 -0
- data/ext/tnef/tests/files/baselines/MAPI_OBJECT-body.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/MAPI_OBJECT.baseline +153 -0
- data/ext/tnef/tests/files/baselines/Makefile.am +35 -0
- data/ext/tnef/tests/files/baselines/Makefile.in +361 -0
- data/ext/tnef/tests/files/baselines/README.baseline +31 -0
- data/ext/tnef/tests/files/baselines/TechlibDEC99-JAN00.doc.baseline +0 -0
- data/ext/tnef/tests/files/baselines/TechlibDEC99.doc.baseline +0 -0
- data/ext/tnef/tests/files/baselines/TechlibNOV99.doc.baseline +0 -0
- data/ext/tnef/tests/files/baselines/Untitled_Attachment.baseline +0 -0
- data/ext/tnef/tests/files/baselines/VIA_Nytt_1402.doc.baseline +0 -0
- data/ext/tnef/tests/files/baselines/VIA_Nytt_1402.pdf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/VIA_Nytt_14021.htm.baseline +1914 -0
- data/ext/tnef/tests/files/baselines/body-body.html.baseline +95 -0
- data/ext/tnef/tests/files/baselines/body.baseline +124 -0
- data/ext/tnef/tests/files/baselines/boot.ini.baseline +6 -0
- data/ext/tnef/tests/files/baselines/data-before-name-body.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/data-before-name.baseline +213 -0
- data/ext/tnef/tests/files/baselines/garbage-at-end.baseline +73 -0
- data/ext/tnef/tests/files/baselines/generpts.src.baseline +1691 -0
- data/ext/tnef/tests/files/baselines/long-filename-body.rtf.baseline +26 -0
- data/ext/tnef/tests/files/baselines/long-filename.baseline +218 -0
- data/ext/tnef/tests/files/baselines/message.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/missing-filenames-body.rtf.baseline +20 -0
- data/ext/tnef/tests/files/baselines/missing-filenames.baseline +252 -0
- data/ext/tnef/tests/files/baselines/multi-name-property.baseline +243 -0
- data/ext/tnef/tests/files/baselines/one-file.baseline +155 -0
- data/ext/tnef/tests/files/baselines/rtf-body.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/rtf.baseline +167 -0
- data/ext/tnef/tests/files/baselines/triples-body.rtf.baseline +0 -0
- data/ext/tnef/tests/files/baselines/triples.baseline +254 -0
- data/ext/tnef/tests/files/baselines/two-files.baseline +186 -0
- data/ext/tnef/tests/files/body.test +9 -0
- data/ext/tnef/tests/files/data-before-name.test +9 -0
- data/ext/tnef/tests/files/datafiles/MAPI_ATTACH_DATA_OBJ.list +4 -0
- data/ext/tnef/tests/files/datafiles/MAPI_ATTACH_DATA_OBJ.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/MAPI_OBJECT.list +2 -0
- data/ext/tnef/tests/files/datafiles/MAPI_OBJECT.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/Makefile.am +27 -0
- data/ext/tnef/tests/files/datafiles/Makefile.in +351 -0
- data/ext/tnef/tests/files/datafiles/body.list +1 -0
- data/ext/tnef/tests/files/datafiles/body.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/data-before-name.list +4 -0
- data/ext/tnef/tests/files/datafiles/data-before-name.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/garbage-at-end.list +0 -0
- data/ext/tnef/tests/files/datafiles/garbage-at-end.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/long-filename.list +1 -0
- data/ext/tnef/tests/files/datafiles/long-filename.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/missing-filenames.list +1 -0
- data/ext/tnef/tests/files/datafiles/missing-filenames.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/multi-name-property.list +0 -0
- data/ext/tnef/tests/files/datafiles/multi-name-property.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/one-file.list +1 -0
- data/ext/tnef/tests/files/datafiles/one-file.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/rtf.list +1 -0
- data/ext/tnef/tests/files/datafiles/rtf.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/triples.list +1 -0
- data/ext/tnef/tests/files/datafiles/triples.tnef +0 -0
- data/ext/tnef/tests/files/datafiles/two-files.list +2 -0
- data/ext/tnef/tests/files/datafiles/two-files.tnef +0 -0
- data/ext/tnef/tests/files/file-util.sh +38 -0
- data/ext/tnef/tests/files/garbage-at-end.test +9 -0
- data/ext/tnef/tests/files/long-filename.test +9 -0
- data/ext/tnef/tests/files/missing-filenames.test +9 -0
- data/ext/tnef/tests/files/multi-name-property.test +9 -0
- data/ext/tnef/tests/files/one-file.test +9 -0
- data/ext/tnef/tests/files/rtf.test +9 -0
- data/ext/tnef/tests/files/triples.test +9 -0
- data/ext/tnef/tests/files/two-files.test +9 -0
- data/ext/tnef/tests/util.sh +32 -0
- data/ext/tnef/tnef.spec.in +44 -0
- data/lib/tnef.rb +30 -0
- data/lib/tnef/executable.rb +27 -0
- data/lib/tnef/version.rb +3 -0
- metadata +243 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
# mapi-types.data -- data file defining all types found in MAPI TNEF attachment
|
2
|
+
# sym val name
|
3
|
+
szMAPI_UNSPECIFIED 0x0000 MAPI Unspecified
|
4
|
+
szMAPI_NULL 0x0001 MAPI null property
|
5
|
+
szMAPI_SHORT 0x0002 MAPI short (signed 16 bits)
|
6
|
+
szMAPI_INT 0x0003 MAPI integer (signed 32 bits)
|
7
|
+
szMAPI_FLOAT 0x0004 MAPI float (4 bytes)
|
8
|
+
szMAPI_DOUBLE 0x0005 MAPI double
|
9
|
+
szMAPI_CURRENCY 0x0006 MAPI currency (64 bits)
|
10
|
+
szMAPI_APPTIME 0x0007 MAPI application time
|
11
|
+
szMAPI_ERROR 0x000a MAPI error (32 bits)
|
12
|
+
szMAPI_BOOLEAN 0x000b MAPI boolean (16 bits)
|
13
|
+
szMAPI_OBJECT 0x000d MAPI embedded object
|
14
|
+
szMAPI_INT8BYTE 0x0014 MAPI 8 byte signed int
|
15
|
+
szMAPI_STRING 0x001e MAPI string
|
16
|
+
szMAPI_UNICODE_STRING 0x001f MAPI unicode-string (null terminated)
|
17
|
+
szMAPI_SYSTIME 0x0040 MAPI time (64 bits)
|
18
|
+
szMAPI_CLSID 0x0048 MAPI OLE GUID
|
19
|
+
szMAPI_BINARY 0x0102 MAPI binary
|
@@ -0,0 +1,419 @@
|
|
1
|
+
/*
|
2
|
+
* mapi_attr.c -- Functions for handling MAPI attributes
|
3
|
+
*
|
4
|
+
* Copyright (C)1999-2006 Mark Simpson <damned@theworld.com>
|
5
|
+
*
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
8
|
+
* the Free Software Foundation; either version 2, or (at your option)
|
9
|
+
* any later version.
|
10
|
+
*
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
* GNU General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU General Public License
|
17
|
+
* along with this program; if not, you can either send email to this
|
18
|
+
* program's maintainer or write to: The Free Software Foundation,
|
19
|
+
* Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
|
20
|
+
*
|
21
|
+
*/
|
22
|
+
#ifdef HAVE_CONFIG_H
|
23
|
+
# include "config.h"
|
24
|
+
#endif /* HAVE_CONFIG_H */
|
25
|
+
|
26
|
+
#include "common.h"
|
27
|
+
|
28
|
+
#include "mapi_attr.h"
|
29
|
+
#include "alloc.h"
|
30
|
+
#include "options.h"
|
31
|
+
#include "util.h"
|
32
|
+
#include "write.h"
|
33
|
+
|
34
|
+
/* return the length padded to a 4 byte boundary */
|
35
|
+
static size_t
|
36
|
+
pad_to_4byte (size_t length)
|
37
|
+
{
|
38
|
+
return (length+3) & ~3;
|
39
|
+
}
|
40
|
+
|
41
|
+
/* Copy the GUID data from a character buffer */
|
42
|
+
static void
|
43
|
+
copy_guid_from_buf (GUID* guid, unsigned char *buf)
|
44
|
+
{
|
45
|
+
int i;
|
46
|
+
int idx = 0;
|
47
|
+
assert (guid);
|
48
|
+
assert (buf);
|
49
|
+
|
50
|
+
guid->data1 = GETINT32(buf + idx); idx += sizeof (uint32);
|
51
|
+
guid->data2 = GETINT16(buf + idx); idx += sizeof (uint16);
|
52
|
+
guid->data3 = GETINT16(buf + idx); idx += sizeof (uint16);
|
53
|
+
for (i = 0; i < 8; i++, idx += sizeof (uint8))
|
54
|
+
guid->data4[i] = (uint8)(buf[idx]);
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
/* dumps info about MAPI attributes... useful for debugging */
|
59
|
+
static void
|
60
|
+
mapi_attr_dump (MAPI_Attr* attr)
|
61
|
+
{
|
62
|
+
char *name = get_mapi_name_str (attr->name);
|
63
|
+
char *type = get_mapi_type_str (attr->type);
|
64
|
+
size_t i;
|
65
|
+
|
66
|
+
fprintf (stdout, "(MAPI) %s [type: %s] [num_values = %lu] = \n",
|
67
|
+
name, type, (unsigned long)attr->num_values);
|
68
|
+
if (attr->guid)
|
69
|
+
{
|
70
|
+
fprintf (stdout, "\tGUID: ");
|
71
|
+
write_guid (stdout, attr->guid);
|
72
|
+
fputc ('\n', stdout);
|
73
|
+
}
|
74
|
+
|
75
|
+
for (i = 0; i < attr->num_names; i++)
|
76
|
+
fprintf (stdout, "\tname #%d: '%s'\n", (int)i, attr->names[i].data);
|
77
|
+
|
78
|
+
for (i = 0; i < attr->num_values; i++)
|
79
|
+
{
|
80
|
+
fprintf (stdout, "\t#%lu [len: %lu] = ",
|
81
|
+
(unsigned long)i,
|
82
|
+
(unsigned long)attr->values[i].len);
|
83
|
+
|
84
|
+
switch (attr->type)
|
85
|
+
{
|
86
|
+
case szMAPI_NULL:
|
87
|
+
fprintf (stdout, "NULL");
|
88
|
+
break;
|
89
|
+
|
90
|
+
case szMAPI_SHORT:
|
91
|
+
write_int16 (stdout, (int16)attr->values[i].data.bytes2);
|
92
|
+
break;
|
93
|
+
|
94
|
+
case szMAPI_INT:
|
95
|
+
write_int32 (stdout, (int32)attr->values[i].data.bytes4);
|
96
|
+
break;
|
97
|
+
|
98
|
+
case szMAPI_FLOAT:
|
99
|
+
case szMAPI_DOUBLE:
|
100
|
+
write_float (stdout, (float)attr->values[i].data.bytes4);
|
101
|
+
break;
|
102
|
+
|
103
|
+
case szMAPI_BOOLEAN:
|
104
|
+
write_boolean (stdout, attr->values[i].data.bytes4);
|
105
|
+
break;
|
106
|
+
|
107
|
+
case szMAPI_STRING:
|
108
|
+
case szMAPI_UNICODE_STRING:
|
109
|
+
write_string (stdout, (char*)attr->values[i].data.buf);
|
110
|
+
break;
|
111
|
+
|
112
|
+
case szMAPI_SYSTIME:
|
113
|
+
case szMAPI_CURRENCY:
|
114
|
+
case szMAPI_INT8BYTE:
|
115
|
+
case szMAPI_APPTIME:
|
116
|
+
write_uint64 (stdout, attr->values[i].data.bytes8);
|
117
|
+
break;
|
118
|
+
|
119
|
+
case szMAPI_ERROR:
|
120
|
+
write_uint32 (stdout, attr->values[i].data.bytes4);
|
121
|
+
break;
|
122
|
+
|
123
|
+
case szMAPI_CLSID:
|
124
|
+
write_guid (stdout, &attr->values[i].data.guid);
|
125
|
+
break;
|
126
|
+
|
127
|
+
case szMAPI_OBJECT:
|
128
|
+
case szMAPI_BINARY:
|
129
|
+
{
|
130
|
+
size_t x;
|
131
|
+
|
132
|
+
for (x = 0; x < attr->values[i].len; x++)
|
133
|
+
{
|
134
|
+
write_byte (stdout, (uint8)attr->values[i].data.buf[x]);
|
135
|
+
fputc (' ', stdout);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
break;
|
139
|
+
|
140
|
+
default:
|
141
|
+
fprintf (stdout, "<unknown type>");
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
fprintf (stdout, "\n");
|
145
|
+
}
|
146
|
+
|
147
|
+
fflush( NULL );
|
148
|
+
}
|
149
|
+
|
150
|
+
static MAPI_Value*
|
151
|
+
alloc_mapi_values (MAPI_Attr* a)
|
152
|
+
{
|
153
|
+
if (a && a->num_values)
|
154
|
+
{
|
155
|
+
a->values = CHECKED_XCALLOC (MAPI_Value, a->num_values);
|
156
|
+
return a->values;
|
157
|
+
}
|
158
|
+
return NULL;
|
159
|
+
}
|
160
|
+
|
161
|
+
/*
|
162
|
+
2009/07/07
|
163
|
+
Microsoft documentation reference: [MS-OXPROPS] v 2.0, April 10, 2009
|
164
|
+
|
165
|
+
only multivalue types appearing are:
|
166
|
+
szMAPI_INT, szMAPI_SYSTIME, szMAPI_UNICODE_STRING, szMAPI_BINARY
|
167
|
+
*/
|
168
|
+
|
169
|
+
/* parses out the MAPI attibutes hidden in the character buffer */
|
170
|
+
MAPI_Attr**
|
171
|
+
mapi_attr_read (size_t len, unsigned char *buf)
|
172
|
+
{
|
173
|
+
size_t idx = 0;
|
174
|
+
uint32 i,j,mvf;
|
175
|
+
uint32 num_properties = GETINT32(buf+idx);
|
176
|
+
MAPI_Attr** attrs = CHECKED_XMALLOC (MAPI_Attr*, (num_properties + 1));
|
177
|
+
|
178
|
+
idx += 4;
|
179
|
+
|
180
|
+
if (!attrs) return NULL;
|
181
|
+
for (i = 0; i < num_properties; i++)
|
182
|
+
{
|
183
|
+
MAPI_Attr* a = attrs[i] = CHECKED_XCALLOC(MAPI_Attr, 1);
|
184
|
+
MAPI_Value* v = NULL;
|
185
|
+
|
186
|
+
a->type = GETINT16(buf+idx); idx += 2;
|
187
|
+
a->name = GETINT16(buf+idx); idx += 2;
|
188
|
+
|
189
|
+
|
190
|
+
/* Multi-valued attributes have their type modified by the MULTI_VALUE_FLAG value */
|
191
|
+
if (a->type & MULTI_VALUE_FLAG)
|
192
|
+
{
|
193
|
+
a->type -= MULTI_VALUE_FLAG;
|
194
|
+
mvf = 1;
|
195
|
+
|
196
|
+
if (DEBUG_ON)
|
197
|
+
{
|
198
|
+
fprintf( stdout, "!!MULTI_VALUE_FLAG seen (0x%02x 0x%02x)\n", a->name, a->type );
|
199
|
+
fflush( NULL );
|
200
|
+
}
|
201
|
+
}
|
202
|
+
else
|
203
|
+
{
|
204
|
+
mvf = 0;
|
205
|
+
}
|
206
|
+
|
207
|
+
/* handle special case of GUID prefixed properties */
|
208
|
+
if (a->name >= GUID_EXISTS_FLAG)
|
209
|
+
{
|
210
|
+
/* copy GUID */
|
211
|
+
a->guid = CHECKED_XMALLOC(GUID, 1);
|
212
|
+
copy_guid_from_buf(a->guid, buf+idx);
|
213
|
+
idx += sizeof (GUID);
|
214
|
+
|
215
|
+
a->num_names = GETINT32(buf+idx); idx += 4;
|
216
|
+
if (a->num_names > 0)
|
217
|
+
{
|
218
|
+
/* FIXME: do something useful here! */
|
219
|
+
size_t i;
|
220
|
+
|
221
|
+
a->names = CHECKED_XCALLOC(VarLenData, a->num_names);
|
222
|
+
|
223
|
+
for (i = 0; i < a->num_names; i++)
|
224
|
+
{
|
225
|
+
size_t j;
|
226
|
+
|
227
|
+
a->names[i].len = GETINT32(buf+idx); idx += 4;
|
228
|
+
|
229
|
+
/* read the data into a buffer */
|
230
|
+
a->names[i].data
|
231
|
+
= CHECKED_XMALLOC(unsigned char, a->names[i].len);
|
232
|
+
for (j = 0; j < (a->names[i].len >> 1); j++)
|
233
|
+
a->names[i].data[j] = (buf+idx)[j*2];
|
234
|
+
|
235
|
+
/* But what are we going to do with it? */
|
236
|
+
|
237
|
+
idx += pad_to_4byte(a->names[i].len);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
else
|
241
|
+
{
|
242
|
+
/* get the 'real' name */
|
243
|
+
a->name = GETINT32(buf+idx); idx+= 4;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
switch (a->type)
|
248
|
+
{
|
249
|
+
case szMAPI_SHORT: /* 2 bytes */
|
250
|
+
assert(!mvf);
|
251
|
+
a->num_values = 1;
|
252
|
+
v = alloc_mapi_values (a);
|
253
|
+
v->len = 2;
|
254
|
+
v->data.bytes2 = GETINT16(buf+idx);
|
255
|
+
idx += 4; /* assume padding of 2, advance by 4! */
|
256
|
+
break;
|
257
|
+
|
258
|
+
case szMAPI_INT: /* 4 bytes, possible MV */
|
259
|
+
if ( mvf )
|
260
|
+
{
|
261
|
+
a->num_values = GETINT32(buf+idx);
|
262
|
+
idx += 4;
|
263
|
+
}
|
264
|
+
else
|
265
|
+
{
|
266
|
+
a->num_values = 1;
|
267
|
+
}
|
268
|
+
v = alloc_mapi_values (a);
|
269
|
+
for ( j=0; j< a->num_values; j++ )
|
270
|
+
{
|
271
|
+
v->len = 4;
|
272
|
+
v->data.bytes4 = GETINT32(buf+idx);
|
273
|
+
idx += 4;
|
274
|
+
v++;
|
275
|
+
}
|
276
|
+
break;
|
277
|
+
|
278
|
+
case szMAPI_FLOAT: /* 4 bytes */
|
279
|
+
case szMAPI_BOOLEAN: /* this should be 2 bytes + 2 padding */
|
280
|
+
assert(!mvf);
|
281
|
+
a->num_values = 1;
|
282
|
+
v = alloc_mapi_values (a);
|
283
|
+
v->len = 4;
|
284
|
+
v->data.bytes4 = GETINT32(buf+idx);
|
285
|
+
idx += v->len;
|
286
|
+
break;
|
287
|
+
|
288
|
+
case szMAPI_SYSTIME: /* 8 bytes */
|
289
|
+
if ( mvf )
|
290
|
+
{
|
291
|
+
a->num_values = GETINT32(buf+idx);
|
292
|
+
idx += 4;
|
293
|
+
}
|
294
|
+
else
|
295
|
+
{
|
296
|
+
a->num_values = 1;
|
297
|
+
}
|
298
|
+
v = alloc_mapi_values (a);
|
299
|
+
for ( j=0; j< a->num_values; j++ )
|
300
|
+
{
|
301
|
+
v->len = 8;
|
302
|
+
v->data.bytes8[0] = GETINT32(buf+idx);
|
303
|
+
v->data.bytes8[1] = GETINT32(buf+idx+4);
|
304
|
+
idx += 8;
|
305
|
+
v++;
|
306
|
+
}
|
307
|
+
break;
|
308
|
+
|
309
|
+
case szMAPI_DOUBLE: /* 8 bytes */
|
310
|
+
case szMAPI_APPTIME:
|
311
|
+
case szMAPI_CURRENCY:
|
312
|
+
case szMAPI_INT8BYTE:
|
313
|
+
assert(!mvf);
|
314
|
+
a->num_values = 1;
|
315
|
+
v = alloc_mapi_values (a);
|
316
|
+
v->len = 8;
|
317
|
+
v->data.bytes8[0] = GETINT32(buf+idx);
|
318
|
+
v->data.bytes8[1] = GETINT32(buf+idx+4);
|
319
|
+
idx += v->len;
|
320
|
+
break;
|
321
|
+
|
322
|
+
case szMAPI_CLSID:
|
323
|
+
assert(!mvf);
|
324
|
+
a->num_values = 1;
|
325
|
+
v = alloc_mapi_values (a);
|
326
|
+
v->len = sizeof (GUID);
|
327
|
+
copy_guid_from_buf(&v->data.guid, buf+idx);
|
328
|
+
idx += v->len;
|
329
|
+
break;
|
330
|
+
|
331
|
+
case szMAPI_STRING:
|
332
|
+
case szMAPI_UNICODE_STRING:
|
333
|
+
case szMAPI_OBJECT:
|
334
|
+
case szMAPI_BINARY: /* variable length */
|
335
|
+
a->num_values = GETINT32(buf+idx); idx += 4;
|
336
|
+
v = alloc_mapi_values (a);
|
337
|
+
for (j = 0; j < a->num_values; j++)
|
338
|
+
{
|
339
|
+
v->len = GETINT32(buf+idx); idx += 4;
|
340
|
+
|
341
|
+
if (a->type == szMAPI_UNICODE_STRING)
|
342
|
+
{
|
343
|
+
v->data.buf = (unsigned char*)unicode_to_utf8(v->len, buf+idx);
|
344
|
+
}
|
345
|
+
else
|
346
|
+
{
|
347
|
+
v->data.buf = CHECKED_XMALLOC(unsigned char, v->len);
|
348
|
+
memmove (v->data.buf, buf+idx, v->len);
|
349
|
+
}
|
350
|
+
|
351
|
+
idx += pad_to_4byte(v->len);
|
352
|
+
v++;
|
353
|
+
}
|
354
|
+
break;
|
355
|
+
|
356
|
+
case szMAPI_NULL: /* illegal in input tnef streams */
|
357
|
+
case szMAPI_ERROR:
|
358
|
+
case szMAPI_UNSPECIFIED:
|
359
|
+
|
360
|
+
fprintf (stderr,
|
361
|
+
"Invalid attribute, input file may be corrupted\n");
|
362
|
+
if (!ENCODE_SKIP) exit (1);
|
363
|
+
|
364
|
+
return NULL;
|
365
|
+
|
366
|
+
default: /* should never get here */
|
367
|
+
fprintf (stderr,
|
368
|
+
"Undefined attribute, input file may be corrupted\n");
|
369
|
+
if (!ENCODE_SKIP) exit (1);
|
370
|
+
|
371
|
+
return NULL;
|
372
|
+
|
373
|
+
}
|
374
|
+
if (DEBUG_ON) mapi_attr_dump (attrs[i]);
|
375
|
+
|
376
|
+
}
|
377
|
+
attrs[i] = NULL;
|
378
|
+
|
379
|
+
return attrs;
|
380
|
+
}
|
381
|
+
|
382
|
+
static void
|
383
|
+
mapi_attr_free (MAPI_Attr* attr)
|
384
|
+
{
|
385
|
+
if (attr)
|
386
|
+
{
|
387
|
+
size_t i;
|
388
|
+
for (i = 0; i < attr->num_values; i++)
|
389
|
+
{
|
390
|
+
if ((attr->type == szMAPI_STRING)
|
391
|
+
|| (attr->type == szMAPI_UNICODE_STRING)
|
392
|
+
|| (attr->type == szMAPI_BINARY))
|
393
|
+
{
|
394
|
+
XFREE (attr->values[i].data.buf);
|
395
|
+
}
|
396
|
+
}
|
397
|
+
if (attr->num_names > 0) {
|
398
|
+
for (i = 0; i < attr->num_names; i++)
|
399
|
+
{
|
400
|
+
XFREE(attr->names[i].data);
|
401
|
+
}
|
402
|
+
XFREE(attr->names);
|
403
|
+
}
|
404
|
+
XFREE (attr->values);
|
405
|
+
XFREE (attr->guid);
|
406
|
+
memset (attr, '\0', sizeof (MAPI_Attr));
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
void
|
411
|
+
mapi_attr_free_list (MAPI_Attr** attrs)
|
412
|
+
{
|
413
|
+
int i;
|
414
|
+
for (i = 0; attrs && attrs[i]; i++)
|
415
|
+
{
|
416
|
+
mapi_attr_free (attrs[i]);
|
417
|
+
XFREE (attrs[i]);
|
418
|
+
}
|
419
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/*
|
2
|
+
* mapi_attr.h -- Functions for handling MAPI attributes
|
3
|
+
*
|
4
|
+
* Copyright (C)1999-2006 Mark Simpson <damned@theworld.com>
|
5
|
+
*
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
8
|
+
* the Free Software Foundation; either version 2, or (at your option)
|
9
|
+
* any later version.
|
10
|
+
*
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
* GNU General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU General Public License
|
17
|
+
* along with this program; if not, you can either send email to this
|
18
|
+
* program's maintainer or write to: The Free Software Foundation,
|
19
|
+
* Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
|
20
|
+
*
|
21
|
+
*/
|
22
|
+
#ifndef MAPI_ATTR_H
|
23
|
+
#define MAPI_ATTR_H
|
24
|
+
|
25
|
+
#if HAVE_CONFIG_H
|
26
|
+
# include "config.h"
|
27
|
+
#endif /* HAVE_CONFIG_H */
|
28
|
+
|
29
|
+
#include "common.h"
|
30
|
+
|
31
|
+
#include "mapi_types.h"
|
32
|
+
#include "mapi_names.h"
|
33
|
+
|
34
|
+
#define MULTI_VALUE_FLAG 0x1000
|
35
|
+
#define GUID_EXISTS_FLAG 0x8000
|
36
|
+
|
37
|
+
typedef struct
|
38
|
+
{
|
39
|
+
uint32 data1;
|
40
|
+
uint16 data2;
|
41
|
+
uint16 data3;
|
42
|
+
uint8 data4[8];
|
43
|
+
} GUID;
|
44
|
+
|
45
|
+
typedef struct
|
46
|
+
{
|
47
|
+
size_t len;
|
48
|
+
union
|
49
|
+
{
|
50
|
+
unsigned char *buf;
|
51
|
+
uint16 bytes2;
|
52
|
+
uint32 bytes4;
|
53
|
+
uint32 bytes8[2];
|
54
|
+
GUID guid;
|
55
|
+
} data;
|
56
|
+
} MAPI_Value;
|
57
|
+
|
58
|
+
typedef struct
|
59
|
+
{
|
60
|
+
size_t len;
|
61
|
+
unsigned char* data;
|
62
|
+
} VarLenData;
|
63
|
+
|
64
|
+
typedef struct
|
65
|
+
{
|
66
|
+
mapi_type type;
|
67
|
+
mapi_name name;
|
68
|
+
size_t num_values;
|
69
|
+
MAPI_Value* values;
|
70
|
+
GUID *guid;
|
71
|
+
size_t num_names;
|
72
|
+
VarLenData *names;
|
73
|
+
} MAPI_Attr;
|
74
|
+
|
75
|
+
extern MAPI_Attr** mapi_attr_read (size_t len, unsigned char *buf);
|
76
|
+
extern void mapi_attr_free_list (MAPI_Attr** attrs);
|
77
|
+
|
78
|
+
#endif /* MAPI_ATTR_H */
|