3 * Communication of the server with the outside world and its client via input,
4 * output and world state files.
10 #include <stddef.h> /* size_t */
11 #include <stdint.h> /* uint8_t, uint32_t */
12 #include <stdio.h> /* FILE */
13 #include "cleanup.h" /* enum cleanup_flag */
17 /* Wrapper to reading in config files from "path" for DB entries of "size
18 * starting at "entry_start", to be unset by "cleanup" and reading in individual
19 * entry data line by line via "read"(). Assumes all entries start with the
20 * items collected in the EntrySkeleton struct.
25 struct EntrySkeleton * next;
27 extern void read_config_file(char * path, enum cleanup_flag cleanup,
28 void (* read) (char *, uint32_t, char *,
29 struct EntrySkeleton *, FILE *),
30 size_t size, struct EntrySkeleton ** entry_start);
32 /* Return single \0-terminated string read from input queue (world.queue); or,
33 * if queue is empty and world.turn is unequal world.last_update_turn, update
34 * world state file at world.path_worldstate (and update world.last_update_turn
35 * and write a single dot line to output file at world.path_out), then read file
36 * at world.path_in for the next load of bytes to put onto the input queue.
38 * Reading the file at world.path_in may put many \0-terminated strings on the
39 * queue at once. Successive calls of io_round() will make these available one
40 * by one. Each such call cuts off bytes from the beginning of world.queue, up
41 * to and including the last \0 byte that is followed by a non-\0 byte or ends
42 * the queue. If the queue starts with a \0 byte, it and its \0 followers are
43 * cut and a NULL pointer is returned. Reading from the input file stops only
44 * when one or more byte were read and the next read returns 0 bytes. If the
45 * re-filled queue does not end in a \0 byte, a \0 byte is appended to it.
47 extern char * io_round();