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
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?])
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
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;
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 @@
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);
56 prot_printf(imapd_out, "* NO [ALERT] %s\r\n",
57 error_message(IMAP_NO_OVERQUOTA));
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);
66 prot_printf(imapd_out, ")\r\n");
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,
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
83 +#include "byteorder64.h"
85 static int mailbox_doing_reconstruct = 0;
86 #define zeromailbox(m) { memset(&m, 0, sizeof(struct mailbox)); \
89 ntohl(*((bit32 *)(mailbox->index_base+OFFSET_LAST_UID)));
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)));
98 mailbox->quota_mailbox_used =
99 ntohl(*((bit32 *)(mailbox->index_base+OFFSET_QUOTA_MAILBOX_USED-quota_upgrade_offset)));
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 */
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);
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);
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 */
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);
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);
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 @@
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);
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);
162 *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)) =
163 htonl(ntohl(*((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED)))-quotadeleted);
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);
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);
177 @@ -2132,7 +2165,7 @@
178 r = quota_write(&mailbox->quota, &tid);
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);
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;
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;
204 @@ -2617,7 +2650,7 @@
205 else if (r2 == IMAP_QUOTAROOT_NONEXISTENT) r2 = 0;
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);
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
217 #include <sys/types.h>
218 #include <sys/stat.h>
225 #error dont know what to use for bit32
228 +#ifdef HAVE_LONG_LONG_INT
229 +typedef unsigned long long int bit64;
232 #define MAX_MAILBOX_NAME 490
233 #define MAX_MAILBOX_PATH 4096
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;
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
260 struct buf file, data;
263 + uquota_t quotaused = 0;
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
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);
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);
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
298 - unsigned long newused;
302 #define QUOTAGROW 300
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);
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 @@
323 char buf[MAX_MAILBOX_PATH+1];
325 - printf(" Quota %% Used Used Root\n");
326 + printf(" Quota %% Used Used Root\n");
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);
335 else if (quota[i].quota.limit == 0) {
337 (*quota_namespace.mboxname_toexternal)("a_namespace,
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);
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
351 - sscanf(data, "%lu %d", "a->used, "a->limit);
352 + sscanf(data, UQUOTA_T_FMT " %d", "a->used, "a->limit);
357 if (!qrlen) return IMAP_QUOTAROOT_NONEXISTENT;
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);
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
369 #define INCLUDED_QUOTA_H
374 #define FNAME_QUOTADB "/quotas.db"
376 #define QUOTA_UNITS (1024)
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.
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"
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"
396 extern struct db *qdb;
401 /* Information in quota entry */
402 - unsigned long used;
404 int limit; /* in QUOTA_UNITS */
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
412 #include "convert_code.h"
414 +#include "byteorder64.h"
419 char *list_acl, *list_part;
422 - unsigned long new_quota = 0;
423 + uquota_t new_quota = 0;
425 struct index_record message_index, old_index;
426 static struct index_record zero_index;
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);
433 + /* quotas may be 64bit now */
434 +#ifdef HAVE_LONG_LONG_INT
435 + *((bit64 *)(buf+OFFSET_QUOTA_MAILBOX_USED64)) = htonll(new_quota);
437 + *((bit32 *)(buf+OFFSET_QUOTA_MAILBOX_USED32)) = htonl(new_quota);
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
447 +/* byteorder64.c -- convert 64-bit values between host and network byte order
449 + * Copyright (c) 2004 Carnegie Mellon University. All rights reserved.
451 + * Redistribution and use in source and binary forms, with or without
452 + * modification, are permitted provided that the following conditions
455 + * 1. Redistributions of source code must retain the above copyright
456 + * notice, this list of conditions and the following disclaimer.
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
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
474 + * 4. Redistributions of any form whatsoever must retain the following
476 + * "This product includes software developed by Computing Services
477 + * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
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.
492 +#if defined(HAVE_LONG_LONG_INT) && !defined(WORDS_BIGENDIAN)
494 +#include <netinet/in.h>
496 +/* Structure used to swap the bytes in a 64-bit unsigned long long. */
497 +union byteswap_64_u {
498 + unsigned long long a;
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.
508 +unsigned long long _htonll(unsigned long long x)
510 + union byteswap_64_u u1;
511 + union byteswap_64_u u2;
515 + u2.b[0] = htonl(u1.b[1]);
516 + u2.b[1] = htonl(u1.b[0]);
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.
528 +unsigned long long _ntohll(unsigned long long x)
530 + union byteswap_64_u u1;
531 + union byteswap_64_u u2;
535 + u2.b[1] = ntohl(u1.b[0]);
536 + u2.b[0] = ntohl(u1.b[1]);
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
546 +/* byteorder64.h -- convert 64-bit values between host and network byte order
548 + * Copyright (c) 2004 Carnegie Mellon University. All rights reserved.
550 + * Redistribution and use in source and binary forms, with or without
551 + * modification, are permitted provided that the following conditions
554 + * 1. Redistributions of source code must retain the above copyright
555 + * notice, this list of conditions and the following disclaimer.
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
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
573 + * 4. Redistributions of any form whatsoever must retain the following
575 + * "This product includes software developed by Computing Services
576 + * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
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.
589 +#ifndef _BYTEORDER64_H
590 +#define _BYTEORDER64_H
594 +#ifdef HAVE_LONG_LONG_INT
596 +/* 64-bit host/network byte-order swap macros */
597 +#ifdef WORDS_BIGENDIAN
598 +#define htonll(x) (x)
599 +#define ntohll(x) (x)
601 +#define htonll(x) _htonll(x)
602 +#define ntohll(x) _ntohll(x)
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);
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
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
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 \
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
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
639 +#ifdef HAVE_LONG_LONG_INT
641 + unsigned long long int ull;
646 while ((percent = strchr(fmt, '%')) != 0) {
648 prot_write(s, buf, strlen(buf));
651 +#ifdef HAVE_LONG_LONG_INT
653 + switch (*++percent) {
655 + ll = va_arg(pvar, long long int);
656 + snprintf(buf, sizeof(buf), "%lld", ll);
657 + prot_write(s, buf, strlen(buf));
661 + ull = va_arg(pvar, unsigned long long int);
662 + snprintf(buf, sizeof(buf), "%llu", ull);
663 + prot_write(s, buf, strlen(buf));