diff -rau dbmail/auth/authsql.c dbmail-2.0rc2-fixes-snap2/auth/authsql.c
--- dbmail/auth/authsql.c	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/auth/authsql.c	2004-02-27 10:54:00.000000000 -0800
@@ -613,7 +613,7 @@
 
   if (__auth_query(__auth_query_data) == -1) {
       trace(TRACE_ERROR,"%s,%s: could not change client id for user [%llu]",
-			  user_idnr);
+		  __FILE__, __FUNCTION__, user_idnr);
 	  db_store_auth_result();
       return -1;
   }
Only in dbmail-2.0rc2-fixes-snap2/auth: authsql.c~
diff -rau dbmail/bounce.c dbmail-2.0rc2-fixes-snap2/bounce.c
--- dbmail/bounce.c	2004-03-01 05:14:30.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/bounce.c	2004-02-27 10:56:18.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: bounce.c,v 1.28 2004/03/01 10:48:06 ilja Exp $
+/* $Id: bounce.c,v 1.26.2.1 2004/02/04 12:45:48 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  *
  * Bounce.c implements functions to bounce email back to a sender 
@@ -33,6 +33,7 @@
 #include "mime.h"
 #include "db.h"
 #include "debug.h"
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -42,7 +43,7 @@
 
 int bounce(const char *header, const char *destination_address, bounce_reason_t reason)
 {
-  void *sendmail_stream;
+  FILE *sendmail_stream;
   char *sendmail_command = NULL;
   struct list from_addresses;
   struct element *tmpelement;
@@ -65,7 +66,7 @@
     trace(TRACE_FATAL, "%s,%s: POSTMASTER not configured "
 	  "(see config file). Stop.", __FILE__, __FUNCTION__);
 	  
-  trace (TRACE_DEBUG,"%s,%s: creating bounce message for bounce reason [%d]",
+  trace(TRACE_DEBUG,"%s,%s: creating bounce message for bounce reason [%d]",
 	 __FILE__, __FUNCTION__, reason);
 		
   if (!destination_address)
@@ -119,7 +120,7 @@
 
               trace (TRACE_INFO,"bounce(): opening pipe to command "
 	             "%s",sendmail_command);
-	      (FILE *)sendmail_stream=popen (sendmail_command,"w");
+	      sendmail_stream = popen(sendmail_command,"w");
 
 	      if (sendmail_stream==NULL)
 		{
@@ -128,22 +129,22 @@
 			"to %s", __FILE__, __FUNCTION__,sendmail);
 		  return -1;
 		}
-	      fprintf ((FILE *)sendmail_stream,"From: %s\n",dbmail_from_address);
-	      fprintf ((FILE *)sendmail_stream,"To: %s\n",(char *)tmpelement->data);
-	      fprintf ((FILE *)sendmail_stream,"Subject: DBMAIL: delivery failure\n");
-	      fprintf ((FILE *)sendmail_stream,"\n");
-	      fprintf ((FILE *)sendmail_stream,"This is the DBMAIL-SMTP program.\n\n");
-	      fprintf ((FILE *)sendmail_stream,"I'm sorry to inform you that your message, addressed to %s,\n",
+	      fprintf (sendmail_stream,"From: %s\n",dbmail_from_address);
+	      fprintf (sendmail_stream,"To: %s\n",(char *)tmpelement->data);
+	      fprintf (sendmail_stream,"Subject: DBMAIL: delivery failure\n");
+	      fprintf (sendmail_stream,"\n");
+	      fprintf (sendmail_stream,"This is the DBMAIL-SMTP program.\n\n");
+	      fprintf (sendmail_stream,"I'm sorry to inform you that your message, addressed to %s,\n",
 		       destination_address);
-	      fprintf ((FILE *)sendmail_stream,"could not be delivered due to the following error.\n\n");
-	      fprintf ((FILE *)sendmail_stream,"*** E-mail address %s is not known here. ***\n\n",destination_address);
-	      fprintf ((FILE *)sendmail_stream,"If you think this message is incorrect please contact %s.\n\n",postmaster);
-	      fprintf ((FILE *)sendmail_stream,"Header of your message follows...\n\n\n");
-	      fprintf ((FILE *)sendmail_stream,"--- header of your message ---\n");
-	      fprintf ((FILE *)sendmail_stream,"%s",header);
-	      fprintf ((FILE *)sendmail_stream,"--- end of header ---\n\n\n");
-	      fprintf ((FILE *)sendmail_stream,"\n.\n");
-	      pclose ((FILE *)sendmail_stream);
+	      fprintf (sendmail_stream,"could not be delivered due to the following error.\n\n");
+	      fprintf (sendmail_stream,"*** E-mail address %s is not known here. ***\n\n",destination_address);
+	      fprintf (sendmail_stream,"If you think this message is incorrect please contact %s.\n\n",postmaster);
+	      fprintf (sendmail_stream,"Header of your message follows...\n\n\n");
+	      fprintf (sendmail_stream,"--- header of your message ---\n");
+	      fprintf (sendmail_stream,"%s",header);
+	      fprintf (sendmail_stream,"--- end of header ---\n\n\n");
+	      fprintf (sendmail_stream,"\n.\n");
+	      pclose (sendmail_stream);
 
 	      /* jump forward to next recipient */
 	      tmpelement=tmpelement->nextnode;
@@ -197,7 +198,7 @@
 
               trace (TRACE_INFO,"bounce(): opening pipe to command "
 	             "%s",sendmail_command);
-	      (FILE *)sendmail_stream=popen (sendmail_command,"w");
+	      sendmail_stream=popen (sendmail_command,"w");
 
 	      if (sendmail_stream==NULL)
 		{
@@ -206,22 +207,22 @@
 			__FILE__, __FUNCTION__, sendmail);
 		  return -1;
 		}
-	      fprintf ((FILE *)sendmail_stream,"From: %s\n",dbmail_from_address);
-	      fprintf ((FILE *)sendmail_stream,"To: %s\n",(char *)tmpelement->data);
-	      fprintf ((FILE *)sendmail_stream,"Subject: DBMAIL: delivery failure\n");
-	      fprintf ((FILE *)sendmail_stream,"\n");
-	      fprintf ((FILE *)sendmail_stream,"This is the DBMAIL-SMTP program.\n\n");
-	      fprintf ((FILE *)sendmail_stream,"I'm sorry to inform you that your message, addressed to %s,\n",
+	      fprintf (sendmail_stream,"From: %s\n",dbmail_from_address);
+	      fprintf (sendmail_stream,"To: %s\n",(char *)tmpelement->data);
+	      fprintf (sendmail_stream,"Subject: DBMAIL: delivery failure\n");
+	      fprintf (sendmail_stream,"\n");
+	      fprintf (sendmail_stream,"This is the DBMAIL-SMTP program.\n\n");
+	      fprintf (sendmail_stream,"I'm sorry to inform you that your message, addressed to %s,\n",
 		       destination_address);
-	      fprintf ((FILE *)sendmail_stream,"could not be delivered due to the following error.\n\n");
-	      fprintf ((FILE *)sendmail_stream,"*** Mailbox of user %s is FULL ***\n\n",destination_address);
-	      fprintf ((FILE *)sendmail_stream,"If you think this message is incorrect please contact %s.\n\n",postmaster);
-	      fprintf ((FILE *)sendmail_stream,"Header of your message follows...\n\n\n");
-	      fprintf ((FILE *)sendmail_stream,"--- header of your message ---\n");
-	      fprintf ((FILE *)sendmail_stream,"%s",header);
-	      fprintf ((FILE *)sendmail_stream,"--- end of header ---\n\n\n");
-	      fprintf ((FILE *)sendmail_stream,"\n.\n");
-	      pclose ((FILE *)sendmail_stream);
+	      fprintf (sendmail_stream,"could not be delivered due to the following error.\n\n");
+	      fprintf (sendmail_stream,"*** Mailbox of user %s is FULL ***\n\n",destination_address);
+	      fprintf (sendmail_stream,"If you think this message is incorrect please contact %s.\n\n",postmaster);
+	      fprintf (sendmail_stream,"Header of your message follows...\n\n\n");
+	      fprintf (sendmail_stream,"--- header of your message ---\n");
+	      fprintf (sendmail_stream,"%s",header);
+	      fprintf (sendmail_stream,"--- end of header ---\n\n\n");
+	      fprintf (sendmail_stream,"\n.\n");
+	      pclose (sendmail_stream);
 
 	      /* jump forward to next recipient */
 	      tmpelement=tmpelement->nextnode;
Only in dbmail-2.0rc2-fixes-snap2: bounce.c~
diff -rau dbmail/config.c dbmail-2.0rc2-fixes-snap2/config.c
--- dbmail/config.c	2004-01-07 07:00:15.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/config.c	2004-02-27 10:55:42.000000000 -0800
@@ -142,7 +142,8 @@
       /* skip otherwise */
     } while (!serviceFound) ;
 
-  trace(TRACE_DEBUG, "ReadConfig(): config for %s read, found [%d] cfg_items", service, cfg_items->total_nodes);
+  trace(TRACE_DEBUG, "ReadConfig(): config for %s read, found [%ld] cfg_items",
+		  service, cfg_items->total_nodes);
   fclose(cfile);
   return 0;
 }
Only in dbmail-2.0rc2-fixes-snap2: config.c~
diff -rau dbmail/db.c dbmail-2.0rc2-fixes-snap2/db.c
--- dbmail/db.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/db.c	2004-02-27 11:01:48.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: db.c,v 1.12 2004/03/01 10:48:06 ilja Exp $ */
+/* $Id: db.c,v 1.10.2.1 2004/02/02 15:22:44 ilja Exp $ */
 /*
   Copyright (C) 1999-2003 IC & S  dbmail@ic-s.nl
 
@@ -125,7 +125,8 @@
 	     "WHERE user_idnr = '%llu'", curmail_size, user_idnr);
     if (db_query(query) == -1) {
 	trace(TRACE_ERROR, "%s,%s: error setting used quotum of "
-	      "[%llu] for user [%llu]", curmail_size, user_idnr);
+	      "[%llu] for user [%llu]",
+	      __FILE__, __FUNCTION__, curmail_size, user_idnr);
 	return -1;
     }
     return 0;
@@ -750,8 +751,8 @@
 		    __FILE__, __FUNCTION__);
 	      return -1;
 	}
-	 trace(TRACE_INFO, "%s,%s: message [%llu] updated, "
-	       "[%llu] bytes", uids[i], message_size);
+	 trace(TRACE_INFO, "%s,%s: message [%llu] updated, [%llu] bytes",
+	       __FILE__, __FUNCTION__, uids[i], message_size);
 
     }
     my_free(uids);
@@ -778,7 +779,7 @@
      }
 
      if (block_size > READ_BLOCK_SIZE) {
-	  trace(TRACE_ERROR, "%s,%s:blocksize [%llu], maximum is [%llu]",
+	  trace(TRACE_ERROR, "%s,%s: blocksize [%llu], maximum is [%ld]",
 		__FILE__, __FUNCTION__, block_size, READ_BLOCK_SIZE);
 	  return -1;
      }
@@ -860,8 +861,7 @@
     }
 
     if (block_size > READ_BLOCK_SIZE) {
-	trace(TRACE_ERROR,
-	      "%s,%s: blocksize [%llu], maximum is [%llu]",
+	trace(TRACE_ERROR, "%s,%s: blocksize [%llu], maximum is [%ld]",
 	      __FILE__, __FUNCTION__, block_size, READ_BLOCK_SIZE);
 	return -1;
     }
@@ -941,7 +941,7 @@
 	     "SELECT idnr FROM pbsp WHERE ipnumber = '%s'", ip);
     if (db_query(query) == -1) {
 	trace(TRACE_ERROR, "%s,%s: could not access ip-log table "
-	      "(pop/imap-before-smtp): %s", __FILE__, __FUNCTION__);
+	      "(pop/imap-before-smtp): %s", __FILE__, __FUNCTION__, ip);
 	return -1;
     }
 
@@ -1418,7 +1418,7 @@
 	    
 	    if (db_query(query) == -1) {
 		    trace(TRACE_ERROR, "%s,%s: could not delete mailbox [%llu]",
-			  mailbox_idnr);
+			  __FILE__, __FUNCTION__, mailbox_idnr);
 		    return -1;
 	    }
     }
@@ -1432,7 +1432,7 @@
     if (db_query(query) == -1) {
 	trace(TRACE_ERROR,
 	      "%s,%s: could not select message ID's for mailbox [%llu]",
-	      mailbox_idnr);
+	      __FILE__, __FUNCTION__, mailbox_idnr);
 	return -1;
     }
 
@@ -1478,7 +1478,7 @@
     int n;
     char *query_result;
 
-    trace(TRACE_DEBUG, "%s,%s: request for [%d] lines",
+    trace(TRACE_DEBUG, "%s,%s: request for [%ld] lines",
 	  __FILE__, __FUNCTION__, lines);
 
     /* first find the physmessage_id */
@@ -1507,7 +1507,7 @@
 	return 0;
     }
 
-    trace(TRACE_DEBUG, "%s,%s: sending [%d] lines from message [%llu]",
+    trace(TRACE_DEBUG, "%s,%s: sending [%ld] lines from message [%llu]",
 	  __FILE__, __FUNCTION__, lines, message_idnr);
 
     block_count = 0;
@@ -1829,7 +1829,7 @@
     if (((currmail_size) > maxmail_size) && (maxmail_size != 0)) {
 	 trace(TRACE_INFO, "%s,%s: mailboxsize of useridnr "
 	       "%llu exceed with %llu bytes\n",
-	       *user_idnr, (currmail_size) - maxmail_size);
+	       __FILE__, __FUNCTION__, *user_idnr, (currmail_size) - maxmail_size);
 	 
 	 /* user is exceeding, we're going to execute a rollback now */
 	 if (db_delete_message(message_idnr) < 0) {
@@ -1945,12 +1945,13 @@
 
 	if (db_insert_message_block(msgdata, count, message_idnr,
 				    &messageblk_idnr) == -1) {
-	    trace(TRACE_ERROR, "%s,%s: could not insert msg block\n");
+	    trace(TRACE_ERROR, "%s,%s: could not insert msg block\n",
+			    __FILE__, __FUNCTION__);
 	    if (db_delete_message(message_idnr) == -1) {
 		trace(TRACE_ERROR,
 		      "%s,%s: could not delete invalid message"
-		      "%llu. Database could be  invalid now..", __FILE__,
-		      __FUNCTION__, message_idnr);
+		      "%llu. Database could be  invalid now..",
+		      __FILE__, __FUNCTION__, message_idnr);
 	    }
 	    return -1;
 	}
@@ -2702,10 +2703,10 @@
 	      "answered_flag, deleted_flag, flagged_flag, recent_flag, "
 	     "draft_flag, unique_id, status) VALUES "
 	      "('%llu', '%s', '%s', '%s', '%s', "
-	      "'%s', '1', '%s', 'dummy', '%s')",
+	      "'%s', '%s', '%s', 'dummy', '%s')",
 	      mailbox_to, db_get_result(0, 0), db_get_result(0, 1), 
 	      db_get_result(0, 2), db_get_result(0, 3), db_get_result(0, 4), 
-	      db_get_result(0, 6), db_get_result(0,7));
+	      db_get_result(0, 5), db_get_result(0, 6), db_get_result(0,7));
      
      db_free_result();
      if (db_query(query) == -1) {
@@ -3309,7 +3310,7 @@
     if (result == -1) {
 	/* parse error */
 	trace(TRACE_ERROR, "%s,%s: error parsing header of message [%llu]",
-	      msg_idnr);
+	      __FILE__, __FUNCTION__, msg_idnr);
 	if (hdrlist->start) {
 	    list_freelist(&hdrlist->start);
 	    list_init(hdrlist);
@@ -3463,7 +3464,7 @@
 
 	if (db_query(query) < 0) {
 		trace(TRACE_ERROR, "%s,%s: Error creating ACL entry for user "
-		      "[%llu], mailbox [%llu]."
+		      "[%llu], mailbox [%llu].",
 		      __FILE__, __FUNCTION__, userid, mboxid);
 		return -1;
 	}
Only in dbmail-2.0rc2-fixes-snap2: db.c~
Only in dbmail-2.0rc2-fixes-snap2: dbmd5.c~
diff -rau dbmail/dbmsgbuf.c dbmail-2.0rc2-fixes-snap2/dbmsgbuf.c
--- dbmail/dbmsgbuf.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/dbmsgbuf.c	2004-02-27 10:52:12.000000000 -0800
@@ -35,7 +35,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#define MSGBUF_WINDOWSIZE (128ul*1024ul)
+#define MSGBUF_WINDOWSIZE (128ull*1024ull)
 
 static unsigned _msgrow_idx = 0;
 static int _msg_fetch_inited = 0;
Only in dbmail-2.0rc2-fixes-snap2: dbmsgbuf.c~
diff -rau dbmail/dbmsgbuf.h dbmail-2.0rc2-fixes-snap2/dbmsgbuf.h
--- dbmail/dbmsgbuf.h	2004-01-07 07:00:16.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/dbmsgbuf.h	2004-02-27 10:51:40.000000000 -0800
@@ -39,14 +39,10 @@
 
 #define MSGBUF_FORCE_UPDATE -1
 
-/**
- * \todo change names of msgbuf, msgidx and buflen to msgbuf_buf, msgbuf_idx
- *       and msgbuf_buflen to "simulate namespace
- */
-
 char *msgbuf_buf;/**< the message buffer */
 u64_t msgbuf_idx;/**< index within msgbuf, 0 <= msgidx < buflen */
 u64_t msgbuf_buflen;/**< current buffer length: msgbuf[buflen] == '\\0' */
+
 /**
  * \brief initialises a message fetch
  * \param msg_idnr 
Only in dbmail-2.0rc2-fixes-snap2: dbmsgbuf.h~
diff -rau dbmail/debug.c dbmail-2.0rc2-fixes-snap2/debug.c
--- dbmail/debug.c	2004-01-07 07:00:16.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/debug.c	2004-02-27 10:47:39.000000000 -0800
@@ -55,21 +55,21 @@
 /*
  * configure the debug settings
  */
-void configure_debug(int level, int trace_syslog, int trace_verbose)
+void configure_debug(trace_t level, int trace_syslog, int trace_verbose)
 {
   TRACE_LEVEL = level;
   TRACE_TO_SYSLOG = trace_syslog;
   TRACE_VERBOSE = trace_verbose;
 }
 
-void func_memtst (const char *filename,int line,int tst)
+void func_memtst(const char *filename,int line,int tst)
 {
   if (tst != 0) 
     trace(TRACE_FATAL,"func_memtst(): fatal: %s:%d Memory error, result should not be NULL)",
 	  filename,line);
 }
 
-void trace (int level, char *formatstring, ...)
+void trace(trace_t level, char *formatstring, ...)
 {
   va_list argp;
   
Only in dbmail-2.0rc2-fixes-snap2: debug.c~
diff -rau dbmail/debug.h dbmail-2.0rc2-fixes-snap2/debug.h
--- dbmail/debug.h	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/debug.h	2004-02-27 10:47:55.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/*	$Id: debug.h,v 1.42 2004/03/01 10:48:06 ilja Exp $
+/*	$Id: debug.h,v 1.41 2004/01/07 15:00:16 ilja Exp $
  *	(c) 2000-2002 IC&S, The Netherlands
  *
  *	debug.h : headers for debug.c */
@@ -39,16 +39,15 @@
 extern int TRACE_LEVEL;     /* 5: maximum debugging */
                             /* 2: normal operations */
 
-/**
-   \todo change from #defines to enum!
-*/
-#define TRACE_FATAL -1
-#define TRACE_STOP 0
-#define TRACE_MESSAGE 1
-#define TRACE_ERROR 2
-#define TRACE_WARNING 3
-#define TRACE_INFO 4
-#define TRACE_DEBUG 5
+typedef enum {
+    TRACE_FATAL = -1,
+    TRACE_STOP,
+    TRACE_MESSAGE,
+    TRACE_ERROR,
+    TRACE_WARNING,
+    TRACE_INFO,
+    TRACE_DEBUG
+} trace_t;
 
 #define memtst(tstbool) func_memtst (__FILE__,__LINE__,tstbool)
 
@@ -65,11 +64,10 @@
 #endif
 
 
-void func_memtst (const char *filename,int line,int tst);
-
-void trace (int level, char *formatstring, ...);
-
-void configure_debug(int level, int trace_syslog, int trace_verbose);
+void func_memtst(const char *filename, int line, int tst);
+void trace(trace_t level, char *formatstring, ...)
+	 __attribute__((format(printf, 2, 3)));
+void configure_debug(trace_t level, int trace_syslog, int trace_verbose);
 
 void* __debug_malloc(unsigned long size, const char *fname, int linenr);
 void __debug_free(void *ptr, const char *fname, int linenr);
Only in dbmail-2.0rc2-fixes-snap2: debug.h~
diff -rau dbmail/forward.c dbmail-2.0rc2-fixes-snap2/forward.c
--- dbmail/forward.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/forward.c	2004-02-27 11:07:39.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: forward.c,v 1.29 2004/03/01 10:48:06 ilja Exp $
+/* $Id: forward.c,v 1.28 2004/01/30 16:24:35 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  *
  * takes care of forwarding mail to an external address */
@@ -68,11 +68,12 @@
   if (sendmail[0] == '\0')
     trace(TRACE_FATAL, "forward(): SENDMAIL not configured (see config file). Stop.");
   
-  trace (TRACE_INFO,"forward(): delivering to %d external addresses", list_totalnodes(targets));
+  trace(TRACE_INFO, "forward(): delivering to [%ld] external addresses",
+		  list_totalnodes(targets));
 
   if (!msgidnr)
     {
-      trace(TRACE_ERROR,"forward(): got NULL as message id number");
+      trace(TRACE_ERROR, "forward(): got NULL as message id number");
       return -1;
     }
   
@@ -103,37 +104,38 @@
 	      return -1;
 	    }
 
-	  trace (TRACE_DEBUG,"forward(): allocated memory for external command call");
-	  sprintf (command, "%s %s",sendmail, (char *)(target->data));
+	  trace(TRACE_DEBUG, "forward(): allocated memory for external command call");
+	  sprintf (command, "%s %s", sendmail, (char *)(target->data));
 	}
 
-      trace (TRACE_INFO,"forward(): opening pipe to command %s", command);
+      trace(TRACE_INFO, "forward(): opening pipe to command %s", command);
 	
-      pipe = popen(command,"w"); /* opening pipe */
+      pipe = popen(command, "w"); /* opening pipe */
       my_free (command);
       command = NULL;
 
       if (pipe != NULL)
 	{
-	  trace (TRACE_DEBUG,"forward(): call to popen() successfully opened pipe %d", fileno(pipe));
+	  trace(TRACE_DEBUG, "forward(): call to popen() successfully opened pipe [%d]",
+			  fileno(pipe));
 			
           if (((char *)target->data)[0]=='!')
             {
               /* ! tells us to prepend an mbox style header in this pipe */
-              trace (TRACE_DEBUG,"forward(): appending mbox style from header to pipe returnpath : %s", from);
+              trace(TRACE_DEBUG, "forward(): appending mbox style from header to pipe returnpath : %s", from);
               /* format: From<space>address<space><space>Date */
               fprintf (pipe, "From %s  %s\n", from, timestr);   
             }
 
           /* first send header if this is a direct pipe through */
           fprintf (pipe, "%s", header);
-          trace (TRACE_DEBUG,"forward(): wrote header to pipe");  
+          trace(TRACE_DEBUG, "forward(): wrote header to pipe");  
 
-	  trace (TRACE_INFO,"forward(): sending message id number [%llu] to forward pipe", msgidnr);
+	  trace(TRACE_INFO, "forward(): sending message id number [%llu] to forward pipe", msgidnr);
 			
           err = ferror(pipe);
 
-          trace (TRACE_DEBUG, "forward(): ferror reports"
+          trace(TRACE_DEBUG, "forward(): ferror reports"
               " %d, feof reports %d on pipe %d", err,
               feof (pipe),
               fileno (pipe));
@@ -142,27 +144,27 @@
             {
               if (msgidnr != 0)
                 {
-                  trace (TRACE_DEBUG, "forward(): sending lines from"
+                  trace(TRACE_DEBUG, "forward(): sending lines from"
                       "message %llu on pipe %d", msgidnr, fileno(pipe));
                   db_send_message_lines (pipe, msgidnr, -2, 1);
                 }
             }
 
-	  trace (TRACE_DEBUG, "forward(): closing pipes");
+	  trace(TRACE_DEBUG, "forward(): closing pipes");
 
           if (!ferror(pipe))
             {
               pclose (pipe);
-              trace (TRACE_DEBUG, "forward(): pipe closed");
+              trace(TRACE_DEBUG, "forward(): pipe closed");
             }
           else
             {
-              trace (TRACE_ERROR,"forward(): error on pipe");
+              trace(TRACE_ERROR, "forward(): error on pipe");
             }
         }
       else 
         {
-          trace (TRACE_ERROR,"forward(): Could not open pipe to" " [%s]",sendmail);
+          trace(TRACE_ERROR, "forward(): Could not open pipe to [%s]", sendmail);
         }
       target = target->nextnode;
     }
Only in dbmail-2.0rc2-fixes-snap2: forward.c~
diff -rau dbmail/header.c dbmail-2.0rc2-fixes-snap2/header.c
--- dbmail/header.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/header.c	2004-02-27 10:02:46.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: header.c,v 1.3 2004/03/01 10:48:06 ilja Exp $
+/* $Id: header.c,v 1.1 2004/01/30 16:54:11 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  *
  * Header.c implements functions to read an email header
@@ -32,9 +32,10 @@
 
 /* Reads from the specified pipe until either a lone carriage
  * return or lone period stand on a line by themselves. The
- * number of newlines is recorded along the way. The variable
- * "header" should be passed by & reference, and should be
- * defined (duh) but not malloc'ed (honest) before calling.
+ * number of non-\r\n newlines is recorded along the way.
+ * The variable "header" should be passed by & reference,
+ * and should be defined (duh) but not malloc'ed (honest)
+ * before calling.
  *
  * The caller is responsible for free'ing header, even upon error.
  *
@@ -42,38 +43,42 @@
  *   1 on success
  *   0 on failure
  * */
-int read_header(FILE *instream, u64_t *newlines, u64_t *headersize, char **header)
+int read_header(FILE *instream, u64_t *headerrfcsize, u64_t *headersize, char **header)
 {
   char *tmpline;
   char *tmpheader;
-  int usedmem=0, linemem=0; 
+  u64_t tmpheadersize=0, tmpheaderrfcsize=0;
+  size_t usedmem=0, linemem=0; 
+  size_t allocated_blocks=1;
   int myeof=0;
-  int allocated_blocks=1;
 
-  *headersize = 0;
-  *newlines = 0;
-	
-  memtst ((tmpheader = (char *)my_malloc(HEADER_BLOCK_SIZE))==NULL);
-  memtst ((tmpline = (char *)my_malloc(MAX_LINE_SIZE))==NULL);
+  memtst((tmpheader = (char *)my_malloc(HEADER_BLOCK_SIZE))==NULL);
+  memtst((tmpline = (char *)my_malloc(MAX_LINE_SIZE))==NULL);
 
   /* Resetting */
-  memset (tmpline, '\0', MAX_LINE_SIZE);
-  memset (tmpheader, '\0', HEADER_BLOCK_SIZE);
+  memset(tmpline, '\0', MAX_LINE_SIZE);
+  memset(tmpheader, '\0', HEADER_BLOCK_SIZE);
   
   /* here we will start a loop to read in the message header */
   /* the header will be everything up until \n\n or an EOF of */
   /* in_stream (instream) */
 	
-  trace (TRACE_INFO, "read_header(): readheader start\n");
+  trace(TRACE_INFO, "read_header(): readheader start\n");
 
   while (!feof(instream) && !myeof)
     {
       /* fgets will read until \n occurs, and \n is *included* in tmpline */
       if (!fgets(tmpline, MAX_LINE_SIZE, instream))
-	  break;
+          break;
       linemem = strlen(tmpline);
-      (*headersize) += linemem;
-      (*newlines)++;
+      tmpheadersize += linemem;
+      tmpheaderrfcsize += linemem;
+      /* The RFC size assumes all lines end in \r\n,
+       * so if we have a newline (\n) but don't have
+       * a carriage return (\r), count it in rfcsize. */
+      if (tmpline[linemem-1] == '\n')
+          if (tmpline[linemem-2] != '\r')
+              tmpheaderrfcsize++;
 
       if (ferror(instream))
         {
@@ -145,6 +150,8 @@
 
   /* Assign to the external variable */
   *header = tmpheader;
+  *headersize = tmpheadersize;
+  *headerrfcsize = tmpheaderrfcsize;
 
   /* The caller is responsible for freeing header/tmpheader. */
 
@@ -153,194 +160,3 @@
 }
 
 
-
-/*
- * read_header_process()
- *
- * Reads in a mail header (from instream, reading is done until '\n\n' is encountered).
- * If field != NULL scanning is done for delivery on that particular field.
- *
- * Data is saved in hdrdata which should be capable of holding at least READ_BLOCK_SIZE characters.
- *
- * returns data cnt on success, -1 on failure
- */
-int read_header_process(FILE *instream, struct list *userids, struct list *bounces, struct list *fwds, 
-			const char *field, char *hdrdata, u64_t *newlines, char **bounce_path)
-{
-  int len = field ? strlen(field) : 0;
-  char *left, *right, *curr, save, *line;
-  char *frompath = 0;
-  unsigned cnt = 0;
-  *newlines = 0;
-  *bounce_path = 0;
-
-  while (!feof(instream) && !ferror(instream) && cnt < READ_BLOCK_SIZE)
-    {
-      line = &hdrdata[cnt]; /* write directly to hdrdata */
-      fgets(line, READ_BLOCK_SIZE - cnt, instream);
-      (*newlines)++;
-
-      cnt += strlen(line);
-
-      if (strcmp(line, "\n") == 0)
-	break;
-
-      if (field && strncasecmp(line, field, len) == 0 && line[len] == ':' && line[len+1] == ' ')
-	{
-	  /* found the field we're scanning for */
-	  trace(TRACE_DEBUG, "read_header_process(): found field");
-	      
-	  curr = &line[len];
-
-	  while (curr && *curr)
-	    {
-	      left = strchr(curr, '@');
-	      if (!left)
-		break;
-
-	      right = left;
-
-	      /* walk to the left */
-	      while (left != line && left[0]!='<' && left[0]!=' ' && left[0]!='\0' && left[0]!=',')
-		left--;
-		  
-	      left++; /* walked one back too far */
-		  
-	      /* walk to the right */
-	      while (right[0]!='>' && right[0]!=' ' && right[0]!='\0' && right[0]!=',')
-		right++;
-		  
-	      save = *right;
-	      *right = 0; /* terminate string */
-	      
-	      if (add_address(left, userids, bounces, fwds) != 0)
-		trace(TRACE_ERROR,"read_header_process(): could not add [%s]", left);
-
-	      trace(TRACE_DEBUG,"read_header_process(): processed [%s]", left);
-	      *right = save;
-	      curr = right;
-	    }
-	}
-      else if (field && !(*bounce_path) && strncasecmp(line, "return-path", strlen("return-path")) == 0)
-	{
-	  /* found return-path */
-	  *bounce_path = (char*)my_malloc(strlen(line));
-	  if (!(*bounce_path))
-	    return -1;
-
-	  left = strchr(line, ':');
-	  if (left)
-	    strcpy(*bounce_path, &left[1]);
-	  else
-	    {
-	      my_free(bounce_path);
-	      bounce_path = 0;
-	    }
-	}
-      else if (field && !(*bounce_path) && !frompath && strncasecmp(line, "from", strlen("from")) == 0)
-	{
-	  /* found from field */
-	  frompath = (char*)my_malloc(strlen(line));
-	  if (!frompath)
-	    return -1;
-
-	  left = strchr(line, ':');
-	  if (left)
-	    strcpy(frompath, &left[1]);
-	  else
-	    {
-	      my_free(frompath);
-	      frompath = 0;
-	    }
-	}
-    }
-	
-  if (frompath)
-    {
-      if (!(*bounce_path))
-	*bounce_path = frompath;
-      else
-	my_free(frompath);
-    }
-
-  trace(TRACE_DEBUG,"read_header_process(): found bounce path [%s]", *bounce_path ? *bounce_path : "<<none>>");
-
-  return cnt;
-}
-
-
-/*
- * add_address()
- *
- * takes an e-mail address and finds the correct delivery for it:
- * internal (numeric id), bounce, forward
- *
- * returns 0 on success, -1 on failure
- */
-int add_address(const char *address, struct list *userids, struct list *bounces, struct list *fwds)
-{
-  char *domain;
-
-  if (auth_check_user_ext(address, userids, fwds, -1) == 0)
-    {
-      /* not in alias table
-       * check for a domain fwd first; if none present
-       * then make it a bounce
-       */
-      
-      domain = strchr(address, '@');
-      if (!domain)
-	{
-	  /* ?? no '@' in address ? */
-	  trace(TRACE_ERROR, "add_address(): got invalid address [%s]", address);
-	}
-      else
-	{
-	  if (auth_check_user_ext(domain, userids, fwds, -1) == 0)
-	    {
-	      /* ok no domain fwds either --> bounce */
-	      if (list_nodeadd(bounces, address, strlen(address)+1) == 0)
-		{
-		  trace(TRACE_ERROR, "add_address(): could not add bounce [%s]", address);
-		  return -1;
-		}
-	    }
-	}
-    }
-
-  return 0;
-}
-      
-
-/*
- * add_username()
- *
- * adds the (numeric) ID of the user uname to the list of ids.
- *
- * returns 0 on success, -1 on failure
- */
-int add_username(const char *uname, struct list *userids)
-{
-  u64_t uid;
-
-  switch(auth_user_exists(uname, &uid))
-    {
-    case -1:
-      trace(TRACE_ERROR,"add_username(): error verifying user existence");
-      return -1;
-    case 0:
-      trace(TRACE_INFO,"add_username(): non-existent user specified");
-      return -1;
-    default:
-      trace(TRACE_DEBUG,"add_username(): adding user [%s] id [%llu] to list", uname, uid);
-      if (list_nodeadd(userids, &uid, sizeof(uid)) == NULL)
-	{
-	  trace(TRACE_ERROR,"add_username(): out of memory");
-	  list_freelist(&userids->start);
-	  return -1;
-	}
-    }
-  
-  return 0;
-}
-
Only in dbmail-2.0rc2-fixes-snap2: header.c~
diff -rau dbmail/header.h dbmail-2.0rc2-fixes-snap2/header.h
--- dbmail/header.h	2004-01-30 08:54:11.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/header.h	2004-02-27 09:23:02.000000000 -0800
@@ -10,13 +10,19 @@
 
 #include "list.h"
 
+/**
+ * \brief Read from the specified FILE pointer until either
+ * a long carriage-return line-feed or a lone period stand
+ * on a line by themselves.
+ * \param instream A FILE pointer to the stream where the header is.
+ * \param headerrfcsize The size of the header if all lines ended in \r\n.
+ * \param headersize The actual byte count of the header.
+ * \param header A pointer to an unallocated char array. On
+ * error, the pointer may not be valid and must not be used.
+ * \return
+ *      - 1 on success
+ *      - 0 on failure
+*/
 int read_header(FILE *instream, u64_t *newlines, u64_t *headersize, char **header);
-int read_header_process(FILE *instream, struct list *userids,
-		struct list *bounces, struct list *fwds,
-		const char *field, char *hdrdata,
-		u64_t *newlines, char **bounce_path);
-int add_address(const char *address, struct list *userids,
-		struct list *bounces, struct list *fwds);
-int add_username(const char *uname, struct list *userids);
 
 #endif
Only in dbmail-2.0rc2-fixes-snap2: header.h~
Only in dbmail-2.0rc2-fixes-snap2: headers.txt
Only in dbmail-2.0rc2-fixes-snap2: headers.txt~
Only in dbmail-2.0rc2-fixes-snap2: HugeOthello.txt
diff -rau dbmail/lmtp.c dbmail-2.0rc2-fixes-snap2/lmtp.c
--- dbmail/lmtp.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/lmtp.c	2004-02-27 11:21:48.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: lmtp.c,v 1.2 2004/03/01 10:48:06 ilja Exp $
+/* $Id: lmtp.c,v 1.1 2004/01/30 16:54:11 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  *
  * implementation for lmtp commands according to RFC 1081 */
@@ -42,7 +42,7 @@
 char *envelopefrom = NULL;
 
 /* allowed lmtp commands */
-const char *commands [] =
+const char * const commands [] =
 {
   "LHLO", "QUIT", "RSET", "DATA", "MAIL",
   "VRFY", "EXPN", "HELP", "NOOP", "RCPT"
@@ -182,7 +182,8 @@
     return 1;
   }
 
-
+int lmtp_error(PopSession_t *session, void *stream, const char *formatstring, ...)
+	__attribute__((format(printf, 3, 4)));
 int lmtp_error(PopSession_t *session, void *stream, const char *formatstring, ...)
 {
   va_list argp;
@@ -317,7 +318,7 @@
           int helpcmd;
  
           if (value == NULL)
-            return 1;
+            helpcmd = LMTP_END;
           else
             for (helpcmd = LMTP_STRT; helpcmd < LMTP_END; helpcmd++)
               if (strcasecmp(value, commands[helpcmd]) == 0) break;
@@ -328,11 +329,11 @@
               (helpcmd==LMTP_RSET) || (helpcmd==LMTP_QUIT) ||
               (helpcmd==LMTP_NOOP) || (helpcmd==LMTP_HELP) )
             {
-              fprintf((FILE *)stream, LMTP_HELP_TEXT[helpcmd]);
+              fprintf((FILE *)stream, "%s", LMTP_HELP_TEXT[helpcmd]);
             }
           else
             {
-              fprintf((FILE *)stream, LMTP_HELP_TEXT[LMTP_STRT]);
+              fprintf((FILE *)stream, "%s", LMTP_HELP_TEXT[LMTP_END]);
             }
  
           return 1;
@@ -576,7 +577,7 @@
 	    /* Anonymous Block */
 	      {
 	        char *header = NULL;
-                u64_t headersize=0, newlines=0;
+                u64_t headersize=0, headerrfcsize=0;
                 u64_t dummyidx=0,dummysize=0;
                 struct list fromlist, headerfields;
                 struct element *element;
@@ -589,18 +590,16 @@
                 /* We know this to be true from the 354 code, above. */
                 list_nodeadd(&fromlist, envelopefrom, strlen(envelopefrom));
 
-                if (!read_header((FILE *)instream, &newlines, &headersize, &header))
+                if (!read_header((FILE *)instream, &headerrfcsize, &headersize, &header))
 		  {
                     trace(TRACE_ERROR,"main(): fatal error from read_header()");
                     fprintf((FILE *)stream, "500 Error reading header.\r\n" );
 		    return 1;
 		  }
 
-                trace(TRACE_ERROR,"main(): lines of read_header() header is [%d]", newlines);
-       
                 if (header != NULL)
 		  {
-                    trace(TRACE_ERROR,"main(): size of read_header() header is [%d]", headersize);
+                    trace(TRACE_ERROR,"main(): size of read_header() header is [%llu]", headersize);
 		  }
                 else
                   {
@@ -611,14 +610,15 @@
 
                 /* Parse the list and scan for field and content */
                 if (mime_readheader(header, &dummyidx, &mimelist, &dummysize) < 0)
-		  {
+                  {
                     trace(TRACE_ERROR,"main(): fatal error from mime_readheader()");
                     fprintf((FILE *)stream, "500 Error reading header.\r\n" );
-		    return 1;
-		  }
+                    return 1;
+                  }
 
-	        if (insert_messages((FILE *)instream, header, headersize,
-				&headerfields, &rcpt, &fromlist) == -1)
+	        if (insert_messages((FILE *)instream,
+                                    header, headersize, headerrfcsize,
+                                    &headerfields, &rcpt, &fromlist) == -1)
                   {
                     fprintf((FILE *)stream, "503 Message not received\r\n");
                   }
Only in dbmail-2.0rc2-fixes-snap2: lmtp.c~
diff -rau dbmail/lmtpd.c dbmail-2.0rc2-fixes-snap2/lmtpd.c
--- dbmail/lmtpd.c	2004-03-01 05:14:31.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/lmtpd.c	2004-02-14 16:43:09.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: lmtpd.c,v 1.2 2004/03/01 10:48:06 ilja Exp $
+/* $Id: lmtpd.c,v 1.1 2004/01/30 16:54:11 ilja Exp $
 * (c) 2000-2002 IC&S, The Netherlands
 *
 * lmtpd.c
@@ -71,7 +71,7 @@
     {
       if (strcmp (argv[1],"-v") == 0)
         {
-          printf ("\n*** DBMAIL: dbmail-lmtpd version $Revision: 1.2 $ %s\n\n",COPYRIGHT);
+          printf ("\n*** DBMAIL: dbmail-lmtpd version $Revision: 1.1 $ %s\n\n",COPYRIGHT);
           return 0;
         }
       else
diff -rau dbmail/lmtp.h dbmail-2.0rc2-fixes-snap2/lmtp.h
--- dbmail/lmtp.h	2004-01-30 08:54:11.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/lmtp.h	2004-02-26 23:16:28.000000000 -0800
@@ -141,44 +141,64 @@
 
 /* Help */
 static const char * const LMTP_HELP_TEXT[] = {
-/* LMTP_STRT */
-  "214-This is DBMail-LMTP.\r\n"
-  "214-The following commands are supported:\r\n"
-  "214-LHLO, RSET, NOOP, QUIT, HELP.\r\n"
-  "214-VRFY, EXPN, MAIL, RCPT, DATA.\r\n"
-  "214-For more information about a command:\r\n"
-  "214 Use HELP <command>.\r\n"
-/* LMTP_LHLO */ ,
+/* LMTP_LHLO 0 */
   "214-The LHLO command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* LMTP_DATA */ ,
-  "214-The LHLO command begins a client/server\r\n"
+/* LMTP_QUIT 1 */ ,
+  "214-The QUIT command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* LMTP_RSET */ ,
-  "214-The LHLO command begins a client/server\r\n"
+/* LMTP_RSET 2 */ ,
+  "214-The RSET command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* LMTP_QUIT */ ,
-  "214-The LHLO command begins a client/server\r\n"
+/* LMTP_DATA 3 */ ,
+  "214-The DATA command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* LMTP_NOOP */ ,
-  "214-The LHLO command begins a client/server\r\n"
+/* LMTP_MAIL 4 */ ,
+  "214-The MAIL command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* LMTP_HELP */ ,
-  "214-The LHLO command begins a client/server\r\n"
+/* LMTP_VRFY 5 */ ,
+  "214-The VRFY command begins a client/server\r\n"
   "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
   "214-may only be issued after a successful LHLO.\r\n"
   "214 Syntax: LHLO [your hostname]\r\n"
-/* For good measure. */ ,
+/* LMTP_EXPN 6 */ ,
+  "214-The EXPN command begins a client/server\r\n"
+  "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
+  "214-may only be issued after a successful LHLO.\r\n"
+  "214 Syntax: LHLO [your hostname]\r\n"
+/* LMTP_HELP 7 */ ,
+  "214-The HELP command begins a client/server\r\n"
+  "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
+  "214-may only be issued after a successful LHLO.\r\n"
+  "214 Syntax: LHLO [your hostname]\r\n"
+/* LMTP_NOOP 8 */ ,
+  "214-The NOOP command begins a client/server\r\n"
+  "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
+  "214-may only be issued after a successful LHLO.\r\n"
+  "214 Syntax: LHLO [your hostname]\r\n"
+/* LMTP_RCPT 9 */ ,
+  "214-The RCPT command begins a client/server\r\n"
+  "214-dialogue. The commands MAIL, RCPT and DATA\r\n"
+  "214-may only be issued after a successful LHLO.\r\n"
+  "214 Syntax: LHLO [your hostname]\r\n"
+/* LMTP_END 10 */ ,
+  "214-This is DBMail-LMTP.\r\n"
+  "214-The following commands are supported:\r\n"
+  "214-LHLO, RSET, NOOP, QUIT, HELP.\r\n"
+  "214-VRFY, EXPN, MAIL, RCPT, DATA.\r\n"
+  "214-For more information about a command:\r\n"
+  "214 Use HELP <command>.\r\n"
+/* For good measure... */ ,
   NULL
 };
 
Only in dbmail-2.0rc2-fixes-snap2: lmtp.h~
diff -rau dbmail/main.c dbmail-2.0rc2-fixes-snap2/main.c
--- dbmail/main.c	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/main.c	2004-02-27 10:03:16.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: main.c,v 1.44 2004/03/01 10:48:06 ilja Exp $
+/* $Id: main.c,v 1.43 2004/01/30 16:24:35 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  * 
  * main file for dbmail-smtp  */
@@ -66,12 +66,11 @@
 char *header = NULL;
 char *deliver_to_header = NULL;
 char *deliver_to_mailbox = NULL;
-u64_t headersize;
-u64_t newlines;
+u64_t headersize, headerrfcsize;
 
 void print_usage(const char *progname)
 {
-  printf("\n*** DBMAIL: dbmail-smtp version $Revision: 1.44 $ %s\n",
+  printf("\n*** DBMAIL: dbmail-smtp version $Revision: 1.43 $ %s\n",
              COPYRIGHT);
   printf("\nUsage: %s -n [headerfield]   for normal deliveries (default: \"deliver-to\")\n",
              progname);
@@ -232,7 +231,7 @@
     }
 
   /* first we need to read the header */
-  if (!read_header(stdin, &newlines, &headersize, &header))
+  if (!read_header(stdin, &headerrfcsize, &headersize, &header))
     {
       trace(TRACE_ERROR, "main(): read_header failed to read a header");
       exitcode = EX_TEMPFAIL;
@@ -259,10 +258,11 @@
   if (deliver_to_header != NULL)
     {
       /* parse for destination addresses */
-      trace(TRACE_DEBUG, "main(): scanning mimelist for header [%s]", deliver_to_header);
+      trace(TRACE_DEBUG, "main(): scanning for [%s]",
+            deliver_to_header);
       if (mail_adr_list(deliver_to_header, &users, &mimelist) !=0)
         {
-          trace(TRACE_ERROR, "main(): scanner found no email addresses (scanned for %s)", 
+          trace(TRACE_STOP, "main(): scanner found no email addresses (scanned for %s)", 
                 deliver_to_header);
           exitcode = EX_TEMPFAIL;
           goto freeall;
@@ -275,36 +275,15 @@
   
           dsnuser_init(&dsnuser);
           dsnuser.address = strdup((char *)tmp->data);
-
-          if (list_nodeadd(&dsnusers, &dsnuser, sizeof(deliver_to_user_t)) == 0)
-            {
-              trace(TRACE_ERROR, "main(): list_nodeadd reports out of memory"
-                              " while adding to dsnusers");
-              exitcode = EX_TEMPFAIL;
-	      /* If the struct was not added to the list,
-	       * then it won't be released for us at freeall.*/
-	      dsnuser_free(&dsnuser);
-              goto freeall;
-            }
-        }
-    }
-
-  /* If the MAILBOX delivery mode has been selected... */
-  if (deliver_to_mailbox)
-    {
-      /* Loop through the dsnusers list, setting the target mailbox. */
-      for(tmp = list_getstart(&dsnusers); tmp != NULL; tmp = tmp->nextnode)
-        {
-          deliver_to_user_t *dsnuser;
-
-	  dsnuser = (deliver_to_user_t *)tmp->data;
-      
-          dsnuser->mailbox = strdup(deliver_to_mailbox);
+  
+          list_nodeadd(&dsnusers, &dsnuser, sizeof(deliver_to_user_t));
         }
     }
 
   /* inserting messages into the database */
-  if (insert_messages(stdin, header, headersize, &mimelist, &dsnusers, &returnpath) == -1)
+  if (insert_messages(stdin,
+                      header, headersize, headerrfcsize,
+                      &mimelist, &dsnusers, &returnpath) == -1)
     {
       trace(TRACE_ERROR, "main(): insert_messages failed");
       /* Most likely a random failure... */
Only in dbmail-2.0rc2-fixes-snap2: main.c~
Only in dbmail-2.0rc2-fixes-snap2: Makefile~
diff -rau dbmail/mime.c dbmail-2.0rc2-fixes-snap2/mime.c
--- dbmail/mime.c	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/mime.c	2004-02-27 11:06:01.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: mime.c,v 1.40 2004/03/01 10:48:06 ilja Exp $
+/* $Id: mime.c,v 1.38 2004/01/30 16:24:35 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands
  *
  * Functions for parsing a mime mailheader (actually just for scanning for email messages
@@ -57,7 +57,7 @@
   struct mime_record *mr;
   struct element *el;   
 	
-  trace (TRACE_INFO, "mime_list(): entering mime loop\n");
+  trace(TRACE_INFO, "mime_list(): entering mime loop\n");
 
   list_init(mimelist);
   /* alloc mem */
@@ -128,7 +128,7 @@
 	  strncpy(mr->field, startptr, MIME_FIELD_MAX);
 	  strncpy(mr->value, &delimiter[idx], MIME_VALUE_MAX);
 
-	  trace (TRACE_DEBUG,"mime_list(): mimepair found: [%s] [%s] \n",mr->field, mr->value); 
+	  trace(TRACE_DEBUG,"mime_list(): mimepair found: [%s] [%s] \n",mr->field, mr->value); 
 
 #ifdef USE_EXIT_ON_ERROR
 	  memtst((el=list_nodeadd(mimelist,mr,sizeof (*mr)))==NULL);
@@ -157,11 +157,9 @@
 	{
 	  /* no field/value delimiter found, non-valid MIME-header */
 	  my_free(mr);
-	  trace(TRACE_ERROR,"Non valid mimeheader found, freeing list...\n");
+	  trace(TRACE_ERROR,"Non valid mimeheader found, freeing list...");
 	  list_freelist(&mimelist->start);
 	  mimelist->total_nodes = 0;
-	  trace(TRACE_ERROR,"freeing list done, start: %X\n ",mimelist->start);
-
 	  return -1;
 	}
     }
@@ -215,7 +213,7 @@
   struct mime_record *mr,*prev_mr=NULL;
   struct element *el = NULL;   
 	
-  trace (TRACE_DEBUG, "mime_readheader(): entering mime loop\n");
+  trace(TRACE_DEBUG, "mime_readheader(): entering mime loop\n");
 
   list_init(mimelist);
   *headersize = 0;
@@ -322,7 +320,7 @@
 /*	  strncpy(mr->field, startptr, MIME_FIELD_MAX);
 	  strncpy(mr->value, &delimiter[idx], MIME_VALUE_MAX);
 */
-/*	  trace (TRACE_DEBUG,"mime_readheader(): mimepair found: [%s] [%s] \n",mr->field, mr->value); 
+/*	  trace(TRACE_DEBUG,"mime_readheader(): mimepair found: [%s] [%s] \n",mr->field, mr->value); 
 */
 	  el = list_nodeadd(mimelist,mr,sizeof (*mr));
 	  if (!el)
@@ -475,18 +473,20 @@
       return -1;
     }
 
-  trace (TRACE_DEBUG,"mail_adr_list(): mimelist currently has [%d] nodes",mimelist->total_nodes);
+  trace(TRACE_DEBUG, "mail_adr_list(): mimelist currently has [%ld] nodes",
+		  mimelist->total_nodes);
 
   memtst((tmpvalue=(char *)calloc(MIME_VALUE_MAX,sizeof(char)))==NULL);
 
-  trace (TRACE_INFO,"mail_adr_list(): mail address parser starting");
+  trace(TRACE_INFO, "mail_adr_list(): mail address parser starting");
 
   raw=list_getstart(mimelist);
-  trace (TRACE_DEBUG,"mail_adr_list(): total fields in header %lu",mimelist->total_nodes);
+  trace(TRACE_DEBUG, "mail_adr_list(): total fields in header %ld",
+		  mimelist->total_nodes);
   while (raw!=NULL)
     {
       mr=(struct mime_record *)raw->data;
-      trace (TRACE_DEBUG,"mail_adr_list(): scanning for %s",scan_for_field);
+      trace(TRACE_DEBUG, "mail_adr_list(): scanning for %s", scan_for_field);
       if ((strcasecmp(mr->field, scan_for_field)==0))
 	{
 	  /* Scan for email addresses and add them to our list */
@@ -512,20 +512,20 @@
 		     (ptr[0]!=',') &&
 		     (ptr[0]!='\0'))  
 		ptr++;
-	      memtst((strncpy(tmpvalue,tmp,ptr-tmp))==NULL);
+	      memtst((strncpy(tmpvalue, tmp, ptr-tmp)) == NULL);
 				/* always set last value to \0 to end string */
 	      tmpvalue[ptr-tmp]='\0';
 
 				/* one extra for \0 in strlen */
-	      memtst((list_nodeadd(targetlist,tmpvalue,
+	      memtst((list_nodeadd(targetlist, tmpvalue,
 				   (strlen(tmpvalue)+1)))==NULL);
 
 				/* printf ("total nodes:\n");
 				   list_showlist(&targetlist);
 				   next address */
-	      ptr=strstr(ptr,"@");
-	      trace (TRACE_DEBUG,"mail_adr_list(): found %s, next in list is %s",
-		     tmpvalue,ptr ? ptr : "<null>");
+	      ptr = strstr(ptr, "@");
+	      trace(TRACE_DEBUG, "mail_adr_list(): found %s, next in list is %s",
+		     tmpvalue, ptr);
 	    }
 	}
       raw=raw->nextnode;
@@ -533,11 +533,12 @@
 
   my_free(tmpvalue);
 
-  trace (TRACE_DEBUG,"mail_adr_list(): found %d emailaddresses",list_totalnodes(targetlist));
+  trace(TRACE_DEBUG, "mail_adr_list(): found %ld emailaddresses",
+		  targetlist->total_nodes);
 	
-  trace (TRACE_INFO,"mail_adr_list(): mail address parser finished");
+  trace(TRACE_INFO, "mail_adr_list(): mail address parser finished");
 
-  if (list_totalnodes(targetlist)==0) /* no addresses found */
+  if (targetlist->total_nodes == 0) /* no addresses found */
     return -1;
 
   return 0;
Only in dbmail-2.0rc2-fixes-snap2: mime.c~
diff -rau dbmail/mime.h dbmail-2.0rc2-fixes-snap2/mime.h
--- dbmail/mime.h	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/mime.h	2004-02-14 16:43:09.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: mime.h,v 1.23 2004/03/01 10:48:06 ilja Exp $ 
+/* $Id: mime.h,v 1.22 2004/01/07 15:00:16 ilja Exp $ 
  * (c) 2000-2002 IC&S, The Netherlands */
 
 #ifndef _MIME_H
diff -rau dbmail/mysql/dbmysql.c dbmail-2.0rc2-fixes-snap2/mysql/dbmysql.c
--- dbmail/mysql/dbmysql.c	2004-01-29 10:02:07.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/mysql/dbmysql.c	2004-02-27 10:53:16.000000000 -0800
@@ -224,7 +224,7 @@
 	} else {                                                  
 		trace (TRACE_ERROR,"%s,%s: "                          
 				"query buffer is NULL, this is not supposed to happen\n",   
-				__FILE__, __FUNCTION__, querysize);           
+				__FILE__, __FUNCTION__);
 		return -1;                                            
 	}                                                         
 
Only in dbmail-2.0rc2-fixes-snap2/mysql: dbmysql.c~
diff -rau dbmail/pipe.c dbmail-2.0rc2-fixes-snap2/pipe.c
--- dbmail/pipe.c	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/pipe.c	2004-02-27 10:57:00.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: pipe.c,v 1.102 2004/03/01 10:48:06 ilja Exp $
+/* $Id: pipe.c,v 1.99.2.4 2004/02/06 12:49:33 ilja Exp $
  * (c) 2000-2002 IC&S, The Netherlands 
  *
  * Functions for reading the pipe from the MTA */
@@ -40,6 +40,8 @@
 #include "misc.h"
 #include <errno.h>
 #include <string.h>
+#include <strings.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -432,11 +434,14 @@
  *
  * returns a message id number, or -1 on error.
  * */
-static int store_message_temp(FILE *instream, char *header, u64_t headersize, u64_t *temp_message_idnr)
+static int store_message_temp(FILE *instream,
+                char *header, u64_t headersize, u64_t headerrfcsize,
+                u64_t *msgsize, u64_t *rfcsize, u64_t *temp_message_idnr)
 {
   int myeof=0;
   u64_t msgidnr=0;
-  size_t i=0, usedmem=0, totalmem=0, linemem=0;
+  size_t i=0, usedmem=0, linemem=0;
+  u64_t totalmem = 0, rfclines=0;
   char *strblock=NULL, *tmpline=NULL;
   char unique_id[UID_SIZE];
   u64_t messageblk_idnr;
@@ -444,7 +449,12 @@
   int result;
 
   result = auth_user_exists(DBMAIL_DELIVERY_USERNAME, &user_idnr);
-  if (result <= 0) {
+  if (result < 0) {
+	  trace(TRACE_ERROR, "%s,%s: unable to find user_idnr for user "
+		"[%s]\n", __FILE__, __FUNCTION__, DBMAIL_DELIVERY_USERNAME);
+	  return -1;
+  }
+  if (result == 0) {
 	  trace(TRACE_ERROR, "%s,%s: unable to find user_idnr for user "
 		"[%s]. Make sure this system user is in the database!\n",
 		__FILE__, __FUNCTION__, DBMAIL_DELIVERY_USERNAME);
@@ -469,7 +479,8 @@
       return -1;
   }
 
-  trace(TRACE_DEBUG,"store_message_temp(): allocating [%d] bytes of memory for readblock", READ_BLOCK_SIZE);
+  trace(TRACE_DEBUG, "store_message_temp(): allocating [%ld] bytes of memory for readblock",
+		  READ_BLOCK_SIZE);
 
   memtst ((strblock = (char *)my_malloc(READ_BLOCK_SIZE+1))==NULL);
   memtst ((tmpline= (char *)my_malloc(MAX_LINE_SIZE+1))==NULL);
@@ -489,10 +500,16 @@
 
       /* We want to fill up each block if possible,
        * unless of course we're at the end of the file */
-      while (!feof(instream) && (usedmem + linemem < READ_BLOCK_SIZE))
+      while (!feof(instream) && (usedmem +linemem < READ_BLOCK_SIZE))
         {
           fgets(tmpline, MAX_LINE_SIZE, instream);
           linemem = strlen(tmpline);
+          /* The RFC size assumes all lines end in \r\n,
+           * so if we have a newline (\n) but don't have
+           * a carriage return (\r), count it in rfcsize. */
+          if (tmpline[linemem-1] == '\n')
+              if (tmpline[linemem-2] != '\r')
+                  rfclines++;
 
           if (ferror(instream))
             {
@@ -508,8 +525,6 @@
             {
               /* This is the end of the message! */
               myeof = 1;
-	      /* make sure that the function stops by setting linemem to zero
-	       */
 	      linemem = 0;
               break;
             }
@@ -525,7 +540,6 @@
                   tmpline[0] = '\0';
                   linemem = 0;
                 }
-
               /* Don't need an else, see above this while loop for more */
             }
         }
@@ -567,10 +581,13 @@
   my_free (strblock);
   trace(TRACE_DEBUG, "store_message_temp(): strblock freed");
 
-  db_update_message(msgidnr, unique_id, totalmem+headersize, 0);
+  db_update_message(msgidnr, unique_id, (totalmem+headersize),
+                    (totalmem+rfclines+headerrfcsize));
 
   /* Pass the message id out to the caller. */
   *temp_message_idnr = msgidnr;
+  *rfcsize = totalmem + rfclines + headerrfcsize;
+  *msgsize = totalmem + headersize;
 
   return 0;
 }
@@ -608,14 +625,15 @@
  *   - 0 on success
  *   - -1 on full failure
  */
-int insert_messages(FILE *instream, char *header, u64_t headersize,
-     struct list *headerfields, struct list *users, struct list *returnpath)
+int insert_messages(FILE *instream, char *header, u64_t headersize, u64_t headerrfcsize,
+     struct list *headerfields, struct list *dsnusers, struct list *returnpath)
 {
   struct element *element, *ret_path;
-  u64_t tmpmsgidnr, msgsize = 0;
+  u64_t msgsize, rfcsize, tmpmsgidnr;
 
   /* Read in the rest of the stream and store it into a temporary message */
-  switch (store_message_temp(instream, header, headersize, &tmpmsgidnr))
+  switch (store_message_temp(instream, header, headersize, headerrfcsize,
+                             &msgsize, &rfcsize, &tmpmsgidnr))
   {
     case -1:
       /* Major trouble. Bail out immediately. */
@@ -629,64 +647,62 @@
   }
   
   /* Get the user list resolved into fully deliverable form */
-  if (resolve_deliveries(users) != 0)
-    {
+  if (resolve_deliveries(dsnusers) != 0)
       return -1;
-    }
 
   /* Loop through the users list */
-  for (element = list_getstart(users); element != NULL; element = element->nextnode)
+  for (element = list_getstart(dsnusers); element != NULL; element = element->nextnode)
     {
-      struct element *userid_elem;
       deliver_to_user_t *delivery = (deliver_to_user_t *)element->data;
 
-      for (userid_elem = list_getstart(delivery->userids);
-                      userid_elem != NULL; userid_elem = userid_elem->nextnode)
-        {
-          u64_t useridnr = *(u64_t *)userid_elem->data;
-          trace(TRACE_DEBUG, "%s, %s: calling sort_and_deliver for useridnr [%llu]",
-              __FILE__, __FUNCTION__, useridnr);
+      trace(TRACE_ERROR, "%s, %s: calling sort_and_deliver for useridnr [%llu]",
+          __FILE__, __FUNCTION__, delivery->useridnr);
 
-          switch (sort_and_deliver(tmpmsgidnr, header, headersize, msgsize, useridnr, delivery->mailbox))
-            {
-              case 1:
-                /* Indicate success */
-                trace(TRACE_DEBUG, "%s, %s: sort_and_delivery was successful for useridnr [%llu]",
-                            __FILE__, __FUNCTION__, useridnr);
-                break;
-              case 0:
-                /* Indicate failure */
-                trace(TRACE_ERROR, "%s, %s: out of memory",
-                            __FILE__, __FUNCTION__);
-                break;
-              default:
-                /* Assume a failure */
-                trace(TRACE_ERROR, "%s, %s: out of memory",
-                            __FILE__, __FUNCTION__);
-                break;
-            }
-                
-          /* Automatic reply and notification */
-          execute_auto_ran(useridnr, headerfields);
-        } /* from: the useridnr for loop */
+      /* The error reporting really needs to be more verbose
+       * and for goodness sake, no magic numbers! Define these!
+       * */
+      switch (sort_and_deliver(tmpmsgidnr,
+                               header, headersize,
+                               msgsize, rfcsize,
+                               delivery->useridnr, delivery->mailbox))
+        {
+          case 1:
+            /* Indicate success */
+            trace(TRACE_DEBUG, "%s, %s: message successfully sorted and delivered",
+                        __FILE__, __FUNCTION__);
+            break;
+          case 0:
+            /* Indicate failure */
+            trace(TRACE_ERROR, "%s, %s: out of memory",
+                        __FILE__, __FUNCTION__);
+            break;
+          default:
+            /* Assume a failure */
+            trace(TRACE_ERROR, "%s, %s: out of memory",
+                        __FILE__, __FUNCTION__);
+            break;
+        }
+            
+      /* Automatic reply and notification */
+      execute_auto_ran(delivery->useridnr, headerfields);
 
       trace(TRACE_DEBUG,"insert_messages(): we need to deliver [%ld] "
           "messages to external addresses", list_totalnodes(delivery->forwards));
       
-      /* Do we have any forwarding addresses? */
+      /* do we have forward addresses? */
       if (list_totalnodes(delivery->forwards) > 0)
         {
-
+          /* sending the message to forwards */
+      
           trace(TRACE_DEBUG, "insert_messages(): delivering to external addresses");
       
-          /* Only the last step of the returnpath is used. */
           ret_path = list_getstart(returnpath);
           
-          /* Forward using the temporary stored message. */
+          /* deliver using database */
           forward(tmpmsgidnr, delivery->forwards, (ret_path ? ret_path->data : "DBMAIL-MAILER"), header, headersize);
         }
 
-    } /* from: the delivery for loop */
+    } /* from: the main for loop */
 
   db_delete_message(tmpmsgidnr);
   trace(TRACE_DEBUG, "insert_messages(): temporary message deleted from database");
Only in dbmail-2.0rc2-fixes-snap2: pipe.c~
diff -rau dbmail/pipe.h dbmail-2.0rc2-fixes-snap2/pipe.h
--- dbmail/pipe.h	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/pipe.h	2004-02-26 11:14:52.000000000 -0800
@@ -17,7 +17,7 @@
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: pipe.h,v 1.20 2004/03/01 10:48:06 ilja Exp $ 
+/* $Id: pipe.h,v 1.19 2004/01/30 16:24:35 ilja Exp $ 
  * (c) 2000-2002 IC&S, The Netherlands */
 
 #ifndef _PIPE_H
@@ -35,6 +35,7 @@
  * \param instream is a FILE stream where the rest of the message is
  * \param header header of the message
  * \param headersize size of the header
+ * \param headerrfcsize rfc size of the header (newlines counted twice)
  * \param users list of users to sent the message to
  * \param errusers list of users who didn't work for some reason
  * \param returnpath From: addresses. Used for bouncing messages.
@@ -44,8 +45,9 @@
  * \param headerfields list of header fields
  * \return 0
  */
-int insert_messages(FILE *instream, char *header, u64_t headersize,
-	struct list *headerfields, struct list *users, struct list *returnpath);
+int insert_messages(FILE *instream,
+                    char *header, u64_t headersize, u64_t headerrfcsize,
+                    struct list *headerfields, struct list *dsnusers, struct list *returnpath);
 
 
 
Only in dbmail-2.0rc2-fixes-snap2: pipe.h~
diff -rau dbmail/pop3.c dbmail-2.0rc2-fixes-snap2/pop3.c
--- dbmail/pop3.c	2004-01-07 07:00:16.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/pop3.c	2004-02-27 11:23:41.000000000 -0800
@@ -251,25 +251,27 @@
 }
 
 
-int pop3_error (PopSession_t *session, void *stream, const char *formatstring, ...)
+int pop3_error(PopSession_t *session, void *stream, const char *formatstring, ...)
+	__attribute__((format(printf, 3, 4)));
+int pop3_error(PopSession_t *session, void *stream, const char *formatstring, ...)
 {
      va_list argp;
 
      if (session->error_count>=MAX_ERRORS)
      {
-	  trace (TRACE_MESSAGE,"pop3_error(): too many errors (MAX_ERRORS is %d)",MAX_ERRORS);
-	  fprintf ((FILE *)stream, "-ERR loser, go play somewhere else\r\n");
+	  trace(TRACE_MESSAGE, "pop3_error(): too many errors (MAX_ERRORS is %d)", MAX_ERRORS);
+	  fprintf((FILE *)stream, "-ERR loser, go play somewhere else\r\n");
 	  session->SessionResult = 2; /* possible flood */
 	  return -3;
      }
      else
      {
 	  va_start(argp, formatstring);
-	  vfprintf ((FILE *)stream, formatstring, argp);
+	  vfprintf((FILE *)stream, formatstring, argp);
 	  va_end(argp);
      }
 
-     trace (TRACE_DEBUG,"pop3_error(): an invalid command was issued");
+     trace(TRACE_DEBUG, "pop3_error(): an invalid command was issued");
      session->error_count++;
      return 1;
 }
@@ -340,7 +342,7 @@
 	 (cmdtype!=POP3_UIDL) && (cmdtype!=POP3_AUTH) &&
 	 (cmdtype!=POP3_CAPA))
      {
-	  return pop3_error(session, stream,"-ERR your command does not compute\r\n");
+	  return pop3_error(session, stream, "-ERR your command does not compute\r\n");
      }
 
      switch (cmdtype)
Only in dbmail-2.0rc2-fixes-snap2: pop3.c~
diff -rau dbmail/sort/sort.c dbmail-2.0rc2-fixes-snap2/sort/sort.c
--- dbmail/sort/sort.c	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/sort/sort.c	2004-02-27 09:24:34.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: sort.c,v 1.2 2004/03/01 10:48:06 ilja Exp $
+/* $Id: sort.c,v 1.1 2004/01/30 16:54:11 ilja Exp $
  * (c) 2003 Aaron Stone
  *
  * Functions for running user defined sorting rules
@@ -45,7 +45,10 @@
  *
  * Then do it!
  * */
-int sort_and_deliver(u64_t msgidnr, const char *header, u64_t headersize, u64_t msgsize, u64_t useridnr, const char *mailbox)
+int sort_and_deliver(u64_t msgidnr,
+                     const char *header, u64_t headersize,
+                     u64_t totalmsgsize, u64_t totalrfcsize,
+                     u64_t useridnr, const char *mailbox)
 {
   field_t val;
   int do_regex = 0, do_sieve = 0;
@@ -67,8 +70,7 @@
      do_sieve = 1;
 
   list_init(&actions);
-  
-  trace(TRACE_DEBUG, "%s,%s: messagesize = %llu, headersize = %llu, total = %llu", __FILE__, __FUNCTION__, msgsize, headersize, msgsize+headersize);
+
   if (do_regex)
     {
       /* Call out to Jonas' regex sorting function!
@@ -83,7 +85,7 @@
        * call out to a function that encapsulates it!
        * */
 #ifdef SIEVE
-      ret = sortsieve_msgsort(useridnr, header, headersize, msgsize, &actions);
+      ret = sortsieve_msgsort(useridnr, header, headersize, totalmsgsize, &actions);
 #else
       /* Give the postmaster a clue as to why Sieve isn't working... */
       trace(TRACE_ERROR, "%s, %s: Sieve enabled in dbmail.conf, but Sieve support has not been compiled");
@@ -213,13 +215,13 @@
                             break;
                           default:
                             trace(TRACE_MESSAGE, "sort_and_deliver(): message id=%llu, size=%llu is inserted",
-                                newmsgidnr, msgsize+headersize);
+                                newmsgidnr, totalmsgsize);
                            
                             /* Create a unique ID for this message;
                              * Each message for each user must have a unique ID! 
                              * */
                             create_unique_id(unique_id, newmsgidnr); 
-                            db_update_message(newmsgidnr, unique_id, msgsize+headersize, 0);
+                            db_update_message(newmsgidnr, unique_id, totalmsgsize, totalrfcsize);
                          
                             actiontaken = 1;
                             break;
@@ -320,13 +322,13 @@
                 break;
               default:
                 trace(TRACE_MESSAGE,"%s, %s: message id=%llu, size=%llu is inserted",
-                    __FILE__, __FUNCTION__, newmsgidnr, msgsize+headersize);
+                    __FILE__, __FUNCTION__, newmsgidnr, totalmsgsize);
                
                 /* Create a unique ID for this message;
                  * Each message for each user must have a unique ID! 
                  * */
                 create_unique_id(unique_id, newmsgidnr); 
-                db_update_message(newmsgidnr, unique_id, msgsize+headersize, 0);
+                db_update_message(newmsgidnr, unique_id, totalmsgsize, totalrfcsize);
 
                 actiontaken = 1;
                 break;
Only in dbmail-2.0rc2-fixes-snap2/sort: sort.c~
diff -rau dbmail/sort.h dbmail-2.0rc2-fixes-snap2/sort.h
--- dbmail/sort.h	2004-03-01 05:14:32.000000000 -0800
+++ dbmail-2.0rc2-fixes-snap2/sort.h	2004-02-26 11:15:34.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: sort.h,v 1.2 2004/03/01 10:48:06 ilja Exp $ 
+/* $Id: sort.h,v 1.1 2004/01/30 16:54:11 ilja Exp $ 
  * (c) 2003 Aaron Stone
  *
  * Headers for sorting.c */
@@ -28,6 +28,9 @@
   char *message;
 } sort_action_t;
 
-int sort_and_deliver(u64_t msgidnr, const char *header, u64_t headersize, u64_t msgsize, u64_t useridnr, const char *mailbox);
+int sort_and_deliver(u64_t msgidnr,
+                     const char *header, u64_t headersize,
+                     u64_t msgsize, u64_t rfcsize,
+                     u64_t useridnr, const char *mailbox);
 
 #endif /* #ifndef _SORTING_H */
Only in dbmail-2.0rc2-fixes-snap2: sort.h~
