home · contact · privacy
MAJOR re-write. Split plomrogue into a server and a client. Re-wrote large parts
[plomrogue] / src / server / io.h
diff --git a/src/server/io.h b/src/server/io.h
new file mode 100644 (file)
index 0000000..78cb068
--- /dev/null
@@ -0,0 +1,30 @@
+/* io.h:
+ *
+ * Communication of the server with the outside world via input fifo and output
+ * file.
+ */
+
+#ifndef IO_H
+#define IO_H
+
+
+
+/* Return single \0-terminated string read from input queue (world.queue); or,
+ * if queue is empty and world.turn is unequal world.last_update_turn, update
+ * output file at world.path_out (and update world.last_update_turn), then read
+ * file at world.path_in for the next load of bytes to put onto the input queue.
+ *
+ * Reading the file at world.path_in may put many \0-terminated strings on the
+ * queue at once. Successive calls of io_round() will make these available one
+ * by one. Each such call cuts off bytes from the beginning of world.queue, up
+ * to and including the last \0 byte that is followed by a non-\0 byte or ends
+ * the queue. If the queue starts with a \0 byte, it and its \0 followers are
+ * cut and a NULL pointer is returned. Reading from the input file stops only
+ * when one or more byte were read and the next read returns 0 bytes. If the
+ * re-filled queue does not end in a \0 byte, a \0 byte is appended to it.
+ */
+extern char * io_round();
+
+
+
+#endif