annotate src/fail_msg.c @ 434:f2a7271746d1 default tip

Removes Freshmeat.net from the docs The site, which was later renamed to freecode.com, is no longer maintained (contains only a static copy).
author markus schnalke <meillo@marmaro.de>
date Sat, 07 Feb 2015 11:45:07 +0100
parents 8518fe2b0f36
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
1 /*
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
2 ** MasqMail
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
3 ** Copyright (C) 2000-2001 Oliver Kurth
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
4 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
6 ** it under the terms of the GNU General Public License as published by
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
8 ** (at your option) any later version.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
9 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
10 ** This program is distributed in the hope that it will be useful,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
13 ** GNU General Public License for more details.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
14 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
15 ** You should have received a copy of the GNU General Public License
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
16 ** along with this program; if not, write to the Free Software
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
18 */
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
19
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
20 #include <sys/wait.h>
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
21
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
22 #include "masqmail.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
23 #include "peopen.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
24 #include "readsock.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
25
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
26 gboolean
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
27 fail_msg(message *msg, gchar *template, GList *failed_rcpts, gchar *err_fmt,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
28 va_list args)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
29 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
30 gboolean ok = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
31 address *ret_path = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
32
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
33 /* do not bounce bounces, send to postmaster instead */
15
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 10
diff changeset
34 if (msg->return_path->local_part[0] == '\0') {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
35 GList *node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
36
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
37 ret_path = create_address_qualified("postmaster", TRUE,
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
38 conf.host_name);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
39 foreach(failed_rcpts, node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
40 address *addr = (address *) (node->data);
242
bc9d9cd9ee8e made addr_isequal() and addr_isequal_parent() more flexible
markus schnalke <meillo@marmaro.de>
parents: 207
diff changeset
41
bc9d9cd9ee8e made addr_isequal() and addr_isequal_parent() more flexible
markus schnalke <meillo@marmaro.de>
parents: 207
diff changeset
42 if (addr_isequal_parent(addr, ret_path, strcasecmp)) {
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
43 logwrite(LOG_ALERT, "%s == %s: postmaster "
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
44 "address failed\n", msg->uid,
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
45 addr_string(ret_path));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
46 return FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
47 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
48 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
49 } else
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
50 ret_path = copy_address(msg->return_path);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
51
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
52 DEBUG(1) debugf("sending failure notice to %s.\n",
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
53 addr_string(ret_path));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
54
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
55 if (template) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
56 FILE *file;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
57 GList *var_table = var_table_conf(var_table_msg(NULL, msg));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
58 gchar *err_msg = g_strdup_vprintf(err_fmt, args);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
59
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
60 var_table = g_list_prepend(var_table,
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
61 create_pair_string("err_msg", err_msg));
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
62 g_free(err_msg);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
63
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
64 if ((file = fopen(template, "r"))) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
65 FILE *out;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 gchar *cmd;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
67 pid_t pid;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
68
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
69 cmd = g_strdup_printf(SBINDIR "/masqmail -oi -f <> %s@%s", ret_path->local_part, ret_path->domain);
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
70 if (!(out = peidopen(cmd, "w", environ, &pid,
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
71 conf.mail_uid, conf.mail_gid))) {
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
72 logwrite(LOG_ERR, "peopen failed: %s\n",
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
73 strerror(errno));
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
74 } else {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
75 gchar fmt[256], line[256];
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
76 int status, ret;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
77
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
78 while ((ret = read_sockline(file, fmt, 256, 0, 0)) > 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
79 if (fmt[0] == '@') {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
80 GList *node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
81 if (strncmp(fmt, "@failed_rcpts", 13) == 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
82 foreach(failed_rcpts, node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
83 address *rcpt = (address *) (node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
84 fprintf(out, "\t%s\n", addr_string(rcpt));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
85 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
86 } else if (strncmp(fmt, "@msg_headers", 12) == 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
87 foreach(msg->hdr_list, node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
88 header *hdr = (header *) (node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
89 fputs(hdr->header, out);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
90 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
91 } else if (strncmp(fmt, "@msg_body", 9) == 0) {
15
f671821d8222 code beautifying; 0 -> \0 if appropriate
meillo@marmaro.de
parents: 10
diff changeset
92 /* we may have to read the data at this point and remember if we did */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
93 gboolean flag = (msg->data_list == NULL);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
94 if (flag) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
95 if (!spool_read_data(msg)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
96 logwrite(LOG_ALERT, "could not open data spool file %s\n", msg->uid);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
97 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
98 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
99 foreach(msg->data_list, node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
100 gchar *line = (gchar *) (node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
101 fputs(line, out);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
102 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
103 if (flag)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
104 msg_free_data(msg);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
105 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
106 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
107 expand(var_table, fmt, line, 256);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
108 fputs(line, out);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
109 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
110 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
111
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
112 fclose(out);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
113 waitpid(pid, &status, 0);
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
114 if ((WEXITSTATUS(status) != 0) ||
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
115 WIFSIGNALED(status)) {
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
116 if (WEXITSTATUS(status)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
117 logwrite(LOG_WARNING, "child returned %d\n", WEXITSTATUS(status));
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
118 }
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
119 if (WIFSIGNALED(status)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
120 logwrite(LOG_WARNING, "child got signal: %d\n", WTERMSIG(status));
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
121 }
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
122 } else {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
123 ok = TRUE;
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
124 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
125 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
126 g_free(cmd);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
127 fclose(file);
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
128 } else {
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
129 logwrite(LOG_ALERT, "could not open failure message "
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
130 "template %s: %s\n",
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
131 conf.errmsg_file, strerror(errno));
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
132 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
133
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
134 destroy_table(var_table);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
135 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
136
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
137 destroy_address(ret_path);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
138
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
139 return ok;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
140 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
141
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
142 /*
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
143 ** ival : |--|--|----|--------|--------|
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
144 ** warned: |-------W-------------W------
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
145 ** result: |nnnyyyynnnnyyyyyyyyyynnnnnnn
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
146 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
147 static gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 262
diff changeset
148 warn_msg_is_due(message *msg)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
149 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
150 time_t now = time(NULL);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
151
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
152 GList *node;
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
153 for (node = g_list_last(conf.warn_intervals); node;
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
154 node = g_list_previous(node)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
155 gchar *str_ival = (gchar *) (node->data);
254
82d168dd52fd removed the obsolete pos argument from time_interval()
markus schnalke <meillo@marmaro.de>
parents: 242
diff changeset
156 gint ival = time_interval(str_ival);
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
157 if (ival < 0) {
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
158 logwrite(LOG_WARNING, "invalid time interval: %s\n",
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
159 str_ival);
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
160 } else {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
161 DEBUG(5) debugf("ival = %d\n", ival);
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
162 DEBUG(5) debugf("now - msg->received_time = %d\n",
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
163 now - msg->received_time);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
164 if ((now - msg->received_time) > ival) {
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
165 if (msg->warned_time == 0) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
166 return TRUE;
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
167 }
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
168 if ((msg->warned_time - msg->received_time) <
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
169 ival) {
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
170 return TRUE;
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
171 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
172 }
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
173 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
174 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
175 return FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
176 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
177
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
178 gboolean
367
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
179 warn_msg(message *msg, gchar *template, GList *defered_rcpts, gchar *err_fmt,
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
180 va_list args)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
181 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
182 time_t now = time(NULL);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
183
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
184 if (warn_msg_is_due(msg)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
185 if (fail_msg(msg, template, defered_rcpts, err_fmt, args)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
186 msg->warned_time = now;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
187 return TRUE;
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
188 } else {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
189 return FALSE;
406
8518fe2b0f36 Refactoring.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
190 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
191 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
192 return TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
193 }