metadata: implement DEPTH={1,infinity} correctly

RFC5464 (and common sense) specifies that the subtree listed always
includes the root.
sync: fix memory leak syncing annotations
Bug 3723: make GETMETADATA compliant with the RFC

we now accept all the following as valid syntaxes for GETMETADATA:

 // no options - trivially RFC compliant
mailbox entry
mailbox (entries)

 // options in the correct place (per the ABNF in RFC5464)
(options) mailbox entry
(options) mailbox (entries)

 // options in the wrong place (per the examples in RFC5464)
mailbox (options) entry
mailbox (options) (entries)

 // all the above with multiple mailboxes
 // which is a non-standard Cyrus extension
(mailboxes) entry
(mailboxes) (entries)
(options) (mailboxes) entry
(options) (mailboxes) (entries)
(mailboxes) (options) entry
(mailboxes) (options) (entries)
Revert "Bug 3617: fix ACL check setting flags in delivery"

This reverts commit 43a295c51fe404841a14837dd9086d40c6a90160.
See the Bug for reasons why.
Fix use after free during LMTP delivery

Found by Valgrind during the Annotator.set_user_flag_deliver test.

Invalid read of size 1
   at 0x4C292A4: __GI_strlen (mc_replace_strmem.c:284)
   by 0x5070B0A: make_key (duplicate.c:129)
   by 0x5070ED8: duplicate_mark (duplicate.c:224)
   by 0x408BD1: deliver_mailbox (lmtpd.c:604)
   by 0x40976C: deliver_local (lmtpd.c:793)
   by 0x409B93: deliver (lmtpd.c:884)
   by 0x40DA4F: lmtpmode (lmtpengine.c:1271)
   by 0x408012: service_main (lmtpd.c:327)
   by 0x411DE5: main (service.c:627)
 Address 0x7e3d200 is 0 bytes inside a block of size 37 free'd
   at 0x4C27D71: free (vg_replace_malloc.c:366)
   by 0x5085324: mailbox_read_header (mailbox.c:1216)
   by 0x5087281: mailbox_commit_header (mailbox.c:1929)
   by 0x508776B: mailbox_commit (mailbox.c:2040)
   by 0x506896C: append_commit (append.c:261)
   by 0x408B5A: deliver_mailbox (lmtpd.c:597)
   by 0x40976C: deliver_local (lmtpd.c:793)
   by 0x409B93: deliver (lmtpd.c:884)
   by 0x40DA4F: lmtpmode (lmtpengine.c:1271)
   by 0x408012: service_main (lmtpd.c:327)
   by 0x411DE5: main (service.c:627)

The duplicate key is constructed by pointing to the mailbox' uuid.
But that string is freed and reallocated during append_commit() if
a new user flag was added to the mailbox during the append.  That
may be unusual but it is what that test does.

This bug has been lurking for some time but was brought to the
surface when commit

9b3ff71 Bug #3690 - duplicate database - use uniqueid

changed over to always using the uuid for the duplicate DB.
Bug 3535: double free in append_commit error path

A very obscure set of circumstances discovered by Coverity, CID 431.
The sequence set could be freed twice.  Fixed by adding a function
append_free() to centralise the structure cleanup.
Remove unused defined FLAGGROW
const correctness for struct sortcrit
Fix typo in comment above _index_extract_subject
Use struct buf in _pgsql_open()
Use xmalloc in timsieved/parser.c
buf_printf: allocate enough space in the second pass
buf: test long printf again
Bug 3768: Makefile.am: Add -lsasl and -lssl as explicit dependecies

Makefile.am:
`libtool --config` reports on some systems for link_all_deplibs "yes" on
others "no".  To have a reliable build system, when linking the executables,
libsasl and libssl are now mentioned explictly as dependencies.  Otherwise
libtool with link_all_deplibs=no will not pass -lsasl and -lssl to the
linker and the it will fail.
Bug 3782: allow disabling the active Sieve script, when no script is active

... this behaviour is "RFC 5804, Section 2.8 SETACTIVE command"-conform.
mboxevent: fix crash on failed append
index: update firstnotseen correctly when storing

NOTE: if we store \Seen it still doesn't get bumped higher,
but that's OK - since it's only used for optimisation after
the initial select anyway.
Bug 3784: Fix crash in THREAD REFERENCES

For a particular corner case involving messages which reference
themselves and a common missing ancestor.

Based on a patch by Wolfgang Breyha.
Remove mystring_t from timsieved/

Replace uses of this counted-string data structure with either plain
char* or struct buf.  Also, at one point there were three almost
identical mystring.h and mystring.c files.  Soon there will be zero.
Remove mystring_t in perl/sieve/

Replace uses of this counted-string data structure with either plain
char* or struct buf.  Also, at one point there were three almost
identical mystring.h and mystring.c files.  Now there are zero.