2 typedef pthread_t THREAD;
4 /* Uncomment this if you want to track memory leaks.
5 * This incurs some overhead, so don't use it unless you're debugging the code!
7 #define DEBUG_MEMORY_LEAKS
11 * Generic per-session variable or data structure storage
14 struct CtdlSessData *next;
20 * Static user data symbol types
23 SYM_DESIRED_SECTION, /* Used by the MIME parser */
29 * Here's the big one... the Citadel context structure.
31 * This structure keeps track of all information relating to a running
32 * session on the server. We keep one of these for each session thread.
34 * Note that the first element is "*next" so that it may be used without
35 * modification in a linked list.
38 struct CitContext *next; /* Link to next session in the list */
40 struct usersupp usersupp; /* Database record buffers */
41 struct quickroom quickroom;
46 char curr_user[32]; /* name of current user */
47 int logged_in; /* logged in */
48 int internal_pgm; /* authenticated as internal program */
49 char temp[32]; /* temp file name */
50 int nologin; /* not allowed to log in */
54 int n_crit; /* number of critical sections open */
56 int cs_pid; /* session ID */
57 char cs_room[ROOMNAMELEN]; /* current room */
58 time_t cs_lastupdt; /* time of last update */
59 time_t lastcmd; /* time of last command executed */
60 time_t lastidle; /* For computing idle time */
61 char lastcmdname[5]; /* name of last command executed */
62 unsigned cs_flags; /* miscellaneous flags */
64 /* feeping creaturisms... */
65 int cs_clientdev; /* client developer ID */
66 int cs_clienttyp; /* client type code */
67 int cs_clientver; /* client version number */
68 char cs_clientname[32]; /* name of client software */
69 char cs_host[25]; /* host logged in from */
71 FILE *download_fp; /* Fields relating to file transfer */
75 char upl_comment[256];
76 char upl_filedir[256];
77 char chat_room[20]; /* The chat room */
81 struct ExpressMessage *FirstExpressMessage;
83 char fake_username[32]; /* Fake username <bc> */
84 char fake_postname[32]; /* Fake postname <bc> */
85 char fake_hostname[25]; /* Name of the fake hostname <bc> */
86 char fake_roomname[ROOMNAMELEN]; /* Name of the fake room <bc> */
88 int FloorBeingSearched; /* This is used by cmd_lrms() etc. */
89 struct CtdlSessData *FirstSessData;
92 typedef struct CitContext t_context;
94 #define CS_STEALTH 1 /* stealth mode */
95 #define CS_CHAT 2 /* chat mode */
96 #define CS_POSTING 4 /* Posting */
98 struct CitContext *MyContext(void);
99 #define CC ((struct CitContext *)MyContext())
101 extern struct CitContext *ContextList;
102 extern int ScheduledShutdown;
103 extern struct CitControl CitControl;
106 struct ExpressMessage {
107 struct ExpressMessage *next;
108 time_t timestamp; /* When this message was sent */
109 unsigned flags; /* Special instructions */
110 char sender[64]; /* Name of sending user */
111 char *text; /* Message text (if applicable) */
114 #define EM_BROADCAST 1 /* Broadcast message */
115 #define EM_GO_AWAY 2 /* Server requests client log off */
116 #define EM_CHAT 4 /* Server requests client enter chat */
119 struct ChatLine *next;
124 char chat_username[32];
128 * Various things we need to lock and unlock
157 * message transfer formats
160 MT_CITADEL, /* Citadel proprietary */
161 MT_DATE, /* We're only looking for the date */
162 MT_RFC822, /* RFC822 */
163 MT_RAW, /* IGnet raw format */
164 MT_MIME, /* MIME-formatted message */
165 MT_DOWNLOAD /* Download a component */
170 * Citadel DataBases (define one for each cdb we need to open)
173 CDB_MSGMAIN, /* message base */
174 CDB_USERSUPP, /* user file */
175 CDB_QUICKROOM, /* room index */
176 CDB_FLOORTAB, /* floor index */
177 CDB_MSGLISTS, /* room message lists */
178 CDB_VISIT, /* user/room relationships */
179 MAXCDB /* total number of CDB's defined */
188 /* Structures and declarations for function hooks of various types */
190 struct LogFunctionHook {
191 struct LogFunctionHook *next;
193 void (*h_function_pointer) (char *);
195 extern struct LogFunctionHook *LogHookTable;
197 struct CleanupFunctionHook {
198 struct CleanupFunctionHook *next;
199 void (*h_function_pointer) (void);
201 extern struct CleanupFunctionHook *CleanupHookTable;
205 * SessionFunctionHook extensions are used for any type of hook for which
206 * the context in which it's being called (which is determined by the event
207 * type) will make it obvious for the hook function to know where to look for
210 struct SessionFunctionHook {
211 struct SessionFunctionHook *next;
212 void (*h_function_pointer) (void);
215 extern struct SessionFunctionHook *SessionHookTable;
218 * Event types can't be enum'ed, because they must remain consistent between
219 * builds (to allow for binary modules built somewhere else)
221 #define EVT_STOP 0 /* Session is terminating */
222 #define EVT_START 1 /* Session is starting */
223 #define EVT_LOGIN 2 /* A user is logging in */
224 #define EVT_NEWROOM 3 /* Changing rooms */
225 #define EVT_LOGOUT 4 /* A user is logging out */
226 #define EVT_SETPASS 5 /* Setting or changing password */
227 #define EVT_CMD 6 /* Called after each server command */
231 * UserFunctionHook extensions are used for any type of hook which implements
232 * an operation on a user or username (potentially) other than the one
233 * operating the current session.
235 struct UserFunctionHook {
236 struct UserFunctionHook *next;
237 void (*h_function_pointer) (char *username, long usernum);
240 extern struct UserFunctionHook *UserHookTable;
242 #define EVT_PURGEUSER 100 /* Deleting a user */
243 #define EVT_OUTPUTMSG 101 /* Outputting a message */
246 /* Defines the relationship of a user to a particular room */
252 unsigned int v_flags;
255 #define V_FORGET 1 /* User has zapped this room */
256 #define V_LOCKOUT 2 /* User is locked out of this room */
257 #define V_ACCESS 4 /* Access is granted to this room */
260 #define UA_GOTOALLOWED 4
261 #define UA_HASNEWMSGS 8
265 /* Supplementary data for a message on disk
266 * (These are kept separately from the message itself because they are
267 * fields whose values may change at some point after the message is saved.)
270 long smi_msgnum; /* Redundant, but useful for self-check */
271 int smi_refcount; /* Number of rooms which point to this msg */
272 /* more stuff will be added to this record in the future */
277 /* Built-in debuggable stuff for checking for memory leaks */
278 #ifdef DEBUG_MEMORY_LEAKS
280 #define mallok(howbig) tracked_malloc(howbig, __FILE__, __LINE__)
281 #define phree(whichptr) tracked_free(whichptr)
282 #define reallok(whichptr,howbig) tracked_realloc(whichptr,howbig)
284 void *tracked_malloc(size_t, char *, int);
285 void tracked_free(void *);
286 void *tracked_realloc(void *, size_t);
287 void dump_tracked(void);
290 struct TheHeap *next;
296 extern struct TheHeap *heap;
300 #define mallok(howbig) malloc(howbig)
301 #define phree(whichptr) free(whichptr)
302 #define reallok(whichptr,howbig) realloc(whichptr,howbig)