-void lprintf (int loglevel, const char *format, ...);
-void init_sysdep (void);
-void begin_critical_section (int which_one);
-void end_critical_section (int which_one);
-int ig_tcp_server (int port_number, int queue_len);
-int ig_uds_server(char *sockpath, int queue_len);
-struct CitContext *MyContext (void);
-struct CitContext *CreateNewContext (void);
-void InitMyContext (struct CitContext *con);
-void client_write (char *buf, int nbytes);
+#include <stdarg.h>
+#include "sysdep.h"
+
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+
+#ifdef HAVE_DB_H
+#include <db.h>
+#elif defined(HAVE_DB4_DB_H)
+#include <db4/db.h>
+#else
+#error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
+#endif
+
+
+#if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1
+#error Citadel requires Berkeley DB v4.1 or newer. Please upgrade.
+#endif
+
+#include "server.h"
+#include "database.h"
+
+#if SIZEOF_SIZE_T == SIZEOF_INT
+#define SIZE_T_FMT "%d"
+#else
+#define SIZE_T_FMT "%ld"
+#endif
+
+#if SIZEOF_LOFF_T == SIZEOF_LONG
+#define LOFF_T_FMT "%ld"
+#else
+#define LOFF_T_FMT "%lld"
+#endif
+
+void cputbuf(const StrBuf *Buf);
+
+#ifdef __GNUC__
+void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
+#else