rpm  5.4.14
rpmal-py.c
Go to the documentation of this file.
1 
5 #include "system.h"
6 
7 #include <rpmio.h> /* XXX rpmRC returns */
8 #include <rpmiotypes.h> /* XXX fnpyKey */
9 #include <rpmtypes.h>
10 #include <rpmtag.h>
11 
12 #include "rpmal-py.h"
13 #include "rpmds-py.h"
14 #include "rpmfi-py.h"
15 
16 #include "debug.h"
17 
18 /*@null@*/
19 static PyObject *
20 rpmal_Add(rpmalObject * s, PyObject * args, PyObject * kwds)
21  /*@modifies s @*/
22 {
23  rpmdsObject * dso;
24  rpmfiObject * fio;
25  PyObject * key;
27  char * kwlist[] = {"packageKey", "key", "dso", "fileInfo", NULL};
28 
29  if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:Add", kwlist,
30  &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio))
31  return NULL;
32 
33  /* XXX errors */
34  /* XXX transaction colors */
35  pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi, 0);
36 
37  return Py_BuildValue("i", pkgKey);
38 }
39 
40 /*@null@*/
41 static PyObject *
42 rpmal_Del(rpmalObject * s, PyObject * args, PyObject * kwds)
43  /*@globals _Py_NoneStruct @*/
44  /*@modifies s, _Py_NoneStruct @*/
45 {
46  alKey pkgKey;
47  char * kwlist[] = {"key", NULL};
48 
49  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Del", kwlist, &pkgKey))
50  return NULL;
51 
52  rpmalDel(s->al, pkgKey);
53 
55  return Py_None;
56 }
57 
58 /*@null@*/
59 static PyObject *
60 rpmal_AddProvides(rpmalObject * s, PyObject * args, PyObject * kwds)
61  /*@globals _Py_NoneStruct @*/
62  /*@modifies s, _Py_NoneStruct @*/
63 {
64  rpmdsObject * dso;
65  alKey pkgKey;
66  char * kwlist[] = {"index", "packageIndex", "dso", NULL};
67 
68  /* XXX: why is there an argument listed in the format string that
69  * isn't handled? Is that for transaction color? */
70  if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:AddProvides", kwlist,
71  &pkgKey, &rpmds_Type, &dso))
72  return NULL;
73 
74  /* XXX transaction colors */
75  rpmalAddProvides(s->al, pkgKey, dso->ds, 0);
76 
78  return Py_None;
79 }
80 
81 /*@null@*/
82 static PyObject *
83 rpmal_MakeIndex(rpmalObject * s)
84  /*@globals _Py_NoneStruct @*/
85  /*@modifies s, _Py_NoneStruct @*/
86 {
87  rpmalMakeIndex(s->al);
88 
90  return Py_None;
91 }
92 
93 /*@-fullinitblock@*/
94 /*@unchecked@*/ /*@observer@*/
95 static struct PyMethodDef rpmal_methods[] = {
96  {"add", (PyCFunction)rpmal_Add, METH_VARARGS|METH_KEYWORDS,
97  NULL},
98  {"delete", (PyCFunction)rpmal_Del, METH_VARARGS|METH_KEYWORDS,
99  NULL},
100  {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS|METH_KEYWORDS,
101  NULL},
102  {"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_NOARGS,
103  NULL},
104  {NULL, NULL } /* sentinel */
105 };
106 /*@=fullinitblock@*/
107 
108 /* ---------- */
109 
110 static void
111 rpmal_dealloc(rpmalObject * s)
112  /*@modifies s @*/
113 {
114  if (s) {
115  s->al = rpmalFree(s->al);
116  PyObject_Del(s);
117  }
118 }
119 
120 static PyObject * rpmal_getattro(PyObject * o, PyObject * n)
121  /*@*/
122 {
123  return PyObject_GenericGetAttr(o, n);
124 }
125 
126 static int rpmal_setattro(PyObject * o, PyObject * n, PyObject * v)
127  /*@*/
128 {
129  return PyObject_GenericSetAttr(o, n, v);
130 }
131 
134 /*@unchecked@*/ /*@observer@*/
135 static char rpmal_doc[] =
136 "";
137 
138 /*@-fullinitblock@*/
139 /*@unchecked@*/
140 PyTypeObject rpmal_Type = {
141  PyObject_HEAD_INIT(&PyType_Type)
142  0, /* ob_size */
143  "rpm.al", /* tp_name */
144  sizeof(rpmalObject), /* tp_basicsize */
145  0, /* tp_itemsize */
146  /* methods */
147  (destructor) rpmal_dealloc, /* tp_dealloc */
148  (printfunc)0, /* tp_print */
149  (getattrfunc)0, /* tp_getattr */
150  (setattrfunc)0, /* tp_setattr */
151  (cmpfunc)0, /* tp_compare */
152  (reprfunc)0, /* tp_repr */
153  0, /* tp_as_number */
154  0, /* tp_as_sequence */
155  0, /* tp_as_mapping */
156  (hashfunc)0, /* tp_hash */
157  (ternaryfunc)0, /* tp_call */
158  (reprfunc)0, /* tp_str */
159  (getattrofunc) rpmal_getattro, /* tp_getattro */
160  (setattrofunc) rpmal_setattro, /* tp_setattro */
161  0, /* tp_as_buffer */
162  Py_TPFLAGS_DEFAULT, /* tp_flags */
163  rpmal_doc, /* tp_doc */
164 #if Py_TPFLAGS_HAVE_ITER
165  0, /* tp_traverse */
166  0, /* tp_clear */
167  0, /* tp_richcompare */
168  0, /* tp_weaklistoffset */
169  (getiterfunc)0, /* tp_iter */
170  (iternextfunc)0, /* tp_iternext */
171  rpmal_methods, /* tp_methods */
172  0, /* tp_members */
173  0, /* tp_getset */
174  0, /* tp_base */
175  0, /* tp_dict */
176  0, /* tp_descr_get */
177  0, /* tp_descr_set */
178  0, /* tp_dictoffset */
179  0, /* tp_init */
180  0, /* tp_alloc */
181  0, /* tp_new */
182  0, /* tp_free */
183  0, /* tp_is_gc */
184 #endif
185 };
186 /*@=fullinitblock@*/
187 
188 /* ---------- */
189 
190 rpmalObject *
192 {
193  rpmalObject *s = PyObject_New(rpmalObject, &rpmal_Type);
194  if (s == NULL)
195  return NULL;
196  s->al = al;
197  return s;
198 }
alKey pkgKey
Definition: rpmal-py.c:26
char * kwlist[]
Definition: rpmal-py.c:27
struct rpmalObject_s rpmalObject
static PyObject *rpmfiObject * fio
Definition: rpmal-py.c:22
void * alKey
An added/available package retrieval key.
Definition: rpmtypes.h:19
return Py_None
Definition: rpmal-py.c:55
PyTypeObject rpmds_Type
Definition: rpmds-py.c:745
PyObject * args
Definition: rpmts-py.c:200
alKey rpmalAdd(rpmal *alistp, alKey pkgKey, fnpyKey key, rpmds provides, rpmfi fi, rpmuint32_t tscolor)
Add package to available list.
Definition: rpmal.c:222
PyTypeObject rpmfi_Type
Definition: rpmfi-py.c:548
rpmal al
Definition: rpmal-py.h:18
void rpmalAddProvides(rpmal al, alKey pkgKey, rpmds provides, rpmuint32_t tscolor)
Add package provides to available list index.
Definition: rpmal.c:287
Set of available packages, items, and directories.
Definition: rpmal.c:90
key
Definition: macro.c:383
char * o
Definition: macro.c:745
rpmds ds
Definition: rpmds-py.h:20
cbInfo dso
Definition: rpmts-py.c:211
char * n
Definition: macro.c:744
return Py_BuildValue("i", pkgKey)
rpmfi fi
Definition: rpmfi-py.h:20
const char * s
Definition: poptALL.c:734
PyObject_Del(s)
PyTypeObject rpmal_Type
Definition: rpmal-py.c:140
void rpmalDel(rpmal al, alKey pkgKey)
Delete package from available list.
Definition: rpmal.c:201
void rpmalMakeIndex(rpmal al)
Generate index for available list.
Definition: rpmal.c:330
return NULL
Definition: poptALL.c:613
rpmal rpmalFree(rpmal al)
Destroy available list.
static struct PyMethodDef rpmal_methods[]
Definition: rpmal-py.c:95
Py_INCREF(Py_None)
rpmalObject * rpmal_Wrap(rpmal al)
Definition: rpmal-py.c:191