]> git.cworth.org Git - ttt/blob - src/ttt.h
2005-11-29 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
45 #define ASSERT_NOT_REACHED              \
46 do {                                    \
47     static const int NOT_REACHED = 0;   \
48     assert (NOT_REACHED);               \
49     exit (1);                           \
50 } while (0)
51
52 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
53 #define TTT_PRINTF_FORMAT(fmt_index, va_index) \
54         __attribute__((__format__(__printf__, fmt_index, va_index)))
55 #else
56 #define TTT_PRINTF_FORMAT(fmt_index, va_index)
57 #endif
58
59 typedef int ttt_bool_t;
60
61 #define FALSE 0
62 #define TRUE  1
63
64 typedef enum {
65     TTT_STATUS_SUCCESS = 0,
66     TTT_STATUS_FAILURE,
67     TTT_STATUS_EOF,
68     TTT_STATUS_CONNECTION_REFUSED,
69     TTT_STATUS_NETWORK_UNREACHABLE
70 } ttt_status_t;
71
72 typedef struct _ttt_server ttt_server_t;
73 typedef struct _ttt_client ttt_client_t;
74
75 #include "x.h"
76
77 #endif