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 /* Logging levels - correspond to syslog(3) */
46 /* When about to exit the server for an unrecoverable error */
47 CTDL_EMERG, /* system is unusable */
48 /* Manual intervention is required to avoid an abnormal exit */
49 CTDL_ALERT, /* action must be taken immediately */
50 /* The server can continue to run with degraded functionality */
51 CTDL_CRIT, /* critical conditions */
52 /* An error occurs but the server continues to run normally */
53 CTDL_ERR, /* error conditions */
54 /* An abnormal condition was detected; server will continue normally */
55 CTDL_WARNING, /* warning conditions */
56 /* Normal messages (login/out, activity, etc.) */
57 CTDL_NOTICE, /* normal but significant condition */
58 /* Unimportant progress messages, etc. */
59 CTDL_INFO, /* informational */
60 /* Debugging messages */
61 CTDL_DEBUG /* debug-level messages */
65 void lprintf (enum LogLevel loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
66 void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)));
68 void lprintf (enum LogLevel loglevel, const char *format, ...);
69 void cprintf (const char *format, ...);
72 void vlprintf (enum LogLevel loglevel, const char *format, va_list arg_ptr);
74 extern pthread_key_t MyConKey; /* TSD key for MyContext() */
76 extern int enable_syslog;
78 void init_sysdep (void);
79 int ig_tcp_server (char *ip_addr, int port_number, int queue_len,char **errormessage);
80 int ig_uds_server(char *sockpath, int queue_len, char **errormessage);
81 struct CitContext *MyContext (void);
82 struct CitContext *CreateNewContext (void);
83 void InitMyContext (struct CitContext *con);
84 void buffer_output(void);
85 void unbuffer_output(void);
86 void flush_output(void);
87 void client_write (char *buf, int nbytes);
88 int client_read_to (char *buf, int bytes, int timeout);
89 int client_read (char *buf, int bytes);
90 int client_getln (char *buf, int maxbytes);
91 void sysdep_master_cleanup (void);
92 void kill_session (int session_to_kill);
93 void *sd_context_loop (struct CitContext *con);
94 void start_daemon (int do_close_stdio);
95 void cmd_nset (char *cmdbuf);
96 int convert_login (char *NameToConvert);
97 void *worker_thread (void *arg);
98 void *context_cleanup_thread (void *arg);
99 void become_session(struct CitContext *which_con);
100 void InitializeMasterCC(void);
101 void init_master_fdset(void);
102 void create_worker(void);
105 extern int num_sessions;
106 extern volatile int exit_signal;
107 extern volatile int shutdown_and_halt;
108 extern volatile int running_as_daemon;
109 extern volatile int restart_server;
111 extern int verbosity;
117 extern int SyslogFacility(char *name);
118 extern int syslog_facility;
122 * Typdefs and stuff to abstract pthread for Citadel
124 #ifdef HAVE_PTHREAD_H
126 typedef pthread_t citthread_t;
127 typedef pthread_key_t citthread_key_t;
128 typedef pthread_mutex_t citthread_mutex_t;
129 typedef pthread_cond_t citthread_cond_t;
130 typedef pthread_attr_t citthread_attr_t;
133 #define citthread_mutex_init pthread_mutex_init
134 #define citthread_cond_init pthread_cond_init
135 #define citthread_attr_init pthread_attr_init
136 #define citthread_mutex_trylock pthread_mutex_trylock
137 #define citthread_mutex_lock pthread_mutex_lock
138 #define citthread_mutex_unlock pthread_mutex_unlock
139 #define citthread_key_create pthread_key_create
140 #define citthread_getspecific pthread_getspecific
141 #define citthread_setspecific pthread_setspecific
142 #define citthread_mutex_destroy pthread_mutex_destroy
143 #define citthread_cond_destroy pthread_cond_destroy
144 #define citthread_attr_destroy pthread_attr_destroy
146 #define citthread_kill pthread_kill
147 #define citthread_cond_signal pthread_cond_signal
148 #define citthread_cancel pthread_cancel
149 #define citthread_cond_timedwait pthread_cond_timedwait
150 #define citthread_equal pthread_equal
151 #define citthread_self pthread_self
152 #define citthread_create pthread_create
153 #define citthread_attr_setstacksize pthread_attr_setstacksize
154 #define citthread_join pthread_join
155 #define citthread_cleanup_push pthread_cleanup_push
156 #define citthread_cleanup_pop pthread_cleanup_pop
159 #endif /* HAVE_PTHREAD_H */
162 #ifdef DEBUG_MEMORY_LEAKS
163 #define malloc(x) tracked_malloc(x, __FILE__, __LINE__)
164 #define realloc(x,y) tracked_realloc(x, y, __FILE__, __LINE__)
166 #define strdup(x) tracked_strdup(x, __FILE__, __LINE__)
167 #define free(x) tracked_free(x)
168 void *tracked_malloc(size_t size, char *file, int line);
169 void *tracked_realloc(void *ptr, size_t size, char *file, int line);
170 void tracked_free(void *ptr);
171 char *tracked_strdup(const char *s, char *file, int line);
172 void dump_heap(void);
175 #endif /* SYSDEP_DECLS_H */