home · contact · privacy
5b67f6b21fb8b430f6e8dfbd87746c023f32391f
[plomrogue] / src / server / io.h
1 /* io.h
2  *
3  * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
4  * or any later version. For details on its copyright, license, and warranties,
5  * see the file NOTICE in the root directory of the PlomRogue source package.
6  *
7  * Communication of the server with the outside world and its client via input,
8  * output and world state files.
9  */
10
11 #ifndef IO_H
12 #define IO_H
13
14
15
16 /* Return single \0-terminated string read from input queue (world.queue); or,
17  * if queue is empty and world.do_update is set, update world state file (and
18  * unset world.do_update) and write a single dot line to server out file, then
19  * read server in file for the next load of bytes to put onto the input queue.
20  *
21  * Reading the server in file may put many \0-terminated strings on the queue at
22  * once. Successive calls of io_round() will make these available one by one.
23  * Each such call cuts off bytes from the beginning of world.queue, up to and
24  * including the last \0 byte that is followed by a non-\0 byte or ends the
25  * queue. If the queue starts with a \0 byte, it and its \0 followers are cut
26  * before returning anything after them. Reading from the input file stops only
27  * at its end or when one or more byte were read and the next read returns 0
28  * bytes. If the re-filled queue doesn't end in \0, a \0 byte is appended to it.
29  */
30 extern char * io_round();
31
32 /* Write to savefile (atomically) god commands (one per line) to rebuild the
33  * current world state.
34  */
35 extern void save_world();
36
37
38
39 #endif