1/* $NetBSD$ */ 2 3#ifndef _REC_TYPE_H_INCLUDED_ 4#define _REC_TYPE_H_INCLUDED_ 5 6/*++ 7/* NAME 8/* rec_type 3h 9/* SUMMARY 10/* Postfix record types 11/* SYNOPSIS 12/* #include <rec_type.h> 13/* DESCRIPTION 14/* .nf 15 16 /* 17 * System library. 18 */ 19#include <ctype.h> 20#include <stdlib.h> 21 22 /* 23 * Diagnostic codes, not real record lookup results. 24 */ 25#define REC_TYPE_EOF -1 /* no record */ 26#define REC_TYPE_ERROR -2 /* bad record */ 27 28 /* 29 * A queue file or IPC mail message consists of a sequence of typed records. 30 * The first record group contains time stamp, full name, sender envelope 31 * information, and optionally contains recipient information. The second 32 * record group contains data records with the message content. The last 33 * record group is optional; it contains information extracted from message 34 * headers, such as recipients, errors-to and return-receipt. 35 * 36 * Note: REC_TYPE_FILT and REC_TYPE_CONT are encoded with the same 'L' 37 * constant, and it is too late to change that now. 38 */ 39#define REC_TYPE_SIZE 'C' /* first record, created by cleanup */ 40#define REC_TYPE_TIME 'T' /* arrival time, required */ 41#define REC_TYPE_CTIME 'c' /* create time, optional */ 42#define REC_TYPE_FULL 'F' /* full name, optional */ 43#define REC_TYPE_INSP 'I' /* inspector transport */ 44#define REC_TYPE_FILT 'L' /* loop filter transport */ 45#define REC_TYPE_FROM 'S' /* sender, required */ 46#define REC_TYPE_DONE 'D' /* delivered recipient, optional */ 47#define REC_TYPE_RCPT 'R' /* todo recipient, optional */ 48#define REC_TYPE_ORCP 'O' /* original recipient, optional */ 49#define REC_TYPE_DRCP '/' /* canceled recipient, optional */ 50#define REC_TYPE_WARN 'W' /* warning message time */ 51#define REC_TYPE_ATTR 'A' /* named attribute for extensions */ 52#define REC_TYPE_KILL 'K' /* killed record */ 53 54#define REC_TYPE_RDR '>' /* redirect target */ 55#define REC_TYPE_FLGS 'f' /* cleanup processing flags */ 56#define REC_TYPE_DELAY 'd' /* cleanup delay upon arrival */ 57 58#define REC_TYPE_MESG 'M' /* start message records */ 59 60#define REC_TYPE_CONT 'L' /* long data record */ 61#define REC_TYPE_NORM 'N' /* normal data record */ 62#define REC_TYPE_DTXT 'w' /* padding (was: deleted data) */ 63 64#define REC_TYPE_XTRA 'X' /* start extracted records */ 65 66#define REC_TYPE_RRTO 'r' /* return-receipt, from headers */ 67#define REC_TYPE_ERTO 'e' /* errors-to, from headers */ 68#define REC_TYPE_PRIO 'P' /* priority */ 69#define REC_TYPE_PTR 'p' /* pointer indirection */ 70#define REC_TYPE_VERP 'V' /* VERP delimiters */ 71 72#define REC_TYPE_DSN_RET '<' /* DSN full/hdrs */ 73#define REC_TYPE_DSN_ENVID 'i' /* DSN full/hdrs */ 74#define REC_TYPE_DSN_ORCPT 'o' /* DSN orig rcpt address */ 75#define REC_TYPE_DSN_NOTIFY 'n' /* DSN notify flags */ 76 77#define REC_TYPE_MILT_COUNT 'm' 78 79#define REC_TYPE_END 'E' /* terminator, required */ 80 81 /* 82 * What I expect to see in a "pure recipient" sequence at the end of the 83 * initial or extracted envelope segments, respectively. When a queue file 84 * contains pure recipient sequences only, then the queue manager will not 85 * have to read all the queue file records before starting delivery. This is 86 * often the case with list mail, where such optimization is desirable. 87 * 88 * XXX These definitions include the respective segment terminators to avoid 89 * special cases in the cleanup(8) envelope and extracted record processors. 90 */ 91#define REC_TYPE_ENV_RECIPIENT "MDRO/Kon" 92#define REC_TYPE_EXT_RECIPIENT "EDRO/Kon" 93 94 /* 95 * The types of records that I expect to see while processing different 96 * record groups. The first member in each set is the record type that 97 * indicates the end of that record group. 98 * 99 * XXX A records in the extracted segment are generated only by the cleanup 100 * server, and are not supposed to be present in locally submitted mail, as 101 * this is "postfix internal" information. However, the pickup server has to 102 * allow for the presence of A records in the extracted segment, because it 103 * can be requested to re-process already queued mail with `postsuper -r'. 104 * 105 * Note: REC_TYPE_FILT and REC_TYPE_CONT are encoded with the same 'L' 106 * constant, and it is too late to change that now. 107 */ 108#define REC_TYPE_ENVELOPE "MCTcFILSDRO/WVA>K<ion" 109#define REC_TYPE_CONTENT "XLNw" 110#define REC_TYPE_EXTRACT "EDRO/PreAFIL>Kon" 111 112 /* 113 * The subset of inputs that the postdrop command allows. 114 */ 115#define REC_TYPE_POST_ENVELOPE "MFSRVAin" 116#define REC_TYPE_POST_CONTENT "XLN" 117#define REC_TYPE_POST_EXTRACT "EAR" 118 119 /* 120 * The record at the start of the queue file specifies the message content 121 * size (number of bytes between the REC_TYPE_MESG and REC_TYPE_XTRA meta 122 * records), data offset (offset of the first REC_TYPE_NORM or REC_TYPE_CONT 123 * text record), recipient count, and queue manager hints. These are all 124 * fixed-width fields so they can be updated in place. Queue manager hints 125 * are defined in qmgr_user.h 126 * 127 * See also: REC_TYPE_PTR_FORMAT below. 128 */ 129#define REC_TYPE_SIZE_FORMAT "%15ld %15ld %15ld %15ld %15ld" 130#define REC_TYPE_SIZE_CAST1 long /* Vmailer extra offs - data offs */ 131#define REC_TYPE_SIZE_CAST2 long /* Postfix 1.0 data offset */ 132#define REC_TYPE_SIZE_CAST3 long /* Postfix 1.0 recipient count */ 133#define REC_TYPE_SIZE_CAST4 long /* Postfix 2.1 qmgr flags */ 134#define REC_TYPE_SIZE_CAST5 long /* Postfix 2.4 content length */ 135 136 /* 137 * The warn record specifies when the next warning that the message was 138 * deferred should be sent. It is updated in place by qmgr, so changing 139 * this value when there are deferred mesages in the queue is dangerous! 140 */ 141#define REC_TYPE_WARN_FORMAT "%15ld" /* warning time format */ 142#define REC_TYPE_WARN_ARG(tv) ((long) (tv)) 143#define REC_TYPE_WARN_SCAN(cp, tv) ((tv) = atol(cp)) 144 145 /* 146 * Time information is not updated in place, but it does have complex 147 * formatting requirements, so we centralize things here. 148 */ 149#define REC_TYPE_TIME_FORMAT "%ld %ld" 150#define REC_TYPE_TIME_ARG(tv) (long) (tv).tv_sec, (long) (tv).tv_usec 151#define REC_TYPE_TIME_SCAN(cp, tv) \ 152 do { \ 153 const char *_p = cp; \ 154 (tv).tv_sec = atol(_p); \ 155 while (ISDIGIT(*_p)) \ 156 _p++; \ 157 (tv).tv_usec = atol(_p); \ 158 } while (0) 159 160 /* 161 * Pointer records are used to edit a queue file in place before it is 162 * committed. When a record is appended or modified, we patch it into the 163 * existing record stream with a pointer to storage in a heap after the 164 * end-of-message marker; the new content is followed by a pointer record 165 * back to the existing record stream. 166 * 167 * We need to have a few dummy pointer records in place at strategic places 168 * (after the last recipient, after the last header) so that we can always 169 * append recipients or append/modify headers without having to move message 170 * segment terminators. 171 * 172 * We also need to have a dummy PTR record at the end of the content, so that 173 * we can always replace the message content without having to move the 174 * end-of-message marker. 175 * 176 * A dummy PTR record has a null argument. 177 * 178 * See also: REC_TYPE_SIZE_FORMAT above. 179 */ 180#define REC_TYPE_PTR_FORMAT "%15ld" 181#define REC_TYPE_PTR_PAYL_SIZE 15 /* Payload only, excludes record header. */ 182 183 /* 184 * Programmatic interface. 185 */ 186extern const char *rec_type_name(int); 187 188/* LICENSE 189/* .ad 190/* .fi 191/* The Secure Mailer license must be distributed with this software. 192/* AUTHOR(S) 193/* Wietse Venema 194/* IBM T.J. Watson Research 195/* P.O. Box 704 196/* Yorktown Heights, NY 10598, USA 197/*--*/ 198 199#endif 200