1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef SCAREEXT_PROTOTYPES_H
#define SCAREEXT_PROTOTYPES_H
#include "glk/adrift/scare.h"
#include "common/stream.h"
namespace Glk {
namespace Adrift {
/* True and false, unless already defined. */
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE (!FALSE)
#endif
/* Alias typedef for a test script. */
typedef Common::SeekableReadStream *sx_script;
/* Typedef representing a test descriptor. */
typedef struct sx_test_descriptor_s
{
const sc_char *name;
sc_game game;
sx_script script;
} sx_test_descriptor_t;
/*
* Small utility and wrapper functions. For printf wrappers, try to apply
* gcc printf argument checking; this code is cautious about applying the
* checks.
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
extern void sx_trace (const sc_char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void sx_error (const sc_char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void sx_fatal (const sc_char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
#else
extern void sx_trace (const sc_char *format, ...);
extern void sx_error (const sc_char *format, ...);
extern void sx_fatal (const sc_char *format, ...);
#endif
extern void *sx_malloc (size_t size);
extern void *sx_realloc (void *pointer, size_t size);
extern void sx_free (void *pointer);
extern Common::SeekableReadStream *sx_fopen(const sc_char *name,
const sc_char *extension, const sc_char *mode);
extern sc_char *sx_trim_string (sc_char *string);
extern sc_char *sx_normalize_string (sc_char *string);
/* OS stub hooks controller functions. */
extern void stub_attach_handlers (sc_bool (*read_line) (sc_char *, sc_int),
void (*print_string) (const sc_char *),
void *(*open_file) (sc_bool),
sc_int (*read_file)
(void*, sc_byte*, sc_int),
void (*write_file)
(void*, const sc_byte*, sc_int),
void (*close_file) (void*));
extern void stub_detach_handlers (void);
extern void stub_debug_trace (sc_bool flag);
/* Test controller function. */
extern sc_int test_run_game_tests (const sx_test_descriptor_t tests[],
sc_int count, sc_bool is_verbose);
/* Globbing function. */
extern sc_bool glob_match (const sc_char *pattern, const sc_char *string);
/* Script running and checking functions. */
extern void scr_test_failed (const sc_char *format, const sc_char *string);
extern void scr_set_verbose (sc_bool flag);
extern void scr_start_script (sc_game game, Common::SeekableReadStream *script);
extern sc_int scr_finalize_script (void);
/* Serialization helper for script running and checking. */
extern void *file_open_file_callback (sc_bool is_save);
extern sc_int file_read_file_callback (void *opaque,
sc_byte *buffer, sc_int length);
extern void file_write_file_callback (void *opaque,
const sc_byte *buffer, sc_int length);
extern void file_close_file_callback (void *opaque);
extern void file_cleanup (void);
} // End of namespace Adrift
} // End of namespace Glk
#endif
|