Debian Codegraph @

terps/scare/sxprotos.h

raw symbols SCIP
1 /* vi: set ts=2 shiftwidth=2 expandtab:
2 *
3 * Copyright (C) 2003-2008 Simon Baldwin and Mark J. Tilford
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 * USA
18 */
19
20 #include "scare.h"
21
22 #ifndef SCAREEXT_PROTOTYPES_H
23 #define SCAREEXT_PROTOTYPES_H
24
25 /* True and false, unless already defined. */
26 #ifndef FALSE
27 # define FALSE 0
28 #endif
29 #ifndef TRUE
30 # define TRUE (!FALSE)
31 #endif
32
33 /* Alias typedef for a test script. */
34 typedef FILE *sx_script;
35
36 /* Typedef representing a test descriptor. */
37 typedef struct sx_test_descriptor_s
38 {
39 const sc_char *name;
40 sc_game game;
41 sx_script script;
42 } sx_test_descriptor_t;
43
44 /*
45 * Small utility and wrapper functions. For printf wrappers, try to apply
46 * gcc printf argument checking; this code is cautious about applying the
47 * checks.
48 */
49 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
50 extern void sx_trace (const sc_char *format, ...)
51 __attribute__ ((__format__ (__printf__, 1, 2)));
52 extern void sx_error (const sc_char *format, ...)
53 __attribute__ ((__format__ (__printf__, 1, 2)));
54 extern void sx_fatal (const sc_char *format, ...)
55 __attribute__ ((__format__ (__printf__, 1, 2)));
56 #else
57 extern void sx_trace (const sc_char *format, ...);
58 extern void sx_error (const sc_char *format, ...);
59 extern void sx_fatal (const sc_char *format, ...);
60 #endif
61 extern void *sx_malloc (size_t size);
62 extern void *sx_realloc (void *pointer, size_t size);
63 extern void sx_free (void *pointer);
64 extern FILE *sx_fopen (const sc_char *name,
65 const sc_char *extension, const sc_char *mode);
66 extern sc_char *sx_trim_string (sc_char *string);
67 extern sc_char *sx_normalize_string (sc_char *string);
68
69 /* OS stub hooks controller functions. */
70 extern void stub_attach_handlers (sc_bool (*read_line) (sc_char *, sc_int),
71 void (*print_string) (const sc_char *),
72 void *(*open_file) (sc_bool),
73 sc_int (*read_file)
74 (void*, sc_byte*, sc_int),
75 void (*write_file)
76 (void*, const sc_byte*, sc_int),
77 void (*close_file) (void*));
78 extern void stub_detach_handlers (void);
79 extern void stub_debug_trace (sc_bool flag);
80
81 /* Test controller function. */
82 extern sc_int test_run_game_tests (const sx_test_descriptor_t tests[],
83 sc_int count, sc_bool is_verbose);
84
85 /* Globbing function. */
86 extern sc_bool glob_match (const sc_char *pattern, const sc_char *string);
87
88 /* Script running and checking functions. */
89 extern void scr_test_failed (const sc_char *format, const sc_char *string);
90 extern void scr_set_verbose (sc_bool flag);
91 extern void scr_start_script (sc_game game, FILE *script);
92 extern sc_int scr_finalize_script (void);
93
94 /* Serialization helper for script running and checking. */
95 extern void *file_open_file_callback (sc_bool is_save);
96 extern sc_int file_read_file_callback (void *opaque,
97 sc_byte *buffer, sc_int length);
98 extern void file_write_file_callback (void *opaque,
99 const sc_byte *buffer, sc_int length);
100 extern void file_close_file_callback (void *opaque);
101 extern void file_cleanup (void);
102
103 #endif