tnef 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,141 @@
|
|
|
1
|
+
/* This code snithced from GNUEmacs 20.5.1 with only minor mods */
|
|
2
|
+
/* Declarations for getopt.
|
|
3
|
+
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
|
4
|
+
|
|
5
|
+
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
|
6
|
+
Bugs can be reported to bug-glibc@gnu.org.
|
|
7
|
+
|
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
|
9
|
+
under the terms of the GNU General Public License as published by the
|
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
|
11
|
+
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, write to the Free Software
|
|
20
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
21
|
+
USA. */
|
|
22
|
+
|
|
23
|
+
#ifndef _GETOPT_H
|
|
24
|
+
#define _GETOPT_H 1
|
|
25
|
+
|
|
26
|
+
#ifdef HAVE_CONFIG_H
|
|
27
|
+
#include "config.h"
|
|
28
|
+
#endif /* HAVE_CONFIG_H */
|
|
29
|
+
#ifndef HAVE_GETOPT_LONG
|
|
30
|
+
|
|
31
|
+
#ifdef __cplusplus
|
|
32
|
+
extern "C" {
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
/* For communication from `getopt' to the caller.
|
|
36
|
+
When `getopt' finds an option that takes an argument,
|
|
37
|
+
the argument value is returned here.
|
|
38
|
+
Also, when `ordering' is RETURN_IN_ORDER,
|
|
39
|
+
each non-option ARGV-element is returned here. */
|
|
40
|
+
|
|
41
|
+
extern char *optarg;
|
|
42
|
+
|
|
43
|
+
/* Index in ARGV of the next element to be scanned.
|
|
44
|
+
This is used for communication to and from the caller
|
|
45
|
+
and for communication between successive calls to `getopt'.
|
|
46
|
+
|
|
47
|
+
On entry to `getopt', zero means this is the first call; initialize.
|
|
48
|
+
|
|
49
|
+
When `getopt' returns -1, this is the index of the first of the
|
|
50
|
+
non-option elements that the caller should itself scan.
|
|
51
|
+
|
|
52
|
+
Otherwise, `optind' communicates from one call to the next
|
|
53
|
+
how much of ARGV has been scanned so far. */
|
|
54
|
+
|
|
55
|
+
extern int optind;
|
|
56
|
+
|
|
57
|
+
/* Callers store zero here to inhibit the error message `getopt' prints
|
|
58
|
+
for unrecognized options. */
|
|
59
|
+
|
|
60
|
+
extern int opterr;
|
|
61
|
+
|
|
62
|
+
/* Set to an option character which was unrecognized. */
|
|
63
|
+
|
|
64
|
+
extern int optopt;
|
|
65
|
+
|
|
66
|
+
/* Describe the long-named options requested by the application.
|
|
67
|
+
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
|
68
|
+
of `struct option' terminated by an element containing a name which is
|
|
69
|
+
zero.
|
|
70
|
+
|
|
71
|
+
The field `has_arg' is:
|
|
72
|
+
no_argument (or 0) if the option does not take an argument,
|
|
73
|
+
required_argument (or 1) if the option requires an argument,
|
|
74
|
+
optional_argument (or 2) if the option takes an optional argument.
|
|
75
|
+
|
|
76
|
+
If the field `flag' is not NULL, it points to a variable that is set
|
|
77
|
+
to the value given in the field `val' when the option is found, but
|
|
78
|
+
left unchanged if the option is not found.
|
|
79
|
+
|
|
80
|
+
To have a long-named option do something other than set an `int' to
|
|
81
|
+
a compiled-in constant, such as set a value from `optarg', set the
|
|
82
|
+
option's `flag' field to zero and its `val' field to a nonzero
|
|
83
|
+
value (the equivalent single-letter option character, if there is
|
|
84
|
+
one). For long options that have a zero `flag' field, `getopt'
|
|
85
|
+
returns the contents of the `val' field. */
|
|
86
|
+
|
|
87
|
+
struct option
|
|
88
|
+
{
|
|
89
|
+
#if defined (__STDC__) && __STDC__
|
|
90
|
+
const char *name;
|
|
91
|
+
#else
|
|
92
|
+
char *name;
|
|
93
|
+
#endif
|
|
94
|
+
/* has_arg can't be an enum because some compilers complain about
|
|
95
|
+
type mismatches in all the code that assumes it is an int. */
|
|
96
|
+
int has_arg;
|
|
97
|
+
int *flag;
|
|
98
|
+
int val;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/* Names for the values of the `has_arg' field of `struct option'. */
|
|
102
|
+
|
|
103
|
+
#define no_argument 0
|
|
104
|
+
#define required_argument 1
|
|
105
|
+
#define optional_argument 2
|
|
106
|
+
|
|
107
|
+
#if defined (__STDC__) && __STDC__
|
|
108
|
+
#ifdef __GNU_LIBRARY__
|
|
109
|
+
/* Many other libraries have conflicting prototypes for getopt, with
|
|
110
|
+
differences in the consts, in stdlib.h. To avoid compilation
|
|
111
|
+
errors, only prototype getopt for the GNU C library. */
|
|
112
|
+
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
|
113
|
+
#else /* not __GNU_LIBRARY__ */
|
|
114
|
+
extern int getopt ();
|
|
115
|
+
#endif /* __GNU_LIBRARY__ */
|
|
116
|
+
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
|
117
|
+
const struct option *longopts, int *longind);
|
|
118
|
+
extern int getopt_long_only (int argc, char *const *argv,
|
|
119
|
+
const char *shortopts,
|
|
120
|
+
const struct option *longopts, int *longind);
|
|
121
|
+
|
|
122
|
+
/* Internal only. Users should not call this directly. */
|
|
123
|
+
extern int _getopt_internal (int argc, char *const *argv,
|
|
124
|
+
const char *shortopts,
|
|
125
|
+
const struct option *longopts, int *longind,
|
|
126
|
+
int long_only);
|
|
127
|
+
#else /* not __STDC__ */
|
|
128
|
+
extern int getopt ();
|
|
129
|
+
extern int getopt_long ();
|
|
130
|
+
extern int getopt_long_only ();
|
|
131
|
+
|
|
132
|
+
extern int _getopt_internal ();
|
|
133
|
+
#endif /* __STDC__ */
|
|
134
|
+
|
|
135
|
+
#ifdef __cplusplus
|
|
136
|
+
}
|
|
137
|
+
#endif
|
|
138
|
+
|
|
139
|
+
#endif /* !HAVE_GETOPT_LONG */
|
|
140
|
+
|
|
141
|
+
#endif /* getopt.h */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* malloc.c -- replacement malloc function if provided malloc does not
|
|
3
|
+
* handle malloc(0) well
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C)1999-2006 Mark Simpson <damned@theworld.com>
|
|
6
|
+
*
|
|
7
|
+
* This program is free software; you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation; either version 2, or (at your option)
|
|
10
|
+
* any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program; if not, you can either send email to this
|
|
19
|
+
* program's maintainer or write to: The Free Software Foundation,
|
|
20
|
+
* Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
#if HAVE_CONFIG_H
|
|
24
|
+
# include "config.h"
|
|
25
|
+
#endif
|
|
26
|
+
#undef malloc
|
|
27
|
+
|
|
28
|
+
#include <memory.h>
|
|
29
|
+
|
|
30
|
+
char *malloc ();
|
|
31
|
+
|
|
32
|
+
/* Allocate an N-byte block of memory from the heap.
|
|
33
|
+
If N is zero, allocate a 1-byte block. */
|
|
34
|
+
|
|
35
|
+
char *
|
|
36
|
+
rpl_malloc (size_t n)
|
|
37
|
+
{
|
|
38
|
+
if (n == 0)
|
|
39
|
+
n = 1;
|
|
40
|
+
return malloc (n);
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* strdup.c -- version of strdup for systems without one
|
|
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
|
+
#if !HAVE_STRDUP
|
|
27
|
+
#include <assert.h>
|
|
28
|
+
#include <stdio.h>
|
|
29
|
+
|
|
30
|
+
#if STDC_HEADERS
|
|
31
|
+
# include <stdlib.h>
|
|
32
|
+
#else
|
|
33
|
+
extern size_t strlen (const char *);
|
|
34
|
+
|
|
35
|
+
# if !HAVE_MEMMOVE
|
|
36
|
+
# define memmove(d,s,n) bcopy((s),(d),(n));
|
|
37
|
+
# else
|
|
38
|
+
extern void* memmove (void *, const void *, size_t);
|
|
39
|
+
# endif
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
char *
|
|
43
|
+
strdup (const char *str)
|
|
44
|
+
{
|
|
45
|
+
size_t len = strlen(str);
|
|
46
|
+
char *out = malloc ((len+1) * sizeof (char));
|
|
47
|
+
memmove (out, str, (len + 1));
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
#endif /* !HAVE_STRDUP */
|
|
51
|
+
|
data/ext/tnef/src/rtf.c
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* rtf.c -- utility function for dealing with RTF content
|
|
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
|
+
* Commentary:
|
|
22
|
+
* Entry point is get_rtf_data. All other functions are internal.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#ifdef HAVE_CONFIG_H
|
|
26
|
+
# include "config.h"
|
|
27
|
+
#endif /* HAVE_CONFIG_H */
|
|
28
|
+
|
|
29
|
+
#include "common.h"
|
|
30
|
+
|
|
31
|
+
#include "alloc.h"
|
|
32
|
+
#include "file.h"
|
|
33
|
+
#include "mapi_attr.h"
|
|
34
|
+
#include "path.h"
|
|
35
|
+
#include "util.h"
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
decompression algorithm
|
|
39
|
+
[MS-OXRTFCP] v 2.0 april 10, 2009
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
static const uint32 rtf_uncompressed_magic = 0x414c454d;
|
|
43
|
+
static const uint32 rtf_compressed_magic = 0x75465a4c;
|
|
44
|
+
|
|
45
|
+
static const char* rtf_prebuf = "{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}{\\f0\\fnil \\froman \\fswiss \\fmodern \\fscript \\fdecor MS Sans SerifSymbolArialTimes New RomanCourier{\\colortbl\\red0\\green0\\blue0\r\n\\par \\pard\\plain\\f0\\fs20\\b\\i\\u\\tab\\tx";
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
crc table and crc generation algorithm
|
|
49
|
+
[MS-OXRTFCP] v 2.0 april 10, 2009
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
static uint32 crc_table[256] =
|
|
53
|
+
{
|
|
54
|
+
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
|
55
|
+
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
|
56
|
+
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
|
57
|
+
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
|
58
|
+
|
|
59
|
+
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
|
60
|
+
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
|
61
|
+
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
|
|
62
|
+
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
|
63
|
+
|
|
64
|
+
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
|
65
|
+
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
|
66
|
+
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
|
|
67
|
+
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
|
68
|
+
|
|
69
|
+
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
|
|
70
|
+
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
|
71
|
+
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
72
|
+
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
|
73
|
+
|
|
74
|
+
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
|
|
75
|
+
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
|
76
|
+
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
|
|
77
|
+
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
|
78
|
+
|
|
79
|
+
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
|
80
|
+
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
|
81
|
+
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
|
|
82
|
+
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
|
83
|
+
|
|
84
|
+
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
|
85
|
+
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
|
86
|
+
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
|
87
|
+
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
|
88
|
+
|
|
89
|
+
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
|
|
90
|
+
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
91
|
+
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
|
|
92
|
+
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
|
93
|
+
|
|
94
|
+
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
|
95
|
+
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
|
96
|
+
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
|
97
|
+
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
|
98
|
+
|
|
99
|
+
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
|
|
100
|
+
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
|
101
|
+
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
|
102
|
+
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
|
103
|
+
|
|
104
|
+
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
|
|
105
|
+
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
|
106
|
+
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
|
|
107
|
+
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
|
108
|
+
|
|
109
|
+
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
110
|
+
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
|
111
|
+
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
|
|
112
|
+
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
|
113
|
+
|
|
114
|
+
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
|
|
115
|
+
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
|
116
|
+
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
|
117
|
+
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
|
118
|
+
|
|
119
|
+
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
|
|
120
|
+
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
|
121
|
+
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
|
122
|
+
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
|
123
|
+
|
|
124
|
+
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
|
125
|
+
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
|
126
|
+
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
|
|
127
|
+
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
128
|
+
|
|
129
|
+
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
|
|
130
|
+
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
|
131
|
+
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
|
132
|
+
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
static uint32
|
|
136
|
+
generate_crc(unsigned char *data, size_t len)
|
|
137
|
+
{
|
|
138
|
+
uint32 crc = 0x00000000;
|
|
139
|
+
uint32 i, j;
|
|
140
|
+
unsigned char c;
|
|
141
|
+
|
|
142
|
+
for ( i=0; i<len; i++ )
|
|
143
|
+
{
|
|
144
|
+
c = data[i];
|
|
145
|
+
j = ( crc ^ (uint32)c ) & 0xff;
|
|
146
|
+
crc = crc_table[j] ^ ( crc>>8 );
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return crc;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static int
|
|
153
|
+
is_rtf_data (unsigned char *data)
|
|
154
|
+
{
|
|
155
|
+
size_t compr_size = 0L;
|
|
156
|
+
size_t uncompr_size = 0L;
|
|
157
|
+
uint32 magic;
|
|
158
|
+
size_t idx = 0;
|
|
159
|
+
|
|
160
|
+
compr_size = GETINT32(data + idx); idx += 4;
|
|
161
|
+
uncompr_size = GETINT32(data + idx); idx += 4;
|
|
162
|
+
magic = GETINT32(data + idx); idx += 4;
|
|
163
|
+
|
|
164
|
+
if ((magic == rtf_uncompressed_magic)
|
|
165
|
+
|| (magic == rtf_compressed_magic))
|
|
166
|
+
return 1;
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static unsigned char *
|
|
171
|
+
decompress_rtf_data( unsigned char *src, size_t lenc, size_t lenu )
|
|
172
|
+
{
|
|
173
|
+
const size_t rtf_prebuf_len = strlen( rtf_prebuf );
|
|
174
|
+
|
|
175
|
+
int woff, eoff, roff, rlen;
|
|
176
|
+
int control, cin, cout, i, j, endflag;
|
|
177
|
+
unsigned char *dest;
|
|
178
|
+
unsigned char dict[4096];
|
|
179
|
+
|
|
180
|
+
/* setup dictionary */
|
|
181
|
+
|
|
182
|
+
memset( dict, 0x0, sizeof(dict) );
|
|
183
|
+
memmove( dict, rtf_prebuf, rtf_prebuf_len );
|
|
184
|
+
|
|
185
|
+
woff = rtf_prebuf_len;
|
|
186
|
+
eoff = rtf_prebuf_len;
|
|
187
|
+
|
|
188
|
+
/* setup destination */
|
|
189
|
+
|
|
190
|
+
assert( lenu>0 ); /* sanity check */
|
|
191
|
+
|
|
192
|
+
dest = CHECKED_XCALLOC(unsigned char, lenu);
|
|
193
|
+
cout = 0;
|
|
194
|
+
|
|
195
|
+
/* setup source */
|
|
196
|
+
|
|
197
|
+
assert( lenc>0 );
|
|
198
|
+
|
|
199
|
+
cin = 0;
|
|
200
|
+
|
|
201
|
+
/* processing loop */
|
|
202
|
+
|
|
203
|
+
endflag = 0;
|
|
204
|
+
|
|
205
|
+
while (1)
|
|
206
|
+
{
|
|
207
|
+
if ( endflag ) break;
|
|
208
|
+
|
|
209
|
+
/* get control byte */
|
|
210
|
+
|
|
211
|
+
if ( cin+1 > lenc )
|
|
212
|
+
{
|
|
213
|
+
endflag = -1;
|
|
214
|
+
break; /* input overrun */
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
control = (int)src[cin++];
|
|
218
|
+
|
|
219
|
+
/* handle control run */
|
|
220
|
+
|
|
221
|
+
for ( i=0; i<8; i++ )
|
|
222
|
+
{
|
|
223
|
+
if ( endflag ) break;
|
|
224
|
+
|
|
225
|
+
if ( control & (1<<i) )
|
|
226
|
+
{
|
|
227
|
+
/* dictionary reference */
|
|
228
|
+
|
|
229
|
+
if ( cin+2 > lenc )
|
|
230
|
+
{
|
|
231
|
+
endflag = -1;
|
|
232
|
+
break; /* input overrun */
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
roff = (int)src[cin++];
|
|
236
|
+
rlen = (int)src[cin++];
|
|
237
|
+
|
|
238
|
+
roff = (roff<<4) + (rlen>>4);
|
|
239
|
+
rlen = (rlen&0x0f) + 2;
|
|
240
|
+
|
|
241
|
+
/* the one true exit test */
|
|
242
|
+
|
|
243
|
+
if ( roff == woff )
|
|
244
|
+
{
|
|
245
|
+
endflag = 1;
|
|
246
|
+
break; /* happy ending */
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* handle reference */
|
|
250
|
+
|
|
251
|
+
if ( cout+rlen > lenu )
|
|
252
|
+
{
|
|
253
|
+
endflag = -1;
|
|
254
|
+
break; /* output overrun */
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
for ( j=0; j<rlen; j++ )
|
|
258
|
+
{
|
|
259
|
+
dest[cout++] = dict[roff];
|
|
260
|
+
dict[woff++] = dict[roff++];
|
|
261
|
+
|
|
262
|
+
roff &= 0xfff;
|
|
263
|
+
woff &= 0xfff;
|
|
264
|
+
if ( eoff < 4096 ) eoff++;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else
|
|
268
|
+
{
|
|
269
|
+
/* literal */
|
|
270
|
+
|
|
271
|
+
if ( cin+1 > lenc )
|
|
272
|
+
{
|
|
273
|
+
endflag = -1;
|
|
274
|
+
break; /* input overrun */
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if ( cout+1 > lenu )
|
|
278
|
+
{
|
|
279
|
+
endflag = -1;
|
|
280
|
+
break; /* output overrun */
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* handle literal */
|
|
284
|
+
|
|
285
|
+
dest[cout++] = src[cin];
|
|
286
|
+
dict[woff++] = src[cin++];
|
|
287
|
+
|
|
288
|
+
woff &= 0xfff;
|
|
289
|
+
if ( eoff < 4096 ) eoff++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if ( endflag < 0 )
|
|
295
|
+
{
|
|
296
|
+
fprintf( stderr, "RTF buffer overrun, input file may be corrupted\n" );
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return dest;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
static void
|
|
303
|
+
get_rtf_data_from_buf (size_t len, unsigned char *data,
|
|
304
|
+
size_t *out_len, unsigned char **out_data)
|
|
305
|
+
{
|
|
306
|
+
size_t compr_size = 0L;
|
|
307
|
+
size_t uncompr_size = 0L;
|
|
308
|
+
uint32 magic;
|
|
309
|
+
uint32 checksum;
|
|
310
|
+
size_t idx = 0;
|
|
311
|
+
|
|
312
|
+
compr_size = GETINT32(data + idx); idx += 4;
|
|
313
|
+
uncompr_size = GETINT32(data + idx); idx += 4;
|
|
314
|
+
magic = GETINT32(data + idx); idx += 4;
|
|
315
|
+
checksum = GETINT32 (data + idx); idx += 4;
|
|
316
|
+
|
|
317
|
+
/* sanity check */
|
|
318
|
+
assert (compr_size + 4 == len);
|
|
319
|
+
|
|
320
|
+
(*out_len) = uncompr_size;
|
|
321
|
+
|
|
322
|
+
if (magic == rtf_uncompressed_magic) /* uncompressed rtf stream */
|
|
323
|
+
{
|
|
324
|
+
(*out_data) = CHECKED_XCALLOC(unsigned char, (*out_len));
|
|
325
|
+
memmove ((*out_data), data+4, uncompr_size);
|
|
326
|
+
}
|
|
327
|
+
else if (magic == rtf_compressed_magic) /* compressed rtf stream */
|
|
328
|
+
{
|
|
329
|
+
if ( checksum == generate_crc( data+idx, len-idx ) )
|
|
330
|
+
{
|
|
331
|
+
(*out_data) = decompress_rtf_data (data+idx, len-idx, uncompr_size);
|
|
332
|
+
}
|
|
333
|
+
else
|
|
334
|
+
{
|
|
335
|
+
(*out_data) = CHECKED_XCALLOC(unsigned char, 4);
|
|
336
|
+
(*out_len) = 0;
|
|
337
|
+
fprintf( stderr, "Invalid RTF CRC, input file may be corrupted\n" );
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
VarLenData**
|
|
343
|
+
get_rtf_data (MAPI_Attr *a)
|
|
344
|
+
{
|
|
345
|
+
VarLenData** body
|
|
346
|
+
= (VarLenData**)CHECKED_XCALLOC(VarLenData*, a->num_values + 1);
|
|
347
|
+
|
|
348
|
+
int j;
|
|
349
|
+
for (j = 0; j < a->num_values; j++)
|
|
350
|
+
{
|
|
351
|
+
if (is_rtf_data (a->values[j].data.buf))
|
|
352
|
+
{
|
|
353
|
+
body[j] = (VarLenData*)XMALLOC(VarLenData, 1);
|
|
354
|
+
|
|
355
|
+
get_rtf_data_from_buf (a->values[j].len,
|
|
356
|
+
a->values[j].data.buf,
|
|
357
|
+
&body[j]->len, &body[j]->data);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return body;
|
|
361
|
+
}
|
|
362
|
+
|