The number of mailboxes and the number of messages in each mailbox are stored in the same unsigned integer (32 bits), with 16 bits used for each number. The number of mailboxes is in the upper 16 bits; the number of messages per mailbox is in the lower 16 bits.
It's not hard to re-proportion the number of bits used for each, i.e. by decreasing the number of mailboxes to increase the number of messages or vice-versa. You only need to modify encode_mbox_indices()
and decode_mbox_indices()
in mbox.c
.
I did this in an earlier version of mairix, reducing the number of mailboxes to 8 bits and increasing the number of messages to 24 bits.
Of course you have to rebuild all your mairix index files if you do this.
1027c1059,1063
< unsigned int encode_mbox_indices(unsigned int mb, unsigned int msg)/*{{{*/
---
> #define SHIFTBITS 24 /* how many bits to use to count messages */
> #define SHIFTMASKMBS ((1<<(32-SHIFTBITS))-1)
> #define SHIFTMASKMSGS ((1<<SHIFTBITS)-1)
>
> inline unsigned int encode_mbox_indices(unsigned int mb, unsigned int msg)/*{{{*/
1029,1031c1065
< unsigned int result;
< result = ((mb & 0xffff) << 16) | (msg & 0xffff);
< return result;
---
> return (mb << SHIFTBITS) | msg;
1034c1068
< void decode_mbox_indices(unsigned int index, unsigned int *mb, unsigned int *msg)/*{{{*/
---
> inline void decode_mbox_indices(unsigned int myindex, unsigned int *mb, unsigned int *msg)/*{{{*/
1036,1037c1070,1071
< *mb = (index >> 16) & 0xffff;
< *msg = (index & 0xffff);
---
> *mb = (myindex >> SHIFTBITS) & SHIFTMASKMBS;
> *msg = (myindex & SHIFTMASKMSGS);
1044,1045c1078,1080
< if (db->n_mboxen > 65536) {
< fprintf(stderr, "Too many mboxes (max 65536, you have %d)\n", db->n_mboxen);
---
> if (db->n_mboxen >= SHIFTMASKMBS) {
> fprintf(stderr, "Too many mboxes (max %d, you have %d)\n",
> SHIFTMASKMBS, db->n_mboxen);
1050,1052c1085,1087
< if (db->mboxen[i].n_msgs > 65536) {
< fprintf(stderr, "Too many messages in mbox %s (max 65536, you have %d)\n",
< db->mboxen[i].path, db->mboxen[i].n_msgs);
---
> if (db->mboxen[i].n_msgs >= SHIFTMASKMSGS) {
> fprintf(stderr, "Too many messages in mbox %s (max %d, you have %d)\n",
> db->mboxen[i].path, SHIFTMASKMSGS, db->mboxen[i].n_msgs);