services.h 10.8 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * $Id: services.h,v 0.2 1991/09/15 10:12:50 linus Exp $
 * 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. 
 */
Per Cederqvist's avatar
.    
Per Cederqvist committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
92
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
/*
 *  services.h  --  All the services the LysKOM server makes available
 *		    for clients.
 *
 *  Requires kom-types.h
 *
 *  Created by ceder 1990-03-23
 */


#ifndef  _SERVICES_H_ALREADY_INCLUDED__
#define  _SERVICES_H_ALREADY_INCLUDED__


#if defined (CLIENT)
#	if defined (SERVER)
#		error Both CLIENT and SERVER defined!
#	endif
#	define	KOM_(function)		kom_ ## function
#	define	CONST			const
#elif defined (SERVER)
#	define	KOM_(function)		function
#	define	CONST
#else
#	error	Neither CLIENT nor SERVER defined!
#endif




/*
 * Session control
 */
#ifdef CLIENT
extern  Success
KOM_( open_connection (const char	* server ));

extern  void
KOM_( set_storage_management (malloc_function	new_malloc,
			      realloc_function	new_realloc,
			      free_function	new_free));

#endif


extern  Success
KOM_( login (Pers_no		person,
	     const String	passwd ));

extern  Success
KOM_( logout (void));	/* can never fail */

/* Change Conference */
extern  Success
KOM_( pepsi (Conf_no	conference ));


/* Change name of a person or conference. */
extern  Success
KOM_( change_name (Conf_no	  conf_no,
		   const String	  new_name));

extern  Success
KOM_( change_what_i_am_doing (CONST String  what_am_i_doing ));


/* Get info about a session */

extern  Success
KOM_( get_session_info  (Session_no session_no,
			 Session_info *result) );

/*
 * Disconnect a session. You can disconnect your own session (even if
 * you are not logged in) and any session where you are supervisor of
 * the user that is logged in on that session.
 */
extern  Success
KOM_( disconnect (Session_no session_no));

/*
 * Returns your session number
 */
extern  Success
KOM_( who_am_i (Session_no *session_no));


/******************************
*     Person-related calls    *
******************************/

/*
 *  Create a new person.  Returns 0 if any error occured.
 */
extern  Pers_no
KOM_( create_person (const String  name,
		     const String  passwd ));


/* Obsolete call; use get_person_stat instead. */
extern  Success
KOM_( get_person_stat_old (Pers_no		  person,
			   int			  mask,
			   Person		* result ));

extern  Success
KOM_( get_person_stat (Pers_no		  person,
		       Person		* result ));



extern  Success
KOM_( get_created_texts (Pers_no	  person,
			 Local_text_no	  first,
			 u_long		  no_of_texts,
			 Text_list	* created_texts ));

extern  Success
KOM_( get_membership (Pers_no		  person,
		      u_short		  first,
		      u_short		  no_of_confs,
		      Bool		  want_read_texts,
		      Membership_list	* memberships ));



extern  Success
KOM_( set_priv_bits (Pers_no	person,
		     Priv_bits	privileges ));


/*  Set the password of PERSON to NEW_PWD.  OLD_PWD is the password
 *  of the person who does the set.  This is not necessarily the
 *  same as the one who gets it set.	*/
extern  Success
KOM_( set_passwd (Pers_no	 person,
		  const String   old_pwd,
		  const String   new_pwd ));


/* You can query for unread texts without logging in. */
extern  Success
KOM_( query_read_texts (Pers_no	     pers_no,
			Conf_no	     conf_no,
			Membership * result   ));


extern Success
KOM_( get_unread_confs(Pers_no       pers_no,
		       Conf_no_list *result));

extern Success
KOM_( set_user_area(Pers_no	pers_no,
		    Text_no	user_area));


/****************************************
*	Conference-related calls	*
****************************************/


extern  Conf_no
KOM_( create_conf (const String	  name,
		   Conf_type	  type ));


/*  Delete a conference.  Also used to delete persons.  */
extern  Success
KOM_( delete_conf (Conf_no	conf ));


/*
 *  Map conference name to number.  Returns a list of the conferences
 *  that match the name NAME. Can be done without logging in.
 */
#ifdef SERVER
extern  Success
KOM_( lookup_name (const String	 name,
		   Conf_list_old *result));
#else
extern  Success
KOM_( lookup_name (const String	 name,
		   Conf_list	*result));
#endif

extern  Success
KOM_( get_conf_stat_old (Conf_no	conf_no,
			 int		mask,
			 Conference   * result ));

extern  Success
KOM_( get_conf_stat (Conf_no		  conf_no,
		     Conference		* result ));

extern  Success
KOM_( get_members (Conf_no	  conf,
		   u_short	  first,
		   u_short	  no_of_members,
		   Member_list	* members	));



/* add_member is also used to change the priority of a conference */
extern  Success
KOM_( add_member (Conf_no	conf_no,
		  Pers_no	pers_no,
		  u_char	priority,
		  u_short	where	)); /* Range of where is [0..] */


extern  Success
KOM_( sub_member (Conf_no	conf_no,
		  Pers_no	pers_no ));


/*
 * Tell the server that I want to mark/unmark texts as read so that I
 * get no_of_unread unread texts in conf_no.
 */
extern  Success
KOM_( set_unread (Conf_no   conf_no,
		  Text_no   no_of_unread));

/*
 * set_presentation and set_etc_motd also does some magic with the
 * no_of_marks field in the Text_stat structure of the old and new text.
 */ 

extern  Success
KOM_( set_presentation (Conf_no   conf_no,
			Text_no   text_no )); /* 0 to delete pres. */

extern  Success
KOM_( set_etc_motd (Conf_no	  conf_no,
		    Text_no	  text_no ));


extern  Success
KOM_( set_supervisor (Conf_no	  conf_no,
		      Conf_no	  admin	));

extern  Success
KOM_( set_permitted_submitters (Conf_no	  conf_no,
				Conf_no	  perm_sub ));

extern  Success
KOM_( set_super_conf (Conf_no	  conf_no,
		      Conf_no	  super_conf ));

extern  Success
KOM_( set_conf_type (Conf_no	  conf_no,
		     Conf_type	  type	));

extern  Success
KOM_( set_garb_nice (Conf_no	  conf_no,
		     Garb_nice	  nice	)); /* number of days */



/********************************
*     Calls to handle marks     *
********************************/


extern  Success
KOM_( get_marks (Mark_list *result ));



/*
 *  Will fail if the user is not allowed to read the text.
 */
extern  Success
KOM_( mark_text (Text_no	  text,
		 u_char		  mark_type ));




/*******************************
*     Calls to handle texts    *
*******************************/


extern  Success
KOM_( get_text (Text_no	 	  text,
		String_size	  start_char,
		String_size	  end_char,
		String		* result));


extern  Success
KOM_( get_text_stat (Text_no    text,
		     Text_stat *result));

extern  Success
KOM_( mark_as_read (Conf_no		    conference,
		    int			    no_of_texts,
		    const Local_text_no	  * text_arr   ));


/* Returns 0 on error */
extern  Text_no
KOM_( create_text (CONST String		  message,
		   u_short		  no_of_misc,
		   CONST Misc_info	* misc	     ));

extern Success
KOM_( delete_text( Text_no text_no ));



extern  Success
KOM_( add_recipient (Text_no	  text_no,
		     Conf_no	  conf_no,
		     Info_type	  type	)); /* recpt or cc_recpt */

extern  Success
KOM_( sub_recipient (Text_no	  text_no,
		     Conf_no	  conf_no ));


extern  Success
KOM_( add_comment (Text_no	  comment,
		   Text_no 	  comment_to ));


/*
 *  Make the text COMMENT to not be a comment to text COMMENT_TO
 */
extern  Success
KOM_( sub_comment (Text_no	  comment,
		   Text_no	  comment_to ));

extern Success
KOM_( add_footnote (Text_no	footnote,
		    Text_no 	footnote_to ));

extern Success
KOM_( sub_footnote (Text_no	footnote,
		    Text_no	parent ));

extern  Success
KOM_( get_map (Conf_no		  conf_no,
	       Local_text_no	  first_local_no,
	       u_long		  no_of_texts,
	       Text_list	* result));


/*
 *  Ask what the server thinks the time is. This
 *  might differ if on two different machines.
 */
#ifdef SERVER
extern  Success
KOM_( get_time (time_t *time));
#else				/* CLIENT */
extern  Success
KOM_( get_time (struct tm *clock));
#endif


/*
 * Who is logged on now?
 */
extern  Success
KOM_( who_is_on_old (Who_info_list_old	* result ));

extern  Success
KOM_( who_is_on (Who_info_list	* result ));


/*
 *  Return various information about the server
 */
extern  Success
KOM_( get_info (Info *result ));

/*
 *  Wait for asynchronous message from client, or input on any of
 *  the file-descriptors in opt_set. Returns FAILURE if nothing
 *  happened in msec milliseconds or an error occurs. (kom_errno ==
 *  KOM_NO_ERR if the return was due to a timeout). Returns OK if
 *  there was an asynchronous message or input on any of the fd's in
 *  opt_set.
 *
 *  Set opt_set to NULL if you don't want to wait on any other input
 *  than a message.
 *
 *  To wait for a message or input on stdin the following code can be used:
 *
 *  fd_set read_set;
 *
 *  FD_ZERO(&read_set);
 *  FD_SET(fileno(stdin), &read_set);
 *  if ( kom_wait(read_set, 1000) == OK )
 *  {
 *	if ( FD_ISSET(fileno(stdin), &read_set) )
 *	    handle_stdin_input();
 *	else
 *	    handle_asynchronous_message();
 *  }
 *  else
 *	time_out();
 *
 *  (The handler is called from kom_wait and not handle_asynchronous_message,
 *   but there might be more to do afterwards since a handler cannot call
 *   functions that communicate with the server.)
 */
#ifdef CLIENT
extern  Success
KOM_( wait (fd_set *opt_set,
	    int     msec));
#endif

/*
 * Privileged calls.
 */

extern Success
KOM_( set_motd_of_lyskom (Text_no motd));

/*
 * Set ena_level. 0 means don't use any privileges.
 */
extern Success
KOM_( enable (u_char ena_level));

/*
 * Make LysKOM sync its files.
 */
extern Success
KOM_( sync (void) );

/*
 * Close LysKOM.
 */
extern Success
KOM_( shutdown (int exit_val) );

/*
 * Send a message to all clients. This is obsoleted by send_message()
 * and will soon go away.
 */
extern Success
KOM_( broadcast (const String message) );

/*
 * Send a message to a person, or all persons. If recipient == 0 all
 * connections will receive the message.
 */
extern Success
KOM_( send_message (Pers_no recipient,
		    const String message) );


/*
 * Asynchronous messages.
 */
#ifdef CLIENT
void
register_new_text(void (*async_new_text)(Text_no    text_no, 
					 Text_stat  text_s));

void
register_i_am_on(void (*async_i_am_on)(Who_info info));

void
register_i_am_off (void (*async_i_am_off)(Pers_no pers_no));

void
register_new_name(void (*async_new_name)(Conf_no  conf_no,
					 String   old_name,
					 String   new_name));
#endif	/* CLIENT */
    
#endif	/*  _SERVICES_H_ALREADY_INCLUDED__  */