@INCPATH@
noinst_HEADERS = header-py.h \
- rpmal-py.h rpmbc-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h rpmfts-py.h \
- rpmfi-py.h rpmmi-py.h rpmmpw-py.h rpmrc-py.h rpmte-py.h rpmts-py.h
+ rpmbc-py.h rpmmpw-py.h rpmrng-py.h \
+ rpmal-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h rpmfts-py.h \
+ rpmfi-py.h rpmmi-py.h rpmrc-py.h rpmte-py.h rpmts-py.h
mylibs= \
$(top_builddir)/lib/.libs/librpm.so \
noinst_LTLIBRARIES = librpmmodule.la
librpmmodule_la_SOURCES = rpmmodule.c header-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 rpmmpw-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
+ rpmbc-py.c rpmmpw-py.c rpmrng-py.c \
+ rpmal-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)
$(CC) -o $@ $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)
# rpmrc-py.c rpmte-py.c rpmts-py.c
# rpmmodule.c header-py.c
splint_srcs = \
- rpmal-py.c rpmbc-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
- rpmfi-py.c rpmmi-py.c rpmmpw-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
+ rpmbc-py.c rpmmpw-py.c rpmrng-py.c \
+ rpmal-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:
#include "rpmmi-py.h" /* XXX debug only */
#include "rpmmpw-py.h" /* XXX debug only */
#include "rpmrc-py.h" /* XXX debug only */
+#include "rpmrng-py.h" /* XXX debug only */
#include "rpmte-py.h" /* XXX debug only */
#include "rpmts-py.h" /* XXX debug only */
if (o->ob_type == &hdr_Type) return "hdr";
if (o->ob_type == &mpw_Type) return "mpw";
+ if (o->ob_type == &rng_Type) return "rng";
if (o->ob_type == &rpmal_Type) return "rpmal";
if (o->ob_type == &rpmbc_Type) return "rpmbc";
if (o->ob_type == &rpmds_Type) return "rpmds";
#include "header_internal.h"
#include "header-py.h"
-#include "rpmal-py.h"
#include "rpmbc-py.h"
+#include "rpmmpw-py.h"
+#include "rpmrng-py.h"
+
+#include "rpmal-py.h"
#include "rpmds-py.h"
#include "rpmfd-py.h"
#include "rpmfts-py.h"
#include "rpmfi-py.h"
#include "rpmmi-py.h"
-#include "rpmmpw-py.h"
#include "rpmrc-py.h"
#include "rpmte-py.h"
#include "rpmts-py.h"
#if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */
if (PyType_Ready(&hdr_Type) < 0) return;
+ if (PyType_Ready(&mpw_Type) < 0) return;
+ if (PyType_Ready(&rng_Type) < 0) return;
if (PyType_Ready(&rpmal_Type) < 0) return;
if (PyType_Ready(&rpmbc_Type) < 0) return;
if (PyType_Ready(&rpmds_Type) < 0) return;
if (PyType_Ready(&rpmfts_Type) < 0) return;
if (PyType_Ready(&rpmfi_Type) < 0) return;
if (PyType_Ready(&rpmmi_Type) < 0) return;
- if (PyType_Ready(&mpw_Type) < 0) return;
rpmrc_Type.tp_base = &PyDict_Type;
if (PyType_Ready(&rpmrc_Type) < 0) return;
Py_INCREF(&mpw_Type);
PyModule_AddObject(m, "mpw", (PyObject *) &mpw_Type);
+ Py_INCREF(&rng_Type);
+ PyModule_AddObject(m, "rng", (PyObject *) &rng_Type);
+
Py_INCREF(&rpmal_Type);
PyModule_AddObject(m, "al", (PyObject *) &rpmal_Type);
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
#else
hdr_Type.ob_type = &PyType_Type;
+ mpw_Type.ob_type = &PyType_Type;
+ rng_Type.ob_type = &PyType_Type;
rpmal_Type.ob_type = &PyType_Type;
rpmbc_Type.ob_type = &PyType_Type;
rpmds_Type.ob_type = &PyType_Type;
/** \ingroup py_c
- * \file python/mpw-py.c
+ * \file python/rpmmpw-py.c
*/
#include "system.h"
/** \ingroup py_c
*/
-static int mpw_init(mpwObject * z, PyObject *args, PyObject *kwds)
+static int mpw_init(mpwObject * s, PyObject *args, PyObject *kwds)
/*@modifies z @*/
{
PyObject * o = NULL;
if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1;
if (o == NULL) {
- if (z->n.data == NULL)
- mpnsetw(&z->n, 0);
+ if (s->n.data == NULL)
+ mpnsetw(&s->n, 0);
} else if (PyInt_Check(o)) {
l = PyInt_AsLong(o);
words = sizeof(l)/sizeof(words);
} else if (PyString_Check(o)) {
const unsigned char * hex = PyString_AsString(o);
/* XXX TODO: check for hex. */
- mpnsethex(&z->n, hex);
+ mpnsethex(&s->n, hex);
} else if (is_mpw(o)) {
mpwObject *a = (mpwObject *)o;
- mpnsize(&z->n, a->n.size);
+ mpnsize(&s->n, a->n.size);
if (a->n.size > 0)
- mpsetx(z->n.size, z->n.data, a->n.size, a->n.data);
+ mpsetx(s->n.size, s->n.data, a->n.size, a->n.data);
} else {
PyErr_SetString(PyExc_TypeError, "non-numeric coercion failed (mpw_init)");
return -1;
}
if (words > 0) {
- mpnsize(&z->n, words);
+ mpnsize(&s->n, words);
switch (words) {
case 2:
/*@-shiftimplementation @*/
- z->n.data[0] = (l >> 32) & 0xffffffff;
+ s->n.data[0] = (l >> 32) & 0xffffffff;
/*@=shiftimplementation @*/
- z->n.data[1] = (l ) & 0xffffffff;
+ s->n.data[1] = (l ) & 0xffffffff;
break;
case 1:
- z->n.data[0] = (l ) & 0xffffffff;
+ s->n.data[0] = (l ) & 0xffffffff;
break;
}
}
if (_mpw_debug)
-fprintf(stderr, "*** mpw_init(%p[%s],%p[%s],%p[%s]):\t", z, lbl(z), args, lbl(args), kwds, lbl(kwds)), mpprintln(stderr, z->n.size, z->n.data);
+fprintf(stderr, "*** mpw_init(%p[%s],%p[%s],%p[%s]):\t", s, lbl(s), args, lbl(args), kwds, lbl(kwds)), mpprintln(stderr, s->n.size, s->n.data);
return 0;
}
return ns;
}
-static mpwObject *
-mpw_New(void)
+static mpwObject * mpw_New(void)
+ /*@*/
{
mpwObject * ns = PyObject_New(mpwObject, &mpw_Type);
}
/** \ingroup py_c
- * Convert integer to mp.
+ * Convert integer to mpw.
*/
static mpwObject *
mpw_i2mpw(PyObject * o)
+ /*@*/
{
if (is_mpw(o)) {
Py_INCREF(o);
#include "rpmio_internal.h"
/** \ingroup py_c
- * \file python/rpmbc-py.h
+ * \file python/rpmmpw-py.h
*/
/**
--- /dev/null
+/** \ingroup py_c
+ * \file python/rpmrng-py.c
+ */
+
+#include "system.h"
+
+#include "Python.h"
+#ifdef __LCLINT__
+#undef PyObject_HEAD
+#define PyObject_HEAD int _PyObjectHead;
+#endif
+
+#include "rpmrng-py.h"
+
+#include "rpmdebug-py.c"
+
+#include "debug.h"
+
+/*@unchecked@*/
+static int _rng_debug = 0;
+
+#define is_rng(o) ((o)->ob_type == &rng_Type)
+
+/*@unchecked@*/ /*@observer@*/
+static const char initialiser_name[] = "rpm.rng";
+
+/* ---------- */
+
+static void
+rng_dealloc(rngObject * s)
+ /*@modifies s @*/
+{
+if (_rng_debug < -1)
+fprintf(stderr, "*** rng_dealloc(%p)\n", s);
+
+ randomGeneratorContextFree(&s->rngc);
+ PyObject_Del(s);
+}
+
+static int
+rng_print(rngObject * s, FILE * fp, /*@unused@*/ int flags)
+ /*@globals fileSystem @*/
+ /*@modifies fp, fileSystem @*/
+{
+if (_rng_debug < -1)
+fprintf(stderr, "*** rng_print(%p)\n", s);
+ return 0;
+}
+
+/** \ingroup py_c
+ */
+static int rng_init(rngObject * s, PyObject *args, PyObject *kwds)
+ /*@modifies s @*/
+{
+ PyObject * o = NULL;
+
+ if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1;
+
+ if (randomGeneratorContextInit(&s->rngc, randomGeneratorDefault()) != 0)
+ return -1;
+
+if (_rng_debug)
+fprintf(stderr, "*** rng_init(%p[%s],%p[%s],%p[%s])\n", s, lbl(s), args, lbl(args), kwds, lbl(kwds));
+
+ return 0;
+}
+
+/** \ingroup py_c
+ */
+static void rng_free(/*@only@*/ rngObject * s)
+ /*@modifies s @*/
+{
+if (_rng_debug)
+fprintf(stderr, "*** rng_free(%p[%s])\n", s, lbl(s));
+ randomGeneratorContextFree(&s->rngc);
+ PyObject_Del(s);
+}
+
+/** \ingroup py_c
+ */
+static PyObject * rng_alloc(PyTypeObject * subtype, int nitems)
+ /*@*/
+{
+ PyObject * ns = PyType_GenericAlloc(subtype, nitems);
+
+if (_rng_debug)
+fprintf(stderr, "*** rng_alloc(%p[%s},%d) ret %p[%s]\n", subtype, lbl(subtype), nitems, ns, lbl(ns));
+ return (PyObject *) ns;
+}
+
+static PyObject *
+rng_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
+ /*@*/
+{
+ PyObject * ns = (PyObject *) PyObject_New(rngObject, &rng_Type);
+
+if (_rng_debug < -1)
+fprintf(stderr, "*** rng_new(%p[%s],%p[%s],%p[%s]) ret %p[%s]\n", subtype, lbl(subtype), args, lbl(args), kwds, lbl(kwds), ns, lbl(ns));
+ return ns;
+}
+
+static rngObject *
+rng_New(void)
+{
+ rngObject * ns = PyObject_New(rngObject, &rng_Type);
+
+ return ns;
+}
+
+/* ---------- */
+
+/** \ingroup py_c
+ */
+static PyObject *
+rng_Debug(/*@unused@*/ rngObject * s, PyObject * args)
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies _Py_NoneStruct @*/
+{
+ if (!PyArg_ParseTuple(args, "i:Debug", &_rng_debug)) return NULL;
+
+if (_rng_debug < 0)
+fprintf(stderr, "*** rng_Debug(%p)\n", s);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/*@-fullinitblock@*/
+/*@unchecked@*/ /*@observer@*/
+static struct PyMethodDef rng_methods[] = {
+ {"Debug", (PyCFunction)rng_Debug, METH_VARARGS,
+ NULL},
+ {NULL, NULL} /* sentinel */
+};
+/*@=fullinitblock@*/
+
+static PyObject *
+rng_getattr(PyObject * s, char * name)
+ /*@*/
+{
+ return Py_FindMethod(rng_methods, s, name);
+}
+
+/* ---------- */
+
+/**
+ */
+/*@unchecked@*/ /*@observer@*/
+static char rng_doc[] =
+"";
+
+/*@-fullinitblock@*/
+PyTypeObject rng_Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /* ob_size */
+ "rpm.rng", /* tp_name */
+ sizeof(rngObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor) rng_dealloc, /* tp_dealloc */
+ (printfunc) rng_print, /* tp_print */
+ (getattrfunc) rng_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 */
+ rng_doc, /* tp_doc */
+#if Py_TPFLAGS_HAVE_ITER
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc) 0, /* tp_iter */
+ (iternextfunc) 0, /* tp_iternext */
+ rng_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) rng_init, /* tp_init */
+ (allocfunc) rng_alloc, /* tp_alloc */
+ (newfunc) rng_new, /* tp_new */
+ (destructor) rng_free, /* tp_free */
+ 0, /* tp_is_gc */
+#endif
+};
+/*@=fullinitblock@*/
+
+/* ---------- */
--- /dev/null
+#ifndef H_RPMRNG_PY
+#define H_RPMRNG_PY
+
+#include "rpmio_internal.h"
+
+/** \ingroup py_c
+ * \file python/rpmrng-py.h
+ */
+
+/**
+ */
+typedef struct rngObject_s {
+ PyObject_HEAD
+ PyObject *md_dict; /*!< to look like PyModuleObject */
+ randomGeneratorContext rngc;
+} rngObject;
+
+/**
+ */
+/*@unchecked@*/
+extern PyTypeObject rng_Type;
+
+#endif