Back to index

courier  0.68.2
duphash.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2000 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #ifndef       duphash_h
00007 #define       duphash_h
00008 
00009 #include      "msghash.h"
00010 
00011 
00012 /* Dup detection calculation */
00013 
00014 #define       MAXMSGIDSIZE  128           /* Max size of message ID */
00015 
00016 /* A single hash info */
00017 
00018 struct duphashinfo {
00019        struct duphashinfo *next,   /* Link list of unused duphashinfos,
00020                                    ** or of all hashes in the same bucket
00021                                    */
00022                             *prev; /* Double link list of hashes on same
00023                                    ** bucket
00024                                    */
00025 
00026        MD5_DIGEST    md5;          /* The hash value */
00027        struct duphashmsginfo *firstmsg, *lastmsg;
00028                                    /* All messages with the same hash */
00029        unsigned nmsgs;                    /* # of messages with the same hash */
00030        unsigned ndupmsgs;          /* # of messages here that were dupes
00031                                    ** generated by submit due to too
00032                                    ** many recipients
00033                                    */
00034        } ;
00035 
00036 struct duphashmsginfo {
00037        struct duphashmsginfo *next, *prev;       /* link list of msgs with same hash */
00038        struct duphashinfo *hash;   /* My hash */
00039        char   cancelled;           /* This message has been cancelled */
00040        char   dupmsg;                     /* This is a second copy of a msg
00041                                    ** that was split into multiple msgs
00042                                    ** by submit
00043                                    */
00044        char   msgid[MAXMSGIDSIZE];
00045        } ;
00046 
00047 struct duphash {
00048        unsigned duphashbufsize;
00049        unsigned duplevel;
00050        struct duphashmsginfo              *msgsbuf;
00051        struct duphashinfo   *hashesbuf;
00052 
00053        struct duphashinfo   *hashbuckets[256];   /* Hash buckets */
00054 
00055        unsigned head, tail; /* ptrs into duphashmsginfo circular buf */
00056        struct duphashinfo *freelist;      /* unused duphashinfos */
00057 
00058        } ;
00059 
00060 void duphash_init(struct duphash *,
00061               unsigned,            /* Size of hash buffer */
00062               unsigned);
00063                      /* # of dup messages before they are cancelled */
00064 
00065 int duphash_check(struct duphash *,
00066               MD5_DIGEST *,
00067               const char *, /* msgid */
00068               int,          /* isdupe */
00069               void (*)(const char *));    /* cancel function */
00070 #endif