deheader: remove headers included more than once

The deheader 0.8 programme found some headers included more than once:

cyrus-imap(master)$ deheader
./timsieved/actions.c has more than one inclusion of <stdlib.h>
./imap/reconstruct.c has more than one inclusion of "global.h"
./imap/reconstruct.c has more than one inclusion of <stdlib.h>
./imap/autocreate.c has more than one inclusion of <config.h>
./imap/mbexamine.c has more than one inclusion of <stdlib.h>
./imap/mbdump.c has more than one inclusion of <sys/types.h>
./imap/mbtool.c has more than one inclusion of <stdlib.h>
./imap/idlemsg.c has more than one inclusion of <syslog.h>
./imap/lmtpengine.c has more than one inclusion of <arpa/inet.h>
./imap/lmtpengine.c has more than one inclusion of <netdb.h>
./imap/lmtpengine.c has more than one inclusion of <sys/socket.h>
./imap/lmtpengine.c has more than one inclusion of <netinet/in.h>
./netnews/remotepurge.c has more than one inclusion of <netdb.h>
./netnews/remotepurge.c has more than one inclusion of <netinet/in.h>
./lib/util.c has more than one inclusion of <errno.h>
./master/service-thread.c has more than one inclusion of <sys/time.h>
./master/service-thread.c has more than one inclusion of <sys/types.h>
./master/service.c has more than one inclusion of <sys/time.h>
./master/service.c has more than one inclusion of <sys/types.h>
./ptclient/ptloader.c has more than one inclusion of <sys/types.h>
./sieve/sieve-lex.c has more than one inclusion of <string.h>
./sieve/test.c has more than one inclusion of <sys/stat.h>
./sieve/addr-lex.c has more than one inclusion of <stdlib.h>
./sieve/addr-lex.c has more than one inclusion of <string.h>

(The real output of deheader puts a "deheader: " prefix on each line,
which is removed in the above output).

My sieve/(addr,sieve)-lex.c were generated using flex 2.5.37 .

imap/mbdump.c: (not reported by deheader)
  remove double inclusion of unistd.h (once unconditionally and once
  conditionally)
deheader: remove unnecessary #include <utime.h>

As of http://pubs.opengroup.org/onlinepubs/7908799/xsh/utime.h.html
utime.h defines utime() and struct utimbuf.  None of these are used in
the patched files.  Found with
$ deheader
[...]
deheader: remove <utime.h> from ./imap/append.c
deheader: remove <utime.h> from ./imap/dlist.c
deheader: remove <utime.h> from ./imap/reconstruct.c
deheader: remove <utime.h> from ./imap/sync_client.c
deheader: fix usage of #include <ctype.h>

-- remove #include <ctype.h> from lib/libcyr_cfg.h, lib/mpool.h,
   imap/index.h

-- add #include <ctype.h> to files in ptclient/, as suggested by
   `deheader`

-- remove #include <ctype.h> from all files, as suggested by
   `deheader`

-- add #include <ctype.h> to lib/util.h, as isalnum() etc are used
   there.
deheader: fix usage of #include <syslog.h>

-- remove #include <syslog.h> from imap/index.c, lib/auth_pts.h,
   lib/mpool.h

-- remove #include <syslog.h> from .c files, as suggested by `deheader`

-- tools/config2header : do not #include <syslog.h> in the generated
   lib/imapopts.h
remove notifyd/version.h

.. as the macros defined in the file are nowhere used.
timsieved/: update usage of #include "imap/version.h"
imap/spool.c: remove #include "imap/nntp_err.h"

... as the definitions of nttp_err.h are not used in imap/spool.c (in fact
imap/spool.c does not mention the word nntp)
imap/sync_server.c: remove #include "imap/spool.h"

... as the declarations of imap/spool.h are not used in imap/sync_server.c
timsieved/: fix usage of (actions,codes).h

-- remove timsieved/codes.h from timsieved/actions.h, as the definitions
   from codes.h are not used in timsieved/actions.h
-- include codes.h where necessary
-- remove #include "timsieved/actions.h" from timsieved/lex.c, as it is
   not needed.
deheader: remove unnecessary #include "duplicate.h"
deheader: remove unnecessary #include "sync_log.h"
deheader: remove unnecessary #include "statuscache.h"
imap/cyr_virusscan.c: fix usage of mailbox_expunge

Change to the interface of mailbox_expunge was introduced in commit
fdc0eb3d, but the last parameter in imap/cyr_virusscan.c was not
replaced from 0 to NULL.

-- remove one argument from call of mailbox_open_iwl ()
deheader: fix usage of #include <errno.h>

-- add #include <errno.h> to lib/libconfig.h and imap/append.c

   #include <config.h> implied #include <com_err.h> -> #include
   <table_error.h> -> #include <errno.h>.  So #include <config.h>
   implies #include <errno.h>.  If this implication breaks, lib/libconfig.h
   and imap/append.c wouldn't compile, as they use the
   errno variable.

-- remove #include <errno.h> from imap/index.h, lib/mpool.h, lib/auth_pts.h
   as these header files make no use of errno.h

-- remove #include <errno.h> from all files, that do not need it.
sync: use strarray_t for channel names.

Also, allow "" in sync_log_channels conf option to mean "the default
channel".  This will help sysadmins who have a config with only a single
default sync channel (sync_log=1 but no sync_log_channels) to enable a
sync log to the squatter daemon without disturbing their existing
sync_client configuration.

v2: merged
e134c1a sync: fix some compile warnings
f3ed204 sync: small refactor of sync_log_init()
8dd7100 sync: allow "" in sync_log_channels conf option
00f5a94 sync: fix memleak in sync_log_init()
sync: remove some unncessary code

really, it's unhelpful for code to be able to push log items to a
specific channel and not to others, and it wasn't being used, so delete
it.
sync: pull sync log reading into common code

so that it can be re-used by another process which isn't sync_client,
namely the upcoming daemon mode for squatter.
sync: don't coredump if sync_log_init() not called

All the real programs do so, but the cunit tests don't.
lock: pass filename to ALL lock functions

This will help with lock order debugging, and possibly with
more general "long lock" tracking too.

(cherry-picked from FM branch, partial)
sync: unlock immediately after rename