diff options
Diffstat (limited to 'python/rpmfi-py.c')
-rw-r--r-- | python/rpmfi-py.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index 7dcf25d0e..a43fee323 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -288,20 +288,26 @@ static PyMappingMethods rpmfi_as_mapping = { static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds) { - PyObject * to = NULL; /* unused */ + s->active = 0; + return 0; +} + +static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) +{ + PyObject * to = NULL; Header h = NULL; + rpmfi fi = NULL; + rpmTagVal tagN = RPMTAG_BASENAMES; int flags = 0; char * kwlist[] = {"header", "tag", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|Oi:rpmfi_init", kwlist, hdrFromPyObject, &h, &to, &flags)) - return -1; + return NULL; - rpmfiFree(s->fi); - s->fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, flags); - s->active = 0; + fi = rpmfiNew(NULL, h, tagN, flags); - return 0; + return rpmfi_Wrap(subtype, fi); } static char rpmfi_doc[] = @@ -346,11 +352,18 @@ PyTypeObject rpmfi_Type = { 0, /* tp_dictoffset */ (initproc) rpmfi_init, /* tp_init */ 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ + (newfunc) rpmfi_new, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; +/* ---------- */ + +rpmfi fiFromFi(rpmfiObject * s) +{ + return s->fi; +} + PyObject * rpmfi_Wrap(PyTypeObject *subtype, rpmfi fi) { rpmfiObject *s = (rpmfiObject *)subtype->tp_alloc(subtype, 0); |