rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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;
26 alKey pkgKey;
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
54 Py_INCREF(Py_None);
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
77 Py_INCREF(Py_None);
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
89 Py_INCREF(Py_None);
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 *
191 rpmal_Wrap(rpmal al)
192 {
193 rpmalObject *s = PyObject_New(rpmalObject, &rpmal_Type);
194 if (s == NULL)
195 return NULL;
196 s->al = al;
197 return s;
198 }