Fix bug in setting up w3 and w4 games
[capablanca.git] / lasker-2.2.3 / src / network.h
1 /*
2    Copyright (c) 1993 Richard V. Nash.
3    Copyright (c) 2000 Dan Papasian
4    Copyright (C) Andrew Tridgell 2002
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef NETWORK_H
22 #define NETWORK_H
23
24 #define NET_NETERROR 0
25 #define NET_NEW 1
26 #define NET_DISCONNECT 2
27 #define NET_READLINE 3
28 #define NET_TIMEOUT 4
29 #define NET_NOTCOMPLETE 5
30
31 #define LINE_WIDTH 80
32
33 #ifndef O_NONBLOCK
34 #define O_NONBLOCK      00004
35 #endif
36
37 GENSTRUCT enum netstatus {NETSTAT_EMPTY, NETSTAT_CONNECTED, NETSTAT_IDENT};
38
39 GENSTRUCT struct connection_t {
40         int fd;
41         int outFd;
42         struct in_addr fromHost;
43         enum netstatus status;
44         /* Input buffering */
45         int numPending;
46         int processed;
47         unsigned char inBuf[MAX_STRING_LENGTH+1]; _NULLTERM
48         /* Output buffering */
49         int sndbufsize;         /* size of send buffer (this changes) */
50         int sndbufpos;          /* position in send buffer */
51         unsigned char *sndbuf; _LEN(sndbufsize)_NULLTERM  /* our send buffer, or NULL if none yet */
52         int outPos;             /* column count */
53         int state;              /* 'telnet state' */
54         int mypal;
55         int timeseal;           /* are they using timeseal */
56         int timeseal_init;      /* are they in timeseal initialisation? */
57         unsigned time;          /* last time received from the client */
58 };
59
60 #endif /* NETWORK_H */