12 #define _RPMPS_INTERNAL
14 #include "rpmdebug-py.c"
29 fprintf(stderr,
"*** rpmps_iter(%p)\n", s);
40 PyObject * result = NULL;
43 fprintf(stderr,
"*** rpmps_iternext(%p) ps %p psi %p\n", s, s->
ps, s->
psi);
72 char * kwlist[] = {
"debugLevel", NULL};
74 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"i", kwlist, &
_rpmps_debug))
83 char *pkgNEVR, *altNEVR, *str1;
89 if (!PyArg_ParseTuple(value,
"ssOiisN:rpmps value tuple",
90 &pkgNEVR, &altNEVR, &key,
91 &type, &ignoreProblem, &str1,
96 rpmpsAppend(s->
ps, type, pkgNEVR, key, str1, NULL, altNEVR, ulong1);
105 {
"Debug", (PyCFunction)
rpmps_Debug, METH_VARARGS|METH_KEYWORDS,
107 {
"Append", (PyCFunction)
rpmps_Append, METH_VARARGS|METH_KEYWORDS,
120 fprintf(stderr,
"*** rpmps_dealloc(%p)\n", s);
133 fprintf(stderr,
"*** rpmps_print(%p,%p,%x)\n", s, (
void *)fp, flags);
146 fprintf(stderr,
"*** rpmps_length(%p) rc %d\n", s, rc);
155 PyObject * result = NULL;
160 if (!PyInt_Check(key)) {
162 fprintf(stderr,
"*** rpmps_subscript(%p[%s],%p[%s])\n", s, lbl(s), key, lbl(key));
163 PyErr_SetString(PyExc_TypeError,
"integer expected");
167 ix = (int) PyInt_AsLong(key);
176 fprintf(stderr,
"*** rpmps_subscript(%p,%p) %s\n", s, key, PyString_AsString(result));
184 #define PERMIT_RPMPS_SUBSCRIPT
185 #if defined(PERMIT_RPMPS_SUBSCRIPT)
193 if (!PyArg_Parse(key,
"i:ass_sub", &ix)) {
194 PyErr_SetString(PyExc_TypeError,
"rpmps key type must be integer");
199 if (ix < 0) ix = -ix;
204 fprintf(stderr,
"*** rpmps_ass_sub(%p[%s],%p[%s],%p[%s]) ps %p[%d:%d:%d]\n", s, lbl(s), key, lbl(key), value, lbl(value), ps, ix, ps->numProblems, ps->numProblemsAlloced);
207 if (ix < ps->numProblems) {
210 op->pkgNEVR =
_free(op->pkgNEVR);
211 op->altNEVR =
_free(op->altNEVR);
212 op->str1 =
_free(op->str1);
214 if ((ix+1) == ps->numProblems)
215 memset(op, 0,
sizeof(*op));
217 memmove(op, op+1, (ps->numProblems - ix) *
sizeof(*op));
218 if (ps->numProblems > 0)
223 unsigned long ulong1 = p->ulong1;
225 if (!PyArg_ParseTuple(value,
"ssOiisN:rpmps value tuple",
226 &p->pkgNEVR, &p->altNEVR, &p->key,
227 &p->type, &p->ignoreProblem, &p->str1,
234 if (ix >= ps->numProblems) {
237 p->str1, NULL, p->altNEVR, ulong1);
241 op->pkgNEVR =
_free(op->pkgNEVR);
242 op->altNEVR =
_free(op->altNEVR);
243 op->str1 =
_free(op->str1);
245 p->pkgNEVR = (p->pkgNEVR && *p->pkgNEVR ?
xstrdup(p->pkgNEVR) : NULL);
246 p->altNEVR = (p->altNEVR && *p->altNEVR ?
xstrdup(p->altNEVR) : NULL);
247 p->str1 = (p->str1 && *p->str1 ?
xstrdup(p->str1) : NULL);
261 #if defined(PERMIT_RPMPS_SUBSCRIPT)
271 char * kwlist[] = {NULL};
274 fprintf(stderr,
"*** rpmps_init(%p,%p,%p)\n", s, args, kwds);
276 if (!PyArg_ParseTupleAndKeywords(args, kwds,
":rpmps_init", kwlist))
291 fprintf(stderr,
"%p -- ps %p\n", s, s->
ps);
294 PyObject_Del((PyObject *)s);
302 PyObject * s = PyType_GenericAlloc(subtype, nitems);
305 fprintf(stderr,
"*** rpmps_alloc(%p,%d) ret %p\n", subtype, nitems, s);
312 static PyObject *
rpmps_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
324 fprintf(stderr,
"%p ++ ps %p\n", s, s->
ps);
326 return (PyObject *)s;
337 PyVarObject_HEAD_INIT(&PyType_Type, 0)
354 PyObject_GenericGetAttr,
355 PyObject_GenericSetAttr,
359 #if Py_TPFLAGS_HAVE_ITER
const char * rpmProblemString(const rpmProblem prob)
Return formatted string representation of a problem.
static PyObject * rpmps_iternext(rpmpsObject *s)
void rpmpsAppend(rpmps ps, rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, rpmuint64_t ulong1)
Append a problem to current set of problems.
static PyObject * rpmps_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
char * xstrdup(const char *str)
static PyObject * rpmps_Debug(rpmpsObject *s, PyObject *args, PyObject *kwds)
rpmpsi rpmpsFreeIterator(rpmpsi psi)
Destroy problem set iterator.
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
rpmpsObject * rpmps_Wrap(rpmps ps)
enum rpmProblemType_e rpmProblemType
Enumerate transaction set problem types.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
static int rpmps_Append(rpmpsObject *s, PyObject *value)
static PyObject * rpmps_iter(rpmpsObject *s)
rpmps psFromPs(rpmpsObject *s)
int rpmpsNumProblems(rpmps ps)
Return number of problems in set.
rpmps rpmpsCreate(void)
Create a problem set.
int rpmpsNextIterator(rpmpsi psi)
Return next problem set iterator index.
struct rpmpsObject_s rpmpsObject
static int rpmps_ass_sub(rpmpsObject *s, PyObject *key, PyObject *value)
rpmpsi rpmpsInitIterator(rpmps ps)
Initialize problem set iterator.
static struct PyMethodDef rpmps_methods[]
const char const bson const bson * op
static int rpmps_init(rpmpsObject *s, PyObject *args, PyObject *kwds)
static int rpmps_print(rpmpsObject *s, FILE *fp, int flags)
const char const bson int mongo_write_concern int flags
static PyMappingMethods rpmps_as_mapping
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
static PyObject * rpmps_subscript(rpmpsObject *s, PyObject *key)
const char const bson * key
static void rpmps_dealloc(rpmpsObject *s)
rpmProblem rpmpsProblem(rpmpsi psi)
Return current problem from problem set.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
struct rpmProblem_s * rpmProblem
Raw data for an element of a problem set.
static PyObject * rpmps_alloc(PyTypeObject *subtype, int nitems)
static int rpmps_length(rpmpsObject *s)
static void rpmps_free(rpmpsObject *s)