7 * Uncomment this #define if you are a Citadel developer tracking
8 * down memory leaks in the server. Do NOT do this on a production
9 * system because it definitely incurs a lot of additional overhead.
10 #define DEBUG_MEMORY_LEAKS
23 #elif defined(HAVE_DB4_DB_H)
26 #error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
30 #if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1
31 #error Citadel requires Berkeley DB v4.1 or newer. Please upgrade.
37 #if SIZEOF_SIZE_T == SIZEOF_INT
38 #define SIZE_T_FMT "%d"
40 #define SIZE_T_FMT "%ld"
44 void cprintf (const char *format
, ...) __attribute__((__format__(__printf__
,1,2)));
46 void cprintf (const char *format
, ...);
49 void CtdlLogPrintf(enum LogLevel loglevel
, const char *format
, ...);
50 void vCtdlLogPrintf (enum LogLevel loglevel
, const char *format
, va_list arg_ptr
);
52 extern pthread_key_t MyConKey
; /* TSD key for MyContext() */
54 extern int enable_syslog
;
56 void init_sysdep (void);
57 int ig_tcp_server (char *ip_addr
, int port_number
, int queue_len
,char **errormessage
);
58 int ig_uds_server(char *sockpath
, int queue_len
, char **errormessage
);
59 struct CitContext
*MyContext (void);
60 struct CitContext
*CreateNewContext (void);
61 void InitMyContext (struct CitContext
*con
);
62 void buffer_output(void);
63 void unbuffer_output(void);
64 void flush_output(void);
65 int client_write (char *buf
, int nbytes
);
66 int client_read_to (char *buf
, int bytes
, int timeout
);
67 int client_read (char *buf
, int bytes
);
68 int client_getln (char *buf
, int maxbytes
);
69 void sysdep_master_cleanup (void);
70 void kill_session (int session_to_kill
);
71 void *sd_context_loop (struct CitContext
*con
);
72 void start_daemon (int do_close_stdio
);
73 void cmd_nset (char *cmdbuf
);
74 int convert_login (char *NameToConvert
);
75 void *worker_thread (void *arg
);
76 void *context_cleanup_thread (void *arg
);
77 void become_session(struct CitContext
*which_con
);
78 void InitializeMasterCC(void);
79 void init_master_fdset(void);
80 void create_worker(void);
83 extern int num_sessions
;
84 extern volatile int exit_signal
;
85 extern volatile int shutdown_and_halt
;
86 extern volatile int running_as_daemon
;
87 extern volatile int restart_server
;
95 extern int SyslogFacility(char *name
);
96 extern int syslog_facility
;
100 * Typdefs and stuff to abstract pthread for Citadel
102 #ifdef HAVE_PTHREAD_H
104 typedef pthread_t citthread_t
;
105 typedef pthread_key_t citthread_key_t
;
106 typedef pthread_mutex_t citthread_mutex_t
;
107 typedef pthread_cond_t citthread_cond_t
;
108 typedef pthread_attr_t citthread_attr_t
;
111 #define citthread_mutex_init pthread_mutex_init
112 #define citthread_cond_init pthread_cond_init
113 #define citthread_attr_init pthread_attr_init
114 #define citthread_mutex_trylock pthread_mutex_trylock
115 #define citthread_mutex_lock pthread_mutex_lock
116 #define citthread_mutex_unlock pthread_mutex_unlock
117 #define citthread_key_create pthread_key_create
118 #define citthread_getspecific pthread_getspecific
119 #define citthread_setspecific pthread_setspecific
120 #define citthread_mutex_destroy pthread_mutex_destroy
121 #define citthread_cond_destroy pthread_cond_destroy
122 #define citthread_attr_destroy pthread_attr_destroy
124 #define citthread_kill pthread_kill
125 #define citthread_cond_signal pthread_cond_signal
126 #define citthread_cancel pthread_cancel
127 #define citthread_cond_timedwait pthread_cond_timedwait
128 #define citthread_equal pthread_equal
129 #define citthread_self pthread_self
130 #define citthread_create pthread_create
131 #define citthread_attr_setstacksize pthread_attr_setstacksize
132 #define citthread_join pthread_join
133 #define citthread_cleanup_push pthread_cleanup_push
134 #define citthread_cleanup_pop pthread_cleanup_pop
137 #endif /* HAVE_PTHREAD_H */
140 #ifdef DEBUG_MEMORY_LEAKS
141 #define malloc(x) tracked_malloc(x, __FILE__, __LINE__)
142 #define realloc(x,y) tracked_realloc(x, y, __FILE__, __LINE__)
144 #define strdup(x) tracked_strdup(x, __FILE__, __LINE__)
145 #define free(x) tracked_free(x)
146 void *tracked_malloc(size_t size
, char *file
, int line
);
147 void *tracked_realloc(void *ptr
, size_t size
, char *file
, int line
);
148 void tracked_free(void *ptr
);
149 char *tracked_strdup(const char *s
, char *file
, int line
);
150 void dump_heap(void);
153 #endif /* SYSDEP_DECLS_H */