Debian Codegraph @

lz4/_version.c

raw symbols SCIP
1 /*
2 * Copyright (c) 2016 Jonathan Underwood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of Steeve Morin nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <Python.h>
33
34 #include <stdlib.h>
35 #include <lz4.h>
36 #include <lz4hc.h>
37
38 static PyObject *
39 library_version_number (PyObject * Py_UNUSED (self), PyObject * Py_UNUSED (args))
40 {
41 return Py_BuildValue ("i", LZ4_versionNumber ());
42 }
43
44 static PyObject *
45 library_version_string (PyObject * Py_UNUSED (self), PyObject * Py_UNUSED (args))
46 {
47 return Py_BuildValue ("s", LZ4_versionString ());
48 }
49
50 PyDoc_STRVAR
51 (
52 library_version_number__doc,
53 "library_version_number()\n\n" \
54 "Returns the version number of the LZ4 library.\n" \
55 "\n" \
56 "Args:\n" \
57 " None\n" \
58 "\n" \
59 "Returns:\n" \
60 " int: version number eg. 10705"
61 );
62
63 PyDoc_STRVAR
64 (
65 library_version_string__doc,
66 "library_version_string()\n\n" \
67 "Returns the version number of the LZ4 library as a string\n" \
68 "containing the semantic version.\n" \
69 "\n" \
70 "Args:\n" \
71 " None\n" \
72 "\n" \
73 "Returns:\n" \
74 " str: version number eg. \"1.7.5\""
75 );
76
77 static PyMethodDef module_methods[] = {
78 {
79 "library_version_number",
80 (PyCFunction) library_version_number,
81 METH_VARARGS,
82 library_version_number__doc
83 },
84 {
85 "library_version_string",
86 (PyCFunction) library_version_string,
87 METH_VARARGS,
88 library_version_string__doc
89 },
90 {
91 /* Sentinel */
92 NULL,
93 NULL,
94 0,
95 NULL
96 }
97 };
98
99 static struct PyModuleDef moduledef =
100 {
101 PyModuleDef_HEAD_INIT,
102 "_version",
103 NULL,
104 -1,
105 module_methods
106 };
107
108 PyMODINIT_FUNC
109 PyInit__version(void)
110 {
111 PyObject *module = PyModule_Create (&moduledef);
112
113 if (module == NULL)
114 return NULL;
115
116 #ifdef Py_GIL_DISABLED
117 PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
118 #endif
119
120 return module;
121 }