tmail 1.1.1 → 1.2.0

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.
Files changed (62) hide show
  1. data/CHANGES +5 -0
  2. data/NOTES +84 -0
  3. data/README +6 -1
  4. data/ext/Makefile +20 -0
  5. data/ext/{tmail/base64 → mailscanner/tmail}/MANIFEST +1 -1
  6. data/ext/mailscanner/tmail/depend +1 -0
  7. data/ext/mailscanner/tmail/extconf.rb +24 -0
  8. data/ext/{tmail/scanner_c/scanner_c.c → mailscanner/tmail/mailscanner.c} +8 -7
  9. data/lib/tmail/base64.rb +29 -52
  10. data/lib/tmail/encode.rb +37 -38
  11. data/lib/tmail/interface.rb +632 -49
  12. data/lib/tmail/main.rb +4 -0
  13. data/lib/tmail/net.rb +0 -35
  14. data/lib/tmail/quoting.rb +8 -8
  15. data/lib/tmail/scanner.rb +10 -6
  16. data/lib/tmail/scanner_r.rb +3 -5
  17. data/lib/tmail/version.rb +2 -2
  18. data/log/ChangeLog.txt +1131 -0
  19. data/log/History.txt +40 -0
  20. data/log/Todo.txt +32 -0
  21. data/meta/MANIFEST +118 -0
  22. data/meta/ROLLRC +3 -0
  23. data/meta/icli.yaml +2 -2
  24. data/meta/{tmail-1.1.1.roll → project.yaml} +3 -7
  25. data/sample/bench_base64.rb +48 -0
  26. data/{bat → script}/changelog +0 -0
  27. data/script/clobber/distclean +8 -0
  28. data/{bat → script}/clobber/package +0 -0
  29. data/script/compile +32 -0
  30. data/{bat → script}/config.yaml +2 -2
  31. data/{bat → script}/prepare +4 -2
  32. data/{bat → script}/publish +0 -0
  33. data/{bat → script}/release +0 -0
  34. data/{bat → script}/setup +0 -0
  35. data/{bat → script}/stats +0 -0
  36. data/{bat → script}/tag +0 -0
  37. data/script/test +36 -0
  38. data/test/fixtures/raw_email_reply +32 -0
  39. data/test/fixtures/raw_email_with_bad_date +48 -0
  40. data/test/test_address.rb +1 -3
  41. data/test/test_attachments.rb +1 -2
  42. data/test/test_base64.rb +3 -2
  43. data/test/test_encode.rb +1 -0
  44. data/test/test_header.rb +2 -3
  45. data/test/test_helper.rb +8 -2
  46. data/test/test_mail.rb +45 -16
  47. data/test/test_mbox.rb +1 -1
  48. data/test/test_port.rb +1 -1
  49. data/test/test_scanner.rb +1 -1
  50. data/test/test_utils.rb +1 -2
  51. metadata +82 -76
  52. data/bat/compile +0 -42
  53. data/bat/rdoc +0 -42
  54. data/bat/test +0 -25
  55. data/ext/tmail/Makefile +0 -25
  56. data/ext/tmail/base64/base64.c +0 -264
  57. data/ext/tmail/base64/depend +0 -1
  58. data/ext/tmail/base64/extconf.rb +0 -38
  59. data/ext/tmail/scanner_c/MANIFEST +0 -4
  60. data/ext/tmail/scanner_c/depend +0 -1
  61. data/ext/tmail/scanner_c/extconf.rb +0 -38
  62. data/lib/tmail/tmail.rb +0 -1
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # compile extensions
4
-
5
- main :compile => [:compile_base64, :compile_scanner_c] do
6
- end
7
-
8
- task :compile_base64 do
9
- file = nil
10
- cd('ext/tmail/base64') do
11
- ruby "extconf.rb"
12
- make
13
- file = glob("base64.#{dlext}").first
14
- file = File.expand_path(file) if file
15
- end
16
- if file
17
- mkdir_p("lib/tmail/#{arch}")
18
- mv(file, "lib/tmail/#{arch}/")
19
- end
20
- end
21
-
22
- task :compile_scanner_c do
23
- file = nil
24
- cd("ext/tmail/scanner_c") do
25
- ruby "extconf.rb"
26
- make
27
- file = glob("scanner_c.#{dlext}").first
28
- file = File.expand_path(file) if file
29
- end
30
- if file
31
- mkdir_p("lib/tmail/#{arch}")
32
- mv(file, "lib/tmail/#{arch}/")
33
- end
34
- end
35
-
36
- def dlext
37
- Config::CONFIG['DLEXT']
38
- end
39
-
40
- def arch
41
- Config::CONFIG['arch']
42
- end
data/bat/rdoc DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # generate rdocs
4
- #
5
- # Generate Rdoc documentation. Settings are
6
- # the same as the rdoc command's options.
7
-
8
- main :rdoc do
9
- # Load rdoc configuration.
10
-
11
- config = configuration['rdoc']
12
-
13
- config['op'] = config.delete('output') if config['output']
14
-
15
- config = {
16
- 'template' => 'html',
17
- 'op' => 'doc/rdoc',
18
- 'merge' => true,
19
- 'inline-source' => true,
20
- 'exclude' => %w{MANIFEST, Manifest.txt},
21
- 'include' => %w{[A-Z]* lib ext}
22
- }.update(config)
23
-
24
- output = config['op']
25
-
26
- # Check for parent directory.
27
- # (Helps to ensure we're in the right place.)
28
-
29
- dir!(File.dirname(output))
30
-
31
- # Prepare command arguments.
32
-
33
- vector = config.command_vector('include')
34
-
35
- # Remove old rdocs, if any.
36
-
37
- rm_r(output) if File.exist?(output)
38
-
39
- # Document.
40
-
41
- rdoc(*vector)
42
- end
data/bat/test DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # Run unit tests
4
-
5
- live = ARGV.delete('--live')
6
-
7
- unless live
8
- $LOAD_PATH.unshift(File.expand_path('lib'))
9
- end
10
-
11
- main :test do
12
- if find = argv[0]
13
- unless file?(find)
14
- find = File.join(find, '**', 'test_*.rb')
15
- end
16
- else
17
- find = 'test/**/test_*.rb'
18
- end
19
-
20
- Dir.glob(find).each do |file|
21
- next if dir?(file)
22
- load file
23
- end
24
- end
25
-
@@ -1,25 +0,0 @@
1
- #
2
- # ext/tmail/Makefile
3
- #
4
-
5
- .PHONY: scanner_c base64 clean distclean
6
-
7
- all: scanner_c base64
8
-
9
- scanner_c: scanner_c/Makefile
10
- cd scanner_c; $(MAKE)
11
- scanner_c/Makefile: scanner_c/extconf.rb
12
- cd scanner_c; ruby extconf.rb
13
-
14
- base64: base64/Makefile
15
- cd base64; $(MAKE)
16
- base64/Makefile: base64/extconf.rb
17
- cd base64; ruby extconf.rb
18
-
19
- clean:
20
- cd base64; $(MAKE) clean
21
- cd scanner_c; $(MAKE) clean
22
-
23
- distclean:
24
- cd base64; $(MAKE) distclean
25
- cd scanner_c; $(MAKE) distclean
@@ -1,264 +0,0 @@
1
- /*
2
-
3
- base64.c
4
-
5
- Copyright (c) 2001-2007 Minero Aoki
6
-
7
- This program is free software.
8
- You can distribute/modify this program under the terms of
9
- the GNU Lesser General Public License version 2.1.
10
-
11
- */
12
-
13
- #include "ruby.h"
14
- #include "version.h"
15
- #include <stdio.h>
16
-
17
- #ifdef DEBUG
18
- # define D(code) code
19
- #else
20
- # define D(code)
21
- #endif
22
-
23
- static char *CONVTAB =
24
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
25
- static int REVTAB[256];
26
- #define INIT (-1)
27
- #define SKIP (-2)
28
- #define ILLEGAL (-3)
29
-
30
- #if RUBY_VERSION_CODE < 170 /* Ruby 1.6 */
31
- # define StringValue(s) tmail_rb_string_value(&(s))
32
- static void
33
- tmail_rb_string_value(s)
34
- VALUE *s;
35
- {
36
- if (TYPE(*s) != T_STRING) {
37
- *s = rb_str_to_str(*s);
38
- }
39
- }
40
- #endif
41
-
42
- static void
43
- get_ptrlen(s, ptr, len)
44
- VALUE *s;
45
- char **ptr;
46
- long *len;
47
- {
48
- StringValue(*s);
49
- *ptr = RSTRING(*s)->ptr;
50
- if (!*ptr) *ptr = "";
51
- *len = RSTRING(*s)->len;
52
- }
53
-
54
- static long
55
- calculate_buflen(len, eollen, limit)
56
- long len, eollen;
57
- {
58
- long result;
59
-
60
- result = (len/3 + 1) * 4;
61
- if (eollen) {
62
- result += (result/limit + 1) * eollen;
63
- }
64
- return result;
65
- }
66
-
67
- static VALUE
68
- do_base64(str, eolv, limit)
69
- VALUE str, eolv;
70
- long limit;
71
- {
72
- char *buf, *b;
73
- char *p, *pend;
74
- long len;
75
- char *eol;
76
- long eollen;
77
- VALUE s;
78
- char *linehead;
79
-
80
- get_ptrlen(&str, &p, &len);
81
- pend = p + len;
82
- if (NIL_P(eolv)) {
83
- eol = "";
84
- eollen = 0;
85
- }
86
- else {
87
- get_ptrlen(&eolv, &eol, &eollen);
88
- }
89
- b = buf = ALLOC_N(char, calculate_buflen(len, eollen, limit));
90
- linehead = b;
91
-
92
- while (pend - p >= 3) {
93
- if (eollen) {
94
- if (b - linehead + 4 > limit) {
95
- memcpy(b, eol, eollen); b += eollen;
96
- linehead = b;
97
- }
98
- }
99
- *b++ = CONVTAB[0x3f & (p[0] >> 2)];
100
- *b++ = CONVTAB[0x3f & (((p[0] << 4) & 0x30) | ((p[1] >> 4) & 0xf))];
101
- *b++ = CONVTAB[0x3f & (((p[1] << 2) & 0x3c) | ((p[2] >> 6) & 0x3))];
102
- *b++ = CONVTAB[0x3f & p[2]];
103
- p += 3;
104
- }
105
- if ((b - linehead) + (pend - p) > limit) {
106
- if (eollen) {
107
- memcpy(b, eol, eollen); b += eollen;
108
- }
109
- }
110
- if (pend - p == 2) {
111
- *b++ = CONVTAB[0x3f & (p[0] >> 2)];
112
- *b++ = CONVTAB[0x3f & (((p[0] << 4) & 0x30) | ((p[1] >> 4) &0xf))];
113
- *b++ = CONVTAB[0x3f & (((p[1] << 2) & 0x3c) | 0)];
114
- *b++ = '=';
115
- }
116
- else if (pend - p == 1) {
117
- *b++ = CONVTAB[0x3f & (p[0] >> 2)];
118
- *b++ = CONVTAB[0x3f & (((p[0] << 4) & 0x30) | 0)];
119
- *b++ = '=';
120
- *b++ = '=';
121
- }
122
- if (eollen) {
123
- memcpy(b, eol, eollen); b += eollen;
124
- }
125
-
126
- s = rb_str_new("", 0);
127
- rb_str_cat(s, buf, b - buf);
128
- free(buf);
129
-
130
- return s;
131
- }
132
-
133
- #define DEFAULT_LINE_LIMIT 72
134
-
135
- /* def folding_encode( str, eol, limit ) */
136
- static VALUE
137
- b64_fold_encode(argc, argv, self)
138
- int argc;
139
- VALUE *argv;
140
- VALUE self;
141
- {
142
- VALUE str, eol, limit_v;
143
- long limit = DEFAULT_LINE_LIMIT;
144
-
145
- switch (rb_scan_args(argc, argv, "12", &str, &eol, &limit_v)) {
146
- case 1:
147
- eol = rb_str_new("\n", 1);
148
- break;
149
- case 2:
150
- break;
151
- case 3:
152
- limit = NUM2LONG(limit_v);
153
- if (limit < 4) {
154
- rb_raise(rb_eArgError, "too small line length limit");
155
- }
156
- break;
157
- default:
158
- break;
159
- }
160
- return do_base64(str, eol, limit);
161
- }
162
-
163
- static VALUE
164
- b64_encode(self, str)
165
- VALUE self, str;
166
- {
167
- return do_base64(str, Qnil, 0);
168
- }
169
-
170
- static VALUE
171
- b64_decode(argc, argv, self)
172
- int argc;
173
- VALUE *argv;
174
- VALUE self;
175
- {
176
- VALUE str, strict;
177
- char *buf, *bp;
178
- char *p, *pend;
179
- long len;
180
- int a, b, c, d;
181
- VALUE s;
182
-
183
- if (rb_scan_args(argc, argv, "11", &str, &strict) == 1) {
184
- strict = Qfalse;
185
- }
186
-
187
- get_ptrlen(&str, &p, &len);
188
- pend = p + len;
189
- bp = buf = ALLOC_N(char, (len/4 + 1) * 3);
190
-
191
- #define FETCH(ch) \
192
- while (1) { \
193
- if (p >= pend) goto brk; \
194
- ch = REVTAB[(int)(*p++)]; \
195
- if (ch == ILLEGAL) { \
196
- rb_raise(rb_eArgError, "corrupted base64 string"); \
197
- } \
198
- else if (ch == SKIP) { \
199
- ; \
200
- } \
201
- else { \
202
- break; \
203
- } \
204
- ch = INIT; \
205
- }
206
- a = b = c = d = INIT;
207
- while (p < pend) {
208
- FETCH(a); D(printf("fetch a: %d\n", (int)a));
209
- FETCH(b); D(printf("fetch b: %d\n", (int)b));
210
- FETCH(c); D(printf("fetch c: %d\n", (int)c));
211
- FETCH(d); D(printf("fetch d: %d\n", (int)d));
212
-
213
- *bp++ = (a << 2) | (b >> 4);
214
- *bp++ = (b << 4) | (c >> 2);
215
- *bp++ = (c << 6) | d;
216
- a = b = c = d = INIT;
217
- }
218
- brk:
219
- if (a != INIT && b != INIT && c != INIT) {
220
- D(puts("3bytes"));
221
- *bp++ = (a << 2) | (b >> 4);
222
- *bp++ = (b << 4) | (c >> 2);
223
- }
224
- else if (a != INIT && b != INIT) {
225
- D(puts("2bytes"));
226
- *bp++ = (a << 2) | (b >> 4);
227
- }
228
- /* ignore if only 'a' */
229
-
230
- D(printf("decoded len=%d\n", (int)(bp - buf)));
231
- s = rb_str_new("", 0);
232
- rb_str_cat(s, buf, bp - buf);
233
- free(buf);
234
-
235
- return s;
236
- }
237
-
238
- static void
239
- initialize_reverse_table()
240
- {
241
- int i;
242
-
243
- for (i = 0; i < 256; i++) {
244
- REVTAB[i] = ILLEGAL;
245
- }
246
- REVTAB[(int)'='] = SKIP;
247
- REVTAB[(int)'\r'] = SKIP;
248
- REVTAB[(int)'\n'] = SKIP;
249
- for (i = 0; i < 64; i++) {
250
- REVTAB[(int)CONVTAB[i]] = (char)i;
251
- }
252
- }
253
-
254
- void
255
- Init_base64()
256
- {
257
- VALUE Base64;
258
-
259
- Base64 = rb_eval_string("module TMail; module Base64; end end; ::TMail::Base64");
260
- rb_define_module_function(Base64, "c_folding_encode", b64_fold_encode, -1);
261
- rb_define_module_function(Base64, "c_encode", b64_encode, 1);
262
- rb_define_module_function(Base64, "c_decode", b64_decode, -1);
263
- initialize_reverse_table();
264
- }
@@ -1 +0,0 @@
1
- tmbase64.o: tmbase64.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h Makefile
@@ -1,38 +0,0 @@
1
- require 'mkmf'
2
- require 'rbconfig'
3
-
4
- extension_name = 'base64'
5
-
6
- arch = Config::CONFIG['arch']
7
-
8
- windows = (/mswin/ =~ arch) #RUBY_PLATFORM)
9
-
10
- if (ENV['NORUBYEXT'] == 'true') || windows # TEMPORARILY ADD WINDOWS HERE
11
- #ENV['make'] = 'echo' # THIS DOESN"T GET TO THE PARENT PROCESS!!!
12
- # LETS TRY FAKING IT OUT.
13
- if windows
14
- File.open('make.bat', 'w') do |f|
15
- f << 'echo Native extension will be omitted.'
16
- end
17
- File.open('nmake.bat', 'w') do |f|
18
- f << 'echo Native extension will be omitted.'
19
- end
20
- #File.chmod(0755, "make.bat", "nmake.bat") # need?
21
- end
22
- File.open('Makefile', 'w') do |f|
23
- f << "all:\n"
24
- f << "install:\n"
25
- end
26
- else
27
- if windows && ENV['make'].nil?
28
- $LIBS += " msvcprt.lib"
29
- #dir_config(extension_name)
30
- #create_makefile(extension_name, "tmail")
31
- create_makefile(extension_name, "tmail/#{arch}")
32
- else
33
- $CFLAGS += " -D_FILE_OFFSET_BITS=64" #???
34
- #dir_config(extension_name)
35
- #create_makefile(extension_name, "tmail")
36
- create_makefile(extension_name, "tmail/#{arch}")
37
- end
38
- end
@@ -1,4 +0,0 @@
1
- MANIFEST
2
- mails.c
3
- extconf.rb
4
- depend