Upgrade appendfile so that it is capable of handling quotas that are
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 7 Jun 2005 15:20:55 +0000 (15:20 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 7 Jun 2005 15:20:55 +0000 (15:20 +0000)
greater than 2G.

13 files changed:
doc/doc-txt/ChangeLog
src/src/deliver.c
src/src/expand.c
src/src/lookups/cdb.c
src/src/queue.c
src/src/rda.c
src/src/string.c
src/src/tls-gnu.c
src/src/transports/appendfile.c
src/src/transports/appendfile.h
src/src/transports/autoreply.c
src/src/transports/tf_maildir.c
src/src/transports/tf_maildir.h

index fb3c3124b1e29c40c0b80f8f74a9ec33a12a402f..2459f25fa702eece65876941eccefff0eb2617cb 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.149 2005/06/07 10:41:26 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.150 2005/06/07 15:20:55 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -96,6 +96,14 @@ PH/09 The syntax error of a character other than { following "${if
       An expansion such as ${if def:sender_ident:{xxx}{yyy}} in which an
       accidental colon was present, for example, could give incorrect results.
 
+PH/10 Tidied the code in a number of places where the st_size field of a stat()
+      result is used (not including appendfile, where other changes are about
+      to be made).
+
+PH/11 Upgraded appendfile so that quotas larger than 2G are now supported.
+      This involved changing a lot of size variables from int to off_t. It
+      should work with maildirs and everything.
+
 
 Exim version 4.51
 -----------------
index d9bf21a4c3fd68fddbcc6107c081448f61e9b4e0..cc10c65c1141887615ca1a3d2acdf4e8f475065e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/deliver.c,v 1.15 2005/05/24 08:15:02 tom Exp $ */
+/* $Cambridge: exim/src/src/deliver.c,v 1.16 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -4482,11 +4482,8 @@ if ((rc = spool_read_header(spoolname, TRUE, TRUE)) != spool_read_OK)
     sprintf(CS big_buffer, "%s/input/%s/%s", spool_directory, message_subdir,
       spoolname);
     if (Ustat(big_buffer, &statbuf) == 0)
-      {
-      int size = statbuf.st_size;   /* Because might be a long */
-      log_write(0, LOG_MAIN, "Format error in spool file %s: size=%d",
-        spoolname, size);
-      }
+      log_write(0, LOG_MAIN, "Format error in spool file %s: size=%.30g",
+        spoolname, (double)statbuf.st_size);
     else log_write(0, LOG_MAIN, "Format error in spool file %s", spoolname);
     }
   else
@@ -6343,8 +6340,8 @@ wording. */
             if (emf_text != NULL) fprintf(f, "%s", CS emf_text); else
               {
               fprintf(f,
-"------ The body of the message is %d characters long; only the first\n"
-"------ %d or so are included here.\n", (int)statbuf.st_size, max);
+"------ The body of the message is %.30g characters long; only the first\n"
+"------ %d or so are included here.\n", (double)statbuf.st_size, max);
               }
             }
           }
index 9daf77d0bd39d88d445e343ec2c9f62fa3b7ab41..b19e64f5e2d301d46c3712ae340b3bf7c3318994 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.23 2005/06/07 10:41:27 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.24 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1364,7 +1364,7 @@ while (last > first)
     if (*ss == NULL && deliver_datafile >= 0)  /* Read body when needed */
       {
       uschar *body;
-      int start_offset = SPOOL_DATA_START_OFFSET;
+      off_t start_offset = SPOOL_DATA_START_OFFSET;
       int len = message_body_visible;
       if (len > message_size) len = message_size;
       *ss = body = store_malloc(len+1);
@@ -4540,10 +4540,10 @@ while (*s != 0)
 
         smode[10] = 0;
         s = string_sprintf("mode=%04lo smode=%s inode=%ld device=%ld links=%ld "
-          "uid=%ld gid=%ld size=%ld atime=%ld mtime=%ld ctime=%ld",
+          "uid=%ld gid=%ld size=%.30g atime=%ld mtime=%ld ctime=%ld",
           (long)(st.st_mode & 077777), smode, (long)st.st_ino,
           (long)st.st_dev, (long)st.st_nlink, (long)st.st_uid,
-          (long)st.st_gid, (long)st.st_size, (long)st.st_atime,
+          (long)st.st_gid, (double)st.st_size, (long)st.st_atime,
           (long)st.st_mtime, (long)st.st_ctime);
         yield = string_cat(yield, &size, &ptr, s, Ustrlen(s));
         continue;
index 1daa2bbd4888d2f28c4395848973c5f6fbc7ffb5..e6b1541ccc68e102d5959095a3001fce1a984c49 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/lookups/cdb.c,v 1.1 2004/10/07 13:10:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/lookups/cdb.c,v 1.2 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -167,7 +167,7 @@ cdb_open(uschar *filename,
     if (statbuf.st_size < CDB_HASH_TABLE) {
       int save_errno = errno;
       *errmsg = string_open_failed(errno,
-                                  "%s to short for cdb lookup",
+                                  "%s too short for cdb lookup",
                                   filename);
       errno = save_errno;
       return NULL;
index b2f7dda848d4981fd58a8885ae70eebcaf21cf9c..a443fdfd0077dc269682b26c5cad09572473b018 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/queue.c,v 1.5 2005/02/17 11:58:26 ph10 Exp $ */
+/* $Cambridge: exim/src/src/queue.c,v 1.6 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -895,10 +895,8 @@ for (; f != NULL; f = f->next)
       sprintf(CS big_buffer, "%s/input/%s/%s", spool_directory, message_subdir,
         f->text);
       if (Ustat(big_buffer, &statbuf) == 0)
-        {
-        int size = statbuf.st_size;    /* Because might be a long */
-        printf("*** spool format error: size=%d ***", size);
-        }
+        printf("*** spool format error: size=%.30g ***",
+          (double)statbuf.st_size);
       else printf("*** spool format error ***");
       }
     else printf("*** spool read error: %s ***", strerror(save_errno));
index 311f173945f951c69ed7a98d9449174be919a42e..8f972ca4ec4bc64e9002658f6fc61d81d6da8d2a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/rda.c,v 1.5 2005/04/06 14:40:24 ph10 Exp $ */
+/* $Cambridge: exim/src/src/rda.c,v 1.6 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -299,14 +299,8 @@ if (fread(filebuf, 1, statbuf.st_size, fwd) != statbuf.st_size)
   }
 filebuf[statbuf.st_size] = 0;
 
-/* Don't pass statbuf.st_size directly to debug_printf. On some systems it
-is a long, which may not be the same as an int. */
-
 DEBUG(D_route)
-  {
-  int size = (int)statbuf.st_size;
-  debug_printf("%d bytes read from %s\n", size, filename);
-  }
+  debug_printf("%.30g bytes read from %s\n", (double)statbuf.st_size, filename);
 
 fclose(fwd);
 return filebuf;
index 9edcee5679d9df876f76beb6dcb0e9c51939d13b..ba04aa47137d7759ce6eff4de37e2b2ef19bdfb3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/string.c,v 1.3 2005/05/23 16:58:56 fanf2 Exp $ */
+/* $Cambridge: exim/src/src/string.c,v 1.4 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -944,9 +944,9 @@ on whether the variable length list of data arguments are given explicitly or
 as a va_list item.
 
 The formats are the usual printf() ones, with some omissions (never used) and
-two additions for strings: %S forces lower case, %#s or %#S prints nothing for
-a NULL string. Without the # "NULL" is printed (useful in debugging). There is
-also the addition of %D, which inserts the date in the form used for
+two additions for strings: %S forces lower case, and %#s or %#S prints nothing
+for a NULL string. Without the # "NULL" is printed (useful in debugging). There
+is also the addition of %D, which inserts the date in the form used for
 datestamped log files.
 
 Arguments:
index 944fb076296d76853b7d4645e91e9827b3acc870..723d97b4e2a249b29ba5b6cc2bed788cdb65347a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/tls-gnu.c,v 1.6 2005/03/08 11:38:21 ph10 Exp $ */
+/* $Cambridge: exim/src/src/tls-gnu.c,v 1.7 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -499,8 +499,8 @@ if (cas != NULL)
     return DEFER;
     }
 
-  DEBUG(D_tls) debug_printf("verify certificates = %s size=%d\n",
-    cas_expanded, (int)statbuf.st_size);
+  DEBUG(D_tls) debug_printf("verify certificates = %s size=%.30g\n",
+    cas_expanded, (double)statbuf.st_size);
 
   /* If the cert file is empty, there's no point in loading the CRL file. */
 
index 43575d15ba7a74323099e5f94947f060a8c45d21..6874fa7464284da62208213cb0c3a3d78772c8fb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.6 2005/04/27 10:06:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.7 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -189,11 +189,11 @@ appendfile_transport_options_block appendfile_transport_option_defaults = {
   NULL,           /* check_string (default changed for non-bsmtp file)*/
   NULL,           /* escape_string (ditto) */
   NULL,           /* file_format */
+  0,              /* quota_value */
+  0,              /* quota_warn_threshold_value */
   -1,             /* mailbox_size_value */
   -1,             /* mailbox_filecount_value */
-  0,              /* quota_value */
   0,              /* quota_filecount_value */
-  0,              /* quota_warn_threshold_value */
   APPENDFILE_MODE,           /* mode */
   APPENDFILE_DIRECTORY_MODE, /* dirmode */
   APPENDFILE_LOCKFILE_MODE,  /* lockfile_mode */
@@ -259,8 +259,7 @@ appendfile_transport_setup(transport_instance *tblock, address_item *addrlist,
 appendfile_transport_options_block *ob =
   (appendfile_transport_options_block *)(tblock->options_block);
 uschar *q = ob->quota;
-int *v = &(ob->quota_value);
-int default_value = 0;
+double default_value = 0.0;
 int i;
 
 addrlist = addrlist;    /* Keep picky compilers happy */
@@ -271,9 +270,10 @@ mailbox_filecount */
 
 for (i = 0; i < 5; i++)
   {
-  if (q == NULL) *v = default_value; else
+  double d;
+
+  if (q == NULL) d = default_value; else
     {
-    double d;
     uschar *rest;
     uschar *s = expand_string(q);
 
@@ -314,31 +314,33 @@ for (i = 0; i < 5; i++)
         "in %s transport", s, q, tblock->name);
       return FAIL;
       }
-
-    *v = (int)d;
     }
 
   switch (i)
     {
     case 0:
+    ob->quota_value = (off_t)d;
     q = ob->quota_filecount;
-    v = &(ob->quota_filecount_value);
     break;
 
     case 1:
+    ob->quota_filecount_value = (int)d;
     q = ob->quota_warn_threshold;
-    v = &(ob->quota_warn_threshold_value);
     break;
 
     case 2:
+    ob->quota_warn_threshold_value = (off_t)d;
     q = ob->mailbox_size_string;
-    v = &(ob->mailbox_size_value);
-    default_value = -1;
+    default_value = -1.0;
     break;
 
     case 3:
+    ob->mailbox_size_value = (off_t)d;
     q = ob->mailbox_filecount_string;
-    v = &(ob->mailbox_filecount_value);
+    break;
+
+    case 4:
+    ob->mailbox_filecount_value = (int)d;
     break;
     }
   }
@@ -548,7 +550,7 @@ Returns:     nothing
 */
 
 static void
-notify_comsat(uschar *user, int offset)
+notify_comsat(uschar *user, off_t offset)
 {
 struct servent *sp;
 host_item host;
@@ -557,7 +559,7 @@ uschar buffer[256];
 
 DEBUG(D_transport) debug_printf("notify_comsat called\n");
 
-sprintf(CS buffer, "%.200s@%d\n", user, offset);
+sprintf(CS buffer, "%.200s@%.30g\n", user, (double)offset);
 
 if ((sp = getservbyname("biff", "udp")) == NULL)
   {
@@ -705,11 +707,11 @@ Returns:        the sum of the sizes of the stattable files
                 zero if the directory cannot be opened
 */
 
-int
+off_t
 check_dir_size(uschar *dirname, int *countptr, const pcre *regex)
 {
 DIR *dir;
-int sum = 0;
+off_t sum = 0;
 int count = *countptr;
 struct dirent *ent;
 struct stat statbuf;
@@ -734,12 +736,13 @@ while ((ent = readdir(dir)) != NULL)
     if (pcre_exec(regex, NULL, CS name, Ustrlen(name), 0, 0, ovector,6) >= 2)
       {
       uschar *endptr;
-      int size = Ustrtol(name + ovector[2], &endptr, 10);
+      off_t size = (off_t)Ustrtod(name + ovector[2], &endptr);
       if (endptr == name + ovector[3])
         {
         sum += size;
         DEBUG(D_transport)
-          debug_printf("check_dir_size: size from %s is %d\n", name, size);
+          debug_printf("check_dir_size: size from %s is %.30g\n", name,
+            (double)size);
         continue;
         }
       }
@@ -773,7 +776,9 @@ while ((ent = readdir(dir)) != NULL)
 
 closedir(dir);
 DEBUG(D_transport)
-  debug_printf("check_dir_size: dir=%s sum=%d count=%d\n", dirname, sum, count);
+  debug_printf("check_dir_size: dir=%s sum=%.30g count=%d\n", dirname,
+    (double)sum, count);
+
 *countptr = count;
 return sum;
 }
@@ -875,9 +880,10 @@ Returns:       OK if all went well, DEFER otherwise, with errno preserved
 #define MBX_NUSERFLAGS           30
 
 static int
-copy_mbx_message(int to_fd, int from_fd, int saved_size)
+copy_mbx_message(int to_fd, int from_fd, off_t saved_size)
 {
-int used, size;
+int used;
+off_t size;
 struct stat statbuf;
 
 /* If the current mailbox size is zero, write a header block */
@@ -903,8 +909,8 @@ size, including CRLFs, which is the size of the input (temporary) file. */
 if (fstat(from_fd, &statbuf) < 0) return DEFER;
 size = statbuf.st_size;
 
-sprintf (CS deliver_out_buffer, "%s,%lu;%08lx%04x-%08x\015\012",
-  tod_stamp(tod_mbx), (long unsigned int)size, 0L, 0, 0);
+sprintf (CS deliver_out_buffer, "%s,%.30g;%08lx%04x-%08x\015\012",
+  tod_stamp(tod_mbx), (double)size, 0L, 0, 0);
 used = Ustrlen(deliver_out_buffer);
 
 /* Rewind the temporary file, and copy it over in chunks. */
@@ -1206,8 +1212,8 @@ uid_t uid = geteuid();     /* See note above */
 gid_t gid = getegid();
 int mbformat;
 int mode = (addr->mode > 0)? addr->mode : ob->mode;
-int saved_size = -1;
-int mailbox_size = ob->mailbox_size_value;
+off_t saved_size = -1;
+off_t mailbox_size = ob->mailbox_size_value;
 int mailbox_filecount = ob->mailbox_filecount_value;
 int hd = -1;
 int fd = -1;
@@ -1336,10 +1342,12 @@ else
 
 DEBUG(D_transport)
   {
-  debug_printf("appendfile: mode=%o notify_comsat=%d quota=%d warning=%d%s\n"
+  debug_printf("appendfile: mode=%o notify_comsat=%d quota=%.30g "
+    "warning=%.30g%s\n"
     "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
     "maildir_use_size_file=%s\n",
-    mode, ob->notify_comsat, ob->quota_value, ob->quota_warn_threshold_value,
+    mode, ob->notify_comsat, (double)ob->quota_value,
+    (double)ob->quota_warn_threshold_value,
     ob->quota_warn_threshold_is_percent? "%" : "",
     isdirectory? "directory" : "file",
     path, mailbox_formats[mbformat],
@@ -2254,7 +2262,8 @@ else
 /*  if (???? || ob->quota_value > 0) */
 
       {
-      int size, filecount;
+      off_t size;
+      int filecount;
 
       maildirsize_fd = maildir_ensure_sizefile(check_path, ob, regex, dir_regex,
         &size, &filecount);
@@ -2295,7 +2304,7 @@ else
   if ((mailbox_size < 0 || mailbox_filecount < 0) &&
       (ob->quota_value > 0 || THRESHOLD_CHECK))
     {
-    int size;
+    off_t size;
     int filecount = 0;
     DEBUG(D_transport)
       debug_printf("quota checks on directory %s\n", check_path);
@@ -2573,9 +2582,9 @@ if (ob->quota_value > 0)
   {
   DEBUG(D_transport)
     {
-    debug_printf("Exim quota = %d old size = %d this message = %d "
-      "(%sincluded)\n", ob->quota_value, mailbox_size, message_size,
-      ob->quota_is_inclusive? "" : "not ");
+    debug_printf("Exim quota = %.30g old size = %.30g this message = %d "
+      "(%sincluded)\n", (double)ob->quota_value, (double)mailbox_size,
+      message_size, ob->quota_is_inclusive? "" : "not ");
     debug_printf("  file count quota = %d count = %d\n",
       ob->quota_filecount_value, mailbox_filecount);
     }
@@ -2755,12 +2764,14 @@ to be sent. */
 
 if (THRESHOLD_CHECK)
   {
-  int threshold = ob->quota_warn_threshold_value;
+  off_t threshold = ob->quota_warn_threshold_value;
   if (ob->quota_warn_threshold_is_percent)
-    threshold = (int)(((double)ob->quota_value * threshold) / 100);
+    threshold = (off_t)(((double)ob->quota_value * threshold) / 100);
   DEBUG(D_transport)
-    debug_printf("quota = %d threshold = %d old size = %d message size = %d\n",
-      ob->quota_value, threshold, mailbox_size, message_size);
+    debug_printf("quota = %.30g threshold = %.30g old size = %.30g "
+      "message size = %d\n",
+      (double)ob->quota_value, (double)threshold, (double)mailbox_size,
+      message_size);
   if (mailbox_size <= threshold && mailbox_size + message_size > threshold)
     addr->special_action = SPECIAL_WARN;
 
index cc74508a29bf4cabe05e33e80690e3eaa073fc0f..0aaaf7a1adce63b830a37f76de6348d8ef565bbb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/appendfile.h,v 1.2 2005/01/04 10:00:45 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/appendfile.h,v 1.3 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -30,11 +30,11 @@ typedef struct {
   uschar *check_string;
   uschar *escape_string;
   uschar *file_format;
-  int   mailbox_size_value;
+  off_t quota_value;
+  off_t quota_warn_threshold_value;
+  off_t mailbox_size_value;
   int   mailbox_filecount_value;
-  int   quota_value;
   int   quota_filecount_value;
-  int   quota_warn_threshold_value;
   int   mode;
   int   dirmode;
   int   lockfile_mode;
@@ -92,6 +92,6 @@ extern void appendfile_transport_init(transport_instance *);
 
 /* Function that is shared with tf_maildir.c */
 
-extern int  check_dir_size(uschar *, int *, const pcre *);
+extern off_t  check_dir_size(uschar *, int *, const pcre *);
 
 /* End of transports/appendfile.h */
index cccd82c8825544ecfff18aa9fdb3507dfab7c428..7c1af15098c774c05a795c9e6947029e900f2aad 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/autoreply.c,v 1.2 2005/01/04 10:00:45 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/autoreply.c,v 1.3 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -641,11 +641,11 @@ if (return_message)
       DELIVER_IN_BUFFER_SIZE;
     if (fstat(deliver_datafile, &statbuf) == 0 && statbuf.st_size > max)
       {
-      int size = statbuf.st_size;  /* Because might be a long */
       fprintf(f, "\n"
 "------ This is a copy of the message, including all the headers.\n"
-"------ The body of the message is %d characters long; only the first\n"
-"------ %d or so are included here.\n\n", size, (max/1000)*1000);
+"------ The body of the message is %.30g characters long; only the first\n"
+"------ %d or so are included here.\n\n", (double)statbuf.st_size,
+        (max/1000)*1000);
       }
     else fprintf(f, "\n"
 "------ This is a copy of the message, including all the headers. ------\n\n");
index 6b9252f4ec6f23c4e47a806399f484e8f35cc2de..17f24d7177be68fb8683a8a1f01e83b49a689e54 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/tf_maildir.c,v 1.4 2005/02/17 11:58:27 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/tf_maildir.c,v 1.5 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -198,12 +198,12 @@ Arguments:
 Returns:      the sum of the sizes of the messages
 */
 
-int
+off_t
 maildir_compute_size(uschar *path, int *filecount, time_t *latest,
   const pcre *regex, const pcre *dir_regex, BOOL timestamp_only)
 {
 DIR *dir;
-int sum = 0;
+off_t sum = 0;
 struct dirent *ent;
 struct stat statbuf;
 
@@ -282,8 +282,8 @@ DEBUG(D_transport)
     debug_printf("maildir_compute_size (timestamp_only): %ld\n",
     (long int) *latest);
   else
-    debug_printf("maildir_compute_size: path=%s\n  sum=%d filecount=%d "
-      "timestamp=%ld\n", path, sum, *filecount, (long int) *latest);
+    debug_printf("maildir_compute_size: path=%s\n  sum=%.30g filecount=%d "
+      "timestamp=%ld\n", path, (double)sum, *filecount, (long int) *latest);
   }
 return sum;
 }
@@ -320,15 +320,15 @@ Returns:           >=0  a file descriptor for an open maildirsize file
 
 int
 maildir_ensure_sizefile(uschar *path, appendfile_transport_options_block *ob,
-  const pcre *regex, const pcre *dir_regex, int *returned_size,
+  const pcre *regex, const pcre *dir_regex, off_t *returned_size,
   int *returned_filecount)
 {
 int count, fd;
-int cached_quota = 0;
+off_t cached_quota = 0;
 int cached_quota_filecount = 0;
-int size = 0;
 int filecount = 0;
 int linecount = 0;
+off_t size = 0;
 uschar *filename;
 uschar buffer[MAX_FILE_SIZE];
 uschar *ptr = buffer;
@@ -369,14 +369,14 @@ DEBUG(D_transport)
 
 for (;;)
   {
-  long int n = Ustrtol(ptr, &endptr, 10);
+  off_t n = (off_t)Ustrtod(ptr, &endptr);
 
   /* Only two data items are currently defined; ignore any others that
   may be present. The spec is for a number followed by a letter. Anything
   else we reject and recalculate. */
 
   if (*endptr == 'S') cached_quota = n;
-    else if (*endptr == 'C') cached_quota_filecount = n;
+    else if (*endptr == 'C') cached_quota_filecount = (int)n;
   if (!isalpha(*endptr++))
     {
     DEBUG(D_transport)
@@ -404,9 +404,9 @@ if (cached_quota != ob->quota_value ||
   {
   DEBUG(D_transport)
     debug_printf("cached quota is out of date: recalculating\n"
-      "  quota=%d cached_quota=%d filecount_quota=%d "
-      "cached_quota_filecount=%d\n", ob->quota_value, cached_quota,
-      ob->quota_filecount_value, cached_quota_filecount);
+      "  quota=%.30g cached_quota=%.30g filecount_quota=%d "
+      "cached_quota_filecount=%d\n", (double)ob->quota_value,
+      (double)cached_quota, ob->quota_filecount_value, cached_quota_filecount);
   goto RECALCULATE;
   }
 
@@ -421,7 +421,7 @@ while (*endptr++ == '\n')
   if (*endptr == 0) break;
   linecount++;
   ptr = endptr;
-  size += Ustrtol(ptr, &endptr, 10);
+  size += (off_t)Ustrtod(ptr, &endptr);
   if (*endptr != ' ') break;
   ptr = endptr + 1;
   filecount += Ustrtol(ptr, &endptr, 10);
@@ -439,7 +439,7 @@ if (*endptr == 0)
   if (size < 0 || filecount < 0)
     {
     DEBUG(D_transport) debug_printf("negative value in maildirsize "
-      "(size=%d count=%d): recalculating\n", size, filecount);
+      "(size=%.30g count=%d): recalculating\n", (double)size, filecount);
     goto RECALCULATE;
     }
 
@@ -510,8 +510,8 @@ else
   fd = Uopen(tempname, O_RDWR|O_CREAT|O_EXCL, 0600);
   if (fd >= 0)
     {
-    (void)sprintf(CS buffer, "%dS,%dC\n%d %d\n", ob->quota_value,
-      ob->quota_filecount_value, size, filecount);
+    (void)sprintf(CS buffer, "%.30gS,%dC\n%.30g %d\n", (double)ob->quota_value,
+      ob->quota_filecount_value, (double)size, filecount);
     len = Ustrlen(buffer);
     if (write(fd, buffer, len) != len || Urename(tempname, filename) < 0)
       {
@@ -538,8 +538,8 @@ else
 
 /* Return the sizes and the file descriptor, if any */
 
-DEBUG(D_transport) debug_printf("returning maildir size=%d filecount=%d\n",
-  size, filecount);
+DEBUG(D_transport) debug_printf("returning maildir size=%.30g filecount=%d\n",
+  (double)size, filecount);
 *returned_size = size;
 *returned_filecount = filecount;
 return fd;
index 0659684a3022cc7459d5467011dbfa6dc5a93d33..94b42fa14f554e01b04b95663ff2806e7da864b6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/tf_maildir.h,v 1.2 2005/01/04 10:00:45 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/tf_maildir.h,v 1.3 2005/06/07 15:20:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 /* Header file for the functions that are used to support the use of
 maildirsize files for quota handling in maildir directories. */
 
-extern int  maildir_compute_size(uschar *, int *, time_t *, const pcre *,
-              const pcre *, BOOL);
-extern BOOL maildir_ensure_directories(uschar *, address_item *, BOOL, int);
-extern int  maildir_ensure_sizefile(uschar *,
-              appendfile_transport_options_block *, const pcre *, const pcre *,
-              int *, int *);
-extern void maildir_record_length(int, int);
+extern off_t  maildir_compute_size(uschar *, int *, time_t *, const pcre *,
+                const pcre *, BOOL);
+extern BOOL   maildir_ensure_directories(uschar *, address_item *, BOOL, int);
+extern int    maildir_ensure_sizefile(uschar *,
+                appendfile_transport_options_block *, const pcre *,
+                const pcre *, off_t *, int *);
+extern void   maildir_record_length(int, int);
 
 /* End of tf_maildir.h */