60e51fd2764291df2332f36ff478777627d92b57Sumit Bose Sumit Bose <sbose@redhat.com>
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose Copyright (C) 2012 Red Hat
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose This program is free software; you can redistribute it and/or modify
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose it under the terms of the GNU General Public License as published by
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose the Free Software Foundation; either version 3 of the License, or
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose (at your option) any later version.
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose This program is distributed in the hope that it will be useful,
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose GNU General Public License for more details.
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose You should have received a copy of the GNU General Public License
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose"murmurhash3(key, key_len, seed) -> 32bit integer hash\n\
60e51fd2764291df2332f36ff478777627d92b57Sumit BoseCalculate the murmur hash version 3 of the first key_len bytes from key\n\
60e51fd2764291df2332f36ff478777627d92b57Sumit Boseusing the given seed."
60e51fd2764291df2332f36ff478777627d92b57Sumit Bosestatic PyObject * py_murmurhash3(PyObject *module, PyObject *args)
41454a64c714e984423fd6e94ea89d183a73cc67Lukas Slebodnik if (!PyArg_ParseTuple(args, sss_py_const_p(char, "z#lL"),
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose PyErr_Format(PyExc_ValueError, "Invalid argument\n");
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose if (seed > UINT32_MAX || key_len > INT_MAX || key_len < 0 ||
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose PyErr_Format(PyExc_ValueError, "Invalid value\n");
60e51fd2764291df2332f36ff478777627d92b57Sumit Bose return PyLong_FromUnsignedLong((unsigned long) hash);
56ad566af1e595dacfcc5a213d906e8070bb263cJakub Hrozek { sss_py_const_p(char, "murmurhash3"), (PyCFunction) py_murmurhash3,
341a00311680a440d7f979f06c34c70d86c9367aBohuslav Kabrdastatic struct PyModuleDef pysss_murmurdef = {
341a00311680a440d7f979f06c34c70d86c9367aBohuslav Kabrda "pysss_murmur",
341a00311680a440d7f979f06c34c70d86c9367aBohuslav Kabrda m = Py_InitModule3(sss_py_const_p(char, "pysss_murmur"),
56ad566af1e595dacfcc5a213d906e8070bb263cJakub Hrozek methods, sss_py_const_p(char, "murmur hash functions"));