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
|
/*
grav - N-body gravity simulation
Copyright (C) 2011 Ian Cowburn <ianc@noddybox.co.uk>
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 3 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, see <http://www.gnu.org/licenses/>.
$Id$
This file provides a common interface shared between the core grav
program and the GFX drivers.
*/
#ifndef GRAV_GRAVIFACE_H
#define GRAV_GRAVIFACE_H "$Id$"
#include <mp.h>
/* ---------------------------------------------------------------------------
This determinate the version of the interface, so both sides can
check they were built with the same interface.
*/
#define GRAV_INTERFACE_VERSION 1
/* ---------------------------------------------------------------------------
This type defines an instance of any data that the driver needs to maintain.
As the drivers are sharable objects, it is recommended that this points to
dynamic memory.
*/
typedef void *grav_interface_t;
/* ---------------------------------------------------------------------------
This structure is passed to the driver on initialisation so it can check
compataility. The first field is guaranteed to be an int holding
GRAV_INTERFACE_VERSION.
*/
typedef struct
{
/* Interface version info.
*/
int grav_interface_version;
/* The version of the GNU MP library the core is compiled against.
*/
int grav_mp_version_major;
int grav_mp_version_minor;
/* An interface the driver can use to iterate over loaded config.
p_func is called for every variable in the section along with the
pass client data.
*/
const char (*grav_config_func)(const char *p_section,
void (*p_func)(void *p_client_data,
const char *p_section,
const char *p_value),
void *p_client_data);
/* An interface the driver can use to request termination. p_reason can
be NULL.
*/
void (*grav_exit_func)(const char *p_reason);,
} grav_icb_t;
/* ---------------------------------------------------------------------------
This structure defines a mass to be drawn. Masses are passed in arbitary
order. Each mass has a unique identifier, which is defined by "id".
*/
typedef struct
{
mpz_t id;
const char *name;
} grav_public_mass_t;
/* ---------------------------------------------------------------------------
This function must be exported by the driver, and is used to initialise the
driver. If the driver disagrees with the version then false should be
returned, otherwise true.
The passed pointer is a pointer to a grav_icb_t.
*/
typedef int (*grav_interface_init_func)(const void *p);
#endif /* GRAV_GRAVIFACE_H */
|