Debian Codegraph @

_modes.c

raw symbols SCIP
1 /*
2 * Part of mlat-client - an ADS-B multilateration client.
3 * Copyright 2015, Oliver Jowett <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "_modes.h"
20
21 /* would be nice to move this into the submodule init, but that needs python 3.5 for PyModule_AddFunctions */
22 static PyMethodDef methods[] = {
23 { "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." },
24 { "EventMessage", (PyCFunction)modesmessage_eventmessage, METH_VARARGS|METH_KEYWORDS, "Constructs a new event message with a given type, timestamp, and event data." },
25 { NULL, NULL, 0, NULL }
26 };
27
28 static void free_modes(PyObject *);
29
30 PyDoc_STRVAR(docstr, "C helpers to speed up ModeS message processing");
31 static PyModuleDef module = {
32 PyModuleDef_HEAD_INIT,
33 "_modes", /* m_name */
34 docstr, /* m_doc */
35 -1, /* m_size */
36 methods, /* m_methods */
37 NULL, /* m_slots / m_reload */
38 NULL, /* m_traverse */
39 NULL, /* m_clear */
40 (freefunc)free_modes /* m_free */
41 };
42
43 PyMODINIT_FUNC
44 PyInit__modes(void)
45 {
46 PyObject *m = NULL;
47
48 m = PyModule_Create(&module);
49 if (m == NULL)
50 return NULL;
51
52 if (modescrc_module_init(m) < 0) {
53 goto error;
54 }
55
56 if (modesmessage_module_init(m) < 0) {
57 goto error;
58 }
59
60 if (modesreader_module_init(m) < 0) {
61 goto error;
62 }
63
64 return m;
65
66 error:
67 Py_DECREF(m);
68 return NULL;
69 }
70
71 void free_modes(PyObject *m)
72 {
73 modesreader_module_free(m);
74 modesmessage_module_free(m);
75 modescrc_module_free(m);
76 }