* added message subject to all those tiny messages
[citadel.git] / citadel / sysdep_decls.h
1 /* $Id$ */
2
3
4 /*
5  * Uncomment this #define if you are a Citadel developer tracking
6  * down memory leaks in the server.  Do NOT do this on a production
7  * system because it definitely incurs a lot of additional overhead.
8  */
9 /* #define DEBUG_MEMORY_LEAKS */
10
11
12 #include <pthread.h>
13 #include "sysdep.h"
14 #include "server.h"
15
16 /* Logging levels - correspond to syslog(3) */
17 enum LogLevel {
18         /* When about to exit the server for an unrecoverable error */
19          CTDL_EMERG,    /* system is unusable */
20         /* Manual intervention is required to avoid an abnormal exit */
21          CTDL_ALERT,    /* action must be taken immediately */
22         /* The server can continue to run with degraded functionality */
23          CTDL_CRIT,     /* critical conditions */
24         /* An error occurs but the server continues to run normally */
25          CTDL_ERR,      /* error conditions */
26         /* An abnormal condition was detected; server will continue normally */
27          CTDL_WARNING,  /* warning conditions */
28         /* Normal messages (login/out, activity, etc.) */
29          CTDL_NOTICE,   /* normal but significant condition */
30         /* Unimportant progress messages, etc. */
31          CTDL_INFO,     /* informational */
32         /* Debugging messages */
33          CTDL_DEBUG     /* debug-level messages */
34 };
35
36 #ifdef __GNUC__
37 void lprintf (enum LogLevel loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
38 void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
39 #else
40 void lprintf (enum LogLevel loglevel, const char *format, ...);
41 void cprintf (const char *format, ...);
42 #endif
43
44 extern pthread_key_t MyConKey;                  /* TSD key for MyContext() */
45
46 extern int enable_syslog;
47
48 void init_sysdep (void);
49 void begin_critical_section (int which_one);
50 void end_critical_section (int which_one);
51 int ig_tcp_server (char *ip_addr, int port_number, int queue_len,char **errormessage);
52 int ig_uds_server(char *sockpath, int queue_len, char **errormessage);
53 struct CitContext *MyContext (void);
54 struct CitContext *CreateNewContext (void);
55 void InitMyContext (struct CitContext *con);
56 void buffer_output(void);
57 void unbuffer_output(void);
58 void flush_output(void);
59 void client_write (char *buf, int nbytes);
60 int client_read_to (char *buf, int bytes, int timeout);
61 int client_read (char *buf, int bytes);
62 int client_getln (char *buf, int maxbytes);
63 void sysdep_master_cleanup (void);
64 void kill_session (int session_to_kill);
65 void *sd_context_loop (struct CitContext *con);
66 void start_daemon (int do_close_stdio);
67 void cmd_nset (char *cmdbuf);
68 int convert_login (char *NameToConvert);
69 void *worker_thread (void *arg);
70 void become_session(struct CitContext *which_con);
71 void InitializeMasterCC(void);
72 void init_master_fdset(void);
73 void create_worker(void);
74
75 extern int num_sessions;
76 extern volatile int time_to_die;
77 extern volatile int shutdown_and_halt;
78
79 extern int verbosity;
80 extern int rescan[];
81
82 extern struct worker_node {
83         pthread_t tid;
84         struct worker_node *next;
85 } *worker_list;
86
87 extern int SyslogFacility(char *name);
88 extern int syslog_facility;
89
90 #ifdef DEBUG_MEMORY_LEAKS
91 #define malloc(x) tracked_malloc(x, __FILE__, __LINE__)
92 #define realloc(x,y) tracked_realloc(x, y, __FILE__, __LINE__)
93 #undef strdup
94 #define strdup(x) tracked_strdup(x, __FILE__, __LINE__)
95 #define free(x) tracked_free(x)
96 void *tracked_malloc(size_t size, char *file, int line);
97 void *tracked_realloc(void *ptr, size_t size, char *file, int line);
98 void tracked_free(void *ptr);
99 char *tracked_strdup(const char *s, char *file, int line);
100 void dump_heap(void);
101 #endif
102
103 void create_maintenance_threads(void);
104 extern pthread_t indexer_thread_tid;
105 extern pthread_t checkpoint_thread_tid;