mboxevent: handle unsigned values correctly

This allows master to build with -Werror again
mboxevent: protect against disabled events in add_flags
Revert "sieve/bc_eval: fix memory leak"

This reverts commit 55ac1abac8e4bc8c65351c4eebb4fda306937a8a.

Actually, the memory WAS freed - because it got passed to do_vacation
which, which does horrible things with putting it in a struct and then
freeing it when the struct finishes.

The whole lifetimes of allocated memory and ownership chain is horribly
complex and broken in a lot of sieve - but the way to fix it sure isn't
just blindy deallocating.  It's going to take a lot more work than this.
buf: fix off-by-one in buffer sizing
cyrusdb: add 'cyrusdb_repack' API
cyr_dbtool: add 'repack' command
index: use index_getuid to access index_map in squatter
Bug#3226 Switch Sieve port from 2000 to 4190

supplements commit 4bba1727c06a854ec4 "Change MANAGESIEVE default port
from 2000 to 4190"
idle: close SIGTERM/select race

which was making Cyrus shutdown racily dirty, with both

 - imapds blocking in idle_wait(), and

 - idled itself

randomly failing to respond to the SIGTERM resent from master.
Also use signals_select() in prot_*() functions

from review comments by brong.

This required adding recursion prevention to signals.c, as the
shut_down() in imapd calls prot_fill().
strncmpsafe: more nice APIs
index: add mboxname and hasrights APIs rather than direct access
mailbox: remove mailbox_findopen - not used any more
append: get rid of the mailbox lifetime mismatch

If you do append_setup, the append struct manages the
mailbox lifetime.

If you do append_setup_mbox, the caller is responsible
for creating a locked mailbox struct and closing it again.

Simple.
mailbox: remove mailbox_ref

This abortion is no longer required, because we don't have the
append state being unbalanced any more.
index: remove bogus ;;
fetch: setseen only from lastunseen

Optimisation for common cases
index: minimise the size of struct index_map

This reduces the memory usage for a large index considerably,
from 256 bytes per record down to just 48 bytes.  That's a
pretty massive saving for a big mailbox!

This is achieved by only keeping copies of the mutable data about
each record in the index_map.

There are two new functions - one for re-reading the record and
applying the mutable data to it, and another for writing a record
and updating the mutable data in the map to match.

Because the re-reads may be done without a cyrus.index lock held,
they can contain incorrect data in the mutable fields, but this
gets overwritten by the snapshotted version in the map before use.
index: track generation in index state

This can never change due to the held namelock at the moment, but
later it will be possible to release the namelock and allow a
repack.

We then need to know the repack has happened so we can sweep through
and update the recno pointers to their new locations in the
cyrus.index file.  Luckily, the generation_no header field already
tracks exactly this.

(NOTE: repack can happen without bumping highestmodseq, in fact it
 usually does, hence the need for a separate check)
index: notice UIDVALIDITY changes and treat as deletes

This is necessary because without the namelock, the folder
may be deleted and then created again without our session
noticing, meaning the UIDs will be all wrong.

We can just treat the change the same way we would treat
a delete at the index level.  The user will be told that
the current mailbox has been deleted, and if they select
again they will see the new UIDVALIDITY.