]> git.cworth.org Git - ttt/blob - src/ttt.h
2005-12-09 Carl Worth <cworth@cworth.org>
[ttt] / src / ttt.h
1 /* ttt.h - client-server tic-tac-toe game
2  *
3  * Copyright © 2005 Carl Worth
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Author: Carl Worth <cworth@cworth.org>
20  */
21
22 #ifndef TTT_H
23 #define TTT_H
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 /* We use _GNU_SOURCE to get things like asprintf. */
30 #define _GNU_SOURCE
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <stdarg.h>
34 #include <stdint.h>
35 #include <unistd.h>
36 #include <fcntl.h>
37 #include <assert.h>
38 #include <string.h>
39 #include <errno.h>
40 #include <ctype.h>
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <pthread.h>
44 #include <pwd.h>
45
46 #define ASSERT_NOT_REACHED              \
47 do {                                    \
48     static const int NOT_REACHED = 0;   \
49     assert (NOT_REACHED);               \
50     exit (1);                           \
51 } while (0)
52
53 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
54 #define TTT_PRINTF_FORMAT(fmt_index, va_index) \
55         __attribute__((__format__(__printf__, fmt_index, va_index)))
56 #else
57 #define TTT_PRINTF_FORMAT(fmt_index, va_index)
58 #endif
59
60 typedef int ttt_bool_t;
61
62 #define FALSE 0
63 #define TRUE  1
64
65 #define TTT_SERVER_PROTOCOL_VERSION 1
66
67 typedef enum {
68     TTT_STATUS_SUCCESS = 0,
69     TTT_STATUS_FAILURE,
70     TTT_STATUS_EOF,
71     TTT_STATUS_CONNECTION_REFUSED,
72     TTT_STATUS_NETWORK_UNREACHABLE
73 } ttt_status_t;
74
75 typedef struct _ttt_server ttt_server_t;
76 typedef struct _ttt_client ttt_client_t;
77
78 #include "x.h"
79
80 #endif