Commit | Line | Data |
---|---|---|
7eeb782e AT |
1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ |
2 | * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * | |
3 | * http://www.gnu.org/software/gnugo/ for more information. * | |
4 | * * | |
5 | * To facilitate development of the Go Text Protocol, the two * | |
6 | * files gtp.c and gtp.h are licensed under less restrictive * | |
7 | * terms than the rest of GNU Go. * | |
8 | * * | |
9 | * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 and * | |
10 | * 2009 by the Free Software Foundation. * | |
11 | * * | |
12 | * Permission is hereby granted, free of charge, to any person * | |
13 | * obtaining a copy of this file gtp.h, to deal in the Software * | |
14 | * without restriction, including without limitation the rights * | |
15 | * to use, copy, modify, merge, publish, distribute, and/or * | |
16 | * sell copies of the Software, and to permit persons to whom * | |
17 | * the Software is furnished to do so, provided that the above * | |
18 | * copyright notice(s) and this permission notice appear in all * | |
19 | * copies of the Software and that both the above copyright * | |
20 | * notice(s) and this permission notice appear in supporting * | |
21 | * documentation. * | |
22 | * * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY * | |
24 | * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * | |
25 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * | |
26 | * PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO * | |
27 | * EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS * | |
28 | * NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR * | |
29 | * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING * | |
30 | * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * | |
31 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * | |
32 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * | |
33 | * SOFTWARE. * | |
34 | * * | |
35 | * Except as contained in this notice, the name of a copyright * | |
36 | * holder shall not be used in advertising or otherwise to * | |
37 | * promote the sale, use or other dealings in this Software * | |
38 | * without prior written authorization of the copyright holder. * | |
39 | \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
40 | ||
41 | /* NOTE: GNU Go specific, workarounds dumb Windows sockets. */ | |
42 | #include "winsocket.h" | |
43 | ||
44 | #include <stdarg.h> | |
45 | #include <stdio.h> | |
46 | ||
47 | /* Maximum allowed line length in GTP. */ | |
48 | #define GTP_BUFSIZE 1000 | |
49 | ||
50 | /* Status returned from callback functions. */ | |
51 | #define GTP_QUIT -1 | |
52 | #define GTP_OK 0 | |
53 | #define GTP_FATAL 1 | |
54 | ||
55 | /* Whether the GTP command was successful. */ | |
56 | #define GTP_SUCCESS 0 | |
57 | #define GTP_FAILURE 1 | |
58 | ||
59 | /* Function pointer for callback functions. */ | |
60 | typedef int (*gtp_fn_ptr)(char *s); | |
61 | ||
62 | /* Function pointer for vertex transform functions. */ | |
63 | typedef void (*gtp_transform_ptr)(int ai, int aj, int *bi, int *bj); | |
64 | ||
65 | /* Elements in the array of commands required by gtp_main_loop. */ | |
66 | struct gtp_command { | |
67 | const char *name; | |
68 | gtp_fn_ptr function; | |
69 | }; | |
70 | ||
71 | void gtp_main_loop(struct gtp_command commands[], | |
72 | FILE *gtp_input, FILE *gtp_output, FILE *gtp_dump_commands); | |
73 | void gtp_internal_set_boardsize(int size); | |
74 | void gtp_set_vertex_transform_hooks(gtp_transform_ptr in, | |
75 | gtp_transform_ptr out); | |
76 | void gtp_mprintf(const char *format, ...); | |
77 | void gtp_printf(const char *format, ...); | |
78 | void gtp_start_response(int status); | |
79 | int gtp_finish_response(void); | |
80 | int gtp_success(const char *format, ...); | |
81 | int gtp_failure(const char *format, ...); | |
82 | void gtp_panic(void); | |
83 | int gtp_decode_color(char *s, int *color); | |
84 | int gtp_decode_coord(char *s, int *m, int *n); | |
85 | int gtp_decode_move(char *s, int *color, int *i, int *j); | |
86 | void gtp_print_vertices(int n, int movei[], int movej[]); | |
87 | void gtp_print_vertex(int i, int j); | |
88 | ||
89 | extern FILE *gtp_output_file; | |
90 | ||
91 | /* | |
92 | * Local Variables: | |
93 | * tab-width: 8 | |
94 | * c-basic-offset: 2 | |
95 | * End: | |
96 | */ |