Removed the suppress dups feature from slocal for simplicity reasons.
[mmh] / uip / slocal.c
index 2573cbe..0ef54c6 100644 (file)
 extern int  initgroups(char*, int);
 #endif
 
-/*
-** This define is needed for Berkeley db v2 and above to
-** make the header file expose the 'historical' ndbm APIs.
-** We define it unconditionally because this is simple and
-** harmless.
-*/
-#define DB_DBM_HSEARCH 1
-#ifdef NDBM_HEADER
-#include NDBM_HEADER
-#endif
-
 #include <utmp.h>
 
 #ifndef HAVE_GETUTENT
@@ -89,15 +78,11 @@ static struct swit switches[] = {
        { "verbose", 0 },
 #define NVERBSW  9
        { "noverbose", 0 },
-#define SUPPRESSDUP   10
-       { "suppressdup", 0 },
-#define NSUPPRESSDUP 11
-       { "nosuppressdup", 0 },
-#define DEBUGSW  12
+#define DEBUGSW  10
        { "debug", 0 },
-#define VERSIONSW  13
+#define VERSIONSW  11
        { "version", 0 },
-#define HELPSW  14
+#define HELPSW  12
        { "help", 0 },
        { NULL, 0 }
 };
@@ -110,7 +95,6 @@ char *maildelivery = NMHETCDIR"/maildelivery";
 static int globbed = 0;  /* have we built "vars" table yet? */
 static int parsed = 0;  /* have we built header field table yet   */
 static int utmped = 0;  /* have we scanned umtp(x) file yet */
-static int suppressdup = 0;  /* are we suppressing duplicate messages? */
 
 static int verbose = 0;
 static int debug = 0;
@@ -203,7 +187,6 @@ static int copy_message(int, char *, int);
 static void verbose_printf(char *fmt, ...);
 static void adorn(char *, char *, ...);
 static void debug_printf(char *fmt, ...);
-static int suppress_duplicates(int, char *);
 static char *trim(char *);
 
 
@@ -302,12 +285,6 @@ main(int argc, char **argv)
                                verbose = 0;
                                continue;
 
-                       case SUPPRESSDUP:
-                               suppressdup++;
-                               continue;
-                       case NSUPPRESSDUP:
-                               suppressdup = 0;
-                               continue;
                        case DEBUGSW:
                                debug++;
                                continue;
@@ -443,11 +420,6 @@ main(int argc, char **argv)
 static int
 localmail(int fd, char *mdlvr)
 {
-       /* check if this message is a duplicate */
-       if (suppressdup && suppress_duplicates(fd, mdlvr ?
-                       mdlvr : ".maildelivery") == DONE)
-               return 0;
-
        /* delivery according to personal Maildelivery file */
        if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1)
                return 0;
@@ -1537,108 +1509,3 @@ debug_printf(char *fmt, ...)
        vfprintf(stderr, fmt, ap);
        va_end(ap);
 }
-
-
-/*
-** Check ndbm/db file(s) to see if the Message-Id of this
-** message matches the Message-Id of a previous message,
-** so we can discard it.  If it doesn't match, we add the
-** Message-Id of this message to the ndbm/db file.
-*/
-static int
-suppress_duplicates(int fd, char *file)
-{
-       int fd1, lockfd, state, result;
-       char *cp, buf[BUFSIZ], name[NAMESZ];
-       datum key, value;
-       DBM *db;
-       FILE *in;
-
-       if ((fd1 = dup(fd)) == -1)
-               return -1;
-       if (!(in = fdopen(fd1, "r"))) {
-               close(fd1);
-               return -1;
-       }
-       rewind(in);
-
-       for (state = FLD;;) {
-               state = m_getfld(state, name, buf, sizeof(buf), in);
-               switch (state) {
-               case FLD:
-               case FLDPLUS:
-               case FLDEOF:
-                       /* Search for the message ID */
-                       if (mh_strcasecmp(name, "Message-ID")) {
-                               while (state == FLDPLUS)
-                                       state = m_getfld(state, name, buf,
-                                                       sizeof(buf), in);
-                               continue;
-                       }
-
-                       cp = getcpy(buf);
-                       while (state == FLDPLUS) {
-                               state = m_getfld(state, name, buf,
-                                               sizeof(buf), in);
-                               cp = add(buf, cp);
-                       }
-                       key.dptr = trimcpy(cp);
-                       key.dsize = strlen(key.dptr) + 1;
-                       free(cp);
-                       cp = key.dptr;
-
-                       if (!(db = dbm_open(file, O_RDWR | O_CREAT, 0600))) {
-                               advise(file, "unable to perform dbm_open on");
-                               free(cp);
-                               fclose(in);
-                               return -1;
-                       }
-                       /*
-                       ** Since it is difficult to portable lock a ndbm
-                       ** file, we will open and lock the Maildelivery
-                       ** file instead.  This will fail if your Maildelivery
-                       ** file doesn't exist.
-                       */
-                       if ((lockfd = lkopen(file, O_RDWR, 0)) == -1) {
-                               advise(file, "unable to perform file locking on");
-                               free(cp);
-                               fclose(in);
-                               return -1;
-                       }
-                       value = dbm_fetch(db, key);
-                       if (value.dptr) {
-                               if (verbose)
-                                       verbose_printf("Message-ID: %s\n            already received on %s", cp, value.dptr);
-                               result = DONE;
-                       } else {
-                               value.dptr  = ddate + sizeof("Delivery-Date:");
-                               value.dsize = strlen(value.dptr) + 1;
-                               if (dbm_store(db, key, value, DBM_INSERT))
-                                       advise(file, "possibly corrupt file");
-                               result = 0;
-                       }
-
-                       dbm_close(db);
-                       lkclose(lockfd, file);
-                       free(cp);
-                       fclose(in);
-                       return result;
-                       break;
-
-               case BODY:
-               case BODYEOF:
-               case FILEEOF:
-                       break;
-
-               case LENERR:
-               case FMTERR:
-               default:
-                       break;
-               }
-
-               break;
-       }
-
-       fclose(in);
-       return 0;
-}