Back to index

courier  0.68.2
comctlfile.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2005 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #ifndef       comctlfile_h
00007 #define       comctlfile_h
00008 
00009 #include      "courier.h"
00010 #include      <sys/types.h>
00011 #include      <time.h>
00012 
00013 #ifdef __cplusplus
00014 extern "C" {
00015 #endif
00016 
00017 struct iovec;
00018 
00019 /*
00020        The following structure represents the control file of a message.
00021 */
00022 
00023 struct ctlfile {
00024        int fd;                            /* File descriptor */
00025        ino_t n;                    /* Inode/Queue number */
00026        time_t mtime;               /* Last attempted delivery */
00027        time_t starttime;           /* The timestamp portion of the
00028                                    ** message ID.  **NOT** initialized
00029                                    ** by ctlfile_open, it sets it to 0
00030                                    ** and caller must stat the data
00031                                    ** file and fill this in */
00032 
00033        unsigned long msgsize;             /* Size of the message. NOT
00034                                    ** automatically populated, it is
00035                                    ** initialized to 0, and the
00036                                    ** delivery code is responsible
00037                                    ** for setting it when it open the
00038                                    ** message data.
00039                                    ** If > 0, the size is logged
00040                                    ** upon succesful delivery.
00041                                    */
00042 
00043        char *contents;                    /* The entire control file */
00044 
00045        /* Parsed contents: */
00046 
00047        const char *sender;         /* Envelope sender */
00048        char **receipients;         /* Receipients */
00049        char **oreceipients;        /* Original receipients */
00050        char **dsnreceipients;             /* DSN flags */
00051        char **delstatus;           /* Per-receipient delivery status */
00052        unsigned nreceipients;             /* # of receipients */
00053        char **lines;               /* contents, null terminated lines */
00054        short  cancelled;           /* TRUE - message has been cancelled */
00055 } ;
00056 
00057 int ctlfile_openi(ino_t, struct ctlfile *, int);
00058 int ctlfile_openit(ino_t, time_t, struct ctlfile *, int);
00059 int ctlfile_openfn(const char *, struct ctlfile *, int, int);
00060 void ctlfile_close(struct ctlfile *);
00061 void ctlfile_append(struct ctlfile *, const char *);
00062 int ctlfile_setvhost(struct ctlfile *);
00063 
00064 void ctlfile_append_reply(struct ctlfile *, unsigned,
00065        const char *, char, const char *);
00066 void ctlfile_append_replyfd(int, unsigned,
00067        const char *, char, const char *);
00068 
00069 void ctlfile_append_info(struct ctlfile *, unsigned, const char *);
00070 void ctlfile_append_infofd(int, unsigned, const char *);
00071 void ctlfile_append_connectioninfo(struct ctlfile *,
00072                                    unsigned, char, const char *);
00073 void ctlfile_append_connectioninfofd(int, unsigned, char, const char *);
00074 
00075 int ctlfile_searchfirst(struct ctlfile *, char);
00076 void ctlfile_appendv(struct ctlfile *, const struct iovec *, int);
00077 void ctlfile_appendvfd(int, const struct iovec *, int);
00078 
00079 const char *ctlfile_security(struct ctlfile *);
00080 
00081 void ctlfile_nextattempt(struct ctlfile *, time_t);
00082 void ctlfile_nextattemptfd(int, time_t);
00083 time_t ctlfile_getnextattempt(struct ctlfile *);
00084 
00085 #define       COMCTLFILE_SENDER    's'
00086 #define       COMCTLFILE_RECEIPIENT       'r'
00087 #define       COMCTLFILE_ORECEIPIENT      'R'
00088 #define       COMCTLFILE_DSN              'N'
00089 #define       COMCTLFILE_ENVID     'e'
00090 #define       COMCTLFILE_AUTHNAME  'i'
00091 #define       COMCTLFILE_DSNFORMAT 't'
00092 #define       COMCTLFILE_EXPIRES   'E'
00093 #define COMCTLFILE_FAXEXPIRES      'p'
00094 #define       COMCTLFILE_WARNING   'W'
00095 #define       COMCTLFILE_WARNINGSENT      'w'
00096 #define       COMCTLFILE_8BIT             '8'
00097 #define       COMCTLFILE_FROMMTA   'f'
00098 #define       COMCTLFILE_DELINFO   'I'
00099        #define COMCTLFILE_DELINFO_PEER    'P'
00100        #define       COMCTLFILE_DELINFO_CONNECTIONERROR 'C'
00101        #define       COMCTLFILE_DELINFO_SENT                   'S'
00102        #define       COMCTLFILE_DELINFO_REPLYTYPE              'T'
00103        #define       COMCTLFILE_DELINFO_REPLY           'R'
00104 #define       COMCTLFILE_DELSUCCESS       'S'
00105 #define       COMCTLFILE_DELFAIL   'F'
00106 #define       COMCTLFILE_DELDEFERRED      'D'
00107 #define       COMCTLFILE_DELCOMPLETE      'C'
00108 #define       COMCTLFILE_VERP             'V'
00109 #define COMCTLFILE_VHOST    'v'
00110 #define       COMCTLFILE_CANCEL_MSG       'X'
00111 #define       COMCTLFILE_CANCELLED_ACK 'x'
00112 #define       COMCTLFILE_NEXTATTEMPT      'A'
00113 #define       COMCTLFILE_MSGID     'M'
00114 #define       COMCTLFILE_SUBMITDELAY      'L'
00115 #define COMCTLFILE_SECURITY 'U'
00116 #define COMCTLFILE_MSGSOURCE       'u'
00117 #define COMCTLFILE_TRACK    'T'
00118 
00119 /*
00120 ** HACK ALERT:  We want to log the last line of SMTP replies,
00121 ** showing the remote relay that we delivered to, to syslog, but not to the
00122 ** message log, because it is not part of the SMTP reply received (and it
00123 ** would show up in any DSNs as a noncompliant rfc822; format message).
00124 ** The following code is a special marker in this case, and causes special
00125 ** processing.  This flag is ONLY understood by ctlfile_append_reply().
00126 */
00127 
00128 #define       COMCTLFILE_DELSUCCESS_NOLOG 'Z'
00129 
00130 
00131 /*
00132 ** HACK ALERT, part II: A COMCTLFILE_DELFAIL_NOTRACK is a COMCTLFILE_DELFAIL,
00133 ** but the error is tracked for backscatter purposes.
00134 */
00135 
00136 #define COMCTLFILE_DELFAIL_NOTRACK 'Y'
00137 
00138 
00139 #define       SMTPREPLY_TYPE(s)    ( *(s) == '5' ? COMCTLFILE_DELFAIL: \
00140        *(s) == '1' || *(s) == '2' || *(s) == '3' ? COMCTLFILE_DELSUCCESS:\
00141        COMCTLFILE_DELDEFERRED)
00142 
00143 extern void clog_msg_msgid(struct ctlfile *);
00144 
00145 #ifdef __cplusplus
00146 }
00147 #endif
00148 
00149 #endif