ruby-ripmime 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/ruby-ripmime.c +10 -31
- data/ext/ruby-ripmime.h +4 -1
- metadata +3 -3
data/ext/ruby-ripmime.c
CHANGED
@@ -21,36 +21,31 @@ static VALUE ruby_ripmime_decode(VALUE self, VALUE mailpack, VALUE outputdir) {
|
|
21
21
|
rb_raise(rb_eArgError, "outputdir is empty");
|
22
22
|
}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
if (fp_err == NULL) {
|
27
|
-
rb_raise(rb_eRuntimeError, strerror(errno));
|
24
|
+
if (rb_funcall(rb_cFile, rb_intern("exist?"), 1, mailpack) != Qtrue) {
|
25
|
+
rb_raise(rb_eArgError, "no such file: %s", RSTRING_PTR(mailpack));
|
28
26
|
}
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
if (fd_stdout == -1) {
|
33
|
-
rb_raise(rb_eRuntimeError, strerror(errno));
|
28
|
+
if (rb_funcall(rb_cFile, rb_intern("exist?"), 1, outputdir) != Qtrue) {
|
29
|
+
rb_funcall(rb_cDir, rb_intern("mkdir"), 1, outputdir);
|
34
30
|
}
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
if (dup2(fileno(fp_err), fileno(stdout)) == -1) {
|
39
|
-
rb_raise(rb_eRuntimeError, strerror(errno));
|
40
|
-
}
|
32
|
+
fp_err = tmpfile();
|
41
33
|
|
42
|
-
if (
|
34
|
+
if (fp_err == NULL) {
|
43
35
|
rb_raise(rb_eRuntimeError, strerror(errno));
|
44
36
|
}
|
45
37
|
|
46
38
|
RIPMIME_init(&rm);
|
39
|
+
|
47
40
|
MIME_set_name_by_type(1);
|
41
|
+
LOGGER_set_output_mode(_LOGGER_FILE);
|
42
|
+
LOGGER_set_output_file(fp_err);
|
48
43
|
|
49
44
|
// XXX: for strdup memory leak (ripMIME 1.4.0.10)
|
50
45
|
rm.outputdir = NULL;
|
51
46
|
rm.mailpack = NULL;
|
52
47
|
|
53
|
-
ret = RIPMIME_decode(&rm,
|
48
|
+
ret = RIPMIME_decode(&rm, RSTRING_PTR(mailpack), RSTRING_PTR(outputdir));
|
54
49
|
|
55
50
|
// XXX: for strdup memory leak (ripMIME 1.4.0.10)
|
56
51
|
if (rm.outputdir) {
|
@@ -62,22 +57,6 @@ static VALUE ruby_ripmime_decode(VALUE self, VALUE mailpack, VALUE outputdir) {
|
|
62
57
|
free(rm.mailpack);
|
63
58
|
}
|
64
59
|
|
65
|
-
if (dup2(fd_stdout, fileno(stdout)) == -1) {
|
66
|
-
rb_raise(rb_eRuntimeError, strerror(errno));
|
67
|
-
}
|
68
|
-
|
69
|
-
if (dup2(fd_stdout, fileno(stderr)) == -1) {
|
70
|
-
rb_raise(rb_eRuntimeError, strerror(errno));
|
71
|
-
}
|
72
|
-
|
73
|
-
if (close(fd_stdout) == -1) {
|
74
|
-
rb_warn(strerror(errno));
|
75
|
-
}
|
76
|
-
|
77
|
-
if (close(fd_stderr) == -1) {
|
78
|
-
rb_warn(strerror(errno));
|
79
|
-
}
|
80
|
-
|
81
60
|
rewind(fp_err);
|
82
61
|
|
83
62
|
errmsg = rb_str_new(0, 0);
|
data/ext/ruby-ripmime.h
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
#include <stdio.h>
|
5
5
|
#include <stdlib.h>
|
6
|
-
#include <unistd.h>
|
7
6
|
#include <errno.h>
|
8
7
|
#include <ripmime-api.h>
|
9
8
|
#include <ruby.h>
|
@@ -17,4 +16,8 @@
|
|
17
16
|
|
18
17
|
int MIME_set_name_by_type(int level);
|
19
18
|
|
19
|
+
#define _LOGGER_FILE 3
|
20
|
+
int LOGGER_set_output_mode(int modechoice);
|
21
|
+
int LOGGER_set_output_file(FILE *f);
|
22
|
+
|
20
23
|
#endif //__RUBY_RIPMIME_H__
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-ripmime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- winebarrel
|