diff options
author | jbj <devnull@localhost> | 2002-12-11 00:12:17 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-12-11 00:12:17 +0000 |
commit | 2452c14619fd14c1b7eba69eec0c7d32dbf56d86 (patch) | |
tree | f53843b4b7c7ff962b379ed65a17387ebc0ef2be | |
parent | fe6043016c84107132bd0dc80ef454d2c81342b7 (diff) | |
download | rpm-2452c14619fd14c1b7eba69eec0c7d32dbf56d86.tar.gz rpm-2452c14619fd14c1b7eba69eec0c7d32dbf56d86.tar.bz2 rpm-2452c14619fd14c1b7eba69eec0c7d32dbf56d86.zip |
Add rpmfts-py.[ch] bindings for fts(3) from rpmio.
splint fiddles.
CVS patchset: 5932
CVS date: 2002/12/11 00:12:17
-rw-r--r-- | python/Makefile.am | 8 | ||||
-rw-r--r-- | python/rpmbc-py.c | 50 | ||||
-rw-r--r-- | python/rpmdb-py.c | 10 | ||||
-rw-r--r-- | python/rpmds-py.c | 7 | ||||
-rw-r--r-- | python/rpmfd-py.c | 168 | ||||
-rw-r--r-- | python/rpmfi-py.c | 36 | ||||
-rw-r--r-- | python/rpmfts-py.c | 349 | ||||
-rw-r--r-- | python/rpmfts-py.h | 22 | ||||
-rw-r--r-- | python/rpmmi-py.c | 23 | ||||
-rw-r--r-- | python/rpmmi-py.h | 3 | ||||
-rw-r--r-- | python/rpmmodule.c | 6 | ||||
-rw-r--r-- | python/rpmte-py.c | 14 | ||||
-rw-r--r-- | python/rpmts-py.c | 125 | ||||
-rw-r--r-- | python/rpmts-py.h | 3 |
14 files changed, 660 insertions, 164 deletions
diff --git a/python/Makefile.am b/python/Makefile.am index 70cf242d2..29706f705 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = -I. \ @INCPATH@ noinst_HEADERS = hash.h header-py.h \ - rpmal-py.h rpmbc-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h \ + rpmal-py.h rpmbc-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h rpmfts-py.c \ rpmfi-py.h rpmmi-py.h rpmrc-py.h rpmte-py.h rpmts-py.h \ upgrade.h @@ -53,7 +53,7 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so noinst_LTLIBRARIES = librpmmodule.la librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c header-py.c \ - rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c \ + rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \ rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c rpmmodule.so$(EXEEXT): $(librpmmodule_la_OBJECTS) @@ -70,8 +70,8 @@ poptmodule.so$(EXEEXT): poptmodule.lo # rpmrc-py.c rpmte-py.c rpmts-py.c # rpmmodule.c header-py.c splint_srcs = hash.c upgrade.c \ - rpmal-py.c rpmds-py.c rpmfd-py.c rpmfi-py.c rpmmi-py.c \ - rpmrc-py.c rpmte-py.c rpmts-py.c + rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \ + rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c .PHONY: lint lint: diff --git a/python/rpmbc-py.c b/python/rpmbc-py.c index fc7b8d23f..24836b3b8 100644 --- a/python/rpmbc-py.c +++ b/python/rpmbc-py.c @@ -37,7 +37,7 @@ fprintf(stderr, "*** rpmbc_dealloc(%p)\n", s); static int rpmbc_print(rpmbcObject * s, FILE * fp, /*@unused@*/ int flags) /*@globals fileSystem @*/ - /*@modifies s, fp, fileSystem @*/ + /*@modifies fp, fileSystem @*/ { if (_bc_debug < 0) fprintf(stderr, "*** rpmbc_print(%p)\n", s); @@ -66,7 +66,7 @@ fprintf(stderr, "*** rpmbc_repr(%p)\n", a); /** \ingroup python */ static int rpmbc_init(rpmbcObject * s, PyObject *args, PyObject *kwds) - /*@*/ + /*@modifies s @*/ { PyObject * o = NULL; uint32 words = 0; @@ -104,7 +104,9 @@ fprintf(stderr, "*** rpmbc_init(%p[%s],%p[%s],%p[%s])\n", s, lbl(s), args, lbl(a mp32nsize(&s->n, words); switch (words) { case 2: +/*@-shiftimplementation @*/ s->n.data[0] = (l >> 32) & 0xffffffff; +/*@=shiftimplementation @*/ s->n.data[1] = (l ) & 0xffffffff; break; case 1: @@ -118,8 +120,8 @@ fprintf(stderr, "*** rpmbc_init(%p[%s],%p[%s],%p[%s])\n", s, lbl(s), args, lbl(a /** \ingroup python */ -static void rpmbc_free(rpmbcObject * s) - /*@*/ +static void rpmbc_free(/*@only@*/ rpmbcObject * s) + /*@modifies s @*/ { if (_bc_debug) fprintf(stderr, "*** rpmbc_free(%p[%s])\n", s, lbl(s)); @@ -206,8 +208,7 @@ fprintf(stderr, "*** rpmbc_Debug(%p)\n", s); */ static PyObject * rpmbc_Gcd(/*@unused@*/ rpmbcObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ + /*@*/ { PyObject * op1; PyObject * op2; @@ -240,8 +241,7 @@ fprintf(stderr, "*** rpmbc_Gcd(%p)\n", s); */ static PyObject * rpmbc_Sqrt(/*@unused@*/ rpmbcObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ + /*@*/ { PyObject * op1; rpmbcObject * a = NULL; @@ -495,28 +495,34 @@ static PyObject * rpmbc_lshift(rpmbcObject * a, rpmbcObject * b) /*@*/ { + rpmbcObject * z; uint32 count = 0; if (_bc_debug) -fprintf(stderr, "*** rpmbc_lshift(%p,%p)\n", a, b); - - mp32lshift(a->n.size, a->n.data, count); +fprintf(stderr, "*** rpmbc_lshift(%p[%s],%p[%s])\n", a, lbl(a), b, lbl(b)); - return NULL; + if ((z = rpmbc_New()) != NULL) { + mp32ninit(&z->n, a->n.size, a->n.data); + mp32lshift(z->n.size, z->n.data, count); + } + return (PyObject *)z; } static PyObject * rpmbc_rshift(rpmbcObject * a, rpmbcObject * b) /*@*/ { + rpmbcObject * z; uint32 count = 0; if (_bc_debug) -fprintf(stderr, "*** rpmbc_rshift(%p,%p)\n", a, b); - - mp32rshift(a->n.size, a->n.data, count); +fprintf(stderr, "*** rpmbc_rshift(%p[%s],%p[%s])\n", a, lbl(a), b, lbl(b)); - return NULL; + if ((z = rpmbc_New()) != NULL) { + mp32ninit(&z->n, a->n.size, a->n.data); + mp32rshift(z->n.size, z->n.data, count); + } + return (PyObject *)z; } static PyObject * @@ -548,7 +554,7 @@ fprintf(stderr, "*** rpmbc_or(%p,%p)\n", a, b); static int rpmbc_coerce(PyObject ** pv, PyObject ** pw) - /*@*/ + /*@modifies *pv, *pw @*/ { uint32 words = 0; long l = 0; @@ -579,7 +585,9 @@ fprintf(stderr, "*** rpmbc_coerce(%p[%s],%p[%s])\n", pv, lbl(*pv), pw, lbl(*pw)) mp32nsize(&z->n, words); switch (words) { case 2: +/*@-shiftimplementation @*/ z->n.data[0] = (l >> 32) & 0xffffffff; +/*@=shiftimplementation @*/ z->n.data[1] = (l ) & 0xffffffff; break; case 1: @@ -649,7 +657,7 @@ fprintf(stderr, "*** rpmbc_hex(%p)\n", a); static PyObject * rpmbc_inplace_add(rpmbcObject * a, rpmbcObject * b) - /*@*/ + /*@modifies a @*/ { uint32 carry; @@ -663,7 +671,7 @@ fprintf(stderr, "*** rpmbc_inplace_add(%p,%p)\n", a, b); static PyObject * rpmbc_inplace_subtract(rpmbcObject * a, rpmbcObject * b) - /*@*/ + /*@modifies a @*/ { uint32 carry; @@ -718,7 +726,7 @@ fprintf(stderr, "*** rpmbc_inplace_power(%p,%p,%p)\n", a, b, c); static PyObject * rpmbc_inplace_lshift(rpmbcObject * a, rpmbcObject * b) - /*@*/ + /*@modifies a @*/ { uint32 count = 0; @@ -732,7 +740,7 @@ fprintf(stderr, "*** rpmbc_inplace_lshift(%p,%p)\n", a, b); static PyObject * rpmbc_inplace_rshift(rpmbcObject * a, rpmbcObject * b) - /*@*/ + /*@modifies a @*/ { uint32 count = 0; diff --git a/python/rpmdb-py.c b/python/rpmdb-py.c index e840995cd..1ab1b7c87 100644 --- a/python/rpmdb-py.c +++ b/python/rpmdb-py.c @@ -113,8 +113,8 @@ */ static rpmmiObject * rpmdb_Match (rpmdbObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { PyObject *TagN = NULL; char *key = NULL; @@ -148,7 +148,8 @@ static struct PyMethodDef rpmdb_methods[] = { */ static int rpmdb_length(rpmdbObject * s) - /*@modifies s @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { rpmdbMatchIterator mi; int count = 0; @@ -165,7 +166,8 @@ rpmdb_length(rpmdbObject * s) */ static hdrObject * rpmdb_subscript(rpmdbObject * s, PyObject * key) - /*@modifies s @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { int offset; hdrObject * ho; diff --git a/python/rpmds-py.c b/python/rpmds-py.c index eb30b4568..fed130b34 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -94,7 +94,7 @@ rpmds_compare(rpmdsObject * a, rpmdsObject * b) static PyObject * rpmds_iter(rpmdsObject * s) - /*@modifies s @*/ + /*@*/ { Py_INCREF(s); return (PyObject *)s; @@ -158,7 +158,7 @@ rpmds_Next(rpmdsObject * s, PyObject *args) static PyObject * rpmds_SetNoPromote(rpmdsObject * s, PyObject * args) - /*@*/ + /*@modifies s @*/ { int nopromote; @@ -169,7 +169,8 @@ rpmds_SetNoPromote(rpmdsObject * s, PyObject * args) static PyObject * rpmds_Notify(rpmdsObject * s, PyObject * args) - /*@*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ { const char * where; int rc; diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index f226cd6ab..0df04f509 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -23,7 +23,8 @@ /*@access FD_t @*/ -extern int _rpmio_debug; +/*@unchecked@*/ +static int _rpmfd_debug = 1; /** \ingroup python * \name Class: Rpmfd @@ -36,7 +37,7 @@ rpmfd_Debug(/*@unused@*/ rpmfdObject * s, PyObject * args) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmio_debug)) return NULL; + if (!PyArg_ParseTuple(args, "i", &_rpmfd_debug)) return NULL; Py_INCREF(Py_None); return Py_None; } @@ -73,22 +74,22 @@ static int closeCallback(FILE * f) node = fdhead; last = NULL; while (node) { - if (node->f == f) - break; - last = node; - node = node->next; + if (node->f == f) + break; + last = node; + node = node->next; } if (node) { - if (last) - last->next = node->next; - else - fdhead = node->next; + if (last) + last->next = node->next; + else + fdhead = node->next; node->note = _free (node->note); - node->fd = fdLink(node->fd, "closeCallback"); - Fclose (node->fd); - while (node->fd) - node->fd = fdFree(node->fd, "closeCallback"); - node = _free (node); + node->fd = fdLink(node->fd, "closeCallback"); + (void) Fclose (node->fd); + while (node->fd) + node->fd = fdFree(node->fd, "closeCallback"); + node = _free (node); } return 0; } @@ -96,14 +97,15 @@ static int closeCallback(FILE * f) /** */ static PyObject * -rpmfd_Fopen(/*@unused@*/ PyObject * self, PyObject * args) +rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args) /*@globals fdhead, fdtail @*/ /*@modifies fdhead, fdtail @*/ { - char * path, * mode; + char * path; + char * mode = "r.ufdio"; FDlist *node; - if (!PyArg_ParseTuple(args, "ss", &path, &mode)) + if (!PyArg_ParseTuple(args, "s|s", &path, &mode)) return NULL; node = xmalloc (sizeof(FDlist)); @@ -114,22 +116,22 @@ rpmfd_Fopen(/*@unused@*/ PyObject * self, PyObject * args) if (!node->fd) { PyErr_SetFromErrno(pyrpmError); - node = _free (node); + node = _free (node); return NULL; } if (Ferror(node->fd)) { const char *err = Fstrerror(node->fd); - node = _free(node); - if (err) { + node = _free(node); + if (err) PyErr_SetString(pyrpmError, err); - return NULL; - } + return NULL; } + node->f = fdGetFp(node->fd); if (!node->f) { PyErr_SetString(pyrpmError, "FD_t has no FILE*"); - free(node); + free(node); return NULL; } @@ -137,9 +139,9 @@ rpmfd_Fopen(/*@unused@*/ PyObject * self, PyObject * args) if (!fdhead) { fdhead = fdtail = node; } else if (fdtail) { - fdtail->next = node; + fdtail->next = node; } else { - fdhead = node; + fdhead = node; } fdtail = node; @@ -152,9 +154,9 @@ rpmfd_Fopen(/*@unused@*/ PyObject * self, PyObject * args) /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmfd_methods[] = { {"Debug", (PyCFunction)rpmfd_Debug, METH_VARARGS, - NULL}, + NULL}, {"Fopen", (PyCFunction)rpmfd_Fopen, METH_VARARGS, - NULL}, + NULL}, {NULL, NULL} /* sentinel */ }; /*@=fullinitblock@*/ @@ -163,12 +165,101 @@ static struct PyMethodDef rpmfd_methods[] = { /** \ingroup python */ +static void +rpmfd_dealloc(/*@only@*/ /*@null@*/ rpmfdObject * s) + /*@modifies s @*/ +{ + if (s) { + Fclose(s->fd); + s->fd = NULL; + PyObject_Del(s); + } +} + +/** \ingroup python + */ static PyObject * rpmfd_getattr(rpmfdObject * o, char * name) /*@*/ { return Py_FindMethod(rpmfd_methods, (PyObject *) o, name); } +/** \ingroup python + */ +static int rpmfd_init(rpmfdObject * s, PyObject *args, PyObject *kwds) + /*@*/ +{ + char * path; + char * mode = "r.ufdio"; + +if (_rpmfd_debug) +fprintf(stderr, "*** rpmfd_init(%p,%p,%p)\n", s, args, kwds); + + if (!PyArg_ParseTuple(args, "s|s:rpmfd_init", &path, &mode)) + return -1; + + s->fd = Fopen(path, mode); + + if (s->fd == NULL) { + PyErr_SetFromErrno(pyrpmError); + return -1; + } + + if (Ferror(s->fd)) { + const char *err = Fstrerror(s->fd); + if (s->fd) + Fclose(s->fd); + if (err) + PyErr_SetString(pyrpmError, err); + return -1; + } + return 0; +} + +/** \ingroup python + */ +static void rpmfd_free(/*@only@*/ rpmfdObject * s) + /*@modifies s @*/ +{ +if (_rpmfd_debug) +fprintf(stderr, "%p -- fd %p\n", s, s->fd); + if (s->fd) + Fclose(s->fd); + + PyObject_Del((PyObject *)s); +} + +/** \ingroup python + */ +static PyObject * rpmfd_alloc(PyTypeObject * subtype, int nitems) + /*@*/ +{ + PyObject * s = PyType_GenericAlloc(subtype, nitems); + +if (_rpmfd_debug) +fprintf(stderr, "*** rpmfd_alloc(%p,%d) ret %p\n", subtype, nitems, s); + return s; +} + +/** \ingroup python + */ +static rpmfdObject * rpmfd_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) + /*@*/ +{ + rpmfdObject * s = PyObject_New(rpmfdObject, subtype); + + /* Perform additional initialization. */ + if (rpmfd_init(s, args, kwds) < 0) { + rpmfd_free(s); + return NULL; + } + +if (_rpmfd_debug) +fprintf(stderr, "%p ++ fd %p\n", s, s->fd); + + return s; +} + /** */ /*@unchecked@*/ /*@observer@*/ @@ -184,18 +275,19 @@ PyTypeObject rpmfd_Type = { "rpm.fd", /* tp_name */ sizeof(rpmfdObject), /* tp_size */ 0, /* tp_itemsize */ - (destructor)0, /* tp_dealloc */ + /* methods */ + (destructor) rpmfd_dealloc, /* tp_dealloc */ 0, /* tp_print */ (getattrfunc) rpmfd_getattr, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ + (cmpfunc)0, /* tp_compare */ + (reprfunc)0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -216,10 +308,10 @@ PyTypeObject rpmfd_Type = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ + (initproc) rpmfd_init, /* tp_init */ + (allocfunc) rpmfd_alloc, /* tp_alloc */ + (newfunc) rpmfd_new, /* tp_new */ + (destructor) rpmfd_free, /* tp_free */ 0, /* tp_is_gc */ #endif }; diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index ff1e7e2e3..f1e4c42a2 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -122,15 +122,15 @@ static PyObject * rpmfi_MD5(rpmfiObject * s, PyObject * args) /*@*/ { - const unsigned char * md5; + const unsigned char * MD5; char fmd5[33]; char * t; int i; if (!PyArg_ParseTuple(args, ":MD5")) return NULL; - md5 = rpmfiMD5(s->fi); + MD5 = rpmfiMD5(s->fi); for (i = 0, t = fmd5; i < 16; i++, t += 2) - sprintf(t, "%02x", md5[i]); + sprintf(t, "%02x", MD5[i]); *t = '\0'; return Py_BuildValue("s", xstrdup(fmd5)); } @@ -186,7 +186,7 @@ rpmfi_FGroup(rpmfiObject * s, PyObject * args) #if Py_TPFLAGS_HAVE_ITER static PyObject * rpmfi_iter(rpmfiObject * s, /*@unused@*/ PyObject * args) - /*@modifies s @*/ + /*@*/ { Py_INCREF(s); return (PyObject *)s; @@ -195,7 +195,8 @@ rpmfi_iter(rpmfiObject * s, /*@unused@*/ PyObject * args) static PyObject * rpmfi_iternext(rpmfiObject * s) - /*@modifies s @*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ { PyObject * result = NULL; @@ -219,15 +220,17 @@ rpmfi_iternext(rpmfiObject * s) int VFlags = rpmfiVFlags(s->fi); const char * FUser = rpmfiFUser(s->fi); const char * FGroup = rpmfiFGroup(s->fi); - const unsigned char * md5 = rpmfiMD5(s->fi), *s = md5; +/*@-shadow@*/ + const unsigned char * MD5 = rpmfiMD5(s->fi), *s = MD5; +/*@=shadow@*/ char FMD5[2*16+1], *t = FMD5; static const char hex[] = "0123456789abcdef"; - int gotmd5, i; + int gotMD5, i; - gotmd5 = 0; + gotMD5 = 0; if (s) for (i = 0; i < 16; i++) { - gotmd5 |= *s; + gotMD5 |= *s; *t++ = hex[ (*s >> 4) & 0xf ]; *t++ = hex[ (*s++ ) & 0xf ]; } @@ -258,7 +261,7 @@ rpmfi_iternext(rpmfiObject * s) PyTuple_SET_ITEM(result, 11, Py_None); } else PyTuple_SET_ITEM(result, 11, Py_BuildValue("s", FGroup)); - if (!gotmd5) { + if (!gotMD5) { Py_INCREF(Py_None); PyTuple_SET_ITEM(result, 12, Py_None); } else @@ -272,7 +275,8 @@ rpmfi_iternext(rpmfiObject * s) static PyObject * rpmfi_Next(rpmfiObject * s, /*@unused@*/ PyObject * args) - /*@modifies s @*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ { PyObject * result = NULL; @@ -439,9 +443,9 @@ PyTypeObject rpmfi_Type = { sizeof(rpmfiObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)rpmfi_dealloc, /* tp_dealloc */ - (printfunc)rpmfi_print, /* tp_print */ - (getattrfunc)rpmfi_getattr, /* tp_getattr */ + (destructor) rpmfi_dealloc, /* tp_dealloc */ + (printfunc) rpmfi_print, /* tp_print */ + (getattrfunc) rpmfi_getattr, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ (cmpfunc)0, /* tp_compare */ (reprfunc)0, /* tp_repr */ @@ -461,8 +465,8 @@ PyTypeObject rpmfi_Type = { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ - (getiterfunc)rpmfi_iter, /* tp_iter */ - (iternextfunc)rpmfi_iternext, /* tp_iternext */ + (getiterfunc) rpmfi_iter, /* tp_iter */ + (iternextfunc) rpmfi_iternext, /* tp_iternext */ rpmfi_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ diff --git a/python/rpmfts-py.c b/python/rpmfts-py.c new file mode 100644 index 000000000..7bab19be1 --- /dev/null +++ b/python/rpmfts-py.c @@ -0,0 +1,349 @@ +/** \ingroup python + * \file python/rpmfts-py.c + */ + +#include "system.h" + +#include "Python.h" +#ifdef __LCLINT__ +#undef PyObject_HEAD +#define PyObject_HEAD int _PyObjectHead; +#endif + +#include <fts.h> + +#include <rpmlib.h> /* XXX _free */ + +#include "rpmfts-py.h" + +#include "debug.h" + +/*@unchecked@*/ +static int _rpmfts_debug = 1; + +static char * ftsPaths[] = { + "/usr/share/doc", + NULL +}; + +static int ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT); + +static const char * ftsInfoStrings[] = { + "UNKNOWN", + "D", + "DC", + "DEFAULT", + "DNR", + "DOT", + "DP", + "ERR", + "F", + "INIT", + "NS", + "NSOK", + "SL", + "SLNONE", + "W", +}; + +static const char * ftsInfoStr(int fts_info) + /*@*/ +{ + if (!(fts_info >= 1 && fts_info <= 14)) + fts_info = 0; + return ftsInfoStrings[ fts_info ]; +} + +/** \ingroup python + * \name Class: Rpmfts + * \class Rpmfts + * \brief A python rpm.fts object represents an rpm fts(3) handle. + */ + +static PyObject * +rpmfts_Debug(rpmftsObject * s, PyObject * args) + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ +{ + if (!PyArg_ParseTuple(args, "i:Debug", &_rpmfts_debug)) return NULL; + + return (PyObject *)s; +} + +static PyObject * +rpmfts_Open(rpmftsObject * s, PyObject * args) + /*@*/ +{ + if (!PyArg_ParseTuple(args, ":Open")) return NULL; + +if (_rpmfts_debug) +fprintf(stderr, "*** rpmfts_Open(%p) ftsp %p fts %p\n", s, s->ftsp, s->fts); + + s->ftsp = Fts_open(ftsPaths, ftsOpts, NULL); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +rpmfts_Read(rpmftsObject * s, PyObject * args) + /*@*/ +{ + if (!PyArg_ParseTuple(args, ":Read")) return NULL; + +if (_rpmfts_debug) +fprintf(stderr, "*** rpmfts_Read(%p) ftsp %p fts %p\n", s, s->ftsp, s->fts); + + if (!(s && s->ftsp)) + return NULL; + + s->fts = Fts_read(s->ftsp); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +rpmfts_Children(rpmftsObject * s, PyObject * args) + /*@*/ +{ + int instr = 0; + + if (!PyArg_ParseTuple(args, ":Children")) return NULL; + +if (_rpmfts_debug) +fprintf(stderr, "*** rpmfts_Children(%p) ftsp %p fts %p\n", s, s->ftsp, s->fts); + + if (!(s && s->ftsp)) + return NULL; + + s->fts = Fts_children(s->ftsp, instr); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +rpmfts_Close(rpmftsObject * s, PyObject * args) + /*@*/ +{ + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Close")) return NULL; + + if (s->ftsp) { + rc = Fts_close(s->ftsp); + s->ftsp = NULL; + s->fts = NULL; + } + + return Py_BuildValue("i", rc); +} + +static PyObject * +rpmfts_Set(rpmftsObject * s, PyObject * args) + /*@*/ +{ + int instr = 0; + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Set")) return NULL; + + if (s->ftsp && s->fts) + rc = Fts_set(s->ftsp, s->fts, instr); + + return Py_BuildValue("i", rc); +} + +/** \ingroup python + */ +/*@-fullinitblock@*/ +/*@unchecked@*/ /*@observer@*/ +static struct PyMethodDef rpmfts_methods[] = { + {"Debug", (PyCFunction)rpmfts_Debug, METH_VARARGS, + NULL}, + {"open", (PyCFunction)rpmfts_Open, METH_VARARGS, + NULL}, + {"read", (PyCFunction)rpmfts_Read, METH_VARARGS, + NULL}, + {"children",(PyCFunction)rpmfts_Children, METH_VARARGS, + NULL}, + {"close", (PyCFunction)rpmfts_Close, METH_VARARGS, + NULL}, + {"set", (PyCFunction)rpmfts_Set, METH_VARARGS, + NULL}, + {NULL, NULL} /* sentinel */ +}; +/*@=fullinitblock@*/ + +/* ---------- */ + +/** \ingroup python + */ +static void +rpmfts_dealloc(/*@only@*/ /*@null@*/ rpmftsObject * s) + /*@modifies s @*/ +{ + if (s) { + if (s->ftsp) { + (void) Fts_close(s->ftsp); + s->ftsp = NULL; + s->fts = NULL; + } + PyObject_Del(s); + } +} + +/** \ingroup python + */ +static int +rpmfts_print(rpmftsObject * s, FILE * fp, /*@unused@*/ int flags) + /*@*/ +{ + int indent = 2; + if (!(s && s->ftsp && s->fts)) + return -1; + fprintf(fp, "FTS_%-7s %*s%s", ftsInfoStr(s->fts->fts_info), + indent * (s->fts->fts_level < 0 ? 0 : s->fts->fts_level), "", + s->fts->fts_name); + return 0; + +} + +/** \ingroup python + */ +static PyObject * rpmfts_getattr(rpmftsObject * o, char * name) + /*@*/ +{ + return Py_FindMethod(rpmfts_methods, (PyObject *) o, name); +} + +/** \ingroup python + */ +static int rpmfts_init(rpmftsObject * s, PyObject *args, PyObject *kwds) + /*@*/ +{ +if (_rpmfts_debug) +fprintf(stderr, "*** rpmfts_init(%p,%p,%p)\n", s, args, kwds); + + if (!PyArg_ParseTuple(args, ":rpmfts_init")) + return -1; + + s->ftsp = NULL; + s->fts = NULL; + + return 0; +} + +/** \ingroup python + */ +static void rpmfts_free(/*@only@*/ rpmftsObject * s) + /*@modifies s @*/ +{ +if (_rpmfts_debug) +fprintf(stderr, "%p -- fts %p\n", s, s->ftsp); + + if (s->ftsp) { + (void) Fts_close(s->ftsp); + s->ftsp = NULL; + s->fts = NULL; + } + + PyObject_Del((PyObject *)s); +} + +/** \ingroup python + */ +static PyObject * rpmfts_alloc(PyTypeObject * subtype, int nitems) + /*@*/ +{ + PyObject * s = PyType_GenericAlloc(subtype, nitems); + +if (_rpmfts_debug) +fprintf(stderr, "*** rpmfts_alloc(%p,%d) ret %p\n", subtype, nitems, s); + return s; +} + +/** \ingroup python + */ +static rpmftsObject * rpmfts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) + /*@*/ +{ + rpmftsObject * s = PyObject_New(rpmftsObject, subtype); + + /* Perform additional initialization. */ + if (rpmfts_init(s, args, kwds) < 0) { + rpmfts_free(s); + return NULL; + } + +if (_rpmfts_debug) +fprintf(stderr, "%p ++ fts %p\n", s, s->ftsp); + + return s; +} + +/** + */ +/*@unchecked@*/ /*@observer@*/ +static char rpmfts_doc[] = +""; + +/** \ingroup python + */ +/*@-fullinitblock@*/ +PyTypeObject rpmfts_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "rpm.fts", /* tp_name */ + sizeof(rpmftsObject), /* tp_size */ + 0, /* tp_itemsize */ + /* methods */ + (destructor) rpmfts_dealloc, /* tp_dealloc */ + (printfunc) rpmfts_print, /* tp_print */ + (getattrfunc) rpmfts_getattr, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)0, /* tp_compare */ + (reprfunc)0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + rpmfts_doc, /* tp_doc */ +#if Py_TPFLAGS_HAVE_ITER + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + rpmfts_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc) rpmfts_init, /* tp_init */ + (allocfunc) rpmfts_alloc, /* tp_alloc */ + (newfunc) rpmfts_new, /* tp_new */ + (destructor) rpmfts_free, /* tp_free */ + 0, /* tp_is_gc */ +#endif +}; +/*@=fullinitblock@*/ + +rpmftsObject * rpmfts_Wrap(FTSENT * fts) +{ + rpmftsObject *s = PyObject_New(rpmftsObject, &rpmfts_Type); + if (s == NULL) + return NULL; + return s; +} diff --git a/python/rpmfts-py.h b/python/rpmfts-py.h new file mode 100644 index 000000000..70417fd98 --- /dev/null +++ b/python/rpmfts-py.h @@ -0,0 +1,22 @@ +#ifndef H_RPMFTS_PY +#define H_RPMFTS_PY + +/** \ingroup python + * \file python/rpmfts-py.h + */ + +#include <fts.h> + +typedef struct rpmftsObject_s { + PyObject_HEAD + FTS * ftsp; + FTSENT * fts; +} rpmftsObject; + +/*@unchecked@*/ +extern PyTypeObject rpmfts_Type; + +rpmftsObject * rpmfts_Wrap(FTSENT * ftsp) + /*@*/; + +#endif diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index aff0091eb..48d65185e 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -86,8 +86,8 @@ rpmmi_iter(rpmmiObject * s) */ static PyObject * rpmmi_iternext(rpmmiObject * s) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { Header h; @@ -102,8 +102,8 @@ rpmmi_iternext(rpmmiObject * s) */ static PyObject * rpmmi_Next(rpmmiObject * s, PyObject *args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * result; @@ -123,8 +123,7 @@ rpmmi_Next(rpmmiObject * s, PyObject *args) */ static PyObject * rpmmi_Instance(rpmmiObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@*/ { int rc = 0; @@ -141,8 +140,7 @@ rpmmi_Instance(rpmmiObject * s, PyObject * args) */ static PyObject * rpmmi_Count(rpmmiObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@*/ { int rc = 0; @@ -159,8 +157,8 @@ rpmmi_Count(rpmmiObject * s, PyObject * args) */ static PyObject * rpmmi_Pattern(rpmmiObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject *TagN = NULL; int type; @@ -204,10 +202,11 @@ static struct PyMethodDef rpmmi_methods[] = { /** \ingroup python */ static void rpmmi_dealloc(/*@only@*/ /*@null@*/ rpmmiObject * s) - /*@modifies s @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { if (s) { - if (s->mi) s->mi = rpmdbFreeIterator(s->mi); + s->mi = rpmdbFreeIterator(s->mi); PyObject_Del(s); } } diff --git a/python/rpmmi-py.h b/python/rpmmi-py.h index 68bed7bb9..bfa42fc07 100644 --- a/python/rpmmi-py.h +++ b/python/rpmmi-py.h @@ -20,7 +20,6 @@ struct rpmmiObject_s { extern PyTypeObject rpmmi_Type; rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi) - /*@globals _Py_NoneStruct @*/ - /*@modifies mi, _Py_NoneStruct @*/; + /*@*/; #endif diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 6de56b26c..1a2483141 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -24,6 +24,7 @@ #include "rpmbc-py.h" #include "rpmds-py.h" #include "rpmfd-py.h" +#include "rpmfts-py.h" #include "rpmfi-py.h" #include "rpmmi-py.h" #include "rpmrc-py.h" @@ -347,6 +348,7 @@ void initrpm(void) if (PyType_Ready(&rpmbc_Type) < 0) return; if (PyType_Ready(&rpmds_Type) < 0) return; if (PyType_Ready(&rpmfd_Type) < 0) return; + if (PyType_Ready(&rpmfts_Type) < 0) return; if (PyType_Ready(&rpmfi_Type) < 0) return; if (PyType_Ready(&rpmmi_Type) < 0) return; @@ -391,6 +393,9 @@ void initrpm(void) Py_INCREF(&rpmfd_Type); PyModule_AddObject(m, "fd", (PyObject *) &rpmfd_Type); + Py_INCREF(&rpmfts_Type); + PyModule_AddObject(m, "fts", (PyObject *) &rpmfts_Type); + Py_INCREF(&rpmfi_Type); PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type); @@ -411,6 +416,7 @@ void initrpm(void) rpmbc_Type.ob_type = &PyType_Type; rpmds_Type.ob_type = &PyType_Type; rpmfd_Type.ob_type = &PyType_Type; + rpmfts_Type.ob_type = &PyType_Type; rpmfi_Type.ob_type = &PyType_Type; rpmmi_Type.ob_type = &PyType_Type; rpmte_Type.ob_type = &PyType_Type; diff --git a/python/rpmte-py.c b/python/rpmte-py.c index 18fd1bbfb..ec94a9ccc 100644 --- a/python/rpmte-py.c +++ b/python/rpmte-py.c @@ -19,6 +19,9 @@ #include "debug.h" +/*@access rpmte @*/ +/*@access fnpyKey @*/ + /** \ingroup python * \name Class: Rpmte * \class Rpmte @@ -202,7 +205,8 @@ rpmte_DBOffset(rpmteObject * s, PyObject * args) static PyObject * rpmte_Key(rpmteObject * s, PyObject * args) - /*@*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ { PyObject * Key; @@ -218,7 +222,8 @@ rpmte_Key(rpmteObject * s, PyObject * args) static PyObject * rpmte_DS(rpmteObject * s, PyObject * args) - /*@*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ { PyObject * TagN = NULL; rpmds ds; @@ -247,7 +252,8 @@ rpmte_DS(rpmteObject * s, PyObject * args) static PyObject * rpmte_FI(rpmteObject * s, PyObject * args) - /*@*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ { PyObject * TagN = NULL; rpmfi fi; @@ -341,7 +347,7 @@ static struct PyMethodDef rpmte_methods[] = { static int rpmte_print(rpmteObject * s, FILE * fp, /*@unused@*/ int flags) /*@globals fileSystem @*/ - /*@modifies s, fp, fileSystem @*/ + /*@modifies fp, fileSystem @*/ { const char * tstr; if (!(s && s->te)) diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 8ee79a9a7..7c2b13cf0 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -26,9 +26,18 @@ #include "debug.h" /*@unchecked@*/ +/*@-shadow@*/ static int _rpmts_debug = 0; +/*@=shadow@*/ /*@access alKey @*/ +/*@access FD_t @*/ +/*@access Header @*/ +/*@access rpmal @*/ +/*@access rpmdb @*/ +/*@access rpmds @*/ +/*@access rpmts @*/ +/*@access rpmtsi @*/ /** \ingroup python * \name Class: Rpmts @@ -203,8 +212,8 @@ fprintf(stderr, "\tAddAvailable(%p) list %p\n", ts, ts->availablePackages); */ static PyObject * rpmts_AddInstall(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { hdrObject * h; PyObject * key; @@ -248,8 +257,8 @@ fprintf(stderr, "*** rpmts_AddInstall(%p,%p,%p,%s) ts %p\n", s, h, key, how, s-> */ static PyObject * rpmts_AddErase(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * o; int count; @@ -284,7 +293,7 @@ fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts); uint_32 instance = PyInt_AsLong(o); mi = rpmtsInitIterator(s->ts, RPMDBI_PACKAGES, &instance, sizeof(instance)); - if (instance <= 0 || mi == NULL) { + if (instance == 0 || mi == NULL) { mi = rpmdbFreeIterator(mi); PyErr_SetString(pyrpmError, "package not installed"); return NULL; @@ -345,8 +354,8 @@ fprintf(stderr, "*** rpmts_SolveCallback(%p,%p,%p) \"%s\"\n", ts, ds, data, rpmd */ static PyObject * rpmts_Check(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { rpmps ps; rpmProblem p; @@ -458,8 +467,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb); */ static PyObject * rpmts_Order(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@modifies s @*/ { int rc; @@ -497,8 +505,8 @@ fprintf(stderr, "*** rpmts_Clean(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_IDTXload(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * result = NULL; rpmTag tag = RPMTAG_INSTALLTID; @@ -538,8 +546,8 @@ fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_IDTXglob(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * result = NULL; rpmTag tag = RPMTAG_REMOVETID; @@ -582,8 +590,8 @@ fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_Rollback(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { struct rpmInstallArguments_s * ia = alloca(sizeof(*ia)); rpmtransFlags transFlags; @@ -618,8 +626,8 @@ fprintf(stderr, "*** rpmts_Rollback(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_OpenDB(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { if (_rpmts_debug) @@ -637,8 +645,7 @@ fprintf(stderr, "*** rpmts_OpenDB(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_CloseDB(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@modifies s @*/ { int rc; @@ -657,8 +664,8 @@ fprintf(stderr, "*** rpmts_CloseDB(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_InitDB(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { int rc; @@ -678,8 +685,8 @@ fprintf(stderr, "*** rpmts_InitDB(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_RebuildDB(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { int rc; @@ -699,8 +706,8 @@ fprintf(stderr, "*** rpmts_RebuildDB(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_VerifyDB(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { int rc; @@ -720,8 +727,8 @@ fprintf(stderr, "*** rpmts_VerifyDB(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct, fileSystem @*/ - /*@modifies s, _Py_NoneStruct, fileSystem @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct, fileSystem @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct, fileSystem @*/ { PyObject * result = NULL; Header h; @@ -771,8 +778,8 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc); */ static PyObject * rpmts_HdrCheck(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * blob; PyObject * result = NULL; @@ -826,8 +833,7 @@ fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_SetVSFlags(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@modifies s @*/ { rpmVSFlags vsflags; @@ -877,8 +883,8 @@ fprintf(stderr, "*** rpmts_PgpPrtPkts(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * blob; unsigned char * pkt; @@ -948,9 +954,12 @@ static void * rpmtsCallback(/*@unused@*/ const void * hd, const rpmCallbackType what, const unsigned long amount, const unsigned long total, const void * pkgKey, rpmCallbackData data) - /*@*/ + /*@globals _Py_NoneStruct @*/ + /*@modifies _Py_NoneStruct @*/ { +/*@-castexpose@*/ Header h = (Header) hd; +/*@=castexpose@*/ struct rpmtsCallbackType_s * cbInfo = data; PyObject * pkgObj = (PyObject *) pkgKey; PyObject * args, * result; @@ -1020,8 +1029,7 @@ fprintf(stderr, "\t%ld:%ld key %p\n", amount, total, pkgKey); /** \ingroup python */ static PyObject * rpmts_SetFlags(rpmtsObject * s, PyObject * args) - /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ - /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s @*/ { rpmtransFlags transFlags = 0; @@ -1037,8 +1045,7 @@ fprintf(stderr, "*** rpmts_SetFlags(%p) ts %p transFlags %x\n", s, s->ts, transF /** \ingroup python */ static PyObject * rpmts_SetProbFilter(rpmtsObject * s, PyObject * args) - /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ - /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ + /*@modifies s @*/ { rpmprobFilterFlags ignoreSet = 0; rpmprobFilterFlags oignoreSet; @@ -1125,7 +1132,7 @@ fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet); #if Py_TPFLAGS_HAVE_ITER static PyObject * rpmts_iter(rpmtsObject * s) - /*@modifies s @*/ + /*@*/ { if (_rpmts_debug) fprintf(stderr, "*** rpmts_iter(%p) ts %p\n", s, s->ts); @@ -1140,8 +1147,7 @@ fprintf(stderr, "*** rpmts_iter(%p) ts %p\n", s, s->ts); */ static PyObject * rpmts_iternext(rpmtsObject * s) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@modifies s @*/ { PyObject * result = NULL; rpmte te; @@ -1195,8 +1201,8 @@ fprintf(stderr, "*** rpmts_Next(%p) ts %p\n", s, s->ts); */ static rpmmiObject * rpmts_Match(rpmtsObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies s, _Py_NoneStruct @*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { PyObject *TagN = NULL; char *key = NULL; @@ -1317,20 +1323,19 @@ static struct PyMethodDef rpmts_methods[] = { /** \ingroup python */ -static void rpmts_dealloc(/*@only@*/ PyObject * o) - /*@modifies o @*/ +static void rpmts_dealloc(/*@only@*/ rpmtsObject * s) + /*@modifies *s @*/ { - rpmtsObject * trans = (void *) o; if (_rpmts_debug) -fprintf(stderr, "%p -- ts %p db %p\n", trans, trans->ts, trans->ts->rdb); - rpmtsFree(trans->ts); +fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, s->ts->rdb); + rpmtsFree(s->ts); - if (trans->scriptFd) Fclose(trans->scriptFd); + if (s->scriptFd) Fclose(s->scriptFd); /* this will free the keyList, and decrement the ref count of all the items on the list as well :-) */ - Py_DECREF(trans->keyList); - PyObject_Del(o); + Py_DECREF(s->keyList); + PyObject_Del((PyObject *)s); } /** \ingroup python @@ -1368,7 +1373,8 @@ static int rpmts_setattr(rpmtsObject * o, char * name, PyObject * val) /** \ingroup python */ static int rpmts_init(rpmtsObject * s, PyObject *args, PyObject *kwds) - /*@*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies s, rpmGlobalMacroContext @*/ { char * rootDir = "/"; int vsflags = rpmExpandNumeric("%{?_vsflags_up2date}"); @@ -1392,8 +1398,8 @@ fprintf(stderr, "*** rpmts_init(%p,%p,%p)\n", s, args, kwds); /** \ingroup python */ -static void rpmts_free(rpmtsObject * s) - /*@*/ +static void rpmts_free(/*@only@*/ rpmtsObject * s) + /*@modifies s @*/ { if (_rpmts_debug) fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, s->ts->rdb); @@ -1406,7 +1412,7 @@ fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, s->ts->rdb); the items on the list as well :-) */ Py_DECREF(s->keyList); - _PyObject_GC_Del((PyObject *)s); + PyObject_Del((PyObject *)s); } /** \ingroup python @@ -1424,7 +1430,8 @@ fprintf(stderr, "*** rpmts_alloc(%p,%d) ret %p\n", subtype, nitems, s); /** \ingroup python */ static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) - /*@*/ + /*@globals rpmGlobalMacroContext @*/ + /*@modifies rpmGlobalMacroContext @*/ { rpmtsObject * s = (void *) PyObject_New(rpmtsObject, subtype); @@ -1477,8 +1484,8 @@ PyTypeObject rpmts_Type = { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ - (getiterfunc)rpmts_iter, /* tp_iter */ - (iternextfunc)rpmts_iternext, /* tp_iternext */ + (getiterfunc) rpmts_iter, /* tp_iter */ + (iternextfunc) rpmts_iternext, /* tp_iternext */ rpmts_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ @@ -1508,7 +1515,7 @@ rpmts_Create(/*@unused@*/ PyObject * self, PyObject * args) if (!PyArg_ParseTuple(args, "|si:Create", &rootDir, &vsflags)) return NULL; - o = (void *) PyObject_NEW(rpmtsObject, &rpmts_Type); + o = (void *) PyObject_New(rpmtsObject, &rpmts_Type); o->ts = rpmtsCreate(); (void) rpmtsSetRootDir(o->ts, rootDir); diff --git a/python/rpmts-py.h b/python/rpmts-py.h index 757e89d14..526b83817 100644 --- a/python/rpmts-py.h +++ b/python/rpmts-py.h @@ -27,6 +27,7 @@ enum { }; rpmtsObject * rpmts_Create(PyObject * s, PyObject * args) - /*@*/; + /*@globals rpmGlobalMacroContext @*/ + /*@modifies rpmGlobalMacroContext @*/; #endif |