Back to index

courier  0.68.2
cdmsgq.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2007 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #ifndef       cdmsgq_h
00007 #define       cdmsgq_h
00008 
00009 #if    HAVE_CONFIG_H
00010 #undef PACKAGE
00011 #undef VERSION
00012 #include      "config.h"
00013 #endif
00014 
00015 #include      <sys/types.h>
00016 #include      <time.h>
00017 
00018 #include      "cdrcptinfo.h"
00019 
00020 #include      <string>
00021 #include      <vector>
00022 
00023 class drvinfo;
00024 struct rfc822token;
00025 struct comctlfile;
00026 
00027 class msgq {
00028 public:
00029     int cancelled;          // This message should be cancelled
00030     msgq *next, *prev;             // Sorted by nextdel
00031     msgq *nexthash, *prevhash;     // Same hash bucket
00032     ino_t        msgnum;    // Queue message number
00033 
00034     std::string  msgid;         // Message ID, for logging
00035 
00036     time_t       nextdel;   // Next delivery attempt (used to find the
00037                             // filename in msgq)
00038     time_t       nextsenddel;      // Usually nextdel, but is reset when
00039                             // the queue is flushed -- this is the time
00040                             // when this message should be scheduled
00041                             // for delivery.
00042     unsigned long nksize;       // Size in kilobytes
00043     std::vector<rcptinfo> rcptinfo_list;         // The recipients
00044     unsigned rcptcount;            // # of incomplete deliveries for this msg
00045     msgq();
00046     ~msgq();
00047 
00048     static std::vector<msgq> queue;
00049     static std::vector<msgq *> queuehashfirst, queuehashlast;
00050 
00051 static unsigned queuedelivering, queuewaiting, inprogress;
00052 
00053 static void init(unsigned);
00054 static void logmsgid(msgq *q);
00055 static msgq *queuehead, *queuetail,
00056                      // Message with a next-delivery time stamp
00057                      // IN THE FUTURE
00058        *queuefree;
00059                      // Unused msgqs
00060 
00061 static msgq *findq(ino_t);
00062 
00063 static int tmpscan();
00064 static void queuescan();
00065 
00066 static void flushmsg(ino_t, const char *);
00067 
00068 private:
00069 
00070 static drvinfo *backup_relay_driver;
00071 static std::string backup_relay;
00072 
00073 static int queuescan2(std::string);
00074 static int queuescan3(std::string, std::string, const char *);
00075 
00076 static drvinfo *getdelinfo(struct rfc822token *,
00077        const char *, std::string &, std::string &, std::string &);
00078 
00079 public:
00080        void removeq();
00081        void removewq();
00082        void start_message();
00083 
00084 static void completed(drvinfo &, size_t);
00085 
00086 private:
00087 static void startdelivery(drvinfo *, delinfo *);
00088 
00089 static void done(msgq *, int);
00090 
00091        const char *needs_dsn(struct ctlfile *);
00092        const char *needs_warndsn(struct ctlfile *);
00093 
00094 } ;
00095 
00096 #endif