]>
Commit | Line | Data |
---|---|---|
e3e951fe AM |
1 | diff -Naur cyrus-imapd-2.2.12/configure.in cyrus-imapd-2.2.12quota/configure.in |
2 | --- cyrus-imapd-2.2.12/configure.in 2005-10-26 11:52:48.000000000 +0200 | |
3 | +++ cyrus-imapd-2.2.12quota/configure.in 2005-10-26 11:53:33.000000000 +0200 | |
4 | @@ -100,6 +100,15 @@ | |
5 | fi | |
6 | AC_C_INLINE | |
7 | ||
8 | +dnl Check if `long long int' is available | |
9 | +AC_CHECK_SIZEOF(long long int) | |
10 | +AC_CHECK_SIZEOF(unsigned long long int) | |
11 | +if test "$ac_cv_sizeof_long_long_int" -eq 8 -a \ | |
12 | + "$ac_cv_sizeof_unsigned_long_long_int" -eq 8; then | |
13 | + AC_DEFINE(HAVE_LONG_LONG_INT,[],[Does the compiler support long long int?]) | |
14 | + AC_C_BIGENDIAN | |
15 | +fi | |
16 | + | |
17 | CMU_C___ATTRIBUTE__ | |
18 | CMU_C_FPIC | |
19 | ||
20 | diff -Naur cyrus-imapd-2.2.12/imap/append.c cyrus-imapd-2.2.12quota/imap/append.c | |
21 | --- cyrus-imapd-2.2.12/imap/append.c 2004-05-22 05:45:48.000000000 +0200 | |
22 | +++ cyrus-imapd-2.2.12quota/imap/append.c 2005-10-26 11:53:34.000000000 +0200 | |
23 | @@ -140,7 +140,7 @@ | |
24 | if (!r) { | |
25 | if (m.quota.limit >= 0 && quotacheck >= 0 && | |
26 | m.quota.used + quotacheck > | |
27 | - ((unsigned) m.quota.limit * QUOTA_UNITS)) { | |
28 | + ((uquota_t) m.quota.limit * QUOTA_UNITS)) { | |
29 | r = IMAP_QUOTA_EXCEEDED; | |
30 | } | |
31 | } | |
32 | @@ -208,7 +208,7 @@ | |
33 | if (!r) { | |
34 | if (as->m.quota.limit >= 0 && quotacheck >= 0 && | |
35 | as->m.quota.used + quotacheck > | |
36 | - ((unsigned) as->m.quota.limit * QUOTA_UNITS)) { | |
37 | + ((uquota_t) as->m.quota.limit * QUOTA_UNITS)) { | |
38 | quota_abort(&as->tid); | |
39 | mailbox_close(&as->m); | |
40 | r = IMAP_QUOTA_EXCEEDED; | |
41 | diff -Naur cyrus-imapd-2.2.12/imap/imapd.c cyrus-imapd-2.2.12quota/imap/imapd.c | |
42 | --- cyrus-imapd-2.2.12/imap/imapd.c 2005-02-14 07:39:55.000000000 +0100 | |
43 | +++ cyrus-imapd-2.2.12quota/imap/imapd.c 2005-10-26 11:53:34.000000000 +0200 | |
44 | @@ -2626,10 +2626,10 @@ | |
45 | */ | |
46 | int warnsize = config_getint(IMAPOPT_QUOTAWARNKB); | |
47 | if (warnsize <= 0 || warnsize >= imapd_mailbox->quota.limit || | |
48 | - (int)((imapd_mailbox->quota.limit * QUOTA_UNITS) - | |
49 | - imapd_mailbox->quota.used) < (warnsize * QUOTA_UNITS)) { | |
50 | + ((uquota_t) (imapd_mailbox->quota.limit - warnsize)) * QUOTA_UNITS < | |
51 | + imapd_mailbox->quota.used) { | |
52 | usage = ((double) imapd_mailbox->quota.used * 100.0) / (double) | |
53 | - (imapd_mailbox->quota.limit * QUOTA_UNITS); | |
54 | + ((uquota_t) imapd_mailbox->quota.limit * QUOTA_UNITS); | |
55 | if (usage >= 100.0) { | |
56 | prot_printf(imapd_out, "* NO [ALERT] %s\r\n", | |
57 | error_message(IMAP_NO_OVERQUOTA)); | |
58 | @@ -4626,7 +4626,7 @@ | |
59 | printastring(name); | |
60 | prot_printf(imapd_out, " ("); | |
61 | if (quota.limit >= 0) { | |
62 | - prot_printf(imapd_out, "STORAGE %lu %d", | |
63 | + prot_printf(imapd_out, "STORAGE " UQUOTA_T_FMT " %d", | |
64 | quota.used/QUOTA_UNITS, quota.limit); | |
65 | } | |
66 | prot_printf(imapd_out, ")\r\n"); | |
67 | @@ -4688,7 +4688,7 @@ | |
68 | printastring(mailboxname); | |
69 | prot_printf(imapd_out, " ("); | |
70 | if (mailbox.quota.limit >= 0) { | |
71 | - prot_printf(imapd_out, "STORAGE %lu %d", | |
72 | + prot_printf(imapd_out, "STORAGE " UQUOTA_T_FMT " %d", | |
73 | mailbox.quota.used/QUOTA_UNITS, | |
74 | mailbox.quota.limit); | |
75 | } | |
76 | diff -Naur cyrus-imapd-2.2.12/imap/mailbox.c cyrus-imapd-2.2.12quota/imap/mailbox.c | |
77 | --- cyrus-imapd-2.2.12/imap/mailbox.c 2005-02-14 07:39:57.000000000 +0100 | |
78 | +++ cyrus-imapd-2.2.12quota/imap/mailbox.c 2005-10-26 11:53:34.000000000 +0200 | |
79 | @@ -84,6 +84,7 @@ | |
80 | #include "seen.h" | |
81 | #include "util.h" | |
82 | #include "xmalloc.h" | |
83 | +#include "byteorder64.h" | |
84 | ||
85 | static int mailbox_doing_reconstruct = 0; | |
86 | #define zeromailbox(m) { memset(&m, 0, sizeof(struct mailbox)); \ | |
87 | @@ -788,8 +789,16 @@ | |
88 | mailbox->last_uid = | |
89 | ntohl(*((bit32 *)(mailbox->index_base+OFFSET_LAST_UID))); | |
90 | ||
91 | +#ifdef HAVE_LONG_LONG_INT | |
92 | + if (mailbox->minor_version > 5) { | |
93 | + /* newer versions may use 64bit quotas now */ | |
94 | + mailbox->quota_mailbox_used = | |
95 | + ntohll(*((bit64 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED64))); | |
96 | + } else | |
97 | +#else | |
98 | mailbox->quota_mailbox_used = | |
99 | ntohl(*((bit32 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED-quota_upgrade_offset))); | |
100 | +#endif | |
101 | ||
102 | if (mailbox->start_offset < OFFSET_POP3_LAST_LOGIN-quota_upgrade_offset+sizeof(bit32)) { | |
103 | mailbox->pop3_last_login = 0; | |
104 | @@ -1183,9 +1192,18 @@ | |
105 | *((bit32 *)(buf+OFFSET_EXISTS)) = htonl(mailbox->exists); | |
106 | *((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox->last_appenddate); | |
107 | *((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox->last_uid); | |
108 | - *((bit32 *)(buf+OFFSET_QUOTA_RESERVED_FIELD)) = htonl(0); /* RESERVED */ | |
109 | + | |
110 | + /* quotas may be 64bit now */ | |
111 | +#ifdef HAVE_LONG_LONG_INT | |
112 | + *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = | |
113 | + htonll(mailbox->quota_mailbox_used); | |
114 | +#else | |
115 | + /* zero the unused 32bits */ | |
116 | + *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0) | |
117 | *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) = | |
118 | htonl(mailbox->quota_mailbox_used); | |
119 | +#endif | |
120 | + | |
121 | *((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox->pop3_last_login); | |
122 | *((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox->uidvalidity); | |
123 | *((bit32 *)(buf+OFFSET_DELETED)) = htonl(mailbox->deleted); | |
124 | @@ -1430,9 +1448,18 @@ | |
125 | *((bit32 *)(buf+OFFSET_EXISTS)) = htonl(mailbox->exists); | |
126 | *((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox->last_appenddate); | |
127 | *((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox->last_uid); | |
128 | - /* OFFSET_QUOTA_RESERVED_FIELD left as zero */ | |
129 | + | |
130 | + /* newer versions may use 64bit quotas */ | |
131 | +#ifdef HAVE_LONG_LONG_INT | |
132 | + *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = | |
133 | + htonll(mailbox->quota_mailbox_used); | |
134 | +#else | |
135 | + /* zero the unused 32bits */ | |
136 | + *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonl(0); | |
137 | *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) = | |
138 | htonl(mailbox->quota_mailbox_used); | |
139 | +#endif | |
140 | + | |
141 | *((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox->pop3_last_login); | |
142 | *((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox->uidvalidity); | |
143 | *((bit32 *)(buf+OFFSET_DELETED)) = htonl(mailbox->deleted); | |
144 | @@ -1608,7 +1635,8 @@ | |
145 | size_t fnamebuf_len; | |
146 | FILE *newindex = NULL, *newcache = NULL; | |
147 | unsigned long *deleted; | |
148 | - unsigned numdeleted = 0, quotadeleted = 0; | |
149 | + unsigned numdeleted = 0; | |
150 | + uquota_t quotadeleted = 0; | |
151 | unsigned numansweredflag = 0; | |
152 | unsigned numdeletedflag = 0; | |
153 | unsigned numflaggedflag = 0; | |
154 | @@ -1829,8 +1857,13 @@ | |
155 | *((bit32 *)(buf+OFFSET_FLAGGED)) = htonl(newflagged); | |
156 | ||
157 | /* Fix up quota_mailbox_used */ | |
158 | +#ifdef HAVE_LONG_LONG_INT | |
159 | + *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = | |
160 | + htonll(ntohll(*((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)))-quotadeleted); | |
161 | +#else | |
162 | *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) = | |
163 | htonl(ntohl(*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)))-quotadeleted); | |
164 | +#endif | |
165 | /* Fix up start offset if necessary */ | |
166 | if (mailbox->start_offset < INDEX_HEADER_SIZE) { | |
167 | *((bit32 *)(buf+OFFSET_START_OFFSET)) = htonl(INDEX_HEADER_SIZE); | |
168 | @@ -1862,7 +1895,7 @@ | |
169 | if (!r) quota_commit(&tid); | |
170 | else { | |
171 | syslog(LOG_ERR, | |
172 | - "LOSTQUOTA: unable to record free of %u bytes in quota %s", | |
173 | + "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s", | |
174 | quotadeleted, mailbox->quota.root); | |
175 | } | |
176 | } | |
177 | @@ -2132,7 +2165,7 @@ | |
178 | r = quota_write(&mailbox->quota, &tid); | |
179 | if (r) { | |
180 | syslog(LOG_ERR, | |
181 | - "LOSTQUOTA: unable to record free of %lu bytes in quota %s", | |
182 | + "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s", | |
183 | mailbox->quota_mailbox_used, mailbox->quota.root); | |
184 | } | |
185 | else | |
186 | @@ -2250,7 +2283,7 @@ | |
187 | strcmp(oldmailbox->quota.root, newmailbox->quota.root) != 0) { | |
188 | if (!r && newmailbox->quota.limit >= 0 && | |
189 | newmailbox->quota.used + oldmailbox->quota_mailbox_used > | |
190 | - ((unsigned) newmailbox->quota.limit * QUOTA_UNITS)) { | |
191 | + ((uquota_t) newmailbox->quota.limit * QUOTA_UNITS)) { | |
192 | r = IMAP_QUOTA_EXCEEDED; | |
193 | } | |
194 | } | |
195 | @@ -2464,7 +2497,7 @@ | |
196 | strcmp(oldmailbox.quota.root, newmailbox.quota.root) != 0) { | |
197 | if (!r && newmailbox.quota.limit >= 0 && | |
198 | newmailbox.quota.used + oldmailbox.quota_mailbox_used > | |
199 | - ((unsigned) newmailbox.quota.limit * QUOTA_UNITS)) { | |
200 | + ((uquota_t) newmailbox.quota.limit * QUOTA_UNITS)) { | |
201 | r = IMAP_QUOTA_EXCEEDED; | |
202 | } | |
203 | } | |
204 | @@ -2617,7 +2650,7 @@ | |
205 | else if (r2 == IMAP_QUOTAROOT_NONEXISTENT) r2 = 0; | |
206 | if (r2) { | |
207 | syslog(LOG_ERR, | |
208 | - "LOSTQUOTA: unable to record use of %lu bytes in quota %s", | |
209 | + "LOSTQUOTA: unable to record use of " UQUOTA_T_FMT " bytes in quota %s", | |
210 | newmailbox.quota_mailbox_used, newmailbox.quota.root); | |
211 | } | |
212 | } | |
213 | diff -Naur cyrus-imapd-2.2.12/imap/mailbox.h cyrus-imapd-2.2.12quota/imap/mailbox.h | |
214 | --- cyrus-imapd-2.2.12/imap/mailbox.h 2004-01-22 22:17:09.000000000 +0100 | |
215 | +++ cyrus-imapd-2.2.12quota/imap/mailbox.h 2005-10-26 11:53:34.000000000 +0200 | |
216 | @@ -45,6 +45,7 @@ | |
217 | #include <sys/types.h> | |
218 | #include <sys/stat.h> | |
219 | #include <limits.h> | |
220 | +#include <config.h> | |
221 | ||
222 | #include "auth.h" | |
223 | #include "quota.h" | |
224 | @@ -61,6 +62,10 @@ | |
225 | #error dont know what to use for bit32 | |
226 | #endif | |
227 | ||
228 | +#ifdef HAVE_LONG_LONG_INT | |
229 | +typedef unsigned long long int bit64; | |
230 | +#endif | |
231 | + | |
232 | #define MAX_MAILBOX_NAME 490 | |
233 | #define MAX_MAILBOX_PATH 4096 | |
234 | ||
235 | @@ -126,7 +131,7 @@ | |
236 | unsigned long exists; | |
237 | time_t last_appenddate; | |
238 | unsigned long last_uid; | |
239 | - unsigned long quota_mailbox_used; | |
240 | + uquota_t quota_mailbox_used; | |
241 | unsigned long pop3_last_login; | |
242 | unsigned long uidvalidity; | |
243 | ||
244 | @@ -168,8 +173,8 @@ | |
245 | #define OFFSET_EXISTS 20 | |
246 | #define OFFSET_LAST_APPENDDATE 24 | |
247 | #define OFFSET_LAST_UID 28 | |
248 | -#define OFFSET_QUOTA_RESERVED_FIELD 32 /* Reserved for 64bit quotas */ | |
249 | -#define OFFSET_QUOTA_MAILBOX_USED 36 | |
250 | +#define OFFSET_QUOTA_MAILBOX_USED64 32 /* offset for 64bit quotas */ | |
251 | +#define OFFSET_QUOTA_MAILBOX_USED 36 /* offset for 32bit quotas */ | |
252 | #define OFFSET_POP3_LAST_LOGIN 40 | |
253 | #define OFFSET_UIDVALIDITY 44 | |
254 | #define OFFSET_DELETED 48 /* added for ACAP */ | |
255 | diff -Naur cyrus-imapd-2.2.12/imap/mbdump.c cyrus-imapd-2.2.12quota/imap/mbdump.c | |
256 | --- cyrus-imapd-2.2.12/imap/mbdump.c 2004-05-22 05:45:51.000000000 +0200 | |
257 | +++ cyrus-imapd-2.2.12quota/imap/mbdump.c 2005-10-26 11:53:34.000000000 +0200 | |
258 | @@ -507,7 +507,7 @@ | |
259 | { | |
260 | struct buf file, data; | |
261 | char c; | |
262 | - int quotaused = 0; | |
263 | + uquota_t quotaused = 0; | |
264 | int r = 0; | |
265 | int curfile = -1; | |
266 | const char *userid = NULL; | |
267 | diff -Naur cyrus-imapd-2.2.12/imap/mbexamine.c cyrus-imapd-2.2.12quota/imap/mbexamine.c | |
268 | --- cyrus-imapd-2.2.12/imap/mbexamine.c 2004-12-17 17:32:16.000000000 +0100 | |
269 | +++ cyrus-imapd-2.2.12quota/imap/mbexamine.c 2005-10-26 11:53:34.000000000 +0200 | |
270 | @@ -266,7 +266,7 @@ | |
271 | printf(" Minor Version: %d\n", mailbox.minor_version); | |
272 | printf(" Header Size: %ld bytes Record Size: %ld bytes\n", | |
273 | mailbox.start_offset, mailbox.record_size); | |
274 | - printf(" Number of Messages: %lu Mailbox Size: %lu bytes\n", | |
275 | + printf(" Number of Messages: %lu Mailbox Size: " UQUOTA_T_FMT " bytes\n", | |
276 | mailbox.exists, mailbox.quota_mailbox_used); | |
277 | printf(" Last Append Date: (%ld) %s", mailbox.last_appenddate, | |
278 | ctime(&mailbox.last_appenddate)); | |
279 | diff -Naur cyrus-imapd-2.2.12/imap/mboxlist.c cyrus-imapd-2.2.12quota/imap/mboxlist.c | |
280 | --- cyrus-imapd-2.2.12/imap/mboxlist.c 2004-07-26 20:08:03.000000000 +0200 | |
281 | +++ cyrus-imapd-2.2.12quota/imap/mboxlist.c 2005-10-26 11:53:34.000000000 +0200 | |
282 | @@ -2540,7 +2540,7 @@ | |
283 | r = quota_write(&mailbox.quota, tid); | |
284 | if (r) { | |
285 | syslog(LOG_ERR, | |
286 | - "LOSTQUOTA: unable to record free of %lu bytes in quota %s", | |
287 | + "LOSTQUOTA: unable to record free of " UQUOTA_T_FMT " bytes in quota %s", | |
288 | mailbox.quota_mailbox_used, mailbox.quota.root); | |
289 | } | |
290 | free(mailbox.quota.root); | |
291 | diff -Naur cyrus-imapd-2.2.12/imap/quota.c cyrus-imapd-2.2.12quota/imap/quota.c | |
292 | --- cyrus-imapd-2.2.12/imap/quota.c 2004-06-30 21:23:26.000000000 +0200 | |
293 | +++ cyrus-imapd-2.2.12quota/imap/quota.c 2005-10-26 11:53:34.000000000 +0200 | |
294 | @@ -120,7 +120,7 @@ | |
295 | struct quota quota; | |
296 | int refcount; | |
297 | int deleted; | |
298 | - unsigned long newused; | |
299 | + uquota_t newused; | |
300 | }; | |
301 | ||
302 | #define QUOTAGROW 300 | |
303 | @@ -251,7 +251,7 @@ | |
304 | } | |
305 | memset("a[quota_num], 0, sizeof(struct quotaentry)); | |
306 | quota[quota_num].quota.root = xstrndup(key, keylen); | |
307 | - sscanf(data, "%lu %d", | |
308 | + sscanf(data, UQUOTA_T_FMT " %d", | |
309 | "a[quota_num].quota.used, "a[quota_num].quota.limit); | |
310 | ||
311 | quota_num++; | |
312 | @@ -422,7 +422,7 @@ | |
313 | (*count)++; | |
314 | } | |
315 | if (quota[thisquota].quota.used != quota[thisquota].newused) { | |
316 | - printf("%s: usage was %lu, now %lu\n", quota[thisquota].quota.root, | |
317 | + printf("%s: usage was " UQUOTA_T_FMT ", now " UQUOTA_T_FMT "\n", quota[thisquota].quota.root, | |
318 | quota[thisquota].quota.used, quota[thisquota].newused); | |
319 | quota[thisquota].quota.used = quota[thisquota].newused; | |
320 | r = quota_write("a[thisquota].quota, tid); | |
321 | @@ -489,12 +489,12 @@ | |
322 | int i; | |
323 | char buf[MAX_MAILBOX_PATH+1]; | |
324 | ||
325 | - printf(" Quota %% Used Used Root\n"); | |
326 | + printf(" Quota %% Used Used Root\n"); | |
327 | ||
328 | for (i = 0; i < quota_num; i++) { | |
329 | if (quota[i].deleted) continue; | |
330 | if (quota[i].quota.limit > 0) { | |
331 | - printf(" %7d %7ld", quota[i].quota.limit, | |
332 | + printf(" %7d " QUOTA_REPORT_FMT , quota[i].quota.limit, | |
333 | ((quota[i].quota.used / QUOTA_UNITS) * 100) / quota[i].quota.limit); | |
334 | } | |
335 | else if (quota[i].quota.limit == 0) { | |
336 | @@ -507,6 +507,6 @@ | |
337 | (*quota_namespace.mboxname_toexternal)("a_namespace, | |
338 | quota[i].quota.root, | |
339 | "cyrus", buf); | |
340 | - printf(" %7ld %s\n", quota[i].quota.used / QUOTA_UNITS, buf); | |
341 | + printf(" " QUOTA_REPORT_FMT " %s\n", quota[i].quota.used / QUOTA_UNITS, buf); | |
342 | } | |
343 | } | |
344 | diff -Naur cyrus-imapd-2.2.12/imap/quota_db.c cyrus-imapd-2.2.12quota/imap/quota_db.c | |
345 | --- cyrus-imapd-2.2.12/imap/quota_db.c 2004-05-22 05:45:52.000000000 +0200 | |
346 | +++ cyrus-imapd-2.2.12quota/imap/quota_db.c 2005-10-26 11:53:34.000000000 +0200 | |
347 | @@ -89,7 +89,7 @@ | |
348 | ||
349 | switch (r) { | |
350 | case CYRUSDB_OK: | |
351 | - sscanf(data, "%lu %d", "a->used, "a->limit); | |
352 | + sscanf(data, UQUOTA_T_FMT " %d", "a->used, "a->limit); | |
353 | break; | |
354 | ||
355 | case CYRUSDB_AGAIN: | |
356 | @@ -151,7 +151,7 @@ | |
357 | if (!qrlen) return IMAP_QUOTAROOT_NONEXISTENT; | |
358 | ||
359 | len = snprintf(buf, sizeof(buf) - 1, | |
360 | - "%lu %d", quota->used, quota->limit); | |
361 | + UQUOTA_T_FMT " %d", quota->used, quota->limit); | |
362 | r = QDB->store(qdb, quota->root, qrlen, buf, len, tid); | |
363 | ||
364 | switch (r) { | |
365 | diff -Naur cyrus-imapd-2.2.12/imap/quota.h cyrus-imapd-2.2.12quota/imap/quota.h | |
366 | --- cyrus-imapd-2.2.12/imap/quota.h 2004-02-27 18:44:56.000000000 +0100 | |
367 | +++ cyrus-imapd-2.2.12quota/imap/quota.h 2005-10-26 11:53:34.000000000 +0200 | |
368 | @@ -45,18 +45,37 @@ | |
369 | #define INCLUDED_QUOTA_H | |
370 | ||
371 | #include "cyrusdb.h" | |
372 | +#include <config.h> | |
373 | ||
374 | #define FNAME_QUOTADB "/quotas.db" | |
375 | ||
376 | #define QUOTA_UNITS (1024) | |
377 | ||
378 | +/* Define the proper quota type, it should either be a | |
379 | + * long or a long long int depending upon what the | |
380 | + * the compiler supports. | |
381 | + */ | |
382 | +#ifdef HAVE_LONG_LONG_INT | |
383 | +typedef unsigned long long int uquota_t; | |
384 | +typedef long long int quota_t; | |
385 | +#define UQUOTA_T_FMT "%llu" | |
386 | +#define QUOTA_T_FMT "%lld" | |
387 | +#define QUOTA_REPORT_FMT "%8llu" | |
388 | +#else | |
389 | +typedef unsigned long uquota_t; | |
390 | +typedef long quota_t; | |
391 | +#define UQUOTA_T_FMT "%lu" | |
392 | +#define QUOTA_T_FMT "%ld" | |
393 | +#define QUOTA_REPORT_FMT "%8lu" | |
394 | +#endif | |
395 | + | |
396 | extern struct db *qdb; | |
397 | ||
398 | struct quota { | |
399 | char *root; | |
400 | ||
401 | /* Information in quota entry */ | |
402 | - unsigned long used; | |
403 | + uquota_t used; | |
404 | int limit; /* in QUOTA_UNITS */ | |
405 | }; | |
406 | ||
407 | diff -Naur cyrus-imapd-2.2.12/imap/reconstruct.c cyrus-imapd-2.2.12quota/imap/reconstruct.c | |
408 | --- cyrus-imapd-2.2.12/imap/reconstruct.c 2004-10-11 16:01:24.000000000 +0200 | |
409 | +++ cyrus-imapd-2.2.12quota/imap/reconstruct.c 2005-10-26 11:53:34.000000000 +0200 | |
410 | @@ -93,6 +93,7 @@ | |
411 | #include "retry.h" | |
412 | #include "convert_code.h" | |
413 | #include "util.h" | |
414 | +#include "byteorder64.h" | |
415 | ||
416 | extern int optind; | |
417 | extern char *optarg; | |
418 | @@ -434,7 +435,7 @@ | |
419 | char *list_acl, *list_part; | |
420 | int list_type; | |
421 | ||
422 | - unsigned long new_quota = 0; | |
423 | + uquota_t new_quota = 0; | |
424 | ||
425 | struct index_record message_index, old_index; | |
426 | static struct index_record zero_index; | |
427 | @@ -690,7 +691,14 @@ | |
428 | *((bit32 *)(buf+OFFSET_EXISTS)) = htonl(new_exists); | |
429 | *((bit32 *)(buf+OFFSET_LAST_APPENDDATE)) = htonl(mailbox.last_appenddate); | |
430 | *((bit32 *)(buf+OFFSET_LAST_UID)) = htonl(mailbox.last_uid); | |
431 | - *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) = htonl(new_quota); | |
432 | + | |
433 | + /* quotas may be 64bit now */ | |
434 | +#ifdef HAVE_LONG_LONG_INT | |
435 | + *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonll(new_quota); | |
436 | +#else | |
437 | + *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED32)) = htonl(new_quota); | |
438 | +#endif | |
439 | + | |
440 | *((bit32 *)(buf+OFFSET_POP3_LAST_LOGIN)) = htonl(mailbox.pop3_last_login); | |
441 | *((bit32 *)(buf+OFFSET_UIDVALIDITY)) = htonl(mailbox.uidvalidity); | |
442 | *((bit32 *)(buf+OFFSET_DELETED)) = htonl(new_deleted); | |
443 | diff -Naur cyrus-imapd-2.2.12/lib/byteorder64.c cyrus-imapd-2.2.12quota/lib/byteorder64.c | |
444 | --- cyrus-imapd-2.2.12/lib/byteorder64.c 1970-01-01 01:00:00.000000000 +0100 | |
445 | +++ cyrus-imapd-2.2.12quota/lib/byteorder64.c 2005-10-26 11:53:34.000000000 +0200 | |
446 | @@ -0,0 +1,95 @@ | |
447 | +/* byteorder64.c -- convert 64-bit values between host and network byte order | |
448 | + * | |
449 | + * Copyright (c) 2004 Carnegie Mellon University. All rights reserved. | |
450 | + * | |
451 | + * Redistribution and use in source and binary forms, with or without | |
452 | + * modification, are permitted provided that the following conditions | |
453 | + * are met: | |
454 | + * | |
455 | + * 1. Redistributions of source code must retain the above copyright | |
456 | + * notice, this list of conditions and the following disclaimer. | |
457 | + * | |
458 | + * 2. Redistributions in binary form must reproduce the above copyright | |
459 | + * notice, this list of conditions and the following disclaimer in | |
460 | + * the documentation and/or other materials provided with the | |
461 | + * distribution. | |
462 | + * | |
463 | + * 3. The name "Carnegie Mellon University" must not be used to | |
464 | + * endorse or promote products derived from this software without | |
465 | + * prior written permission. For permission or any other legal | |
466 | + * details, please contact | |
467 | + * Office of Technology Transfer | |
468 | + * Carnegie Mellon University | |
469 | + * 5000 Forbes Avenue | |
470 | + * Pittsburgh, PA 15213-3890 | |
471 | + * (412) 268-4387, fax: (412) 268-7395 | |
472 | + * tech-transfer@andrew.cmu.edu | |
473 | + * | |
474 | + * 4. Redistributions of any form whatsoever must retain the following | |
475 | + * acknowledgment: | |
476 | + * "This product includes software developed by Computing Services | |
477 | + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." | |
478 | + * | |
479 | + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
480 | + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
481 | + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE | |
482 | + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
483 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | |
484 | + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING | |
485 | + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
486 | + * | |
487 | + * $Id$ | |
488 | + */ | |
489 | + | |
490 | +#include <config.h> | |
491 | + | |
492 | +#if defined(HAVE_LONG_LONG_INT) && !defined(WORDS_BIGENDIAN) | |
493 | + | |
494 | +#include <netinet/in.h> | |
495 | + | |
496 | +/* Structure used to swap the bytes in a 64-bit unsigned long long. */ | |
497 | +union byteswap_64_u { | |
498 | + unsigned long long a; | |
499 | + uint32_t b[2]; | |
500 | +}; | |
501 | + | |
502 | +/* Function to byteswap 64bit unsigned integers on | |
503 | + * little endian machines to big endian network order. | |
504 | + * On big endian machines this will be a null macro. | |
505 | + * The macro htonll() is defined in byteorder64.h, | |
506 | + * and if needed refers to _htonll() here. | |
507 | + */ | |
508 | +unsigned long long _htonll(unsigned long long x) | |
509 | +{ | |
510 | + union byteswap_64_u u1; | |
511 | + union byteswap_64_u u2; | |
512 | + | |
513 | + u1.a = x; | |
514 | + | |
515 | + u2.b[0] = htonl(u1.b[1]); | |
516 | + u2.b[1] = htonl(u1.b[0]); | |
517 | + | |
518 | + return u2.a; | |
519 | +} | |
520 | + | |
521 | + | |
522 | +/* Function to byteswap big endian 64bit unsigned integers | |
523 | + * back to little endian host order on little endian machines. | |
524 | + * As above, on big endian machines this will be a null macro. | |
525 | + * The macro ntohll() is defined in byteorder64.h, and if needed, | |
526 | + * refers to _ntohll() here. | |
527 | + */ | |
528 | +unsigned long long _ntohll(unsigned long long x) | |
529 | +{ | |
530 | + union byteswap_64_u u1; | |
531 | + union byteswap_64_u u2; | |
532 | + | |
533 | + u1.a = x; | |
534 | + | |
535 | + u2.b[1] = ntohl(u1.b[0]); | |
536 | + u2.b[0] = ntohl(u1.b[1]); | |
537 | + | |
538 | + return u2.a; | |
539 | +} | |
540 | + | |
541 | +#endif /* defined(HAVE_LONG_LONG_INT) && !defined(WORDS_BIGENDIAN) */ | |
542 | diff -Naur cyrus-imapd-2.2.12/lib/byteorder64.h cyrus-imapd-2.2.12quota/lib/byteorder64.h | |
543 | --- cyrus-imapd-2.2.12/lib/byteorder64.h 1970-01-01 01:00:00.000000000 +0100 | |
544 | +++ cyrus-imapd-2.2.12quota/lib/byteorder64.h 2005-10-26 11:53:34.000000000 +0200 | |
545 | @@ -0,0 +1,65 @@ | |
546 | +/* byteorder64.h -- convert 64-bit values between host and network byte order | |
547 | + * | |
548 | + * Copyright (c) 2004 Carnegie Mellon University. All rights reserved. | |
549 | + * | |
550 | + * Redistribution and use in source and binary forms, with or without | |
551 | + * modification, are permitted provided that the following conditions | |
552 | + * are met: | |
553 | + * | |
554 | + * 1. Redistributions of source code must retain the above copyright | |
555 | + * notice, this list of conditions and the following disclaimer. | |
556 | + * | |
557 | + * 2. Redistributions in binary form must reproduce the above copyright | |
558 | + * notice, this list of conditions and the following disclaimer in | |
559 | + * the documentation and/or other materials provided with the | |
560 | + * distribution. | |
561 | + * | |
562 | + * 3. The name "Carnegie Mellon University" must not be used to | |
563 | + * endorse or promote products derived from this software without | |
564 | + * prior written permission. For permission or any other legal | |
565 | + * details, please contact | |
566 | + * Office of Technology Transfer | |
567 | + * Carnegie Mellon University | |
568 | + * 5000 Forbes Avenue | |
569 | + * Pittsburgh, PA 15213-3890 | |
570 | + * (412) 268-4387, fax: (412) 268-7395 | |
571 | + * tech-transfer@andrew.cmu.edu | |
572 | + * | |
573 | + * 4. Redistributions of any form whatsoever must retain the following | |
574 | + * acknowledgment: | |
575 | + * "This product includes software developed by Computing Services | |
576 | + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." | |
577 | + * | |
578 | + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
579 | + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
580 | + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE | |
581 | + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
582 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN | |
583 | + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING | |
584 | + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
585 | + * | |
586 | + * $Id$ | |
587 | + */ | |
588 | + | |
589 | +#ifndef _BYTEORDER64_H | |
590 | +#define _BYTEORDER64_H | |
591 | + | |
592 | +#include <config.h> | |
593 | + | |
594 | +#ifdef HAVE_LONG_LONG_INT | |
595 | + | |
596 | +/* 64-bit host/network byte-order swap macros */ | |
597 | +#ifdef WORDS_BIGENDIAN | |
598 | +#define htonll(x) (x) | |
599 | +#define ntohll(x) (x) | |
600 | +#else | |
601 | +#define htonll(x) _htonll(x) | |
602 | +#define ntohll(x) _ntohll(x) | |
603 | + | |
604 | +/* little-endian 64-bit host/network byte-order swap functions */ | |
605 | +extern unsigned long long _htonll(unsigned long long); | |
606 | +extern unsigned long long _ntohll(unsigned long long); | |
607 | + | |
608 | +#endif /* WORDS_BIGENDIAN */ | |
609 | +#endif /* HAVE_LONG_LONG_INT */ | |
610 | +#endif /* _BYTEORDER64_H */ | |
611 | diff -Naur cyrus-imapd-2.2.12/lib/Makefile.in cyrus-imapd-2.2.12quota/lib/Makefile.in | |
612 | --- cyrus-imapd-2.2.12/lib/Makefile.in 2005-10-26 11:52:48.000000000 +0200 | |
613 | +++ cyrus-imapd-2.2.12quota/lib/Makefile.in 2005-10-26 11:54:08.000000000 +0200 | |
614 | @@ -88,7 +88,7 @@ | |
615 | $(srcdir)/lsort.h $(srcdir)/stristr.h \ | |
616 | $(srcdir)/util.h $(srcdir)/xmalloc.h $(srcdir)/imapurl.h \ | |
617 | $(srcdir)/cyrusdb.h $(srcdir)/iptostring.h $(srcdir)/rfc822date.h \ | |
618 | - $(srcdir)/libcyr_cfg.h | |
619 | + $(srcdir)/libcyr_cfg.h $(srcdir)/byteorder64.h | |
620 | ||
621 | LIBCYR_OBJS = acl.lo bsearch.lo charset.lo glob.lo retry.lo util.lo \ | |
622 | libcyr_cfg.lo mkgmtime.lo prot.lo parseaddr.lo imclient.lo imparse.lo \ | |
623 | @@ -96,7 +96,7 @@ | |
624 | chartable.lo imapurl.lo nonblock_@WITH_NONBLOCK@.lo lock_@WITH_LOCK@.lo \ | |
625 | gmtoff_@WITH_GMTOFF@.lo map_@WITH_MAP@.lo $(ACL) $(AUTH) \ | |
626 | @LTLIBOBJS@ @CYRUSDB_OBJS@ \ | |
627 | - iptostring.lo xmalloc.lo wildmat.lo | |
628 | + iptostring.lo xmalloc.lo wildmat.lo byteorder64.lo | |
629 | ||
630 | LIBCYRM_HDRS = $(srcdir)/hash.h $(srcdir)/mpool.h $(srcdir)/xmalloc.h \ | |
631 | $(srcdir)/strhash.o $(srcdir)/libconfig.h $(srcdir)/assert.h \ | |
632 | diff -Naur cyrus-imapd-2.2.12/lib/prot.c cyrus-imapd-2.2.12quota/lib/prot.c | |
633 | --- cyrus-imapd-2.2.12/lib/prot.c 2004-02-27 23:08:56.000000000 +0100 | |
634 | +++ cyrus-imapd-2.2.12quota/lib/prot.c 2005-10-26 11:53:34.000000000 +0200 | |
635 | @@ -871,6 +871,11 @@ | |
636 | char buf[30]; | |
637 | va_start(pvar, fmt); | |
638 | ||
639 | +#ifdef HAVE_LONG_LONG_INT | |
640 | + long long int ll; | |
641 | + unsigned long long int ull; | |
642 | +#endif | |
643 | + | |
644 | assert(s->write); | |
645 | ||
646 | while ((percent = strchr(fmt, '%')) != 0) { | |
647 | @@ -894,6 +899,27 @@ | |
648 | prot_write(s, buf, strlen(buf)); | |
649 | break; | |
650 | ||
651 | +#ifdef HAVE_LONG_LONG_INT | |
652 | + case 'l': | |
653 | + switch (*++percent) { | |
654 | + case 'd': | |
655 | + ll = va_arg(pvar, long long int); | |
656 | + snprintf(buf, sizeof(buf), "%lld", ll); | |
657 | + prot_write(s, buf, strlen(buf)); | |
658 | + break; | |
659 | + | |
660 | + case 'u': | |
661 | + ull = va_arg(pvar, unsigned long long int); | |
662 | + snprintf(buf, sizeof(buf), "%llu", ull); | |
663 | + prot_write(s, buf, strlen(buf)); | |
664 | + break; | |
665 | + | |
666 | + default: | |
667 | + abort(); | |
668 | + } | |
669 | + break; | |
670 | +#endif | |
671 | + | |
672 | default: | |
673 | abort(); | |
674 | } | |
675 |