diff options
author | Erik Troan <ewt@redhat.com> | 1999-08-20 22:15:24 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-08-20 22:15:24 +0000 |
commit | 74601ba3e645cfe9ed3812b64b18eb7821dc0df9 (patch) | |
tree | a6772d75da90a3fd3b7a59b24c866b671ad0b998 /rpmmodule | |
parent | 234e9436c7b762ec19b440178533c87add1043b7 (diff) | |
download | anaconda-74601ba3e645cfe9ed3812b64b18eb7821dc0df9.tar.gz anaconda-74601ba3e645cfe9ed3812b64b18eb7821dc0df9.tar.xz anaconda-74601ba3e645cfe9ed3812b64b18eb7821dc0df9.zip |
added load and unload of headers
Diffstat (limited to 'rpmmodule')
-rw-r--r-- | rpmmodule/rpmmodule.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/rpmmodule/rpmmodule.c b/rpmmodule/rpmmodule.c index 038baefe6..e0d07e753 100644 --- a/rpmmodule/rpmmodule.c +++ b/rpmmodule/rpmmodule.c @@ -28,13 +28,15 @@ static void hdrDealloc(hdrObject * s); static PyObject * hdrGetAttr(hdrObject * s, char * name); static PyObject * hdrSubscript(hdrObject * s, PyObject * item); static PyObject * hdrKeyList(hdrObject * s, PyObject * args); +static PyObject * hdrUnload(hdrObject * s, PyObject * args); static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args); void initrpm(void); static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args); -static PyObject * archScore(PyObject * self, PyObject * args); +static PyObject * hdrLoad(PyObject * self, PyObject * args); static PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args); static PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args); +static PyObject * archScore(PyObject * self, PyObject * args); static PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args); static PyObject * findUpgradeSet(PyObject * self, PyObject * args); @@ -51,13 +53,14 @@ static int rpmtransSetAttr(rpmtransObject * o, char * name, /* Types */ static PyMethodDef rpmModuleMethods[] = { - { "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL }, + { "TransactionSet", (PyCFunction) rpmtransCreate, METH_VARARGS, NULL }, { "archscore", (PyCFunction) archScore, METH_VARARGS, NULL }, { "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL }, { "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL }, - { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS, NULL }, + { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL }, + { "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL }, { "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS, NULL }, - { "TransactionSet", (PyCFunction) rpmtransCreate, METH_VARARGS, NULL }, + { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS, NULL }, { NULL } } ; @@ -170,6 +173,7 @@ static struct PyMethodDef rpmtransMethods[] = { static struct PyMethodDef hdrMethods[] = { {"keys", (PyCFunction) hdrKeyList, 1 }, + {"unload", (PyCFunction) hdrUnload, 1 }, {"verifyFile", (PyCFunction) hdrVerifyFile, 1 }, {NULL, NULL} /* sentinel */ }; @@ -461,6 +465,29 @@ static PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args) { } +static PyObject * hdrLoad(PyObject * self, PyObject * args) { + char * obj; + Header hdr; + hdrObject * h; + int len; + + if (!PyArg_ParseTuple(args, "s#", &obj, &len)) return NULL; + + hdr = headerLoad(obj); + if (!hdr) { + PyErr_SetString(pyrpmError, "bad header"); + return NULL; + } + + h = (hdrObject *) PyObject_NEW(PyObject, &hdrType); + h->h = hdr; + h->fileList = h->linkList = h->md5list = NULL; + h->uids = h->gids = h->mtimes = h->fileSizes = NULL; + h->modes = h->rdevs = NULL; + + return (PyObject *) h; +} + static PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args) { char * filespec; FD_t fd; @@ -770,6 +797,20 @@ static PyObject * hdrKeyList(hdrObject * s, PyObject * args) { return list; } +static PyObject * hdrUnload(hdrObject * s, PyObject * args) { + char * buf; + int len; + PyObject * rc; + + len = headerSizeof(s->h, 1); + buf = headerUnload(s->h); + + rc = PyString_FromStringAndSize(buf, len); + free(buf); + + return rc; +} + /* Returns a list of these tuple for each part which failed: (attr_name, correctValue, currentValue) |