postfix_status_line 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/postfix_status_line_core.c +22 -5
- data/lib/postfix_status_line/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb7606470d80a2813ba8d50eaae1daf882731b0
|
4
|
+
data.tar.gz: caa4474fdd96b24c0f1bc16e9572a84424023934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6360bdf590686caea775f8ff732e65d2d2ea35e7a808bbdf2a2db3d39eaa6cac032f040c9074b3c5ad3275e60849e43cdc27622bb9ea58757b5b59176d90ca36
|
7
|
+
data.tar.gz: f5025a3ff875b364ccd48d8deee65fe0bdc59f620ef1265cea3522f405ff5eef45a53051eb10dde869aa25188723ddbe0333834ffd2e2682f7f3fe36cf460317
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ PostfixStatusLine.parse(status_line)
|
|
38
38
|
# "relay" => "gateway-f1.isp.att.net[204.127.217.16]:25",
|
39
39
|
# "status" => "sent",
|
40
40
|
# "status_detail" => "(250 ok ; id=20120227140036M0700qer4ne)",
|
41
|
-
# "time" =>
|
41
|
+
# "time" => 1424995357,
|
42
42
|
# "to" => "<*******@bellsouth.net>",
|
43
43
|
# "domain" => "bellsouth.net"
|
44
44
|
# }
|
@@ -68,14 +68,14 @@ static int split_p1(char *str, char **time, char **hostname, char **process) {
|
|
68
68
|
return 0;
|
69
69
|
}
|
70
70
|
|
71
|
-
static int split_line1(char buf[], char **
|
71
|
+
static int split_line1(char buf[], char **tm, char **hostname, char **process, char **queue_id, char **attrs) {
|
72
72
|
char *p1, *p2, *p3;
|
73
73
|
|
74
74
|
if (split3(buf, &p1, &p2, &p3) != 0) {
|
75
75
|
return -1;
|
76
76
|
}
|
77
77
|
|
78
|
-
if (split_p1(p1,
|
78
|
+
if (split_p1(p1, tm, hostname, process) != 0) {
|
79
79
|
return -1;
|
80
80
|
}
|
81
81
|
|
@@ -187,6 +187,23 @@ static void split_line2(char *str, int mask, VALUE hash) {
|
|
187
187
|
}
|
188
188
|
}
|
189
189
|
|
190
|
+
static void put_time(char *str, VALUE hash) {
|
191
|
+
time_t now = time(NULL);
|
192
|
+
struct tm *t = localtime(&now);
|
193
|
+
|
194
|
+
if (strptime(str, "%b %d %H:%M:%S", t) == NULL) {
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
|
198
|
+
time_t epoch = mktime(t);
|
199
|
+
|
200
|
+
if (epoch == -1) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
|
204
|
+
rb_hash_aset(hash, rb_str_new2("time"), LONG2NUM(epoch));
|
205
|
+
}
|
206
|
+
|
190
207
|
static VALUE rb_postfix_status_line_parse(VALUE self, VALUE v_str, VALUE v_mask) {
|
191
208
|
Check_Type(v_str, T_STRING);
|
192
209
|
|
@@ -208,14 +225,14 @@ static VALUE rb_postfix_status_line_parse(VALUE self, VALUE v_str, VALUE v_mask)
|
|
208
225
|
strncpy(buf, str, len);
|
209
226
|
buf[len] = '\0';
|
210
227
|
|
211
|
-
char *
|
228
|
+
char *tm, *hostname, *process, *queue_id, *attrs;
|
212
229
|
|
213
|
-
if (split_line1(buf, &
|
230
|
+
if (split_line1(buf, &tm, &hostname, &process, &queue_id, &attrs) != 0) {
|
214
231
|
return Qnil;
|
215
232
|
}
|
216
233
|
|
217
234
|
VALUE hash = rb_hash_new();
|
218
|
-
|
235
|
+
put_time(tm, hash);
|
219
236
|
rb_hash_aset(hash, rb_str_new2("hostname"), rb_str_new2(hostname));
|
220
237
|
rb_hash_aset(hash, rb_str_new2("process"), rb_str_new2(process));
|
221
238
|
rb_hash_aset(hash, rb_str_new2("queue_id"), rb_str_new2(queue_id));
|