lyskomd.texi 89.8 KB
Newer Older
David Byers's avatar
David Byers committed
1
\input texinfo
2
@c $Id: lyskomd.texi,v 1.19 1999/05/21 11:31:59 byers Exp $
David Byers's avatar
David Byers committed
3
4
@c %**start of header
@setfilename lyskomd.info
5
6
@include version.texi
@settitle lyskomd @value{VERSION} Reference Manual
David Byers's avatar
David Byers committed
7
8
9
@setchapternewpage odd
@c %**end of header

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@iftex
@parindent 0pt
@begin tex
\global\def\BB#1{\b{#1}}
\global\def\II#1{\i{#1}}
@end tex
@end iftex

@ifinfo
@macro BB {text}
'\text\'
@end macro
@macro II {text}
/\text\/
@end macro
@end ifinfo

David Byers's avatar
David Byers committed
27
@ifinfo
28
29
This is the reference manual for the lyskomd LysKOM server version
@value{VERSION}.
David Byers's avatar
David Byers committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

Copyright @copyright{} 1999 Lysator ACS.

Permission is granted to make and distribute verbatim copies of this
specification provided the copyright notice and this permission notice
are preserved on all copies.
@end ifinfo

@dircategory LysKOM
@direntry
* lyskomd: (lyskomd).                lyskomd reference manual.
@end direntry

@titlepage
@sp 10
45
@title lyskomd Reference Manual
David Byers's avatar
David Byers committed
46
@sp 2
47
@subtitle Server version @value{VERSION}
David Byers's avatar
David Byers committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@sp 2
@author by the lyskomd developers

@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995-1999 Lysator ACS

Permission is granted to make and distribute verbatim copies of this document
provided the copyright notice and this permission notice are preserved on all
copies.

Modified versions of this document may be redistributed with the added
condition that all modifications not cleared with the LysKOM development group
are clearly marked and that the entire modified work be redistributed under the
same conditions as the original.

Permission is granted to copy and distribute translations of this manual into
another language under the same conditions as for modified versions.

@end titlepage

@ifinfo
David Byers's avatar
David Byers committed
70
@node Top, Copying, (dir), (dir)
David Byers's avatar
David Byers committed
71
72
73
@top lyskomd

lyskomd is a server for the LysKOM conferencing system. This info file
74
documents version @value{VERSION} of lyskomd.
David Byers's avatar
David Byers committed
75
76
77
78
79
80
81

@menu
* Copying::                     lyskomd is free software.
* Overview::                    Overview of LysKOM.
* Installation::                How to install lyskomd.
* Configuration::               How to configure lyskomd.
* Running lyskomd::             How to run lyskomd.
82
83
* Invoking updateLysKOM::       How to run updateLysKOM.
* Invoking komrunning::         How to run komrunning.
David Byers's avatar
David Byers committed
84
* Administration::              Administering a LysKOM server.
David Byers's avatar
David Byers committed
85
86
87
* Bugs::                        Known bugs in lyskomd.
* DBCK Reference::              Checking and repairing the database.
* Hacking::                     Notes for server developers.
88
* lyskomd Database Specification::  
David Byers's avatar
David Byers committed
89
90
91
92
@end menu

@end ifinfo

David Byers's avatar
David Byers committed
93
@node Copying, Overview, Top, Top
David Byers's avatar
David Byers committed
94
95
96
97
98
99
100
@chapter Copying

lyskomd is free software. It is distributed under the Gnu General Public 
License version 2. The file COPYING in the top level of the distribution 
contains the text of the license.


David Byers's avatar
David Byers committed
101
@node Overview, Installation, Copying, Top
David Byers's avatar
David Byers committed
102
103
104
105
106
107
108
109
110
111
@chapter Overview

LysKOM is a conferencing system@footnote{Or in modern terms, enabling
technology for Computer-Supported Cooperative Work (CSCW).}. Similar
systems were QZ-KOM and PortaCOM@footnote{Also known as ``PottaKOM'' and
``BortaKOM''.}. The LysKOM system is copyrighted by Lysator Academic
Computing Society and distributed under conditions of the GNU Public
License. LysKOM and its documentation is provided ``as is'' without
warranty of any kind.

112
113
This reference manual documents version @value{VERSION} of the lyskomd
LysKOM server. The lyskomd server is the work of several people. The main
David Byers's avatar
David Byers committed
114
115
116
contributors have been
Per Cederqvist @email{ceder@@lysator.liu.se}, 
Inge Wallin @email{inge@@lysator.liu.se}, 
117
118
119
Thomas Bellman @email{bellman@@lysator.liu.se}, 
David Byers @email{byers@@lysator.liu.se} and
Peter Eriksson @email{pen@@lysator.liu.se}.
David Byers's avatar
David Byers committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

Commercial service for LysKOM is available from Signum Support
@url{http://www.signum.se/}.


@section History

In 1990, Per Cederqvist @email{ceder@@lysator.liu.se} and Peter Eriksson
@email{pen@@lysator.liu.se} and a few other persons started to write the
server. It was operational in the summer of 1990, even though the
members of Lysator discovered a thing called MUD. We started using RCS
on 20 May 1991. The first release was made on 16 Sept 1991. Around that
time we switched from RCS to CVS, and ceder started to write pcl-cvs (a
GNU Emacs front-end to CVS) instead of LysKOM. After a while, he started
writing Bugtrack, to be able to handle all bug reports he recieved about
pcl-cvs. He hopes to be able to devote some more time to LysKOM in the
future.



David Byers's avatar
David Byers committed
140
@node Installation, Configuration, Overview, Top
David Byers's avatar
David Byers committed
141
142
143
144
145
146
147
@chapter Installation

Instructions for compiling and installing lyskomd are in the file
INSTALL, located in the top level of the lyskomd distribution.
Installation should be straightforward on most platforms.


David Byers's avatar
David Byers committed
148
@node Configuration, Running lyskomd, Installation, Top
David Byers's avatar
David Byers committed
149
150
151
152
153
154
155
156
157
158
159
160
@chapter Configuration

There are two configuration files for lyskomd. One defines the server
options and the other defines aux-item types @ref{(protocol-a)The
Aux-Item List,The Aux-Item List}. 

@menu
* Server Configuration File::   The server configuration file.
* Aux-Item Definition File::    The aux-item definition file.
@end menu


David Byers's avatar
David Byers committed
161
@node Server Configuration File, Aux-Item Definition File, Configuration, Configuration
David Byers's avatar
David Byers committed
162
163
164
@section Server Configuration File

The server reads its configuration from a configuration file. The
165
default configuration file is @file{/usr/lyskom/etc/config}. The
David Byers's avatar
David Byers committed
166
167
168
169
170
171
172
173
174
175
176
177
178
location of the configuration file can be changed at run-time by
supplying an argument to lyskomd.

The configuration file is line oriented. Each line consists of a
parameter name followed by a colon, and the value of the parameter.
Empty lines and lines whose first non-blank character is a @code{#} are
ignored.

@menu
* Parameter Types::             Types of configuration parameters.
* Parameters::                  Valid configuration parameters.
@end menu

David Byers's avatar
David Byers committed
179
@node Parameter Types, Parameters, Server Configuration File, Server Configuration File
David Byers's avatar
David Byers committed
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
@subsection Parameter Types

Every parameter has a type. The legal types are:

@table @code
@item bool
The parameter can be true or false. Legal values are @code{on},
@code{true}, @code{yes} and @code{1} for true and @code{off},
@code{false}, @code{no} and @code{0} for false.

@item locale-name
The parameter is a locale name. The value must be a legal locale name of 
the system where lyskomd is running.

@item path
The parameter is a path name. The value must be a legal path on the
196
197
system where lyskomd is running. Most paths you can specify can be
either absolute paths (if they begin with a @samp{/}) or paths relative 
David Byers's avatar
David Byers committed
198
to the installation prefix which is specified at compile time or with
199
the @samp{Prefix} parameter in the configuration file.
David Byers's avatar
David Byers committed
200
201
202

@item portname
The parameter is a TCP/IP port. It can be a symbolic port name
203
(traditionally looked up in @file{/etc/services}) or a port number.
David Byers's avatar
David Byers committed
204
205
206
207
208
209
210
211

@item int
The parameter is a number of some sort. It can be a conference number,
text number or perhaps a timeout. 

@end table


David Byers's avatar
David Byers committed
212
@node Parameters,  , Parameter Types, Server Configuration File
David Byers's avatar
David Byers committed
213
214
215
216
@subsection Parameters

@table @code

David Byers's avatar
David Byers committed
217
218
219
220
221
222
223
224
225
226
@item Max conferences: @var{int}
The maximum number of conferences possible in the server. This number
must be larger than the number of conferences in the database. This
parameter is required. There is no default.

@item Max texts: @var{int}
The maximum number of texts possible in the server. This number
must be larger than the number of texts in the database. This
parameter is required. There is no default.

227
228
@item Locale: @var{string}
Use @var{string} as the locale to run in. This parameter is only
David Byers's avatar
David Byers committed
229
230
231
232
available om systems which support the @code{setlocale} call. If this
parameter is not set, no call to @code{setlocale} will be made. The
default is unset.

233
@item Force ISO 8859-1: @var{bool}
David Byers's avatar
David Byers committed
234
235
This option is provided for those with dysfunctional computers that
cannot handle @code{setlocale} properly. If this is set, lyskomd will
236
handle texts according to the ISO 8859-1 (latin1) alphabet. Default
David Byers's avatar
David Byers committed
237
238
is off.

239
@item Prefix: @var{path}
David Byers's avatar
David Byers committed
240
241
All files that the server uses are found in sub-directories of this
directory. The default value of this parameter is set at compile time. 
242
The default at compile time is @file{/usr/lyskom}.
David Byers's avatar
David Byers committed
243

244
@item Send async: @var{bool}
David Byers's avatar
David Byers committed
245
246
247
248
Do not send any non-requested messages. This disables the sending of
messages about events in the server to all connections. Use of this
parameter is not recommended. Default is on.

249
250
251
252
253
254
255
@item Client host: @var{hostname}
Specify which IP number the server should use when listening for new
clients.  @var{hostname} may be a FQDN (such as
@samp{kom.lysator.liu.se}) or an IP number (such as @samp{10.0.0.1}).
Default is to bind @code{INADDR_ANY}, which means that the server will
listen to all IP numbers of the computer it is running on.

256
257
@item Client port: @var{portname}
Listen for new clients on port @var{portname}. The default is 4894, which
David Byers's avatar
David Byers committed
258
259
260
is what all clients expect. Do not change this parameter without really
good reason.

261
@item Presentation of conferences: @var{int}
David Byers's avatar
David Byers committed
262
263
264
265
266
The number of the conference where presentations should be sent. 
Defaults to 1. This option is ignored in lyskomd 1.9 and later. Set this
using dbck or the @ref{(protocol-a)set-info,set-info}.


267
@item Presentation of persons: @var{int}
David Byers's avatar
David Byers committed
268
269
270
271
The number of the conference where presentations should be sent. 
Defaults to 2. This option is ignored in lyskomd 1.9 and later. Set this
using dbck or the @ref{(protocol-a)set-info,set-info}.

272
@item Motd-conference: @var{int}
David Byers's avatar
David Byers committed
273
274
275
276
The number of the conference where "message-of-the-day" messages should
be sent. Defaults to 3. This option is ignored in lyskomd 1.9 and later. 
Set this using dbck or the @ref{(protocol-a)set-info,set-info}.

277
@item News-conference: @var{int}
David Byers's avatar
David Byers committed
278
279
280
281
282
283
284
285
The number of the conference where news of interest to the readers of
this LysKOM server should be written. This is typically a conference
with very low traffic which everyone shoule be a member of. Clients
should offer new users to join it. Defaults to 4. This option is ignored
in lyskomd 1.9 and later. Set this using dbck or the
@ref{(protocol-a)set-info,set-info}.


286
@item Message of the day: @var{int}
David Byers's avatar
David Byers committed
287
288
289
290
291
292
Default message-of-the-day of this server. The text will be shown
automatically by conforming LysKOM clients when a user logs on. This
option is ignored in lyskomd 1.9 and later. Set this using dbck or the
@ref{(protocol-a)set-info,set-info}.


293
@item Garb: @var{bool}
David Byers's avatar
David Byers committed
294
295
296
Should the database be automatically purged of old texts?  The default
is on.

297
@item Never save: @var{bool}
David Byers's avatar
David Byers committed
298
299
300
Completely disables saving the database while the server is running. Do
not use this unless you really know what you're doing. The default is
@code{false}.
David Byers's avatar
David Byers committed
301

302
@item Log accesses: @var{path}
David Byers's avatar
David Byers committed
303
304
305
306
307
308
This parameter can only be set if the server has been compiled with
@code{LOGACCESSES} defined. It will save a trace of all activity in the
database to a file, for later use in simulations et c. Compiling with
@code{LOGACCESSES} slows the server down quite a lot, so it is normally
not defined. 

309
@item Data file: @var{path}
David Byers's avatar
David Byers committed
310
The path relative to the installation prefix where part of the database
311
is kept. The default is @file{db/lyskomd-data}.
David Byers's avatar
David Byers committed
312

313
@item Backup file: @var{path}
David Byers's avatar
David Byers committed
314
315
The path relative to the installation prefix where a backup of the
database is kept. This file will always contain a complete database, but 
316
it may be a little out-of-date. Default is @file{db/lyskomd-backup}.
David Byers's avatar
David Byers committed
317

318
@item Backup file 2: @var{path}
David Byers's avatar
David Byers committed
319
320
321
The path relative to the installation prefix where a previous generation
of the backup of the database is kept. This file may be needed if an
error in the backup file is detected during the creation of the data
322
file. Default is @file{db/lyskomd-backup-prev}.
David Byers's avatar
David Byers committed
323

324
325
326
327
328
329
@item Lock file: @var{path}
Name of the lock file that ensures that @code{dbck} and @code{lyskomd}
never attempt to modify the database at the same time.  It should always
reside in the same directory as the @samp{Data file}.  Default is
@file{db/lyskomd-lock}.

330
@item Text file: @var{path}
David Byers's avatar
David Byers committed
331
The path relative to the installation prefix where the actual texts in
332
the database are kept. Default is @file{db/lyskomd-texts}.
David Byers's avatar
David Byers committed
333

334
@item Text backup file: @var{path}
David Byers's avatar
David Byers committed
335
336
337
338
When dbck is run with the @code{-g} option (@ref{(dbck)Invoking
dbck,Invoking dbck}, it will store the previous contents of the text
file in the file specified by this option. The path is relative to the
installation prefix. This file is never used by lyskomd itself. Default
339
is @file{db/lyskomd-texts-backup}.
David Byers's avatar
David Byers committed
340

341
@item Log file: @var{path}
David Byers's avatar
David Byers committed
342
The path relative to the installation prefix where log messages from
343
lyskomd are written. Default is @file{etc/server-log}.
David Byers's avatar
David Byers committed
344

345
346
@item Log statistics: @var{path}
Whenever lyskomd receives a SIGUSR1 it will append a timestamp and
David Byers's avatar
David Byers committed
347
348
a count of how many different atomic calls have been made in this file.
The path is relative to the installation prefix. Default is
349
@file{etc/lyskomd-log}.
David Byers's avatar
David Byers committed
350

351
@item Pid file: @var{path}
David Byers's avatar
David Byers committed
352
353
354
When lyskomd is up and running it will write its pid in this file. The
path is relative to the installation prefix. This file is used so the
@code{updateLysKOM} script can easily find out what pid the LysKOM
355
server has. Default is @file{etc/pid}.
David Byers's avatar
David Byers committed
356

357
358
359
This file should be removed when the computer reboots, before
@code{komrunning} or @code{updateLysKOM} is run.

360
@item Memory usage file: @var{path}
David Byers's avatar
David Byers committed
361
362
When lyskomd exits normally it appends some info on its usage of memory
to this file. The path is relative to the installation prefix. Almost
363
364
any memory leak bugs should be detectable by looking in this file.
Default is @file{etc/memory-usage}.
David Byers's avatar
David Byers committed
365

366
@item Aux-item definition file: @var{path}
David Byers's avatar
David Byers committed
367
368
369
This file defines which aux-items the server should support and how it
should handle them. @xref{Aux-Item Definition File} for more details. 
The path is relative to the installation prefix. Default is
370
@file{etc/aux-items.conf}.
David Byers's avatar
David Byers committed
371

David Byers's avatar
David Byers committed
372
373
374
375
@item Core directory: @var{path}
The Directory where core dumps are written. This path is relative to the 
installation prefix. Default is @file{cores}.

376
377
378
379
380
381
@item Status file: @var{path}
This file is created by @code{komrunning} to indicate that lyskomd
should currently not be running.  When this file exists
@code{updateLysKOM} will send it a @code{SIGHUP} signal, so that it
saves the database and dies.  Default is @file{etc/status}.

David Byers's avatar
David Byers committed
382
383
384
@item Nologin file: @var{path}
If this file exists, the server will not allow any connections at all.
Default is @code{/etc/nologin}.
David Byers's avatar
David Byers committed
385

386
@item Idle timeout: @var{int}
David Byers's avatar
David Byers committed
387
388
389
Number of milliseconds to sleep when there is nothing for lyskomd
to do. Default is @code{120000} (two minutes.)

390
@item Garb timeout: @var{garb}
David Byers's avatar
David Byers committed
391
392
393
394
Number of milliseconds to sleep when the server is garbage-collecting
texts, but has nothing else important to do. Default is @code{100} (0.1
seconds.)

395
@item Sync timeout: @var{sync}
David Byers's avatar
David Byers committed
396
397
398
Number of milliseconds to sleep when lyskomd is saving its database.
Defaults to 0.

399
@item Permissive sync: @var{bool}
David Byers's avatar
David Byers committed
400
401
402
403
Turning this option on lets any session sync the LysKOM database.
Turning it off restricts the operation to LysKOM administrators. Default 
is off.

404
@item Garb interval: @var{int}
David Byers's avatar
David Byers committed
405
406
407
Number of minutes between each garb sweep. Defaults to @code{1440}, that
is, a garb sweep will be run once per day.

408
@item Sync interval: @var{int}
David Byers's avatar
David Byers committed
409
410
411
412
413
Number of minutes between syncs. The current version of lyskomd keeps
changes to the database in memory until they are synced to disk. This
parameter specifies the number of minutes the server waits before
attempting to dump the database. The default is @code{5}.

414
@item Sync retry interval: @var{int}
David Byers's avatar
David Byers committed
415
416
417
418
If anything goes wrong while trying to dump the data base (such as if
the disk is full), lyskomd will wait for this many minutes before trying
again. Default is @code{1}.

David Byers's avatar
David Byers committed
419
420
421
422
@item Max client data length: @var{int}
The maxiumum allowed length for client name and version data. The
default is @code{60}.

423
@item Max conference name length: @var{int}
David Byers's avatar
David Byers committed
424
425
The maximum length of conference names. The default is @code{60}.

426
@item Max password length: @var{int}
David Byers's avatar
David Byers committed
427
428
429
430
Only the first eight characters of the password are currently
significant, even if this number is much larger. The default is
@code{128}.

431
@item Max what am I doing length: @var{int}
David Byers's avatar
David Byers committed
432
433
434
435
The maximum length of the string permitted in the protocol A call
@ref{(protocol-a)change-what-i-am-doing, change-what-i-am-doing}. The
default is 60.

436
@item Max username length: @var{int}
David Byers's avatar
David Byers committed
437
438
The maximum length permitted for user names. Default is 128.

439
@item Max text length: @var{int}
David Byers's avatar
David Byers committed
440
441
The maximum length allowed for a text. The default is 131072 characters.

442
@item Max broadcast length: @var{int}
David Byers's avatar
David Byers committed
443
444
445
The maximum length allowed for broadcast messges. The default is 1024
characters.

446
@item Max regexp length: @var{int}
David Byers's avatar
David Byers committed
447
448
449
The maximum length allowed for regexps in various calls. The default is
1024 characters.

450
@item Max marks per person: @var{int}
David Byers's avatar
David Byers committed
451
452
453
The maximum number of marks a person is allowed to have. The default is
2048.

454
@item Max marks per text: @var{int}
David Byers's avatar
David Byers committed
455
456
The maximum number of marks a text can have. The default is 1024.

457
@item Max recipients per text: @var{int}
David Byers's avatar
David Byers committed
458
459
The maximum number of recipients of a text. The default is 512.

460
@item Max comments per text: @var{int}
David Byers's avatar
David Byers committed
461
462
The maximum number of comments a text can have. The default is 128.

463
@item Max footnotes per text: @var{int}
David Byers's avatar
David Byers committed
464
465
The maximum number of footnotes a text can have. The default is 32.

466
@item Max links per text: @var{int}
David Byers's avatar
David Byers committed
467
468
FIXME: What is this?

469
@item Max mark_as_read chunks: @var{int}
David Byers's avatar
David Byers committed
470
471
FIXME: What is this?

472
@item Max super_conf loop: @var{int}
David Byers's avatar
David Byers committed
473
474
FIXME: What is this?

475
@item Max accept_async len: @var{int}
David Byers's avatar
David Byers committed
476
477
478
Maximum length of list accepted in the accept_async call. Default is
128.

479
@item Max aux_items deleted per call: @var{int}
David Byers's avatar
David Byers committed
480
481
482
Maximum number of aux_items that can be deleted in one call. Default is
128.

483
@item Max aux_items added per call: @var{int}
David Byers's avatar
David Byers committed
484
485
Maximum number of aux_items that can be added at once. Default is 2048.

486
@item Default garb nice: @var{int}
David Byers's avatar
David Byers committed
487
488
489
490
491
Each conference has a lifetime for texts written in it. The lifetime is
counted in days, and can be set for each conference by the administrator
of the conference. This is the default value assigned to new
conferences. Default is 77 days.

492
@item Default keep commented nice: @var{int}
David Byers's avatar
David Byers committed
493
494
495
496
497
A text will not be removed if it has comments newer than a certain
number of days. This number can be set for each conference. This
parameter specifies the default value for that number of days. The
default is 77.

498
@item Max client transmit queue: @var{int}
Per Cederqvist's avatar
Per Cederqvist committed
499
Max number of pending data blocks in the reply queue to a client. If
David Byers's avatar
David Byers committed
500
501
502
503
there is ever more than this many data blocks in the queue the client
will be disconnected. Each atomic question typically generates two data
blocks. Default is 300.

504
@item Max simultaneous client replies: @var{int}
David Byers's avatar
David Byers committed
505
506
507
This is a performance tuning parameter of little real interest. Default
is 10.

508
@item Open files: @var{int}
David Byers's avatar
David Byers committed
509
510
511
512
513
Try to persuade the operating system to allow lyskomd to have this many
open file descriptors simultaneously. Each client that is connected to
the server occupies one file descriptor, and lyskomd needs several file
descriptors for internal purposes. Default is to not use this parameter.

514
@item Anyone can create new persons: @var{bool}
David Byers's avatar
David Byers committed
515
516
517
If this is set, anyone can create a new person, even if he lacks
special bits for doing so. Default is on.

518
@item Anyone can create new conferences: @var{bool}
David Byers's avatar
David Byers committed
519
520
521
If this is set, anyone can create a new conferences, even if he lacks
special bits for doing so. Default is on.

522
@item Allow creation of persons before login: @var{bool}
David Byers's avatar
David Byers committed
523
524
525
526
527
If this is set, persons can connect the the server and create a new
person without logging in.  This is how new users register in open
environments. If this option is off, then new persons can only be
created by existing users. The default is on.

528
@item Default change name capability: @var{bool}
David Byers's avatar
David Byers committed
529
530
531
If this is set, new users are created with the ability to change their
own name. Default is on.

532
@item Ident-authentication: @var{policy}
David Byers's avatar
David Byers committed
533
534
Decide how strictly the server should use the IDENT protocol.
The policy can take any of three values:
535

David Byers's avatar
David Byers committed
536
537
538
539
540
541
542
543
544
545
546
547
@table @asis
@item @code{off} or @code{never}
Do not use the IDENT protocol.

@item @code{on} or @code{try}
Use it, but allow logins even if the lookup fails.

@item @code{require} or @code{required}
Disallow connections if the server cannot find a IDENT login name.
@end table


548
@item Log login: @var{bool}
David Byers's avatar
David Byers committed
549
550
Should logins be logged to the log file?  Default value is off.

551
@item Cache conference limit: @var{int}
David Byers's avatar
David Byers committed
552
553
554
555
How many conference statuses the server cache should hold in main
memory. Default is 20. This parameter should be set to at least the
number of expected simultaneous logins.

556
@item Cache person limit: @var{int}
David Byers's avatar
David Byers committed
557
558
559
560
How many person statuses the server cache should hold in main
memory. Default is 20. This parameter should be set to at least the
number of expected simultaneous logins.

561
@item Cache text_stat limit: @var{int}
David Byers's avatar
David Byers committed
562
563
564
565
How many text statuses the server cache should hold in main
memory. The default is 20. This parameter should be increased on busy
servers.

566
567
@item Echo: @var{string}
Write @var{string} in the log when the config file is read.
David Byers's avatar
David Byers committed
568

569
570
571
@item Jubel: @var{pers_no} @var{text_no}
States that @var{pers_no} is not allowed to create text number
@var{text_no}. Default is unset.
David Byers's avatar
David Byers committed
572

573
574
575
@item Jubel: @var{pers_no} @var{dividend} @var{remainder}
States that @var{pers_no} is not allowed to create any text number
@var{T} which meets the condition @var{T} % @var{dividend} == @var{remainder}.
David Byers's avatar
David Byers committed
576
577
Default is unset.

578
@item Add members by invitation: @var{bool}
David Byers's avatar
David Byers committed
579
580
581
582
If this is set, then adding others as members to a conference sets the
invitation bit of the membership. If this is off, the membership bit is
set to whatever the caller specifies. The default is on.

583
@item Allow secret memberships: @var{bool}
David Byers's avatar
David Byers committed
584
585
586
587
If this is set, then memberships may be secret. Otherwise any attempt
to create a secret membership or change an existing membership to a
secret membership will fail. The default is on.

588
@item Allow reinvitations: @var{bool}
David Byers's avatar
David Byers committed
589
590
591
592
593
594
If this is set, then it is possible to set the invitation bit of a
membership even after it has been cleared. If it is not set, then the
invitation bit of a conference type can only be set when the
membership is created. It can be cleared at any time. The default is
off.

595
@item Regexps use collate table: @var{bool}
David Byers's avatar
David Byers committed
596
597
598
599
600
If this is set, regexp matching of conference names uses the same
collate table used by regular matching. This usually implies that the
regexp ``foo'' will match ``foo'', ``Foo'', ``fOo'' and several other
variants. The defalt is on.

601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
@item lyskomd path: @var{path}
Path to the @code{lyskomd} binary.  This is used by @code{updateLysKOM}
to find the right program to run.  Defaults to @file{bin/lyskomd}.

@item savecore path: @var{path}
Path to the @code{savecore} program.  If a file named @file{core} exists
in the directory specified with @code{Core directory} when
@code{updateLysKOM} is about to start @code{lyskomd}, this program will
be called first.  It could, for instance, move the core file so that it
is available for later debugging.

@item Normal shutdown time: @var{int}
In a normal setup, @code{updateLysKOM} will be run from @code{cron} once
every ten minutes or so.  If it detects that it has taken @code{lyskomd}
more than @var{int} minutes to shut down it will print a warning
message.

@item Mail after downtime: @var{int}
@itemx Mail until downtime: @var{int}

If @code{lyskomd} has been down for X minutes, where @code{Mail after
downtime} <= X < @code{Mail until downtime}, @code{updateLysKOM} will
send a mail message to the mail address found on the first line of the
status file.  Actually, it is the age of the status file (named with
@code{Status file}) that is measured.

David Byers's avatar
David Byers committed
627
628
629
@end table


David Byers's avatar
David Byers committed
630
@node Aux-Item Definition File,  , Server Configuration File, Configuration
David Byers's avatar
David Byers committed
631
632
633
634
635
636
@section Aux-Item Definition File

The default aux-item definition file should not be changed unless it is
really necessary. The need to change the definitions will probably only
arise at installations used for client or server development.

637
638
The location of the aux-item definition file is specified by the
@code{Aux-item definition file} option in the server configuration
639
file. The default location is @file{/usr/lyskom/etc/aux-items.conf}.
David Byers's avatar
David Byers committed
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659


@subsection Syntax of the Aux-Item Definition File

The aux-item definition file contains a sequence of aux-item
definitions. Each definition specifies one type of predefined aux-item:
its number, name, and properties. Empty lines and all characters from a
# character to the end of the line are ignored.

Each entry has the following format:

@example
        tag : name (target, target, ... )
        @{
            field = value;
            field = value;
            ...
        @}
@end example

660
@var{tag} is an integer, the aux-item's tag. If a tag is defined more than 
David Byers's avatar
David Byers committed
661
662
once, the last definition is used. 

663
The @var{target}s specify what kind of objects aux-items with tag @var{tag}
David Byers's avatar
David Byers committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
can be added to. Valid targets are:

@table @code
@item any
Aux-items with the specified tag can be added to any object in the
database. This is shorthand for @code{text,conference,letterbox,server}.

@item text
Aux-items with the specified tag can be added to texts.

@item conference
Aux-items with the specified tag can be added to conferences that are
@i{not} letterboxes.

@item letterbox
Aux-items with the specified tag can be added to conferences that are
letterboxes.
681
682
683
684

@item server
Aux-items with the specified tag can be added to the server itself.

David Byers's avatar
David Byers committed
685
686
687
688
689
690
691
692
693
694
@end table

It is legal to add one of the keywords @code{create} or @code{modify}
before any target except @code{server}. If @code{create} is specified,
aux-items with the specified tag can only be added when an object is
being created. They cannot be added later. If @code{modify} is
specified, aux-items with the specified tag can only be added after an
object has been created. They cannot be added when the object is being
created.

695
Each @var{field}/@var{value} pair specifies a property of aux-items with the 
David Byers's avatar
David Byers committed
696
697
698
699
700
701
702
703
704
705
706
707
708
specified tag. Most values are boolean or trillian. Legal values for
either type are @code{true} and @code{false}. Boolean values have
reasonable defaults; trillian values can be unset.

@table @code

@item author-only
Boolean, default false. When true, only the author of a text or
supervisor of a conference can create items with this tag. 

@item supervisor-only
Boolean, default false. When true, only the supervisors of the author or
letterbox can create items with this tag. In all likelihood, the
David Byers's avatar
David Byers committed
709
710
711
712
713
714
implementation of this flag is screwed up in version 2.0 of lyskomd.

@item system-only
Boolean, default false. When true, only the server can initiate creation 
of items with this tag. This is normally used for items that are created
automatically in response to events in the system.
David Byers's avatar
David Byers committed
715
716

@item permanent           
717
718
719
Boolean, default false. When true, aux-items with this tag cannot be
deleted once they have been created.  (They will be deleted
automatically when the object they are assigned to is deleted.)
David Byers's avatar
David Byers committed
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755

@item unique
Boolean, default false. When true, there can only be one non-deleted
item with this tag per creator.

@item inherit-limit
Integer, default 0. The maximum number of times items with this tag can
be inherited, plus one. Zero means an unlimited number of times, one
means no times, 2 means once and so forth. This number overrides the
inherit-limit set by the client only if that number is higher than this
one.

@item inherit
Trillian. When set, the inherit bit on new items with this tag is forced
to the specified value.

@item secret
Trillian. When set, the secret bit on new items with this tag is forced
to the specified value.

@item hide-creator        
Trillian. When set, the hide-creator bit on new items with this tag is
forced to the specified value.

@item dont-garb	    
Trillian. When set, the dont-garb bit on new items will be forced to the
specified value.

@item reserved-2
@item reserved-3
@item reserved-4
Trillian. When set, these flags force the values of the three reserved
bits in the aux-item flags field. These should only be used by lyskomd
developers, and then only very carefully.

@item validate            
David Byers's avatar
David Byers committed
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773

String or function, default none. When set to a string, this specifies a
regexp that must match the data field in newly created items with this
tag. If the regexp fails to match, then the item will not be created. 
The syntax for strings is essentially the same as the syntax used in C
files. When set to a function, this specified a built-in validation
function to call.

The following validator functions are currently implemented:

@table @code

@item existing-readable-text
Creation is only allowed if the item contains the number of an existing
text that the item creator has permission to read.

@end table

David Byers's avatar
David Byers committed
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798

@end table

There are a few fields which specify actions the server is to take when
something happens to aux-items with the specified tag. Each of these
values is a function specification, the name of a trigger function
defined in lyskomd. The syntax for functions is the name followed by
an empty pair of parens. It is not possible to pass arguments to the
functions yet.

@table @code
@item add-trigger
Function to call when an item with the specified tag is added to an
object.

@item delete-trigger
Function to call when an item with the specified tag is scheduled for
deletion.

@item undelete-trigger
Function to call when an item with the specified tag scheduled for
deletion is unscheduled. It should undo the effects of the delete
trigger.
@end table

David Byers's avatar
David Byers committed
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
The following trigger functions are currently defined:

@table @code
@item mark-text
Increase the mark count for the text the item refers to. The item must
contain the number of a text. This trigger should be combined with the
existing-readable-text validation function.

@item unmark-text
Decrease the mark count for the text the item refers to. The item must
contain the number of a text. This trigger should be combined with the
existing-readable-text validation function.

@item link-faq
Create a faq-for-conf item linked to a faq-text item. This trigger is
used exclusively for faq-text items. The item must contain the number of
a text. This trigger must be combined with the existing-readable-text
validation function.

@end table


David Byers's avatar
David Byers committed
821
822


David Byers's avatar
David Byers committed
823
@node Running lyskomd, Invoking updateLysKOM, Configuration, Top
David Byers's avatar
David Byers committed
824
825
826
827
828
829
830
831
832
833
834
835
@chapter Running lyskomd

This section explains how to run lyskomd, the files it uses and how it
can be controlled while running.

@menu
* Invoking lyskomd::            How to run lyskomd.
* Signals::                     How to control lyskomd with Unix signals.
* Files::                       Files used by lyskomd.
@end menu


David Byers's avatar
David Byers committed
836
@node Invoking lyskomd, Signals, Running lyskomd, Running lyskomd
David Byers's avatar
David Byers committed
837
838
839
@section Invoking lyskomd

@example
840
        lyskomd [-d] [@var{config-file}]
David Byers's avatar
David Byers committed
841
842
843
844
845
846
847
@end example

The option @code{-d} adds one to the debug level. The amount of output
on stderr is increased for each time the option is specified on the
command line. Furthermore, if this option is used, lyskomd will not run
as a daemon, but will stay in forground mode.

848
Using one @code{-d} makes the process print a `>' for every timeout, a
David Byers's avatar
David Byers committed
849
850
851
852
message for every person that is connecting or disconnecting and a
message for every successful or unsuccessful communication to the
process.

853
The optional @var{config-file} argument can be used to specify the server
David Byers's avatar
David Byers committed
854
855
856
configuration file. @xref{Server Configuration File}.


David Byers's avatar
David Byers committed
857
@node Signals, Files, Invoking lyskomd, Running lyskomd
David Byers's avatar
David Byers committed
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
@section Signals

It is possible to control some aspects of lyskomd using Unix signals.
The following signals have special meaning to the server:

@table @code
@item SIGHUP
Logs out all sessions, saves the database and exits normally.

@item SIGQUIT
Saves the database and dump core. (This should only be used for
debugging purposes.)

@item SIGUSR1
Print statistics about how often different commands have been used
since the process started.

@item SIGUSR2
Forks a child that immediately dumps core. The main process just waits
877
until the child is done and then continues.
David Byers's avatar
David Byers committed
878
879
880
@end table


David Byers's avatar
David Byers committed
881
@node Files,  , Signals, Running lyskomd
David Byers's avatar
David Byers committed
882
883
884
885
886
@section Files Used by lyskomd

All file names can be changed in the server configuration file.
@xref{Parameters}.

887
@table @file
David Byers's avatar
David Byers committed
888
@item /usr/lyskom
889
890
891
Default value of the @code{Prefix} parameter. The default of this value
is set at compile time, but it can be changed in the server
configuration file.  @xref{Parameters}.
David Byers's avatar
David Byers committed
892

893
@item @code{Prefix}/db/lyskomd-data
894
Half of the database: all status information.
David Byers's avatar
David Byers committed
895

896
@item @code{Prefix}/db/lyskomd-texts
David Byers's avatar
David Byers committed
897
898
The other half of the database: the actual texts.

899
900
@item @code{Prefix}/db/lyskomd-backup
A backup copy of @file{lyskomd-data}. Never, ever delete this file
David Byers's avatar
David Byers committed
901
902
903
unless you know what you are doing, or you may lose the entire data
base. Most of the time this is the only complete database file!

904
@item @code{Prefix}/etc/pid
David Byers's avatar
David Byers committed
905
906
File with the pid of the lyskom-process.

907
@item @code{Prefix}/etc/memory-usage
David Byers's avatar
David Byers committed
908
909
910
On normal exit, @code{lyskomd} will append some statistics to this file. 
It can be used for detecting memory leaks.

911
@item @code{Prefix}/etc/aux-items.conf
David Byers's avatar
David Byers committed
912
913
914
This file contains definitions of the aux-items that the server should
support.  It is read by @code{lyskomd} at startup. 

David Byers's avatar
David Byers committed
915
916
917
918
919
@item /etc/nologin
If this file exists, lyskomd will not allow anyone to connect to the
server. This path can be set with the @code{Nologin file} parameter in
the server configuration file.

David Byers's avatar
David Byers committed
920
921
922
@end table


David Byers's avatar
David Byers committed
923
@node Invoking updateLysKOM, Invoking komrunning, Running lyskomd, Top
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
@chapter Invoking updateLysKOM

@example
        updateLysKOM [-c @var{config-file}] [ -v ] [ -V ]
@end example

@code{updateLysKOM} determines if @code{lyskomd} should be running.  It
can start or stop @code{lyskomd} if needed.  It uses the same
configuration file as @code{lyskomd} (@pxref{Server Configuration
File}).  You can use @samp{-c @var{config-file}} to override the
compiled-in default.  Note, however, that this option is not passed
along to @code{lyskomd} if @code{updateLysKOM} starts it, so the option
should be used with extreme caution.

@samp{-v} and @samp{-V} causes @code{updateLysKOM} to report its version
number and exit.

@code{updateLysKOM} is normally run from @code{cron};
@pxref{Administration}.

David Byers's avatar
David Byers committed
944
@node Invoking komrunning, Administration, Invoking updateLysKOM, Top
945
946
947
948
949
950
@chapter Invoking komrunning

@example
        komrunning [-c config-file] [start | stop]
        komrunning -v | -V
@end example
David Byers's avatar
David Byers committed
951

952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
@code{komrunning}, when invoked with no arguments, reports whether
@code{lyskomd} is currently running or not, and whether it should be
running or not.  @code{komrunning start} attempts to start
@code{lyskomd}.  @code{komrunning stop} attempts to stop @code{lyskomd},
and it will not return until the server has saved its database and
exited.

@code{komrunning} uses the same configuration file as @code{lyskomd}
(@pxref{Server Configuration File}).  You can use @samp{-c
@var{config-file}} to override the compiled-in default.  Note, however,
that this option is not passed along to @code{updateLysKOM} if
@code{komrunning} invokes it, so the option should be used with extreme
caution.

The @code{komrunning} can be installed in @file{/etc/init.d/}.  Be
careful, however, to ensure that the pid file is removed earlier during
the boot sequence.

970
971
972
@samp{-v} and @samp{-V} causes @code{komrunning} to report its version
number and exit.

David Byers's avatar
David Byers committed
973
@node Administration, Bugs, Invoking komrunning, Top
David Byers's avatar
David Byers committed
974
975
976
@chapter Administration

The first thing you will have to do is to follow the instructions in the
977
978
979
files @file{INSTALL} and @file{README}. This will set up the LysKOM
system with a database containing a few necessary conferences and one
person - the administrator.
David Byers's avatar
David Byers committed
980
981
982
983
984
985
986
987
988
989

Once the LysKOM system is running, there is not much you will have to do
to keep it that way. One thing to remember is that the current release
of the server has an incomplete handling of garbage collection of the
database. The database is split into two files, the information file and
the text file. Newly written texts are concatenated to the text file and
old texts are never removed. The information file contains information
about conferences, users and where in the text file the texts are. This
file is properly garbage collected, but not the text file.

990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
There is a program called @code{dbck} (Data Base Check) which is used to
check the consistency of the LysKOM database. This program can also be
used to shrink the text file. To do this, just type @samp{dbck
-g}. @xref{(dbck)}. When @code{dbck} is to be run on the database, the
LysKOM server @emph{must} be stopped, or unrepairable damage may
result. See below for a description on how to stop the server.

There is a program called @code{updateLysKOM} which is used to ensure
continuous operation. This program should be run with certain intervals,
for instance from @code{cron}. If the LysKOM server has died for some
reason, @code{updateLysKOM} restarts it. If the server is still running
properly, @code{updateLysKOM} sends a signal (@code{SIGUSR1}) to it,
which causes the server to write some statistics to a file named
@file{etc/lyskomd-log} in the lyskom directory.
David Byers's avatar
David Byers committed
1004
1005
1006

Taking the server down cleanly can be done in two ways: through the use
of the LysKOM protocol on a socket, preferably through the use of a
1007
1008
1009
1010
1011
1012
1013
1014
1015
suitable client, or by sending the signal @code{SIGHUP} to it. This will
cause the server to save the database and close all client
connections. It will also create a file named @file{etc/memory-usage} in
which the memory usage of the server is reported.

To prevent @code{updateLysKOM} from restarting a server, create a file
named @file{/usr/lyskom/etc/status}. The file should contain a valid
mail address on the first line. @code{updateLysKOM} will not restart the
server as long as that file exists. In addition, if the file is between
1016
1017
1018
1019
1020
1 and 2 hours old (configurable) an email will be sent to the mail
address found in the file. If the file is older than that, an error
message will be printed on stderr and @code{updateLysKOM} will exit with
a non-zero exit status. cron is expected to deliver the error message to
an operator.
1021
1022
1023

The shell script @code{komrunning} can be used to start and stop the
LysKOM server. With no arguments, it will report the status.
David Byers's avatar
David Byers committed
1024
1025
1026
1027
1028

@example
	komrunning off
@end example

1029
1030
1031
1032
1033
will (attempt to) shut down the server, creating the file
@file{/usr/lyskom/etc/status}.  If the user running @code{komrunning}
doesn't have permission to send signals to @code{lyskomd} the actual
shutdown will be delayed until the next time that @code{updateLysKOM} is
run.
David Byers's avatar
David Byers committed
1034
1035
1036
1037
1038

@example
	komrunning on
@end example

1039
1040
1041
will restart the server.  The actual starting of the server will be done
by @code{updateLysKOM} the next time it is run.  @code{komrunning} only
removes the lock file.
David Byers's avatar
David Byers committed
1042
1043


David Byers's avatar
David Byers committed
1044
1045
@node Bugs, DBCK Reference, Administration, Top
@comment  node-name,  next,  previous,  up
David Byers's avatar
David Byers committed
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
@chapter Known Bugs

@itemize @bullet
@item lyskomd should re-read the config file when a @code{SIGHUP} is
received.

@item lyskomd should terminate when a @code{SIGINT} or @code{SIGTERM} is
received.

@item The security policy is vague and the implementation is frayed at
the edges.

@item The choice of asynchronous messages is not very good.

@item The server uses too much memory.

@end itemize



David Byers's avatar
David Byers committed
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330

@c ======================================================================
@c ======================================================================
@c ==                                                                  ==
@c ==                            DBCK REFERENCE                        ==
@c ==                                                                  ==
@c ======================================================================
@c ======================================================================

@node DBCK Reference, Hacking, Bugs, Top
@comment  node-name,  next,  previous,  up
@chapter DBCK Reference

dbck is a program that can is used for minor database maintenance tasks
and for repairing a corrupt lyskomd database.

@menu
* DBCK Overview::               Overview of dbck.
* Invoking dbck::               How to run dbck.
* DBCK Notes::                  Notes about running dbck.
* DBCK Files::                  Files used by dbck.
* DBCK Bugs::                   Known bugs in dbck.
@end menu


@node DBCK Overview, Invoking dbck, DBCK Reference, DBCK Reference
@comment  node-name,  next,  previous,  up
@section Overview

The dbck program is used for minor maintenance of the LysKOM database
and for repairing corrupt databases. In brief it performs the following
functions:

@itemize @bullet
@item Compact the text file to remove deleted texts.
@item Repair inconsistent membership information.
@item Repair invalid recipients
@item Repair inconsistent comment links
@item Correct invalid local text numbers
@item Correct invalid text maps
@item Set special conferences
@item Convert between database formats
@end itemize


@node Invoking dbck, DBCK Notes, DBCK Overview, DBCK Reference
@comment  node-name,  next,  previous,  up
@section Invoking dbck

The functionality of dbck is controlled through command-line switches.
These are documented below.

If @code{dbck} is invoked without any options it will read the database
and report on its integrity.  No files will be modified.

@menu
* General Options::             Controlling the overall behavior of dbck.
* Database Repair Options::     Repairing errors in the LysKOM database.
* Format Conversion Options::   Converting the database file to a new format.
* Database Maintenance Options::  Options for database maintenance.
* Reporting Options::           Options controlling status reports.
@end menu


@node General Options, Database Repair Options, Invoking dbck, Invoking dbck
@comment  node-name,  next,  previous,  up
@subsection General Options

These options control the general behavior of lyskomd.

@table @asis
@item @code{-h} or @code{--help}
Give a usage message (which includes the version number and the
compiled-in default location of the config file) and exit immediately.

@item @code{-v} or @code{--verbose}
Verbose mode. Report not only errors but the status of the database.

@item @code{-F} or @code{--force-output}
This option forces dbck to write the database file. Normally @code{dbck} 
will only write a new database file if changes have been made for some
other reason. If you want to simply convert a database from one version
to another, you will probably have to give this option.
@end table


@node Database Repair Options, Format Conversion Options, General Options, Invoking dbck
@comment  node-name,  next,  previous,  up
@subsection Database Repair Options

The following options control database repair.

@table @asis
@item @code{-i} or @code{--interactive}
Run interactively. If any inconsistency is found, a remedial cure will
be suggested and the user must confirm the correction.

@item @code{-r} or @code{--auto-repair}
Repair simple errors without asking.

@item @code{-c} or @code{--set-change-name}
Consider it an error if the @code{change-name} capability of a person is 
not set. Due to a bug that capability was never set for newly created
persons in release 1.6.1 of lyskomd. This option can be used to repair
the damage.
@end table


@node Format Conversion Options, Database Maintenance Options, Database Repair Options, Invoking dbck
@comment  node-name,  next,  previous,  up
@subsection Format Conversion Options

dbck can be used to conver the LysKOM database from one storage format
to another. This is necessary only when moving the database to a new
server version.

@table @asis
@item @code{-F} or @code{--force-output}
This option forces dbck to write the database file. Normally @code{dbck} 
will only write a new database file if changes have been made for some
other reason. If you want to simply convert a database from one version
to another, you will probably have to give this option.

@item @code{-o} or @code{--output-version}
This option is used to set the output version of the database. This
option will normally be used in conjunction with the @code{-F} option.

Version 1.9 of @code{lyskomd} requires database version 1; version 2.0
requires database version 2. Versions of @code{lyskomd} prior to 1.9
requires database version 0. Note that information is irrevocably lost
when converting from a higher to a lower database version. This options
requires an argument: the output format version.
@end table


@node Database Maintenance Options, Reporting Options, Format Conversion Options, Invoking dbck
@comment  node-name,  next,  previous,  up
@subsection Database Update Options

dbck can be used to update certain aspects of the database that either
were impossible to update in early versions of protocol A or that are
inconvenient in all protocol versions.

@table @asis
@item @code{-g} or @code{--compact-text-mass}
Do garbage collection on the texts part of the database. This removes
all unreferenced texts from the database. 

@item @code{-P} or @code{--clear-password}
Clear the password of a specified user. This option is silently ignored
if the user does not exist. This option requires an argument: the ID of
the person whose password is to be cleared.

@item @code{-G} or @code{--grant-all}
Grant all privileges to the specified user. This option is silently
ignored if the user does not exist. This option requires an argument:
the ID of the person who is to be granted all privileges.

@item @code{--pers-pres-conf}
Set the person presentation conference of the server to the specified
conference. Since version 1.9 of lyskomd the @code{set-info} call can be 
used to do this.

@item @code{--conf-pres-conf}
Set the conference presentation conference of the server to the specified
conference. Since version 1.9 of lyskomd the @code{set-info} call can be 
used to do this.

@item @code{--motd-conf}
Set the message-of-the-day conference of the server to the specified
conference. Since version 1.9 of lyskomd the @code{set-info} call can be 
used to do this.

@item @code{--kom-news-conf}
Set the news-about-lyskom conference of the server to the specified
conference. Since version 1.9 of lyskomd the @code{set-info} call can be 
used to do this.

@item @code{--motd-of-kom}
Set the message of the day of the server to the specified text. Since
version 1.9 of lyskomd the @code{set-info} call can be used to do this.
@end table


@node Reporting Options,  , Database Maintenance Options, Invoking dbck
@comment  node-name,  next,  previous,  up
@subsection Reporting Options

These options control reporting of information about the database.

@table @asis
@item @code{-s} or @code{--print-statistics}
Gather statistics about the lengths of texts. A table containing the
frequence of all lengths that are currently present is printed.

@item @code{-t} or @code{--list-text-no}
Print ``Checking @i{text-no}'' for every text that examined.
@b{Warning:} This produces lots of output.
@end table


@node DBCK Notes, DBCK Files, Invoking dbck, DBCK Reference
@comment  node-name,  next,  previous,  up
@section Notes for DBCK

The messages ``Conference @var{conf-no} has a bad Text-list. Starts with
0'' and ``Person @var{pers-no} has created @var{num} conferences, not
@var{num} (as said in person-stat).'' are normal. If you get them when
you specify the @code{-g} option, let @code{dbck} repair them and run
@code{dbck -g} again.


@node DBCK Files, DBCK Bugs, DBCK Notes, DBCK Reference
@comment  node-name,  next,  previous,  up
@section Files Used by dbck

dbck uses the same files as @code{lyskomd} (@xref{(lyskomd)}.)

All file names can be changed in the server configuration file.
@xref{(lyskomd)Parameters}.

@table @file
@item /usr/lyskom
Default value of @code{Prefix}. The default of this value is set at compile 
time, but it can be changed in the server configuration file.
@xref{(lyskomd)Parameters}.

@item @code{Prefix}/db/lyskomd-data
Half of the database: all status information.

@item @code{Prefix}/db/lyskomd-texts
The other half of the database: the actual texts.

@item @code{Prefix}/db/lyskomd-backup
A backup copy of @code{lyskomd-data}. Never, ever delete this file
unless you know what you are doing, or you may lose the entire data
base. Most of the time this is the only complete database file!

@end table


@node DBCK Bugs,  , DBCK Files, DBCK Reference
@comment  node-name,  next,  previous,  up
@section Known Bugs

@itemize @bullet
@item Does not lock the database.
@item Never checks if the database is locked.
@item Should have an unlock database option.
@item Does not check that the data file and text file are consistent.
@end itemize





@c ======================================================================
@c ======================================================================
@c ==                                                                  ==
@c ==                       LYSKOMD HACKING GUIDE                      ==
@c ==                                                                  ==
@c ======================================================================
@c ======================================================================


1331
@node Hacking, lyskomd Database Specification, DBCK Reference, Top
David Byers's avatar
David Byers committed
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
@comment  node-name,  next,  previous,  up
@chapter Hacking lyskomd


@menu
* The Database::                
* Adding Configuration Parameters::  How to add configuration options.
* Adding Asynchronous Messages::  Adding protocol A messages.
* Adding a New Protocol Request::  Adding protocol A calls.
* Adding Aux-Item Types::       Adding predefined aux item types.
* Modifying Stored Types::      Modifying types stored in the DB.
* Notes::                       Mixed notes.
* Debugging and Testing::       How to test and debug the server.
@end menu

@node The Database, Adding Configuration Parameters, Hacking, Hacking
@comment  node-name,  next,  previous,  up
@section The Database

@c FIXME: ramkomd är död! Länge leve LysKOM!
@c FIXME: 
@c FIXME: Jag har tillsammans med Inge kommit på ett sätt att dels få ner
@c FIXME: väntetiden i samband med syncningar till <1 sekund, dels få ner
@c FIXME: storleken på serverprocessen till mer rimliga nivåer. Denna lösning
@c FIXME: lider dock av det stora problemet att den kräver dubbelt så mycket
@c FIXME: diskutrymme som den egentligen behöver. Det gör även ramkomd, så det
@c FIXME: är ingen försämring i det avseendet. Dock är detta bara en temporär
@c FIXME: lösning i väntan på ldb.
@c FIXME: 
@c FIXME: Varför spara allt på en gång? Varför inte spara en liten del av filen
@c FIXME: i taget, och utföra några atomiska anrop mellan varje liten
@c FIXME: delsynkning? Ungefär så tänkte jag när jag kom på följande schema för
@c FIXME: hur man kan göra det hela bättre än det är nu.
@c FIXME: 
@c FIXME: Den databas som ligger på fil är en ögonblickbild (snapshot) av det
@c FIXME: som finns i LysKOM. Så är det i ramkomd; så blir det i diskomd.
@c FIXME: (Bättre namn, någon? lyskomd tycker jag är reserverat för den version
@c FIXME: som har en riktig cache&ldb.) I ramkomd skrivs allt ut på disk
@c FIXME: samtidigt. I diskomd minns man bara vad som skall sparas, och sparar
@c FIXME: bara en bit i taget.
@c FIXME: 
@c FIXME: I ramkomd finns allt inne i ram-minnet (i teorin. I praktiken är det
@c FIXME: mesta utswappat - något som märks varje gång det är dags att synca!).
@c FIXME: I diskomd ligger det mesta på disk. I minnet finns dels det som har
@c FIXME: använts nyligen, dels det som är ändrat och ännu ej syncat. Diskomd
@c FIXME: har alltid minst en, ofta två, databasfiler öppna:
@c FIXME: 
@c FIXME:         Fil A		Senaste kompletta fil.
@c FIXME:         Fil B		Fil under uppbyggnad.
1381
1382
1383
1384
@c FIXME FIXME:   Fil Z         Näst senast kompletta fil
@c FIXME FIXME:                 (den här gick att kopiera en gång i
@c FIXME FIXME:                 tiden, även om A inte går att kopiera
@c FIXME FIXME:                 just nu.)
David Byers's avatar
David Byers committed
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
@c FIXME: 
@c FIXME: (Dessutom textmassefilen, precis som ramkomd nuförtiden.)
@c FIXME: 
@c FIXME: Så till detaljerna:
@c FIXME: 
@c FIXME: Det finns tre typer av objekt som berörs av den här ändringen:
@c FIXME: Text_stat, Person och Conference. Jag använder Person som ett exempel
@c FIXME: nedan.
@c FIXME: 
@c FIXME: I ram-cache.c finns en array 
@c FIXME: 
@c FIXME:         Person *pers_arr[ MAX_CONF ];
@c FIXME: 
@c FIXME: Den byts mot
@c FIXME: 
@c FIXME:         Cache_node *pers_arr[ MAX_CONF ];
@c FIXME: 
@c FIXME: typedef struct cache_node ä
@c FIXME:         Bool	exists;
@c FIXME:         Bool	exists_b;
@c FIXME:         Bool	dirty;		/* Är *ptr modifierad? */
@c FIXME:         void   *snap_shot;
@c FIXME:         void   *ptr;
@c FIXME:         off_t   pos;
@c FIXME:         off_t   pos_b;
@c FIXME:         struct cache_node *lru_link;
@c FIXME:         int	lock_cnt;
@c FIXME: å Cache_node;
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: UPPSTART
@c FIXME: 
@c FIXME: När servern startas scannar den igenom datafilen (fil A) och fyller i
@c FIXME: fältet exists till TRUE/FALSE och pos till att peka på början av det
@c FIXME: ställe i filen där data ligger. Övriga fält sätts till FALSE/NULL/0.
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: CACHE_GET_PERSON
@c FIXME: 
@c FIXME: När ovanliggande rutiner vill läsa en person händer följande:
@c FIXME: 
@c FIXME: !exists			Returnera NULL
@c FIXME: ptr != NULL		Lägg noden först i lru_link. Returnera ptr.
@c FIXME: snap_shot != NULL	Kopiera snap_shot till ptr. Lägg noden först i
@c FIXME:                         lru_link. Returnera ptr.
@c FIXME: annars			Läs in från fil A, sätt ptr till den inlästa
@c FIXME:                         structen, lägg noden först i lru_link,
@c FIXME:                         returnera ptr.
@c FIXME: 
@c FIXME: 
@c FIXME: MARK_PERSON_AS_CHANGED
@c FIXME: 
@c FIXME: När något har ändrats sätts dirty-flaggan till TRUE.
@c FIXME: 
@c FIXME: 
@c FIXME: CREATE_PERSON
@c FIXME: 
@c FIXME: Sätt exists=TRUE, dirty=TRUE, ptr och lru.
@c FIXME: 
@c FIXME: 
@c FIXME: DELETE_PERSON
@c FIXME: 
@c FIXME: Sätt exists=FALSE. ptr=NULL. Troligtvis error om lock_cnt != 0.
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: THROW-OUT
@c FIXME: 
@c FIXME: För att inte diskomd ska bli för stor slängs saker ut ur cachen.
@c FIXME: Algoritm: tag första elementet i lru_list. Om dirty==FALSE och
@c FIXME: ptr!=NULL och lock_cnt==0 så frigör ptr. Upprepa tills antalet noder
@c FIXME: med ptr!=NULL och dirty==FALSE är mindre än antalet "rena" element man
@c FIXME: vill ha inne i minnet. (Smutsiga element slängs aldrig ut.)
@c FIXME: 
@c FIXME: 
@c FIXME: LOCK_PERSON
@c FIXME: 
@c FIXME: Öka lock_cnt.
@c FIXME: 
@c FIXME: 
@c FIXME: UNLOCK_PERSON
@c FIXME: 
@c FIXME: Minska lock_cnt.
@c FIXME: 
@c FIXME: 
@c FIXME: PRE-SYNC
@c FIXME: 
@c FIXME: Utsparningen till fil sker i tre steg. Först sveper man över alla
@c FIXME: Cache_noder. För alla som har dirty=TRUE gör man följande:
@c FIXME: 
@c FIXME:     if ( lock_cnt == 0 ) ä
@c FIXME:         snap_shot = ptr; (Pekartilldelning, ej kopiering av innehållet.) 
@c FIXME:         ptr = NULL;
@c FIXME:         Ta bort ptr ur lru-kedjan.
@c FIXME:     å else ä
@c FIXME:         snap_shot = copy(ptr);
@c FIXME:     å
@c FIXME: 
@c FIXME:     dirty = FALSE;
@c FIXME: 
@c FIXME: För _alla_ noder görs dessutom följande:
@c FIXME: 
@c FIXME:    b_exists==exists;
@c FIXME: 
@c FIXME: 
@c FIXME: SYNC
@c FIXME: 
@c FIXME: Steg två utförs en liten bit i taget. Till exempel så skulle man kunna
@c FIXME: spara en person efter varje atomiskt anrop, eller så.
@c FIXME: 
@c FIXME: b_exists==FALSE?	   Sätt pos_b. Skriv "@@\n" till fil B.
@c FIXME: Är snap_shot != NULL?	   Sätt pos_b. Skriv ut innehållet i snap_shot 
@c FIXME:                            till fil B.
@c FIXME: dirty==FALSE && ptr!=NULL  Skriv ut innehållet i ptr till fil B.
@c FIXME: annars:			   Kopiera från fil A till fil B. (Eftersom man
@c FIXME:                            vet både var blocket börjar och slutar kan man
@c FIXME:                            kopiera blocket utan att bry sig om vad som
@c FIXME:                            står i det -> väldigt lite CPU går åt).
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: POST-SYNC
@c FIXME: 
@c FIXME: När alla Person:er har hanterats som i SYNC ovan är det dags för det
@c FIXME: tredje steget. Då går man igenom alla Cache_node:er och gör följande:
@c FIXME: 
@c FIXME:         pos = pos_b;
@c FIXME:         file_b = FALSE;
@c FIXME:         free(snap_shot);
@c FIXME:         snap_shot = NULL;
@c FIXME: 
@c FIXME: Fil B som man förut hade öppen för skrivning öppnar man i stället för
@c FIXME: läsning som fil A.
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: 
@c FIXME: ANMÄRKNINGAR
@c FIXME: 
@c FIXME: Innehållet i snap_shot är alltid "smutsigt" jämfört med innehållet i
@c FIXME: fil A. Det som snap_shot pekar på finns aldrig med i lru-kedjan.
@c FIXME: 



@node Adding Configuration Parameters, Adding Asynchronous Messages, The Database, Hacking
@comment  node-name,  next,  previous,  up
@section Adding Configuration Parameters

Make sure that you really understand what you want to configure. Think
it over again. Find a good, descriptive name for it.

Decide what values the parameter can be set to. Integers? Booleans?

Document the parameter in @code{lyskomd.texi}.

Add a field to @code{stuct kom_par} in @code{param.h}.

Add it to @code{parameters[]} in @code{server-config.c}. See
@code{conf-file.h} and maybe @code{conf-file.c} for information on this
structure.

Make sure that the parameter is used instead of any previous hard-coded
value. Make sure that @code{dbck} can cope with it.


@node Adding Asynchronous Messages, Adding a New Protocol Request, Adding Configuration Parameters, Hacking
@comment  node-name,  next,  previous,  up
@section Adding Asynchronous Messages

@table @code

@item async.h
Add the message in @code{typedef enum @{ @} Async}. Make sure that
@code{ay_dummy_last} is one more than any other message. If the message
is to be sent by default, which is @i{not} recommended, place its number
info @code{ASYNC_DEFAULT_MESSAGES}.

@item prot-a-send-async.c
@item prot-a-send-async.h
Write a function that sends the message. This function is responsible
for writing the message to a particular connection and for ensuring that
the message is not sent to clients who do not want it. Make sure that
the second argument to @code{async_header} really is the number of
elements being sent. Arrays count as two elements: the item count and
the elements.

@item send-async.c
@item send-async.h
Write a function that sends the message to appropriate clients. This
function is responsible for checking that async messages should be sent
at all, for each client check if it allowed to see the message and
ensure that the protocol specified by the connection is appropriate. The
send function should either take a @code{struct connection *} as an
argument and send the message to that connection, or loop over all
connections. Most send functions take a connection pointer; the looping
is dealt with elsewhere.

@item Make sure that the message is sent in appropriate places.

@item Document the message type in @code{Protocol-A.texi}.

@end table

@menu
* Function Templates for prot-a-send-async.c::  
* Function Templates for send-async.c::  
@end menu


@node Function Templates for prot-a-send-async.c, Function Templates for send-async.c, Adding Asynchronous Messages, Adding Asynchronous Messages
@comment  node-name,  next,  previous,  up
@subsection Function Templates for prot-a-send-async.c

This is what a typical function in @code{prot-a-send-async.c} should
look like. This function is responsible for checking that the client is
accepting the message and writing the message itself to the connection. 

@example
void
prot_a_async_@i{something}(Connection   *cptr,
                           @i{parameters})
@{
    ASYNC_CHECK_ACCEPT(cptr, ay_@i{something});
    async_header(cptr, @i{num_tokens}, ay_@i{something});
    /* Output the body of the message */
    async_trailer(cptr);
@}
@end example


@node Function Templates for send-async.c,  , Function Templates for prot-a-send-async.c, Adding Asynchronous Messages
@comment  node-name,  next,  previous,  up
@subsection Function Templates for send-async.h

This is what a typical function in @code{send-async.c} should look like.
This function is responsible for sending the message to all connections
that are appropriate, not sending it if the server is not supposed to
send messages at all, and for checking that the protocol specified by
the client is one the server knows.

@example
void async_@i{something}( @i{parameters} )
@{
    Connection *cptr;
    Session_no i = 0;

    if (!param.send_async_messages)
	return;

    while ((i = traverse_connections(i)) != 0)
    @{
	cptr = get_conn_by_number(i);

	switch(cptr->protocol)
	@{
	case 0:
            /* No protocol specified yet */
	    break;
	case 'A':
            /* Check that connection is logged on. We might
               want to check other things here too, such as
               if the connection is allowed to see the message */
	    if (cptr->username_valid == TRUE)
		prot_a_async_@i{something}(cptr, @i{parameters});
	    break;
	default:
	    restart_kom("async_@i{something}(): bad protocol.\n");
	    break;
	@}
    @}
@}
@end example

Template for a function that sends to a single connection:
@example
void async_@i{something}(struct connection *cptr,
                         @i{parameters})
@{
    if (!param.send_async_messages)
	return;

    switch(cptr->protocol)
    @{
    case 0:
        /* No protocol specified yet */
	break;
    case 'A':
        /* Check that connection is logged on. We might
           want to check other things here too, such as
           if the connection is allowed to see the message */
	if (cptr->username_valid == TRUE)
	    prot_a_async_@i{something}(cptr, @i{parameters});
	break;
    default:
	restart_kom("async_@i{something}(): bad protocol.\n");
	break;
    @}
@}
@end example


@node Adding a New Protocol Request, Adding Aux-Item Types, Adding Asynchronous Messages, Hacking
@comment  node-name,  next,  previous,  up
@section Adding a New Protocol Request

Before doing anything, think again. Make sure that the protocol request
is needed, is in line with the rest of the protocol, behaves the way
people want it to, and that everyone involved agrees that it is a good
idea.

@enumerate
@item Document the request in @code{Protocol-A.texi}

@item Declare the function in @code{include/services.h