return PyBytes_FromStringAndSize((const char*)digest, length);
}
-static PyObject* _File_hexdigest(FileObject* self, enum pakfire_digest_types type) {
- char* hexdigest = pakfire_file_get_hexdigest(self->file, type);
- if (!hexdigest)
- Py_RETURN_NONE;
-
- PyObject* obj = PyUnicode_FromString(hexdigest);
- free(hexdigest);
-
- return obj;
-}
-
-static PyObject* File_hexdigest(FileObject* self, PyObject* args) {
- int type = 0;
-
- if (!PyArg_ParseTuple(args, "i", &type))
- return NULL;
-
- return _File_hexdigest(self, type);
-}
-
static struct PyMethodDef File_methods[] = {
{
"digest",
METH_VARARGS,
NULL,
},
- {
- "hexdigest",
- (PyCFunction)File_hexdigest,
- METH_VARARGS,
- NULL,
- },
{ NULL },
};