connections.h 6.22 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2
 * $Id: connections.h,v 0.8 1992/04/01 20:50:40 ceder Exp $
Linus Tolke's avatar
Linus Tolke committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * Copyright (C) 1991  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
/*
26
 * $Id: connections.h,v 0.8 1992/04/01 20:50:40 ceder Exp $
Per Cederqvist's avatar
Per Cederqvist committed
27
 *
Per Cederqvist's avatar
Per Cederqvist committed
28
29
30
31
32
33
  * connections.h -- The top level of the communication packet.
  *
  * Requires kom-types.h, com.h
  */


34
35
36
extern volatile Bool go_and_die; /* Set this to TRUE to kill the server. */
extern volatile Bool do_sync_db; /* Set this to TRUE to force a sync via
				    signal. */
Per Cederqvist's avatar
Per Cederqvist committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#define CONN_MAGIC_ALLOC	0x18F4AE74
#define CONN_MAGIC_FREE         0x67A7B144

typedef struct connection {
    unsigned long       magic;           /* Hey, this is like magic! */
    
    struct connection * prev;
    struct connection * next;
    
    /* The following are used by services.c */

    Pers_no		pers_no;         /* 0 if not yet logged in. */
    Person	      * person;	         /* NULL if not yet logged in. */
    time_t		session_start;   /* the time when the current session
					    was started */
    Conf_no		cwc;	         /* Current working conference */
    String		what_am_i_doing;
    u_char		ena_level;       /* Enable level */
    String		username;        /* Userid and hostname. */
    String		hostname;        /* Real hostname  */
58
59
    String		ident_user; 	 /* Real username */
    Bool		invisible; 	 /* Is this session invisible? */
Per Cederqvist's avatar
Per Cederqvist committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

    /* The following are used by server/connections.c */
    
    struct mux         *mux;
    u_char		protocol;

    int			parse_pos;
    int			fnc_parse_pos;
    int			array_parse_pos;
    int			struct_parse_pos;
    int			string_parse_pos;

    int			ref_no;
    Call_header		function; /* Function to call. */

    /* Gather data in these variables. */
    
    long		num0;
    long		num1;
    long		num2;
    long		num3;
    String		c_string0; /* These strings are used for strings
				    * that are *NOT* freed by services.c.
				    * They are freed by free_parsed() in
				    * connections.c */
    String		c_string1;
    String		string0; /* This string is used for strings that
				   * are freed by the routines in services.c */
    Misc_info	       *c_misc_info_p;	/* Freead by free_parsed(). */
    Local_text_no      *c_local_text_no_p; /* Freead by free_parsed(). */
    Priv_bits		priv_bits;
    Conf_type		conf_type;
Linus Tolke's avatar
Linus Tolke committed
92
    struct tm		time;
Per Cederqvist's avatar
Per Cederqvist committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

    /* Protocol independent things. */
    
    String              unparsed;
    String_size		first_to_parse; /* Index into unparsed. */
    Bool		more_to_parse;	/* Any chance that there is anything
					   left in unparsed? */
    time_t		last_request;   /* Set every time a packet is
					    received from the client. */
    
    Session_no		session_no;      /* A unique number. */
    Bool                kill_me;        /* Yeah! */
} Connection;
/*
 * It is guaranteed that in the Connection struct the pers_no and person 
 * fields are either both 0/NULL, or both non-0/non-NULL.
 */


/*
 * Data for the isc-server.
 */
extern struct isc_mcb *kom_server_mcb;

/*
 * active_connection points to the info about the client who initiated this
 * call. This is set by connectins.c whenever a complete message is parsed
 * and a function in services.c is called.
 */
Connection * active_connection;


/*
 * This enum describes the result of a function in services.c.
 */
typedef enum {
Linus Tolke's avatar
Linus Tolke committed
129
    rt_number,			/* E.g. Pers_no, Conf_no, Text_no.
Per Cederqvist's avatar
Per Cederqvist committed
130
131
132
				   This is somewhat special in that the
				   function indicates an error by returning
				   0 and not FAILURE. */
133
    rt_success,			/* Only return a Success. */
Per Cederqvist's avatar
Per Cederqvist committed
134
135
136
    /* Functions of the following types returns a Success _and_ data
       of the indicated type. The corresponding types are found in
       kom-types.h */
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    rt_person,
    rt_membership,
    rt_conf_list,
    rt_conf_no_list,
    rt_conference,
    rt_string,
    rt_mark_list,
    rt_text_stat,
    rt_text_list,
    rt_who_info_list,
    rt_who_info_list_old,
    rt_info,
    rt_membership_list,
    rt_member_list,
    rt_time_date,
    rt_session_info,
Linus Tolke's avatar
Linus Tolke committed
153
    rt_session_no,
154
155
156
    rt_text_no,
    rt_session_info_ident,
    rt_who_info_ident_list
Per Cederqvist's avatar
Per Cederqvist committed
157
158
159
160
} Res_type;

/*
 * The result from a call is stored in this union.
161
162
163
164
165
166
 *
 * The pointers in these structures are normally set to point into
 * data from the cache, and should thus not be free()d. In those cases
 * where this actually contains newly allocated memory (and it is not
 * allocated via tmp_alloc()) it should be free()d in prot_a_reply() in
 * prot-a.c.
Per Cederqvist's avatar
Per Cederqvist committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
 */
typedef union {
        u_long			  number;
    	Person			  person;
	Membership		  membership;
	Conf_list_old		  conf_list;
	Conf_no_list		  conf_no_list;
	Conference		  conference;
	Mark_list		  mark_list;
	String			  string;
	Text_stat		  text_stat;
	Text_list		  text_list;
	Info			  info;
	Who_info_list		  who_info_list;
	Who_info_list_old	  who_info_list_old;
	Membership_list		  membership_list;
	Member_list		  member_list;
	time_t			  time_date;
	Session_info		  session_info;
	Session_no		  session_no;
Linus Tolke's avatar
Linus Tolke committed
187
	Text_no			  text_no;
Per Cederqvist's avatar
Per Cederqvist committed
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
} Result_holder;


typedef struct {
    Res_type  result;
    /* The function that is used to parse args for this function: */
    void      (*parser)(Connection *client);
} Fnc_descriptor;

extern const Fnc_descriptor fnc_defs[];

/*
 * This array holds number of calls to each service. It is dumped to the
 * log file every time the server syncs.
 */
extern u_long service_statistics[];


Per Cederqvist's avatar
Per Cederqvist committed
206
#ifdef _JBLEN
Per Cederqvist's avatar
Per Cederqvist committed
207
208
209
210
211
212
213
214
extern jmp_buf parse_env;
#endif

extern void
toploop(void);

extern void
dump_statistics(void);
215
216
217

extern void
logout_all_clients(void);