3 #ifndef _DSN_UTIL_H_INCLUDED_
4 #define _DSN_UTIL_H_INCLUDED_
10 /* DSN status parsing routines
12 /* #include <dsn_util.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.
37 char data
[DSN_SIZE
]; /* NOT a public interface */
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; \
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.
56 DSN_STAT dsn
; /* RFC 3463 status */
57 const char *text
; /* free text */
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 *);
71 /* The Secure Mailer license must be distributed with this software.
74 /* IBM T.J. Watson Research
76 /* Yorktown Heights, NY 10598, USA