From 7ed904da030dc4640ff9bce8458ba07cc09d830d Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 20 Mar 2001 15:00:07 +0000 Subject: Strip header regions during unload. CVS patchset: 4643 CVS date: 2001/03/20 15:00:07 --- python/rpmmodule.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'python') diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 89501bf6f..1dd736024 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -149,13 +149,25 @@ static PyObject * hdrKeyList(hdrObject * s, PyObject * args) { /** \ingroup python */ -static PyObject * hdrUnload(hdrObject * s, PyObject * args) { +static PyObject * hdrUnload(hdrObject * s, PyObject * args, PyObject *keywords) { char * buf; - int len; PyObject * rc; + int len, legacy = 0; + static char *kwlist[] = { "legacyHeader", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, keywords, "|i", kwlist, &legacy)) + return NULL; + + if (legacy) { + Header h; - len = headerSizeof(s->h, 0); - buf = headerUnload(s->h); + h = headerCopy(s->h); + len = headerSizeof(h, 0); + buf = headerUnload(h); + } else { + len = headerSizeof(s->h, 0); + buf = headerUnload(s->h); + } rc = PyString_FromStringAndSize(buf, len); free(buf); @@ -418,7 +430,7 @@ static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) { */ static struct PyMethodDef hdrMethods[] = { {"keys", (PyCFunction) hdrKeyList, 1 }, - {"unload", (PyCFunction) hdrUnload, 1 }, + {"unload", (PyCFunction) hdrUnload, METH_VARARGS|METH_KEYWORDS }, {"verifyFile", (PyCFunction) hdrVerifyFile, 1 }, {"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 }, {"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 }, @@ -2335,7 +2347,7 @@ void initrpm(void) { #define REGISTER_ENUM(val) \ - PyDict_SetItemString(d, #val, o=PyInt_FromLong(## val)); \ + PyDict_SetItemString(d, #val, o=PyInt_FromLong( val )); \ Py_DECREF(o); REGISTER_ENUM(RPMFILE_STATE_NORMAL); -- cgit v1.2.3