splint fiddles.
CVS patchset: 5932
CVS date: 2002/12/11 00:12:17
@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
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)
# 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:
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);
/** \ingroup python
*/
static int rpmbc_init(rpmbcObject * s, PyObject *args, PyObject *kwds)
- /*@*/
+ /*@modifies s @*/
{
PyObject * o = NULL;
uint32 words = 0;
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:
/** \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));
*/
static PyObject *
rpmbc_Gcd(/*@unused@*/ rpmbcObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
+ /*@*/
{
PyObject * op1;
PyObject * op2;
*/
static PyObject *
rpmbc_Sqrt(/*@unused@*/ rpmbcObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
+ /*@*/
{
PyObject * op1;
rpmbcObject * a = NULL;
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 *
static int
rpmbc_coerce(PyObject ** pv, PyObject ** pw)
- /*@*/
+ /*@modifies *pv, *pw @*/
{
uint32 words = 0;
long l = 0;
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:
static PyObject *
rpmbc_inplace_add(rpmbcObject * a, rpmbcObject * b)
- /*@*/
+ /*@modifies a @*/
{
uint32 carry;
static PyObject *
rpmbc_inplace_subtract(rpmbcObject * a, rpmbcObject * b)
- /*@*/
+ /*@modifies a @*/
{
uint32 carry;
static PyObject *
rpmbc_inplace_lshift(rpmbcObject * a, rpmbcObject * b)
- /*@*/
+ /*@modifies a @*/
{
uint32 count = 0;
static PyObject *
rpmbc_inplace_rshift(rpmbcObject * a, rpmbcObject * b)
- /*@*/
+ /*@modifies a @*/
{
uint32 count = 0;
*/
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;
*/
static int
rpmdb_length(rpmdbObject * s)
- /*@modifies s @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
rpmdbMatchIterator mi;
int count = 0;
*/
static hdrObject *
rpmdb_subscript(rpmdbObject * s, PyObject * key)
- /*@modifies s @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
int offset;
hdrObject * ho;
static PyObject *
rpmds_iter(rpmdsObject * s)
- /*@modifies s @*/
+ /*@*/
{
Py_INCREF(s);
return (PyObject *)s;
static PyObject *
rpmds_SetNoPromote(rpmdsObject * s, PyObject * args)
- /*@*/
+ /*@modifies s @*/
{
int nopromote;
static PyObject *
rpmds_Notify(rpmdsObject * s, PyObject * args)
- /*@*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies _Py_NoneStruct @*/
{
const char * where;
int rc;
/*@access FD_t @*/
-extern int _rpmio_debug;
+/*@unchecked@*/
+static int _rpmfd_debug = 1;
/** \ingroup python
* \name Class: Rpmfd
/*@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;
}
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;
}
/**
*/
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));
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;
}
if (!fdhead) {
fdhead = fdtail = node;
} else if (fdtail) {
- fdtail->next = node;
+ fdtail->next = node;
} else {
- fdhead = node;
+ fdhead = node;
}
fdtail = node;
/*@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@*/
/* ---------- */
+/** \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@*/
"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 */
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
};
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));
}
#if Py_TPFLAGS_HAVE_ITER
static PyObject *
rpmfi_iter(rpmfiObject * s, /*@unused@*/ PyObject * args)
- /*@modifies s @*/
+ /*@*/
{
Py_INCREF(s);
return (PyObject *)s;
static PyObject *
rpmfi_iternext(rpmfiObject * s)
- /*@modifies s @*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies s, _Py_NoneStruct @*/
{
PyObject * result = NULL;
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 ];
}
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
static PyObject *
rpmfi_Next(rpmfiObject * s, /*@unused@*/ PyObject * args)
- /*@modifies s @*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies s, _Py_NoneStruct @*/
{
PyObject * result = NULL;
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 */
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 */
--- /dev/null
+/** \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;
+}
--- /dev/null
+#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
*/
static PyObject *
rpmmi_iternext(rpmmiObject * s)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
Header h;
*/
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;
*/
static PyObject *
rpmmi_Instance(rpmmiObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@*/
{
int rc = 0;
*/
static PyObject *
rpmmi_Count(rpmmiObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@*/
{
int rc = 0;
*/
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;
/** \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);
}
}
extern PyTypeObject rpmmi_Type;
rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi)
- /*@globals _Py_NoneStruct @*/
- /*@modifies mi, _Py_NoneStruct @*/;
+ /*@*/;
#endif
#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"
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;
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);
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;
#include "debug.h"
+/*@access rpmte @*/
+/*@access fnpyKey @*/
+
/** \ingroup python
* \name Class: Rpmte
* \class Rpmte
static PyObject *
rpmte_Key(rpmteObject * s, PyObject * args)
- /*@*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies _Py_NoneStruct @*/
{
PyObject * Key;
static PyObject *
rpmte_DS(rpmteObject * s, PyObject * args)
- /*@*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies _Py_NoneStruct @*/
{
PyObject * TagN = NULL;
rpmds ds;
static PyObject *
rpmte_FI(rpmteObject * s, PyObject * args)
- /*@*/
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies _Py_NoneStruct @*/
{
PyObject * TagN = NULL;
rpmfi fi;
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))
#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
*/
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;
*/
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;
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;
*/
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;
*/
static PyObject *
rpmts_Order(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@modifies s @*/
{
int rc;
*/
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;
*/
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;
*/
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;
*/
static PyObject *
rpmts_OpenDB(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
if (_rpmts_debug)
*/
static PyObject *
rpmts_CloseDB(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@modifies s @*/
{
int rc;
*/
static PyObject *
rpmts_InitDB(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
int rc;
*/
static PyObject *
rpmts_RebuildDB(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
int rc;
*/
static PyObject *
rpmts_VerifyDB(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
int rc;
*/
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;
*/
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;
*/
static PyObject *
rpmts_SetVSFlags(rpmtsObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@modifies s @*/
{
rpmVSFlags vsflags;
*/
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;
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;
/** \ingroup python
*/
static PyObject * rpmts_SetFlags(rpmtsObject * s, PyObject * args)
- /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
- /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
+ /*@modifies s @*/
{
rpmtransFlags transFlags = 0;
/** \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;
#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);
*/
static PyObject *
rpmts_iternext(rpmtsObject * s)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
+ /*@modifies s @*/
{
PyObject * result = NULL;
rpmte te;
*/
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;
/** \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
/** \ingroup python
*/
static int rpmts_init(rpmtsObject * s, PyObject *args, PyObject *kwds)
- /*@*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies s, rpmGlobalMacroContext @*/
{
char * rootDir = "/";
int vsflags = rpmExpandNumeric("%{?_vsflags_up2date}");
/** \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);
the items on the list as well :-) */
Py_DECREF(s->keyList);
- _PyObject_GC_Del((PyObject *)s);
+ PyObject_Del((PyObject *)s);
}
/** \ingroup python
/** \ingroup python
*/
static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
- /*@*/
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies rpmGlobalMacroContext @*/
{
rpmtsObject * s = (void *) PyObject_New(rpmtsObject, subtype);
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 */
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);
};
rpmtsObject * rpmts_Create(PyObject * s, PyObject * args)
- /*@*/;
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies rpmGlobalMacroContext @*/;
#endif