60becc03e383ec786231cc5c010228851a5f77ed
[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         
25         long *msglist;
26         int num_msgs;
27
28         char curr_user[32];             /* name of current user */
29         int curr_rm;                    /* index of current room */
30         int logged_in;                  /* logged in */
31         int internal_pgm;               /* authenticated as internal program */
32         char temp[32];                  /* temp file name */
33         int nologin;                    /* not allowed to log in */
34
35         char net_node[32];
36         THREAD mythread;
37         int client_socket;
38         struct ExpressMessage *FirstExpressMessage;
39         int cs_pid;                     /* session ID */
40         char cs_room[20];               /* current room */
41         long cs_lastupdt;               /* time of last update */
42         time_t lastcmd;                 /* time of last command executed */
43         time_t lastidle;                /* For computing idle time */
44         char lastcmdname[5];            /* name of last command executed */
45         unsigned cs_flags;              /* miscellaneous flags */
46
47                                         /* feeping creaturisms... */
48         int cs_clientdev;               /* client developer ID */
49         int cs_clienttyp;               /* client type code */
50         int cs_clientver;               /* client version number */
51         char cs_clientname[32];         /* name of client software */
52         char cs_host[25];               /* host logged in from */
53
54         FILE *download_fp;              /* Fields relating to file transfer */
55         FILE *upload_fp;
56         char upl_file[256];
57         char upl_path[256];
58         char upl_comment[256];
59         char upl_filedir[256];
60         char chat_room[20];             /* The chat room */
61         char dl_is_net;
62         char upload_type;
63
64         char ucache_name[32];           /* For a performance boost, we cache */
65         long ucache_pos;                /* the position of the last user rec */
66         char fake_username[32];         /* Fake username <bc>                */
67         char fake_postname[32];         /* Fake postname <bc>                */
68         char fake_hostname[25];         /* Name of the fake hostname <bc>    */
69         char fake_roomname[20];         /* Name of the fake room <bc>        */
70         char last_pager[32];            /* The username of the last pager    */
71
72         int CtdlErrno;                  /* Error return for CitadelAPI calls */
73         };
74
75 #define CS_STEALTH      1               /* stealth mode */
76 #define CS_CHAT         2               /* chat mode */
77 #define CS_POSTING      4               /* Posting */
78
79 struct CitContext *MyContext(void);
80 #define CC ((struct CitContext *)MyContext())
81
82 extern struct CitContext *ContextList;
83 extern int ScheduledShutdown;
84 extern struct CitControl CitControl;
85
86 struct ChatLine {
87         struct ChatLine *next;
88         int chat_seq;
89         time_t chat_time;
90         char chat_text[256];
91         char chat_room[20];
92         char chat_username[32];
93         };
94
95 /*
96  * Various things we need to lock and unlock
97  */
98 #define S_USERSUPP      0
99 #define S_USER_TRANS    1
100 #define S_QUICKROOM     2
101 #define S_MSGMAIN       3
102 #define S_CALLLOG       4
103 #define S_SESSION_TABLE 5
104 #define S_FLOORTAB      6
105 #define S_CHATQUEUE     7
106 #define S_CONTROL       8
107 #define S_HOUSEKEEPING  9
108 #define MAX_SEMAPHORES  10
109
110
111 /*
112  * Upload types
113  */
114 #define UPL_FILE        0
115 #define UPL_NET         1
116 #define UPL_IMAGE       2
117
118
119
120 /*
121  * Citadel DataBases (define one for each cdb we need to open)
122  */
123 #define CDB_MSGMAIN     0       /* message base */
124 #define CDB_USERSUPP    1       /* user file */
125 #define CDB_QUICKROOM   2       /* room index */
126 #define CDB_FLOORTAB    3       /* floor index */
127 #define CDB_MSGLISTS    4       /* room message lists */
128 #define CDB_MAILBOXES   5       /* mailbox message lists */
129 #define MAXCDB          6       /* total number of CDB's defined */
130
131 struct cdbdata {
132         size_t len;
133         char *ptr;
134         };