Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / dsn_util.h
blobe9c8d0b2d9f38a16b60282832c9dcc90d1789c2c
1 /* $NetBSD$ */
3 #ifndef _DSN_UTIL_H_INCLUDED_
4 #define _DSN_UTIL_H_INCLUDED_
6 /*++
7 /* NAME
8 /* dsn_util 3h
9 /* SUMMARY
10 /* DSN status parsing routines
11 /* SYNOPSIS
12 /* #include <dsn_util.h>
13 /* DESCRIPTION
14 /* .nf
17 * Utility library.
19 #include <vstring.h>
22 * Detail format is digit "." digit{1,3} "." digit{1,3}.
24 #define DSN_DIGS1 1 /* leading digits */
25 #define DSN_DIGS2 3 /* middle digits */
26 #define DSN_DIGS3 3 /* trailing digits */
27 #define DSN_LEN (DSN_DIGS1 + 1 + DSN_DIGS2 + 1 + DSN_DIGS3)
28 #define DSN_SIZE (DSN_LEN + 1)
31 * Storage for an enhanced status code. Avoid using malloc for itty-bitty
32 * strings with a known size limit.
34 * XXX gcc version 2 complains about sizeof() as format width specifier.
36 typedef struct {
37 char data[DSN_SIZE]; /* NOT a public interface */
38 } DSN_STAT;
40 #define DSN_UPDATE(dsn_buf, dsn, len) do { \
41 if (len >= sizeof((dsn_buf).data)) \
42 msg_panic("DSN_UPDATE: bad DSN code \"%.*s...\" length %d", \
43 INT_SIZEOF((dsn_buf).data) - 1, dsn, len); \
44 strncpy((dsn_buf).data, (dsn), (len)); \
45 (dsn_buf).data[len] = 0; \
46 } while (0)
48 #define DSN_STATUS(dsn_buf) ((const char *) (dsn_buf).data)
50 #define DSN_CLASS(dsn_buf) ((dsn_buf).data[0])
53 * Split flat text into detail code and free text.
55 typedef struct {
56 DSN_STAT dsn; /* RFC 3463 status */
57 const char *text; /* free text */
58 } DSN_SPLIT;
60 extern DSN_SPLIT *dsn_split(DSN_SPLIT *, const char *, const char *);
61 extern size_t dsn_valid(const char *);
64 * Create flat text from detail code and free text.
66 extern char *dsn_prepend(const char *, const char *);
68 /* LICENSE
69 /* .ad
70 /* .fi
71 /* The Secure Mailer license must be distributed with this software.
72 /* AUTHOR(S)
73 /* Wietse Venema
74 /* IBM T.J. Watson Research
75 /* P.O. Box 704
76 /* Yorktown Heights, NY 10598, USA
77 /*--*/
79 #endif