Initial revision
[citadel.git] / citadel / server.h
1
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         struct fullroom fullroom;
25
26         char curr_user[32];             /* name of current user */
27         int curr_rm;                    /* index of current room */
28         int logged_in;                  /* logged in */
29         int internal_pgm;               /* authenticated as internal program */
30         char temp[32];                  /* temp file name */
31         int nologin;                    /* not allowed to log in */
32
33         char net_node[32];
34         THREAD mythread;
35         int client_socket;
36         struct ExpressMessage *FirstExpressMessage;
37         int cs_pid;                     /* session ID */
38         char cs_room[20];               /* current room */
39         long 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 */
44
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 */
51
52         FILE *download_fp;              /* Fields relating to file transfer */
53         FILE *upload_fp;
54         char upl_file[256];
55         char upl_path[256];
56         char upl_comment[256];
57         char upl_filedir[256];
58         char chat_room[20];             /* The chat room */
59         char dl_is_net;
60         char upload_type;
61
62         char ucache_name[32];           /* For a performance boost, we cache */
63         long ucache_pos;                /* the position of the last user rec */
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[20];         /* Name of the fake room <bc>        */
68         char last_pager[32];            /* The username of the last pager    */
69         };
70
71 #define CS_STEALTH      1               /* stealth mode */
72 #define CS_CHAT         2               /* chat mode */
73 #define CS_POSTING      4               /* Posting */
74
75 struct CitContext *MyContext(void);
76 #define CC ((struct CitContext *)MyContext())
77
78 extern struct CitContext *ContextList;
79 extern int ScheduledShutdown;
80 extern struct CitControl CitControl;
81
82 struct ChatLine {
83         struct ChatLine *next;
84         int chat_seq;
85         time_t chat_time;
86         char chat_text[256];
87         char chat_room[20];
88         char chat_username[32];
89         };
90
91 /*
92  * Various things we need to lock and unlock
93  */
94 #define S_USERSUPP      0
95 #define S_USER_TRANS    1
96 #define S_QUICKROOM     2
97 #define S_MSGMAIN       3
98 #define S_CALLLOG       4
99 #define S_SESSION_TABLE 5
100 #define S_FLOORTAB      6
101 #define S_CHATQUEUE     7
102 #define S_CONTROL       8
103 #define S_HOUSEKEEPING  9
104 #define MAX_SEMAPHORES  10
105
106
107 /*
108  * Upload types
109  */
110 #define UPL_FILE        0
111 #define UPL_NET         1
112 #define UPL_IMAGE       2
113
114
115
116 /*
117  * Citadel DataBases (define one for each cdb we need to open)
118  */
119 #define CDB_MSGMAIN     0       /* message base */
120 #define CDB_USERSUPP    1       /* user file */
121 #define CDB_QUICKROOM   2       /* room index */
122 #define CDB_FULLROOM    3       /* room message lists */
123 #define CDB_FLOORTAB    4       /* floor index */
124 #define MAXCDB          5       /* total number of CDB's defined */
125
126 struct cdbdata {
127         size_t len;
128         char *ptr;
129         };