Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / qmgr / qmgr_error.c
blob1d531ce27c80b544327c13e69b702ed846b21eee
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* qmgr_error 3
6 /* SUMMARY
7 /* look up/create error/retry queue
8 /* SYNOPSIS
9 /* #include "qmgr.h"
11 /* QMGR_TRANSPORT *qmgr_error_transport(service)
12 /* const char *service;
14 /* QMGR_QUEUE *qmgr_error_queue(service, dsn)
15 /* const char *service;
16 /* DSN *dsn;
18 /* char *qmgr_error_nexthop(dsn)
19 /* DSN *dsn;
20 /* DESCRIPTION
21 /* qmgr_error_transport() looks up the error transport for the
22 /* specified service. The result is null if the transport is
23 /* not available.
25 /* qmgr_error_queue() looks up an error queue for the specified
26 /* service and problem. The result is null if the queue is not
27 /* availabe.
29 /* qmgr_error_nexthop() computes the next-hop information for
30 /* the specified problem. The result must be passed to myfree().
32 /* Arguments:
33 /* .IP dsn
34 /* See dsn(3).
35 /* .IP service
36 /* One of MAIL_SERVICE_ERROR or MAIL_SERVICE_RETRY.
37 /* DIAGNOSTICS
38 /* Panic: consistency check failure. Fatal: out of memory.
39 /* LICENSE
40 /* .ad
41 /* .fi
42 /* The Secure Mailer license must be distributed with this software.
43 /* AUTHOR(S)
44 /* Wietse Venema
45 /* IBM T.J. Watson Research
46 /* P.O. Box 704
47 /* Yorktown Heights, NY 10598, USA
48 /*--*/
50 /* System library. */
52 #include <sys_defs.h>
54 /* Utility library. */
56 #include <mymalloc.h>
57 #include <stringops.h>
59 /* Global library. */
61 /* Application-specific. */
63 #include "qmgr.h"
65 /* qmgr_error_transport - look up error transport for specified service */
67 QMGR_TRANSPORT *qmgr_error_transport(const char *service)
69 QMGR_TRANSPORT *transport;
72 * Find or create retry transport.
74 if ((transport = qmgr_transport_find(service)) == 0)
75 transport = qmgr_transport_create(service);
76 if (QMGR_TRANSPORT_THROTTLED(transport))
77 return (0);
80 * Done.
82 return (transport);
85 /* qmgr_error_queue - look up error queue for specified service and problem */
87 QMGR_QUEUE *qmgr_error_queue(const char *service, DSN *dsn)
89 QMGR_TRANSPORT *transport;
90 QMGR_QUEUE *queue;
91 char *nexthop;
94 * Find or create transport.
96 if ((transport = qmgr_error_transport(service)) == 0)
97 return (0);
100 * Find or create queue.
102 nexthop = qmgr_error_nexthop(dsn);
103 if ((queue = qmgr_queue_find(transport, nexthop)) == 0)
104 queue = qmgr_queue_create(transport, nexthop, nexthop);
105 myfree(nexthop);
106 if (QMGR_QUEUE_THROTTLED(queue))
107 return (0);
110 * Done.
112 return (queue);
115 /* qmgr_error_nexthop - compute next-hop information from problem description */
117 char *qmgr_error_nexthop(DSN *dsn)
119 char *nexthop;
121 nexthop = concatenate(dsn->status, " ", dsn->reason, (char *) 0);
122 return (nexthop);