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