c2f95780459e9a7dec6c4d831d587420c39432ae
[citadel.git] / citadel / sysdep_decls.h
1
2 #ifndef SYSDEP_DECLS_H
3 #define SYSDEP_DECLS_H
4
5 #include <stdarg.h>
6 #include "sysdep.h"
7
8 #ifdef HAVE_PTHREAD_H
9 #include <pthread.h>
10 #endif
11
12 #ifdef HAVE_DB_H
13 #include <db.h>
14 #elif defined(HAVE_DB4_DB_H)
15 #include <db4/db.h>
16 #else
17 #error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
18 #endif
19
20
21 #if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1
22 #error Citadel requires Berkeley DB v4.1 or newer.  Please upgrade.
23 #endif
24
25 #include "server.h"
26 #include "database.h"
27
28 #if SIZEOF_SIZE_T == SIZEOF_INT 
29 #define SIZE_T_FMT "%d"
30 #else
31 #define SIZE_T_FMT "%ld"
32 #endif
33
34 void cputbuf(const StrBuf *Buf);
35
36 #ifdef __GNUC__
37 void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
38 #else
39 void cprintf (const char *format, ...);
40 #endif
41
42 void init_sysdep (void);
43 int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errormessage);
44 int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage);
45 void buffer_output(void);
46 void unbuffer_output(void);
47 void flush_output(void);
48 int client_write (const char *buf, int nbytes);
49 int client_read_to (char *buf, int bytes, int timeout);
50 int client_read (char *buf, int bytes);
51 int client_getln (char *buf, int maxbytes);
52 int CtdlClientGetLine(StrBuf *Target);
53 int client_read_blob(StrBuf *Target, int bytes, int timeout);
54 void client_set_inbound_buf(long N);
55 int client_read_random_blob(StrBuf *Target, int timeout);
56 void client_close(void);
57 void sysdep_master_cleanup (void);
58 void kill_session (int session_to_kill);
59 void start_daemon (int do_close_stdio);
60 void checkcrash(void);
61 void cmd_nset (char *cmdbuf);
62 int convert_login (char *NameToConvert);
63 void *worker_thread (void *arg);
64 void init_master_fdset(void);
65 void create_worker(void);
66 void *select_on_master (void *arg);
67
68 extern volatile int exit_signal;
69 extern volatile int shutdown_and_halt;
70 extern volatile int running_as_daemon;
71 extern volatile int restart_server;
72
73 extern int verbosity;
74 extern int rescan[];
75
76
77 extern int SyslogFacility(char *name);
78
79
80 /*
81  * Typdefs and stuff to abstract pthread for Citadel
82  */
83 #ifdef HAVE_PTHREAD_H
84
85 typedef pthread_t       citthread_t;
86 typedef pthread_key_t   citthread_key_t;
87 typedef pthread_mutex_t citthread_mutex_t;
88 typedef pthread_cond_t  citthread_cond_t;
89 typedef pthread_attr_t  citthread_attr_t;
90
91
92 #define citthread_mutex_init    pthread_mutex_init
93 #define citthread_cond_init     pthread_cond_init
94 #define citthread_attr_init     pthread_attr_init
95 #define citthread_mutex_trylock pthread_mutex_trylock
96 #define citthread_mutex_lock    pthread_mutex_lock
97 #define citthread_mutex_unlock  pthread_mutex_unlock
98 #define citthread_key_create    pthread_key_create
99 #define citthread_getspecific   pthread_getspecific
100 #define citthread_setspecific   pthread_setspecific
101 #define citthread_mutex_destroy pthread_mutex_destroy
102 #define citthread_cond_destroy  pthread_cond_destroy
103 #define citthread_attr_destroy  pthread_attr_destroy
104
105 #define citthread_kill          pthread_kill
106 #define citthread_cond_signal   pthread_cond_signal
107 #define citthread_cancel        pthread_cancel
108 #define citthread_cond_timedwait        pthread_cond_timedwait
109 #define citthread_equal         pthread_equal
110 #define citthread_self          pthread_self
111 #define citthread_create        pthread_create
112 #define citthread_attr_setstacksize     pthread_attr_setstacksize
113 #define citthread_join          pthread_join
114 #define citthread_cleanup_push  pthread_cleanup_push
115 #define citthread_cleanup_pop   pthread_cleanup_pop
116
117
118 #endif /* HAVE_PTHREAD_H */
119
120 #endif /* SYSDEP_DECLS_H */