forked from adsb-related-code/mlat-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_modes.c
76 lines (64 loc) · 2.28 KB
/
_modes.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
/*
* Part of mlat-client - an ADS-B multilateration client.
* Copyright 2015, Oliver Jowett <[email protected]>
*
* 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/>.
*/
#include "_modes.h"
/* would be nice to move this into the submodule init, but that needs python 3.5 for PyModule_AddFunctions */
static PyMethodDef methods[] = {
{ "crc", modescrc_crc, METH_VARARGS, "Calculate the Mode S CRC over a buffer. Don't include the message's trailing CRC bytes in the provided buffer." },
{ "EventMessage", (PyCFunction)modesmessage_eventmessage, METH_VARARGS|METH_KEYWORDS, "Constructs a new event message with a given type, timestamp, and event data." },
{ NULL, NULL, 0, NULL }
};
static void free_modes(PyObject *);
PyDoc_STRVAR(docstr, "C helpers to speed up ModeS message processing");
static PyModuleDef module = {
PyModuleDef_HEAD_INIT,
"_modes", /* m_name */
docstr, /* m_doc */
-1, /* m_size */
methods, /* m_methods */
NULL, /* m_slots / m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
(freefunc)free_modes /* m_free */
};
PyMODINIT_FUNC
PyInit__modes(void)
{
PyObject *m = NULL;
m = PyModule_Create(&module);
if (m == NULL)
return NULL;
if (modescrc_module_init(m) < 0) {
goto error;
}
if (modesmessage_module_init(m) < 0) {
goto error;
}
if (modesreader_module_init(m) < 0) {
goto error;
}
return m;
error:
Py_DECREF(m);
return NULL;
}
void free_modes(PyObject *m)
{
modesreader_module_free(m);
modesmessage_module_free(m);
modescrc_module_free(m);
}