143
143
#define SENDER_FORMAT "%-11s%8ld %20.20s %s\n"
144
144
#define DROP_FORMAT "%-10s%c%8ld %20.20s (maildrop queue, sender UID %u)\n"
146
static void showq_reasons(VSTREAM *, BOUNCE_LOG *, HTABLE *);
146
static void showq_reasons(VSTREAM *, BOUNCE_LOG *, RCPT_BUF *, DSN_BUF *,
148
149
#define STR(x) vstring_str(x)
236
239
&& dup_filter == 0
237
240
&& (logfile = bounce_log_open(MAIL_QUEUE_DEFER, id, O_RDONLY, 0)) != 0) {
238
241
dup_filter = htable_create(var_dup_filter_limit);
239
showq_reasons(client, logfile, dup_filter);
243
rcpt_buf = rcpb_create();
245
dsn_buf = dsb_create();
246
showq_reasons(client, logfile, rcpt_buf, dsn_buf, dup_filter);
240
247
if (bounce_log_close(logfile))
241
248
msg_warn("close %s %s: %m", MAIL_QUEUE_DEFER, id);
244
251
vstring_free(buf);
245
252
vstring_free(printable_quoted_addr);
247
258
htable_free(dup_filter, (void (*) (char *)) 0);
250
261
/* showq_reasons - show deferral reasons */
252
static void showq_reasons(VSTREAM *client, BOUNCE_LOG *bp, HTABLE *dup_filter)
263
static void showq_reasons(VSTREAM *client, BOUNCE_LOG *bp, RCPT_BUF *rcpt_buf,
264
DSN_BUF *dsn_buf, HTABLE *dup_filter)
254
266
char *saved_reason = 0;
268
RECIPIENT *rcpt = &rcpt_buf->rcpt;
269
DSN *dsn = &dsn_buf->dsn;
257
while (bounce_log_read(bp) != 0) {
271
while (bounce_log_read(bp, rcpt_buf, dsn_buf) != 0) {
260
274
* Update the duplicate filter.
262
276
if (var_dup_filter_limit == 0
263
277
|| dup_filter->used < var_dup_filter_limit)
264
if (htable_locate(dup_filter, bp->recipient) == 0)
265
htable_enter(dup_filter, bp->recipient, (char *) 0);
278
if (htable_locate(dup_filter, rcpt->address) == 0)
279
htable_enter(dup_filter, rcpt->address, (char *) 0);
268
282
* Don't print the reason when the previous recipient had the same
271
if (saved_reason == 0 || strcmp(saved_reason, bp->text) != 0) {
285
if (saved_reason == 0 || strcmp(saved_reason, dsn->reason) != 0) {
272
286
if (saved_reason)
273
287
myfree(saved_reason);
274
saved_reason = mystrdup(bp->text);
288
saved_reason = mystrdup(dsn->reason);
275
289
if ((padding = 76 - strlen(saved_reason)) < 0)
277
291
vstream_fprintf(client, "%*s(%s)\n", padding, "", saved_reason);
279
vstream_fprintf(client, STRING_FORMAT, "", "", "", bp->recipient);
293
vstream_fprintf(client, STRING_FORMAT, "", "", "", rcpt->address);
281
295
if (saved_reason)
282
296
myfree(saved_reason);