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 * Here's the big one... the Citadel context structure.
13 * This structure keeps track of all information relating to a running
14 * session on the server. We keep one of these for each session thread.
16 * Note that the first element is "*next" so that it may be used without
17 * modification in a linked list.
20 struct CitContext *next; /* Link to next session in the list */
22 struct usersupp usersupp; /* Database record buffers */
23 struct quickroom quickroom;
28 char curr_user[32]; /* name of current user */
29 int logged_in; /* logged in */
30 int internal_pgm; /* authenticated as internal program */
31 char temp[32]; /* temp file name */
32 int nologin; /* not allowed to log in */
37 int cs_pid; /* session ID */
38 char cs_room[ROOMNAMELEN]; /* current room */
39 time_t cs_lastupdt; /* time of last update */
40 time_t lastcmd; /* time of last command executed */
41 time_t lastidle; /* For computing idle time */
42 char lastcmdname[5]; /* name of last command executed */
43 unsigned cs_flags; /* miscellaneous flags */
45 /* feeping creaturisms... */
46 int cs_clientdev; /* client developer ID */
47 int cs_clienttyp; /* client type code */
48 int cs_clientver; /* client version number */
49 char cs_clientname[32]; /* name of client software */
50 char cs_host[25]; /* host logged in from */
52 FILE *download_fp; /* Fields relating to file transfer */
56 char upl_comment[256];
57 char upl_filedir[256];
58 char chat_room[20]; /* The chat room */
62 struct ExpressMessage *FirstExpressMessage;
64 char fake_username[32]; /* Fake username <bc> */
65 char fake_postname[32]; /* Fake postname <bc> */
66 char fake_hostname[25]; /* Name of the fake hostname <bc> */
67 char fake_roomname[ROOMNAMELEN];/* Name of the fake room <bc> */
69 int FloorBeingSearched; /* This is used by cmd_lrms() etc. */
70 char desired_section[64]; /* This is used for MIME downloads */
73 typedef struct CitContext t_context;
75 #define CS_STEALTH 1 /* stealth mode */
76 #define CS_CHAT 2 /* chat mode */
77 #define CS_POSTING 4 /* Posting */
79 struct CitContext *MyContext(void);
80 #define CC ((struct CitContext *)MyContext())
82 extern struct CitContext *ContextList;
83 extern int ScheduledShutdown;
84 extern struct CitControl CitControl;
87 struct ExpressMessage {
88 struct ExpressMessage *next;
89 time_t timestamp; /* When this message was sent */
90 unsigned flags; /* Special instructions */
91 char sender[64]; /* Name of sending user */
92 char *text; /* Message text (if applicable) */
95 #define EM_BROADCAST 1 /* Broadcast message */
96 #define EM_GO_AWAY 2 /* Server requests client log off */
97 #define EM_CHAT 4 /* Server requests client enter chat */
100 struct ChatLine *next;
105 char chat_username[32];
109 * Various things we need to lock and unlock
112 #define S_USER_TRANS 1
113 #define S_QUICKROOM 2
116 #define S_SESSION_TABLE 5
118 #define S_CHATQUEUE 7
120 #define S_HOUSEKEEPING 9
121 #define S_DATABASE 10
122 #define MAX_SEMAPHORES 11
134 * message transfer formats
136 #define MT_CITADEL 0 /* Citadel proprietary */
137 #define MT_DATE 1 /* We're only looking for the date */
138 #define MT_RFC822 2 /* RFC822 */
139 #define MT_RAW 3 /* IGnet raw format */
140 #define MT_MIME 4 /* MIME-formatted message */
141 #define MT_DOWNLOAD 5 /* Download a component */
145 * Citadel DataBases (define one for each cdb we need to open)
147 #define CDB_MSGMAIN 0 /* message base */
148 #define CDB_USERSUPP 1 /* user file */
149 #define CDB_QUICKROOM 2 /* room index */
150 #define CDB_FLOORTAB 3 /* floor index */
151 #define CDB_MSGLISTS 4 /* room message lists */
152 #define CDB_VISIT 5 /* user/room relationships */
153 #define MAXCDB 6 /* total number of CDB's defined */
161 /* Structures and declarations for function hooks of various types */
163 struct LogFunctionHook {
164 struct LogFunctionHook *next;
166 void (*h_function_pointer) (char *);
168 extern struct LogFunctionHook *LogHookTable;
170 struct CleanupFunctionHook {
171 struct CleanupFunctionHook *next;
172 void (*h_function_pointer) (void);
174 extern struct CleanupFunctionHook *CleanupHookTable;
178 * SessionFunctionHook extensions are used for any type of hook for which
179 * the context in which it's being called (which is determined by the event
180 * type) will make it obvious for the hook function to know where to look for
183 struct SessionFunctionHook {
184 struct SessionFunctionHook *next;
185 void (*h_function_pointer) (void);
188 extern struct SessionFunctionHook *SessionHookTable;
190 #define EVT_STOP 0 /* Session is terminating */
191 #define EVT_START 1 /* Session is starting */
192 #define EVT_LOGIN 2 /* A user is logging in */
193 #define EVT_NEWROOM 3 /* Changing rooms */
194 #define EVT_LOGOUT 4 /* A user is logging out */
195 #define EVT_SETPASS 5 /* Setting or changing password */
199 * UserFunctionHook extensions are used for any type of hook which implements
200 * an operation on a user or username (potentially) other than the one
201 * operating the current session.
203 struct UserFunctionHook {
204 struct UserFunctionHook *next;
205 void (*h_function_pointer) (char *username, long usernum);
208 extern struct UserFunctionHook *UserHookTable;
210 #define EVT_PURGEUSER 100 /* Deleting a user */
211 #define EVT_OUTPUTMSG 101 /* Outputting a message */
214 /* Defines the relationship of a user to a particular room */
220 unsigned int v_flags;
223 #define V_FORGET 1 /* User has zapped this room */
224 #define V_LOCKOUT 2 /* User is locked out of this room */
225 #define V_ACCESS 4 /* Access is granted to this room */
228 #define UA_GOTOALLOWED 4
229 #define UA_HASNEWMSGS 8
234 /* Built-in debuggable stuff for checking for memory leaks */
235 #ifdef DEBUG_MEMORY_LEAKS
237 #define mallok(howbig) tracked_malloc(howbig, __FILE__, __LINE__)
238 #define phree(whichptr) tracked_free(whichptr)
239 #define reallok(whichptr,howbig) tracked_realloc(whichptr,howbig)
241 void *tracked_malloc(size_t, char *, int);
242 void tracked_free(void *);
243 void *tracked_realloc(void *, size_t);
244 void dump_tracked(void);
247 struct TheHeap *next;
253 extern struct TheHeap *heap;
257 #define mallok(howbig) malloc(howbig)
258 #define phree(whichptr) free(whichptr)
259 #define reallok(whichptr,howbig) realloc(whichptr,howbig)