tnef 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data/ext/tnef/AUTHORS +7 -0
  2. data/ext/tnef/BUGS.in +5 -0
  3. data/ext/tnef/COPYING +340 -0
  4. data/ext/tnef/ChangeLog +1550 -0
  5. data/ext/tnef/INSTALL +234 -0
  6. data/ext/tnef/Makefile.am +7 -0
  7. data/ext/tnef/Makefile.in +699 -0
  8. data/ext/tnef/NEWS +177 -0
  9. data/ext/tnef/README +39 -0
  10. data/ext/tnef/THANKS +1 -0
  11. data/ext/tnef/TODO +7 -0
  12. data/ext/tnef/acinclude.m4 +47 -0
  13. data/ext/tnef/aclocal.m4 +1012 -0
  14. data/ext/tnef/configure +6815 -0
  15. data/ext/tnef/configure.in +67 -0
  16. data/ext/tnef/depcomp +584 -0
  17. data/ext/tnef/doc/FAQ +25 -0
  18. data/ext/tnef/doc/Makefile.am +6 -0
  19. data/ext/tnef/doc/Makefile.in +623 -0
  20. data/ext/tnef/doc/file-format.tex +139 -0
  21. data/ext/tnef/doc/tnef.1.in +183 -0
  22. data/ext/tnef/doc/www/Makefile.am +14 -0
  23. data/ext/tnef/doc/www/Makefile.in +542 -0
  24. data/ext/tnef/doc/www/cgi-bin/Makefile.am +14 -0
  25. data/ext/tnef/doc/www/cgi-bin/Makefile.in +340 -0
  26. data/ext/tnef/doc/www/htdocs/Makefile.am +14 -0
  27. data/ext/tnef/doc/www/htdocs/Makefile.in +340 -0
  28. data/ext/tnef/extconf.rb +3 -0
  29. data/ext/tnef/install-sh +507 -0
  30. data/ext/tnef/missing +367 -0
  31. data/ext/tnef/mkinstalldirs +161 -0
  32. data/ext/tnef/src/Makefile.am +48 -0
  33. data/ext/tnef/src/Makefile.in +700 -0
  34. data/ext/tnef/src/alloc.c +107 -0
  35. data/ext/tnef/src/alloc.h +54 -0
  36. data/ext/tnef/src/attr.c +270 -0
  37. data/ext/tnef/src/attr.h +74 -0
  38. data/ext/tnef/src/common.h +101 -0
  39. data/ext/tnef/src/config.h.in +111 -0
  40. data/ext/tnef/src/date.c +66 -0
  41. data/ext/tnef/src/date.h +43 -0
  42. data/ext/tnef/src/debug.c +45 -0
  43. data/ext/tnef/src/debug.h +32 -0
  44. data/ext/tnef/src/file.c +259 -0
  45. data/ext/tnef/src/file.h +48 -0
  46. data/ext/tnef/src/main.c +386 -0
  47. data/ext/tnef/src/mapi-names.data +430 -0
  48. data/ext/tnef/src/mapi-types.data +19 -0
  49. data/ext/tnef/src/mapi_attr.c +419 -0
  50. data/ext/tnef/src/mapi_attr.h +78 -0
  51. data/ext/tnef/src/mkdata.awk +100 -0
  52. data/ext/tnef/src/options.c +32 -0
  53. data/ext/tnef/src/options.h +67 -0
  54. data/ext/tnef/src/path.c +397 -0
  55. data/ext/tnef/src/path.h +34 -0
  56. data/ext/tnef/src/replace/Makefile.am +8 -0
  57. data/ext/tnef/src/replace/Makefile.in +435 -0
  58. data/ext/tnef/src/replace/basename.c +45 -0
  59. data/ext/tnef/src/replace/dummy.c +7 -0
  60. data/ext/tnef/src/replace/getopt_long.c +940 -0
  61. data/ext/tnef/src/replace/getopt_long.h +141 -0
  62. data/ext/tnef/src/replace/malloc.c +41 -0
  63. data/ext/tnef/src/replace/strdup.c +51 -0
  64. data/ext/tnef/src/rtf.c +362 -0
  65. data/ext/tnef/src/rtf.h +36 -0
  66. data/ext/tnef/src/tnef-names.data +34 -0
  67. data/ext/tnef/src/tnef-types.data +12 -0
  68. data/ext/tnef/src/tnef.c +396 -0
  69. data/ext/tnef/src/tnef.h +45 -0
  70. data/ext/tnef/src/util.c +112 -0
  71. data/ext/tnef/src/util.h +42 -0
  72. data/ext/tnef/src/write.c +136 -0
  73. data/ext/tnef/src/write.h +25 -0
  74. data/ext/tnef/src/xstrdup.c +41 -0
  75. data/ext/tnef/tests/Makefile.am +4 -0
  76. data/ext/tnef/tests/Makefile.in +530 -0
  77. data/ext/tnef/tests/cmdline/AUTHORS +8 -0
  78. data/ext/tnef/tests/cmdline/AUTHORS.baseline +8 -0
  79. data/ext/tnef/tests/cmdline/Makefile.am +33 -0
  80. data/ext/tnef/tests/cmdline/Makefile.in +455 -0
  81. data/ext/tnef/tests/cmdline/basic.baseline +4 -0
  82. data/ext/tnef/tests/cmdline/basic.test +39 -0
  83. data/ext/tnef/tests/cmdline/body-test.html.baseline +95 -0
  84. data/ext/tnef/tests/cmdline/body.baseline +929 -0
  85. data/ext/tnef/tests/cmdline/body.test +55 -0
  86. data/ext/tnef/tests/cmdline/debug.baseline +155 -0
  87. data/ext/tnef/tests/cmdline/debug.test +14 -0
  88. data/ext/tnef/tests/cmdline/directory.baseline +3 -0
  89. data/ext/tnef/tests/cmdline/directory.test +35 -0
  90. data/ext/tnef/tests/cmdline/help.baseline +63 -0
  91. data/ext/tnef/tests/cmdline/help.test +12 -0
  92. data/ext/tnef/tests/cmdline/interactive.test +5 -0
  93. data/ext/tnef/tests/cmdline/list.baseline +5 -0
  94. data/ext/tnef/tests/cmdline/list.test +21 -0
  95. data/ext/tnef/tests/cmdline/maxsize.baseline +828 -0
  96. data/ext/tnef/tests/cmdline/maxsize.test +43 -0
  97. data/ext/tnef/tests/cmdline/message.html.baseline +95 -0
  98. data/ext/tnef/tests/cmdline/mime-types.baseline +3 -0
  99. data/ext/tnef/tests/cmdline/mime-types.test +11 -0
  100. data/ext/tnef/tests/cmdline/overwrite.baseline +8 -0
  101. data/ext/tnef/tests/cmdline/overwrite.test +40 -0
  102. data/ext/tnef/tests/cmdline/rtf-test.rtf.baseline +0 -0
  103. data/ext/tnef/tests/cmdline/stdin.baseline +2 -0
  104. data/ext/tnef/tests/cmdline/stdin.test +18 -0
  105. data/ext/tnef/tests/cmdline/test.tnef +0 -0
  106. data/ext/tnef/tests/cmdline/triples-test-2.rtf.baseline +0 -0
  107. data/ext/tnef/tests/cmdline/triples-test-2.txt.baseline +0 -0
  108. data/ext/tnef/tests/cmdline/triples-test.txt.baseline +0 -0
  109. data/ext/tnef/tests/cmdline/use-path.baseline +0 -0
  110. data/ext/tnef/tests/cmdline/use-path.test +5 -0
  111. data/ext/tnef/tests/cmdline/verbose.baseline +5 -0
  112. data/ext/tnef/tests/cmdline/verbose.test +19 -0
  113. data/ext/tnef/tests/cmdline/version.baseline +17 -0
  114. data/ext/tnef/tests/cmdline/version.test +14 -0
  115. data/ext/tnef/tests/files/MAPI_ATTACH_DATA_OBJ.test +9 -0
  116. data/ext/tnef/tests/files/MAPI_OBJECT.test +9 -0
  117. data/ext/tnef/tests/files/Makefile.am +16 -0
  118. data/ext/tnef/tests/files/Makefile.in +636 -0
  119. data/ext/tnef/tests/files/baselines/AUTHORS.baseline +8 -0
  120. data/ext/tnef/tests/files/baselines/AUTOEXEC.BAT.baseline +0 -0
  121. data/ext/tnef/tests/files/baselines/CONFIG.SYS.baseline +0 -0
  122. data/ext/tnef/tests/files/baselines/MAPI_ATTACH_DATA_OBJ-body.rtf.baseline +0 -0
  123. data/ext/tnef/tests/files/baselines/MAPI_ATTACH_DATA_OBJ.baseline +229 -0
  124. data/ext/tnef/tests/files/baselines/MAPI_OBJECT-body.rtf.baseline +0 -0
  125. data/ext/tnef/tests/files/baselines/MAPI_OBJECT.baseline +153 -0
  126. data/ext/tnef/tests/files/baselines/Makefile.am +35 -0
  127. data/ext/tnef/tests/files/baselines/Makefile.in +361 -0
  128. data/ext/tnef/tests/files/baselines/README.baseline +31 -0
  129. data/ext/tnef/tests/files/baselines/TechlibDEC99-JAN00.doc.baseline +0 -0
  130. data/ext/tnef/tests/files/baselines/TechlibDEC99.doc.baseline +0 -0
  131. data/ext/tnef/tests/files/baselines/TechlibNOV99.doc.baseline +0 -0
  132. data/ext/tnef/tests/files/baselines/Untitled_Attachment.baseline +0 -0
  133. data/ext/tnef/tests/files/baselines/VIA_Nytt_1402.doc.baseline +0 -0
  134. data/ext/tnef/tests/files/baselines/VIA_Nytt_1402.pdf.baseline +0 -0
  135. data/ext/tnef/tests/files/baselines/VIA_Nytt_14021.htm.baseline +1914 -0
  136. data/ext/tnef/tests/files/baselines/body-body.html.baseline +95 -0
  137. data/ext/tnef/tests/files/baselines/body.baseline +124 -0
  138. data/ext/tnef/tests/files/baselines/boot.ini.baseline +6 -0
  139. data/ext/tnef/tests/files/baselines/data-before-name-body.rtf.baseline +0 -0
  140. data/ext/tnef/tests/files/baselines/data-before-name.baseline +213 -0
  141. data/ext/tnef/tests/files/baselines/garbage-at-end.baseline +73 -0
  142. data/ext/tnef/tests/files/baselines/generpts.src.baseline +1691 -0
  143. data/ext/tnef/tests/files/baselines/long-filename-body.rtf.baseline +26 -0
  144. data/ext/tnef/tests/files/baselines/long-filename.baseline +218 -0
  145. data/ext/tnef/tests/files/baselines/message.rtf.baseline +0 -0
  146. data/ext/tnef/tests/files/baselines/missing-filenames-body.rtf.baseline +20 -0
  147. data/ext/tnef/tests/files/baselines/missing-filenames.baseline +252 -0
  148. data/ext/tnef/tests/files/baselines/multi-name-property.baseline +243 -0
  149. data/ext/tnef/tests/files/baselines/one-file.baseline +155 -0
  150. data/ext/tnef/tests/files/baselines/rtf-body.rtf.baseline +0 -0
  151. data/ext/tnef/tests/files/baselines/rtf.baseline +167 -0
  152. data/ext/tnef/tests/files/baselines/triples-body.rtf.baseline +0 -0
  153. data/ext/tnef/tests/files/baselines/triples.baseline +254 -0
  154. data/ext/tnef/tests/files/baselines/two-files.baseline +186 -0
  155. data/ext/tnef/tests/files/body.test +9 -0
  156. data/ext/tnef/tests/files/data-before-name.test +9 -0
  157. data/ext/tnef/tests/files/datafiles/MAPI_ATTACH_DATA_OBJ.list +4 -0
  158. data/ext/tnef/tests/files/datafiles/MAPI_ATTACH_DATA_OBJ.tnef +0 -0
  159. data/ext/tnef/tests/files/datafiles/MAPI_OBJECT.list +2 -0
  160. data/ext/tnef/tests/files/datafiles/MAPI_OBJECT.tnef +0 -0
  161. data/ext/tnef/tests/files/datafiles/Makefile.am +27 -0
  162. data/ext/tnef/tests/files/datafiles/Makefile.in +351 -0
  163. data/ext/tnef/tests/files/datafiles/body.list +1 -0
  164. data/ext/tnef/tests/files/datafiles/body.tnef +0 -0
  165. data/ext/tnef/tests/files/datafiles/data-before-name.list +4 -0
  166. data/ext/tnef/tests/files/datafiles/data-before-name.tnef +0 -0
  167. data/ext/tnef/tests/files/datafiles/garbage-at-end.list +0 -0
  168. data/ext/tnef/tests/files/datafiles/garbage-at-end.tnef +0 -0
  169. data/ext/tnef/tests/files/datafiles/long-filename.list +1 -0
  170. data/ext/tnef/tests/files/datafiles/long-filename.tnef +0 -0
  171. data/ext/tnef/tests/files/datafiles/missing-filenames.list +1 -0
  172. data/ext/tnef/tests/files/datafiles/missing-filenames.tnef +0 -0
  173. data/ext/tnef/tests/files/datafiles/multi-name-property.list +0 -0
  174. data/ext/tnef/tests/files/datafiles/multi-name-property.tnef +0 -0
  175. data/ext/tnef/tests/files/datafiles/one-file.list +1 -0
  176. data/ext/tnef/tests/files/datafiles/one-file.tnef +0 -0
  177. data/ext/tnef/tests/files/datafiles/rtf.list +1 -0
  178. data/ext/tnef/tests/files/datafiles/rtf.tnef +0 -0
  179. data/ext/tnef/tests/files/datafiles/triples.list +1 -0
  180. data/ext/tnef/tests/files/datafiles/triples.tnef +0 -0
  181. data/ext/tnef/tests/files/datafiles/two-files.list +2 -0
  182. data/ext/tnef/tests/files/datafiles/two-files.tnef +0 -0
  183. data/ext/tnef/tests/files/file-util.sh +38 -0
  184. data/ext/tnef/tests/files/garbage-at-end.test +9 -0
  185. data/ext/tnef/tests/files/long-filename.test +9 -0
  186. data/ext/tnef/tests/files/missing-filenames.test +9 -0
  187. data/ext/tnef/tests/files/multi-name-property.test +9 -0
  188. data/ext/tnef/tests/files/one-file.test +9 -0
  189. data/ext/tnef/tests/files/rtf.test +9 -0
  190. data/ext/tnef/tests/files/triples.test +9 -0
  191. data/ext/tnef/tests/files/two-files.test +9 -0
  192. data/ext/tnef/tests/util.sh +32 -0
  193. data/ext/tnef/tnef.spec.in +44 -0
  194. data/lib/tnef.rb +30 -0
  195. data/lib/tnef/executable.rb +27 -0
  196. data/lib/tnef/version.rb +3 -0
  197. metadata +243 -0
@@ -0,0 +1,101 @@
1
+ /*
2
+ * common.h -- 'common' declarations etc.
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 COMMON_H
23
+ #define COMMON_H 1
24
+
25
+ #if HAVE_CONFIG_H
26
+ # include "config.h"
27
+ #endif
28
+
29
+ #include <assert.h>
30
+ #include <stdio.h>
31
+
32
+ #if STDC_HEADERS
33
+ # include <stdarg.h>
34
+ # include <stdlib.h>
35
+ # include <memory.h>
36
+ # if HAVE_STRING_H
37
+ # include <string.h>
38
+ # endif
39
+ # if HAVE_STRINGS_H
40
+ # include <strings.h>
41
+ # endif
42
+ #else
43
+ extern int strcmp (const char *, const char *);
44
+ extern char *strcpy (char *, const char *);
45
+ extern char *strcat (char *, const char *);
46
+ extern void abort (void);
47
+ extern void exit (int);
48
+ extern void* memset (void* ptr, int c, size_t size);
49
+ extern void* malloc (size_t size);
50
+ # if !HAVE_MEMMOVE
51
+ # define memmove (d,s,n) bcopy((s),(d),(n))
52
+ # else
53
+ extern void *memmove (void *, const void*, size_t)
54
+ # endif
55
+ #endif
56
+
57
+ #ifdef HAVE_SYS_STAT_H
58
+ # include <sys/stat.h>
59
+ #endif
60
+
61
+ extern char* xstrdup (const char* str);
62
+
63
+ /* ********** SIZES ********** */
64
+
65
+ /*
66
+ * typedefs for the types specified in the grammar:
67
+ * BYTE -- 1 byte -- char
68
+ * WORD -- 2 bytes -- short/int
69
+ * DWORD -- 4 bytes -- int/long
70
+ */
71
+ typedef signed char int8;
72
+ typedef unsigned char uint8;
73
+ #if (SIZEOF_INT == 4)
74
+ typedef short int16;
75
+ typedef unsigned short uint16;
76
+ typedef int int32;
77
+ typedef unsigned int uint32;
78
+ #else
79
+ typedef int int16;
80
+ typedef unsigned int uint16;
81
+ typedef long int32;
82
+ typedef unsigned long uint32;
83
+ #endif /* SIZEOF_INT == 4 */
84
+
85
+ /* ********** SIZES ********** */
86
+
87
+ /* ********** REPLACED FUNCS ********** */
88
+ #if !HAVE_DECL_BASENAME
89
+ extern char *basename (char *path);
90
+ #endif
91
+
92
+ #if HAVE_VPRINTF
93
+ # define VPRINTF(s,f,a) vfprintf((s),(f),(a))
94
+ #elif HAVE_DOPRNT
95
+ # define VPRINTF(s,f,a) _doprnt((f),(a),(s))
96
+ #else
97
+ # error Neither vpritnf nor _doprnt defined
98
+ #endif
99
+ /* ********** REPLACED FUNCS ********** */
100
+
101
+ #endif /* COMMON_H */
@@ -0,0 +1,111 @@
1
+ /* src/config.h.in. Generated from configure.in by autoheader. */
2
+
3
+ /* Define to 1 if you have the `basename' function. */
4
+ #undef HAVE_BASENAME
5
+
6
+ /* Define to 1 if you have the declaration of `basename', and to 0 if you
7
+ don't. */
8
+ #undef HAVE_DECL_BASENAME
9
+
10
+ /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
11
+ #undef HAVE_DOPRNT
12
+
13
+ /* Define to 1 if you have the `getopt_long' function. */
14
+ #undef HAVE_GETOPT_LONG
15
+
16
+ /* Define to 1 if you have the <inttypes.h> header file. */
17
+ #undef HAVE_INTTYPES_H
18
+
19
+ /* Define to 1 if you have the `intl' library (-lintl). */
20
+ #undef HAVE_LIBINTL
21
+
22
+ /* Define to 1 if you have the <libintl.h> header file. */
23
+ #undef HAVE_LIBINTL_H
24
+
25
+ /* Define to 1 if your system has a GNU libc compatible `malloc' function, and
26
+ to 0 otherwise. */
27
+ #undef HAVE_MALLOC
28
+
29
+ /* Define to 1 if you have the `memmove' function. */
30
+ #undef HAVE_MEMMOVE
31
+
32
+ /* Define to 1 if you have the <memory.h> header file. */
33
+ #undef HAVE_MEMORY_H
34
+
35
+ /* Define to 1 if you have the `memset' function. */
36
+ #undef HAVE_MEMSET
37
+
38
+ /* Define to 1 if you have the <stdint.h> header file. */
39
+ #undef HAVE_STDINT_H
40
+
41
+ /* Define to 1 if you have the <stdlib.h> header file. */
42
+ #undef HAVE_STDLIB_H
43
+
44
+ /* Define to 1 if you have the `strdup' function. */
45
+ #undef HAVE_STRDUP
46
+
47
+ /* Define to 1 if you have the <strings.h> header file. */
48
+ #undef HAVE_STRINGS_H
49
+
50
+ /* Define to 1 if you have the <string.h> header file. */
51
+ #undef HAVE_STRING_H
52
+
53
+ /* Define to 1 if you have the `strrchr' function. */
54
+ #undef HAVE_STRRCHR
55
+
56
+ /* Define to 1 if you have the `strtoul' function. */
57
+ #undef HAVE_STRTOUL
58
+
59
+ /* Define to 1 if you have the <sys/stat.h> header file. */
60
+ #undef HAVE_SYS_STAT_H
61
+
62
+ /* Define to 1 if you have the <sys/types.h> header file. */
63
+ #undef HAVE_SYS_TYPES_H
64
+
65
+ /* Define to 1 if you have the <unistd.h> header file. */
66
+ #undef HAVE_UNISTD_H
67
+
68
+ /* Define to 1 if you have the `vprintf' function. */
69
+ #undef HAVE_VPRINTF
70
+
71
+ /* Name of package */
72
+ #undef PACKAGE
73
+
74
+ /* Define to the address where bug reports for this package should be sent. */
75
+ #undef PACKAGE_BUGREPORT
76
+
77
+ /* Define to the full name of this package. */
78
+ #undef PACKAGE_NAME
79
+
80
+ /* Define to the full name and version of this package. */
81
+ #undef PACKAGE_STRING
82
+
83
+ /* Define to the one symbol short name of this package. */
84
+ #undef PACKAGE_TARNAME
85
+
86
+ /* Define to the home page for this package. */
87
+ #undef PACKAGE_URL
88
+
89
+ /* Define to the version of this package. */
90
+ #undef PACKAGE_VERSION
91
+
92
+ /* The size of `int', as computed by sizeof. */
93
+ #undef SIZEOF_INT
94
+
95
+ /* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
96
+ #undef STAT_MACROS_BROKEN
97
+
98
+ /* Define to 1 if you have the ANSI C header files. */
99
+ #undef STDC_HEADERS
100
+
101
+ /* Version number of package */
102
+ #undef VERSION
103
+
104
+ /* Define to empty if `const' does not conform to ANSI C. */
105
+ #undef const
106
+
107
+ /* Define to rpl_malloc if the replacement function should be used. */
108
+ #undef malloc
109
+
110
+ /* Define to `unsigned int' if <sys/types.h> does not define. */
111
+ #undef size_t
@@ -0,0 +1,66 @@
1
+ /*
2
+ * date.c -- functions for dealing with dates.
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 "date.h"
29
+ #include "util.h"
30
+
31
+ /* Array of days of the week for translating a date */
32
+ const char* day_of_week[] = { "Sun", "Mon", "Tue",
33
+ "Wed", "Thu", "Fri", "Sat" };
34
+
35
+ extern const char *
36
+ dow_str(int dow)
37
+ {
38
+ assert (dow >= 0 && dow <= 6);
39
+ return day_of_week[dow];
40
+ }
41
+
42
+ const char *
43
+ date_to_str (struct date *dt)
44
+ {
45
+ static char buf[32];
46
+ sprintf (buf, "%s %04d/%02d/%02d %02d:%02d:%02d",
47
+ dow_str(dt->dow),
48
+ dt->year, dt->month, dt->day,
49
+ dt->hour, dt->min, dt->sec);
50
+ return buf;
51
+ }
52
+
53
+ void
54
+ date_read (struct date *dt, const unsigned char *buf)
55
+ {
56
+ size_t i = 0;
57
+ unsigned char *tmp = (unsigned char *)buf;
58
+ dt->year = GETINT16 (tmp + i); i += sizeof (uint16);
59
+ dt->month = GETINT16 (tmp + i); i += sizeof (uint16);
60
+ dt->day = GETINT16 (tmp + i); i += sizeof (uint16);
61
+ dt->hour = GETINT16 (tmp + i); i += sizeof (uint16);
62
+ dt->min = GETINT16 (tmp + i); i += sizeof (uint16);
63
+ dt->sec = GETINT16 (tmp + i); i += sizeof (uint16);
64
+ dt->dow = GETINT16 (tmp + i); i += sizeof (uint16);
65
+ }
66
+
@@ -0,0 +1,43 @@
1
+ /*
2
+ * date.h -- functions for dealing with dates.
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 DATE_H
23
+ #define DATE_H
24
+
25
+ #if HAVE_CONFIG_H
26
+ # include "config.h"
27
+ #endif /* HAVE_CONFIG_H */
28
+
29
+ #include "common.h"
30
+
31
+ /* Store a date according to file specification */
32
+ struct date
33
+ {
34
+ int16 year, month, day;
35
+ int16 hour, min, sec;
36
+ int16 dow;
37
+ };
38
+
39
+ extern const char *date_to_str (struct date* dt);
40
+ extern void date_read (struct date *dt, const unsigned char *buf);
41
+
42
+ #endif /* DATE_H */
43
+
@@ -0,0 +1,45 @@
1
+ /*
2
+ * debug.c -- functions for debug output
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 "debug.h"
29
+ #include "options.h"
30
+
31
+ /* print message only when debug on */
32
+ void
33
+ debug_print (const char *fmt, ...)
34
+ {
35
+ if (DEBUG_ON)
36
+ {
37
+ va_list args;
38
+ va_start (args, fmt);
39
+ VPRINTF(stdout, fmt, args);
40
+ va_end (args);
41
+
42
+ fflush( NULL ); /* make sure it gets output */
43
+ }
44
+ }
45
+
@@ -0,0 +1,32 @@
1
+ /*
2
+ * debug.h -- functions for debug output
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 DEBUG_H
23
+ #define DEBUG_H
24
+
25
+ #if HAVE_CONFIG_H
26
+ # include "config.h"
27
+ #endif /* HAVE_CONFIG_H */
28
+
29
+ extern void debug_print (const char *fmt, ...);
30
+
31
+ #endif /* DEBUG_H */
32
+
@@ -0,0 +1,259 @@
1
+ /*
2
+ * file.c -- functions for dealing with file output
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 "alloc.h"
29
+ #include "date.h"
30
+ #include "debug.h"
31
+ #include "file.h"
32
+ #include "mapi_attr.h"
33
+ #include "options.h"
34
+ #include "path.h"
35
+
36
+ #define TNEF_DEFAULT_FILENAME "tnef-tmp"
37
+
38
+ /* ask user for confirmation of the action */
39
+ static int
40
+ confirm_action (const char *prompt, ...)
41
+ {
42
+ if (INTERACTIVE)
43
+ {
44
+ int confirmed = 0;
45
+ char buf[BUFSIZ + 1];
46
+ va_list args;
47
+ va_start (args, prompt);
48
+
49
+ VPRINTF(stdout, prompt, args);
50
+ fgets (buf, BUFSIZ, stdin);
51
+ if (buf[0] == 'y' || buf[0] == 'Y') confirmed = 1;
52
+
53
+ va_end (args);
54
+
55
+ return confirmed;
56
+ }
57
+ return 1;
58
+ }
59
+
60
+ void
61
+ file_write (File *file, const char* directory)
62
+ {
63
+ char *path = NULL;
64
+
65
+ assert (file);
66
+ if (!file) return;
67
+
68
+ if (file->name == NULL)
69
+ {
70
+ file->name = strdup( TNEF_DEFAULT_FILENAME );
71
+ debug_print ("No file name specified, using default %s.\n", TNEF_DEFAULT_FILENAME);
72
+ }
73
+
74
+ if ( file->path == NULL )
75
+ {
76
+ file->path = munge_fname( file->name );
77
+
78
+ if (file->path == NULL)
79
+ {
80
+ file->path = strdup( TNEF_DEFAULT_FILENAME );
81
+ debug_print ("No path name available, using default %s.\n", TNEF_DEFAULT_FILENAME);
82
+ }
83
+ }
84
+
85
+ path = concat_fname( directory, file->path );
86
+
87
+ if (path == NULL)
88
+ {
89
+ path = strdup( TNEF_DEFAULT_FILENAME );
90
+ debug_print ("No path generated, using default %s.\n", TNEF_DEFAULT_FILENAME);
91
+ }
92
+
93
+ debug_print ("%sWRITING\t|\t%s\t|\t%s\n",
94
+ ((LIST_ONLY==0)?"":"NOT "), file->name, path);
95
+
96
+ if (!LIST_ONLY)
97
+ {
98
+ FILE *fp = NULL;
99
+
100
+ if (!confirm_action ("extract %s?", file->name)) return;
101
+ if (!OVERWRITE_FILES)
102
+ {
103
+ if (file_exists (path))
104
+ {
105
+ if (!NUMBER_FILES)
106
+ {
107
+ fprintf (stderr,
108
+ "tnef: %s: Could not create file: File exists\n",
109
+ path);
110
+ return;
111
+ }
112
+ else
113
+ {
114
+ char *tmp = find_free_number (path);
115
+ debug_print ("Renaming %s to %s\n", path, tmp);
116
+ XFREE (path);
117
+ path = tmp;
118
+ }
119
+ }
120
+ }
121
+
122
+ fp = fopen (path, "wb");
123
+ if (fp == NULL)
124
+ {
125
+ perror (path);
126
+ exit (1);
127
+ }
128
+ if (fwrite (file->data, 1, file->len, fp) != file->len)
129
+ {
130
+ perror (path);
131
+ exit (1);
132
+ }
133
+ fclose (fp);
134
+ }
135
+
136
+ if (LIST_ONLY || VERBOSE_ON)
137
+ {
138
+ if (LIST_ONLY && VERBOSE_ON)
139
+ {
140
+ /* FIXME: print out date and stuff */
141
+ const char *date_str = date_to_str(&file->dt);
142
+ fprintf (stdout, "%11lu\t|\t%s\t|\t%s\t|\t%s",
143
+ (unsigned long)file->len,
144
+ date_str+4, /* skip the day of week */
145
+ file->name,
146
+ path);
147
+ }
148
+ else
149
+ {
150
+ fprintf (stdout, "%s\t|\t%s", file->name, path);
151
+ }
152
+ if ( SHOW_MIME )
153
+ {
154
+ fprintf (stdout, "\t|\t%s", file->mime_type ? file->mime_type : "unknown");
155
+ fprintf (stdout, "\t|\t%s", file->content_id ? file->content_id : "");
156
+ }
157
+ fprintf (stdout, "\n");
158
+ }
159
+ XFREE(path);
160
+ }
161
+
162
+ static void
163
+ file_add_mapi_attrs (File* file, MAPI_Attr** attrs)
164
+ {
165
+ int i;
166
+ for (i = 0; attrs[i]; i++)
167
+ {
168
+ MAPI_Attr* a = attrs[i];
169
+
170
+ if (a->num_values)
171
+ {
172
+
173
+ switch (a->name)
174
+ {
175
+ case MAPI_ATTACH_LONG_FILENAME:
176
+ if (file->name) XFREE(file->name);
177
+ file->name = strdup( (char*)a->values[0].data.buf );
178
+ break;
179
+
180
+ case MAPI_ATTACH_DATA_OBJ:
181
+ file->len = a->values[0].len;
182
+ if (file->data) XFREE (file->data);
183
+ file->data = CHECKED_XMALLOC (unsigned char, file->len);
184
+ memmove (file->data, a->values[0].data.buf, file->len);
185
+ break;
186
+
187
+ case MAPI_ATTACH_MIME_TAG:
188
+ if (file->mime_type) XFREE (file->mime_type);
189
+ file->mime_type = CHECKED_XMALLOC (char, a->values[0].len);
190
+ memmove (file->mime_type, a->values[0].data.buf, a->values[0].len);
191
+ break;
192
+
193
+ case MAPI_ATTACH_CONTENT_ID:
194
+ if (file->content_id) XFREE(file->content_id);
195
+ file->content_id = CHECKED_XMALLOC (char, a->values[0].len);
196
+ memmove (file->content_id, a->values[0].data.buf, a->values[0].len);
197
+ break;
198
+
199
+ default:
200
+ break;
201
+ }
202
+ }
203
+ }
204
+ }
205
+
206
+ void
207
+ file_add_attr (File* file, Attr* attr)
208
+ {
209
+ assert (file && attr);
210
+ if (!(file && attr)) return;
211
+
212
+ /* we only care about some things... we will skip most attributes */
213
+ switch (attr->name)
214
+ {
215
+ case attATTACHMODIFYDATE:
216
+ copy_date_from_attr (attr, &file->dt);
217
+ break;
218
+
219
+ case attATTACHMENT:
220
+ {
221
+ MAPI_Attr **mapi_attrs = mapi_attr_read (attr->len, attr->buf);
222
+ if (mapi_attrs)
223
+ {
224
+ file_add_mapi_attrs (file, mapi_attrs);
225
+ mapi_attr_free_list (mapi_attrs);
226
+ XFREE (mapi_attrs);
227
+ }
228
+ }
229
+ break;
230
+
231
+ case attATTACHTITLE:
232
+ file->name = strdup( (char*)attr->buf );
233
+ break;
234
+
235
+ case attATTACHDATA:
236
+ file->len = attr->len;
237
+ file->data = CHECKED_XMALLOC(unsigned char, attr->len);
238
+ memmove (file->data, attr->buf, attr->len);
239
+ break;
240
+
241
+ default:
242
+ break;
243
+ }
244
+ }
245
+
246
+ void
247
+ file_free (File *file)
248
+ {
249
+ if (file)
250
+ {
251
+ XFREE (file->name);
252
+ XFREE (file->data);
253
+ XFREE (file->mime_type);
254
+ XFREE (file->content_id);
255
+ XFREE (file->path);
256
+ memset (file, '\0', sizeof (File));
257
+ }
258
+ }
259
+