/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#ifdef _WIN32
#include <process.h>
#include <sys/socket.h>
* simple state machine.
* Initial state is SCANNING_ID.
* In state SCANNING_ID, buffer the character. If it's a space,
- * decode the id that has been buffered, and enter state BUFFERING
+ * decode the ID that has been buffered, and enter state BUFFERING
* or COPYING depending on its value.
* In state BUFFERING, buffer the character. If it's newline,
- * pass id and buffered text to servercmd(), then enter state
+ * pass ID and buffered text to servercmd(), then enter state
* SCANNING_ID.
* In state COPYING, pass the character to outch(). If it's
* newline, enter state SCANNING_ID.
state = BUFFERING;
break;
default:
- /* unknown or unexpected id, treat like C_DATA */
+ /* unknown or unexpected ID, treat like C_DATA */
case C_DATA:
state = COPYING;
break;
return -1;
if (n == 0) {
/*
- * Can't put EOF cookie into INBUF here, it may not fit.
+ * Can't put EOF cookie into @inbuf here, it may not fit.
* Leave it to caller.
*/
res = 0;
play(int sock, char *history_file)
{
/*
- * Player input flows from INPUT_FD through recv_input() into ring
- * buffer INBUF, which drains into SOCK. This must not block.
- * Server output flows from SOCK into recv_output(). Reading SOCK
- * must not block.
+ * Player input flows from @input_fd through recv_input() into
+ * ring buffer @inbuf, which drains into @sock. This must not
+ * block. Server output flows from @sock into recv_output().
+ * Reading @sock must not block.
*/
struct sigaction sa;
struct ring inbuf; /* input buffer, draining to SOCK */