* serv_spam.c: use redirect_buffer instead of redirect_sock
[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 void init_sysdep (void);
45 void begin_critical_section (int which_one);
46 void end_critical_section (int which_one);
47 int ig_tcp_server (char *ip_addr, int port_number, int queue_len);
48 int ig_uds_server(char *sockpath, int queue_len);
49 struct CitContext *MyContext (void);
50 struct CitContext *CreateNewContext (void);
51 void InitMyContext (struct CitContext *con);
52 void buffer_output(void);
53 void unbuffer_output(void);
54 void flush_output(void);
55 void client_write (char *buf, int nbytes);
56 int client_read_to (char *buf, int bytes, int timeout);
57 int client_read (char *buf, int bytes);
58 int client_getln (char *buf, int maxbytes);
59 void sysdep_master_cleanup (void);
60 void kill_session (int session_to_kill);
61 void *sd_context_loop (struct CitContext *con);
62 void start_daemon (int do_close_stdio);
63 void cmd_nset (char *cmdbuf);
64 int convert_login (char *NameToConvert);
65 void *worker_thread (void *arg);
66 void become_session(struct CitContext *which_con);
67 void CtdlRedirectOutput(FILE *fp);
68 void InitializeMasterCC(void);
69 void init_master_fdset(void);
70 void create_worker(void);
71
72 extern int num_sessions;
73 extern volatile int time_to_die;
74 extern int verbosity;
75 extern int rescan[];
76
77 extern struct worker_node {
78         pthread_t tid;
79         struct worker_node *next;
80 } *worker_list;
81
82 extern int SyslogFacility(char *name);
83 extern int syslog_facility;
84
85 #ifdef DEBUG_MEMORY_LEAKS
86 #define malloc(x) tracked_malloc(x, __FILE__, __LINE__)
87 #define realloc(x,y) tracked_realloc(x, y, __FILE__, __LINE__)
88 #undef strdup
89 #define strdup(x) tracked_strdup(x, __FILE__, __LINE__)
90 #define free(x) tracked_free(x)
91 void *tracked_malloc(size_t size, char *file, int line);
92 void *tracked_realloc(void *ptr, size_t size, char *file, int line);
93 void tracked_free(void *ptr);
94 char *tracked_strdup(const char *s, char *file, int line);
95 void dump_heap(void);
96 #endif