1 diff -ur postfix-2.7.0/src/virtual/maildir.c postfix-2.7.0-bg/src/virtual/maildir.c
2 --- postfix-2.7.0/src/virtual/maildir.c 2010-04-15 16:46:03.766130197 +0200
3 +++ postfix-2.7.0-bg/src/virtual/maildir.c 2010-04-15 16:55:02.496126981 +0200
9 #include <sys/types.h> /* opendir(3), stat(2) */
10 #include <sys/stat.h> /* stat(2) */
11 #include <dirent.h> /* opendir(3) */
13 * Returns the size of all mails as read from maildirsize,
14 * zero if it couldn't read the file.
16 -static long read_maildirsize(char *filename, long *sumptr, long *countptr)
17 +static long read_maildirsize(char *filename, int64_t *sumptr, int64_t *countptr)
19 char *myname = "read_maildirsize";
24 - long sum = 0, count = 0, ret_value = -1;
25 + int64_t sum = 0, count = 0, ret_value = -1;
28 msg_info("%s: we will use sizefile = '%s'", myname, filename);
34 + int64_t n = 0, c = 0;
42 - if (sscanf(q, "%ld %ld", &n, &c) == 2) {
43 + if (sscanf(q, "%lld %lld", &n, &c) == 2) {
51 - msg_info("%s: we will return Maildir size = %ld, count = %ld", myname, *sumptr, *countptr);
52 + msg_info("%s: we will return Maildir size = %lld, count = %lld", myname, *sumptr, *countptr);
57 * Returns the size given in ",S=<size>" in the filename,
58 * zero if it cannot find ",S=<size>" in the filename.
60 -static long maildir_parsequota(const char *n)
61 +static int64_t maildir_parsequota(const char *n)
72 while (*o >= '0' && *o <= '9')
73 s = s*10 + (*o++ - '0');
75 * Returns the sum of the sizes of all measurable files,
76 * zero if the directory could not be opened.
78 -static long check_dir_size(char *dirname, long *countptr)
79 +static int64_t check_dir_size(char *dirname, int64_t *countptr)
81 char *myname = "check_dir_size";
90 while ((ent = readdir(dir)) != NULL) {
91 char *name = ent->d_name;
96 /* do not count dot a double-dot dirs */
99 if ((statbuf.st_mode & S_IFREG) != 0) {
100 if (strcmp(dirname + strlen(dirname) - 3, "new") == 0 || strcmp(dirname + strlen(dirname) - 3, "cur") == 0 || strcmp(dirname + strlen(dirname) - 3, "tmp") == 0) {
101 - sum += (long) statbuf.st_size;
102 + sum += (int64_t) statbuf.st_size;
110 - msg_info("%s: full scan done: dir=%s sum=%ld count=%ld", myname, dirname, sum, *countptr);
111 + msg_info("%s: full scan done: dir=%s sum=%lld count=%lld", myname, dirname, sum, *countptr);
116 char *sizefilename = (char *) 0; /* Maildirsize file name. */
117 VSTRING *filequota; /* Quota setting from the maildirsize file. */
118 VSTREAM *sizefile; /* Maildirsize file handle. */
119 - long n = 0; /* Limit in long integer format. */
120 - long saved_count = 0; /* The total number of files. */
121 - long saved_size = 0; /* The total quota of all files. */
122 + int64_t n = 0; /* Limit in long integer format. */
123 + int64_t saved_count = 0; /* The total number of files. */
124 + int64_t saved_size = 0; /* The total quota of all files. */
125 struct stat mail_stat; /* To check the size of the mail to be written. */
126 struct stat sizefile_stat; /* To check the size of the maildirsize file. */
127 time_t tm; /* To check the age of the maildirsize file. */
129 * warn the user, else use the value directly as the maildir limit.
131 if (*var_virt_mailbox_limit_maps != 0 && (limit_res = mail_addr_find(virtual_mailbox_limit_maps, state.msg_attr.user, (char **) NULL)) != 0) {
132 - n = atol(limit_res);
133 + n = strtoll(limit_res, NULL, 10);
135 if ((n < var_message_limit) && (!var_virt_mailbox_limit_override)) {
136 n = var_virt_mailbox_limit;
137 @@ -552,13 +553,13 @@
141 - msg_info("%s: set virtual maildir limit size for %s to %ld",
142 + msg_info("%s: set virtual maildir limit size for %s to %lld",
143 myname, usr_attr.mailbox, n);
148 - msg_info("%s: set virtual maildir limit size for %s to %ld",
149 + msg_info("%s: set virtual maildir limit size for %s to %lld",
150 myname, usr_attr.mailbox, n);
154 x >= 0 = reading successfully finished - sum si returned, so sum size of Maildir was 0 or more */
155 if (!var_virt_mailbox_limit_inbox && var_virt_maildir_extended && read_maildirsize(sizefilename, &saved_size, &saved_count) >= 0) {
157 - msg_info("%s: maildirsize used=%s sum=%ld count=%ld", myname, sizefilename, saved_size, saved_count);
158 + msg_info("%s: maildirsize used=%s sum=%lld count=%lld", myname, sizefilename, saved_size, saved_count);
161 msg_info("%s: var_virt_mailbox_limit == 1 OR var_virt_maildir_extended == 0 OR read_maildidrsize() returned value x < 0 as saying something failed", myname);
164 if (stat(tmpfile, &mail_stat) == 0) {
166 - saved_size += (long) mail_stat.st_size;
167 + saved_size += (int64_t) mail_stat.st_size;
170 if (var_virt_maildir_extended) {
173 if (saved_size > n) {
174 mail_copy_status = MAIL_COPY_STAT_WRITE;
175 - if (((long) mail_stat.st_size > n) || (var_virt_overquota_bounce))
176 + if (((int64_t) mail_stat.st_size > n) || (var_virt_overquota_bounce))
181 filequota = vstring_alloc(128);
182 vstring_get_null_bound(filequota, sizefile, 127);
183 vstream_fclose(sizefile);
184 - if (atol(vstring_export(filequota)) != n)
185 + if (strtoll(vstring_export(filequota), NULL, 10) != n)
186 unlink(sizefilename);
189 @@ -909,13 +910,13 @@
191 /* If the creation worked, write to the file, otherwise just give up. */
193 - vstream_fprintf(sizefile, "%ldS\n%ld %ld\n", n, saved_size, saved_count);
194 + vstream_fprintf(sizefile, "%lldS\n%lld %lld\n", n, saved_size, saved_count);
195 vstream_fclose(sizefile);
199 /* We opened maildirsize, so let's just append this transaction and close it. */
200 - vstream_fprintf(sizefile, "%ld 1\n", (long) mail_stat.st_size);
201 + vstream_fprintf(sizefile, "%lld 1\n", (int64_t) mail_stat.st_size);
202 vstream_fclose(sizefile);