]> code.citadel.org Git - citadel.git/blob - citadel/server.h
Added a new type of module hook for adding logging functions
[citadel.git] / citadel / server.h
1 /* $Id$ */
2 typedef pthread_t THREAD;
3
4
5 struct ExpressMessage {
6         struct ExpressMessage *next;
7         char em_text[300];
8         };
9
10 /*
11  * Here's the big one... the Citadel context structure.
12  *
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.
15  *
16  * Note that the first element is "*next" so that it may be used without
17  * modification in a linked list.
18  */
19 struct CitContext {
20         struct CitContext *next;        /* Link to next session in the list */
21
22         struct usersupp usersupp;       /* Database record buffers */
23         struct quickroom quickroom;
24         
25         long *msglist;
26         int num_msgs;
27
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 */
33
34         char net_node[32];
35         THREAD mythread;
36         int client_socket;
37         struct ExpressMessage *FirstExpressMessage;
38         int cs_pid;                     /* session ID */
39         char cs_room[20];               /* current room */
40         time_t cs_lastupdt;             /* time of last update */
41         time_t lastcmd;                 /* time of last command executed */
42         time_t lastidle;                /* For computing idle time */
43         char lastcmdname[5];            /* name of last command executed */
44         unsigned cs_flags;              /* miscellaneous flags */
45
46                                         /* feeping creaturisms... */
47         int cs_clientdev;               /* client developer ID */
48         int cs_clienttyp;               /* client type code */
49         int cs_clientver;               /* client version number */
50         char cs_clientname[32];         /* name of client software */
51         char cs_host[25];               /* host logged in from */
52
53         FILE *download_fp;              /* Fields relating to file transfer */
54         FILE *upload_fp;
55         char upl_file[256];
56         char upl_path[256];
57         char upl_comment[256];
58         char upl_filedir[256];
59         char chat_room[20];             /* The chat room */
60         char dl_is_net;
61         char upload_type;
62
63         char ucache_name[32];           /* For a performance boost, we cache */
64         long ucache_pos;                /* the position of the last user rec */
65         char fake_username[32];         /* Fake username <bc>                */
66         char fake_postname[32];         /* Fake postname <bc>                */
67         char fake_hostname[25];         /* Name of the fake hostname <bc>    */
68         char fake_roomname[ROOMNAMELEN];/* Name of the fake room <bc>        */
69         char last_pager[32];            /* The username of the last pager    */
70
71         int FloorBeingSearched;         /* This is used by cmd_lrms() etc.   */
72
73         int CtdlErrno;                  /* Error return for CitadelAPI calls */
74         };
75
76 typedef struct CitContext t_context;
77
78 #define CS_STEALTH      1               /* stealth mode */
79 #define CS_CHAT         2               /* chat mode */
80 #define CS_POSTING      4               /* Posting */
81
82 struct CitContext *MyContext(void);
83 #define CC ((struct CitContext *)MyContext())
84
85 extern struct CitContext *ContextList;
86 extern int ScheduledShutdown;
87 extern struct CitControl CitControl;
88
89 struct ChatLine {
90         struct ChatLine *next;
91         int chat_seq;
92         time_t chat_time;
93         char chat_text[256];
94         char chat_room[20];
95         char chat_username[32];
96         };
97
98 /*
99  * Various things we need to lock and unlock
100  */
101 #define S_USERSUPP      0
102 #define S_USER_TRANS    1
103 #define S_QUICKROOM     2
104 #define S_MSGMAIN       3
105 #define S_CALLLOG       4
106 #define S_SESSION_TABLE 5
107 #define S_FLOORTAB      6
108 #define S_CHATQUEUE     7
109 #define S_CONTROL       8
110 #define S_HOUSEKEEPING  9
111 #define S_DATABASE      10
112 #define MAX_SEMAPHORES  11
113
114
115 /*
116  * Upload types
117  */
118 #define UPL_FILE        0
119 #define UPL_NET         1
120 #define UPL_IMAGE       2
121
122
123
124 /*
125  * Citadel DataBases (define one for each cdb we need to open)
126  */
127 #define CDB_MSGMAIN     0       /* message base                  */
128 #define CDB_USERSUPP    1       /* user file                     */
129 #define CDB_QUICKROOM   2       /* room index                    */
130 #define CDB_FLOORTAB    3       /* floor index                   */
131 #define CDB_MSGLISTS    4       /* room message lists            */
132 #define CDB_VISIT       5       /* user/room relationships       */
133 #define MAXCDB          6       /* total number of CDB's defined */
134
135 struct cdbdata {
136         size_t len;
137         char *ptr;
138         };
139
140
141 /* Structures and declarations for function hooks of various types */
142
143 struct LogFunctionHook {
144         struct LogFunctionHook *next;
145         int loglevel;
146         void (*h_function_pointer) (char *);
147         };
148 extern struct LogFunctionHook *LogHookTable;
149
150 struct CleanupFunctionHook {
151         struct CleanupFunctionHook *next;
152         void (*h_function_pointer) (void);
153         };
154 extern struct CleanupFunctionHook *CleanupHookTable;
155
156
157 /*
158  * SessionFunctionHook extensions are used for any type of hook for which
159  * the context in which it's being called (which is determined by the event
160  * type) will make it obvious for the hook function to know where to look for
161  * pertinent data.
162  */
163 struct SessionFunctionHook {
164         struct SessionFunctionHook *next;
165         void (*h_function_pointer) (void);
166         int eventtype;
167         };
168 extern struct SessionFunctionHook *SessionHookTable;
169
170 #define EVT_STOP        0       /* Session is terminating */
171 #define EVT_START       1       /* Session is starting */
172 #define EVT_LOGIN       2       /* A user is logging in */
173 #define EVT_NEWROOM     3       /* Changing rooms */
174 #define EVT_LOGOUT      4       /* A user is logging out */
175 #define EVT_SETPASS     5       /* Setting or changing password */
176
177
178 /*
179  * UserFunctionHook extensions are used for any type of hook which implements
180  * an operation on a user or username (potentially) other than the one
181  * operating the current session.
182  */
183 struct UserFunctionHook {
184         struct UserFunctionHook *next;
185         void (*h_function_pointer) (char *username, long usernum);
186         int eventtype;
187         };
188 extern struct UserFunctionHook *UserHookTable;
189
190 #define EVT_PURGEUSER   100     /* Deleting a user */
191 #define EVT_OUTPUTMSG   101     /* Outputting a message */
192
193
194 /* Defines the relationship of a user to a particular room */
195 struct visit {
196         long v_roomnum;
197         long v_roomgen;
198         long v_usernum;
199         long v_lastseen;
200         unsigned int v_flags;
201         };
202
203 #define V_FORGET        1               /* User has zapped this room        */
204 #define V_LOCKOUT       2               /* User is locked out of this room  */
205 #define V_ACCESS        4               /* Access is granted to this room   */
206
207 #define UA_KNOWN                2
208 #define UA_GOTOALLOWED          4
209 #define UA_HASNEWMSGS           8
210 #define UA_ZAPPED               16