-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgluefe.c
83 lines (68 loc) · 1.47 KB
/
gluefe.c
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
/*
* gluefe.c: A wrapper for the frontend functions of the Windows Modern port.
*/
#include <assert.h>
#include <stdarg.h>
#include "puzzles.h"
struct frontend_adapter *adapter = NULL;
void get_random_seed(void **randseed, int *randseedsize)
{
assert(adapter && adapter->get_random_seed);
adapter->get_random_seed(randseed, randseedsize);
}
char *getenv(const char *key)
{
if (adapter && adapter->getenv)
return adapter->getenv(key);
return 0;
}
void frontend_default_colour(frontend *fe, float *output)
{
if (adapter && adapter->frontend_default_colour)
adapter->frontend_default_colour(fe, output);
else
output[0] = output[1] = output[2] = 0.9f;
}
void fatal(const char *fmt, ...)
{
char fullmsg[1024];
va_list va;
va_start(va, fmt);
vsprintf(fullmsg, fmt, va);
va_end(va);
if (adapter && adapter->fatal)
adapter->fatal(fullmsg);
else
exit(1);
}
void deactivate_timer(frontend *fe)
{
if (adapter && adapter->deactivate_timer)
adapter->deactivate_timer(fe);
}
void activate_timer(frontend *fe)
{
if (adapter && adapter->activate_timer)
adapter->activate_timer(fe);
}
void set_frontend_adapter(struct frontend_adapter *fea)
{
adapter = fea;
}
void check_abort(void)
{
if (adapter && adapter->check_abort)
adapter->check_abort();
}
#ifdef DEBUGGING
void debug_printf(const char *fmt, ...)
{
char fullmsg[1024];
va_list va;
va_start(va, fmt);
vsprintf(fullmsg, fmt, va);
va_end(va);
if (adapter && adapter->debugout)
adapter->debugout(fullmsg);
}
#endif