2 libloc - A library to determine the location of someone on the Internet
4 Copyright (C) 2017 IPFire Development Team <info@ipfire.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
19 #include "locationmodule.h"
25 PyMODINIT_FUNC
PyInit_location(void);
27 static void location_free(void) {
33 static PyMethodDef location_module_methods
[] = {
37 static struct PyModuleDef location_module
= {
38 .m_base
= PyModuleDef_HEAD_INIT
,
41 .m_doc
= "Python module for libloc",
42 .m_methods
= location_module_methods
,
43 .m_free
= (freefunc
)location_free
,
46 PyMODINIT_FUNC
PyInit_location(void) {
47 // Initialise loc context
48 int r
= loc_new(&loc_ctx
);
52 PyObject
* m
= PyModule_Create(&location_module
);
57 if (PyType_Ready(&ASType
) < 0)
61 PyModule_AddObject(m
, "AS", (PyObject
*)&ASType
);
64 if (PyType_Ready(&DatabaseType
) < 0)
67 Py_INCREF(&DatabaseType
);
68 PyModule_AddObject(m
, "Database", (PyObject
*)&DatabaseType
);
71 if (PyType_Ready(&NetworkType
) < 0)
74 Py_INCREF(&NetworkType
);
75 PyModule_AddObject(m
, "Network", (PyObject
*)&NetworkType
);
78 if (PyType_Ready(&WriterType
) < 0)
81 Py_INCREF(&WriterType
);
82 PyModule_AddObject(m
, "Writer", (PyObject
*)&WriterType
);