rpm  5.4.15
rpmal-py.c
Go to the documentation of this file.
1 
5 #include "system-py.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_RETURN_NONE;
55 }
56 
57 /*@null@*/
58 static PyObject *
59 rpmal_AddProvides(rpmalObject * s, PyObject * args, PyObject * kwds)
60  /*@globals _Py_NoneStruct @*/
61  /*@modifies s, _Py_NoneStruct @*/
62 {
63  rpmdsObject * dso;
64  alKey pkgKey;
65  char * kwlist[] = {"index", "packageIndex", "dso", NULL};
66 
67  /* XXX: why is there an argument listed in the format string that
68  * isn't handled? Is that for transaction color? */
69  if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:AddProvides", kwlist,
70  &pkgKey, &rpmds_Type, &dso))
71  return NULL;
72 
73  /* XXX transaction colors */
74  rpmalAddProvides(s->al, pkgKey, dso->ds, 0);
75 
76  Py_RETURN_NONE;
77 }
78 
79 /*@null@*/
80 static PyObject *
82  /*@globals _Py_NoneStruct @*/
83  /*@modifies s, _Py_NoneStruct @*/
84 {
85  rpmalMakeIndex(s->al);
86 
87  Py_RETURN_NONE;
88 }
89 
90 /*@-fullinitblock@*/
91 /*@unchecked@*/ /*@observer@*/
92 static struct PyMethodDef rpmal_methods[] = {
93  {"add", (PyCFunction)rpmal_Add, METH_VARARGS|METH_KEYWORDS,
94  NULL},
95  {"delete", (PyCFunction)rpmal_Del, METH_VARARGS|METH_KEYWORDS,
96  NULL},
97  {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS|METH_KEYWORDS,
98  NULL},
99  {"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_NOARGS,
100  NULL},
101  {NULL, NULL } /* sentinel */
102 };
103 /*@=fullinitblock@*/
104 
105 /* ---------- */
106 
107 static void
109  /*@modifies s @*/
110 {
111  if (s) {
112  s->al = rpmalFree(s->al);
113  PyObject_Del(s);
114  }
115 }
116 
119 /*@unchecked@*/ /*@observer@*/
120 static char rpmal_doc[] =
121 "";
122 
123 /*@-fullinitblock@*/
124 /*@unchecked@*/
125 PyTypeObject rpmal_Type = {
126  PyVarObject_HEAD_INIT(&PyType_Type, 0)
127  "rpm.al", /* tp_name */
128  sizeof(rpmalObject), /* tp_basicsize */
129  0, /* tp_itemsize */
130  /* methods */
131  (destructor) rpmal_dealloc, /* tp_dealloc */
132  (printfunc)0, /* tp_print */
133  (getattrfunc)0, /* tp_getattr */
134  (setattrfunc)0, /* tp_setattr */
135  (cmpfunc)0, /* tp_compare */
136  (reprfunc)0, /* tp_repr */
137  0, /* tp_as_number */
138  0, /* tp_as_sequence */
139  0, /* tp_as_mapping */
140  (hashfunc)0, /* tp_hash */
141  (ternaryfunc)0, /* tp_call */
142  (reprfunc)0, /* tp_str */
143  PyObject_GenericGetAttr, /* tp_getattro */
144  PyObject_GenericSetAttr, /* tp_setattro */
145  0, /* tp_as_buffer */
146  Py_TPFLAGS_DEFAULT, /* tp_flags */
147  rpmal_doc, /* tp_doc */
148 #if Py_TPFLAGS_HAVE_ITER
149  0, /* tp_traverse */
150  0, /* tp_clear */
151  0, /* tp_richcompare */
152  0, /* tp_weaklistoffset */
153  (getiterfunc)0, /* tp_iter */
154  (iternextfunc)0, /* tp_iternext */
155  rpmal_methods, /* tp_methods */
156  0, /* tp_members */
157  0, /* tp_getset */
158  0, /* tp_base */
159  0, /* tp_dict */
160  0, /* tp_descr_get */
161  0, /* tp_descr_set */
162  0, /* tp_dictoffset */
163  0, /* tp_init */
164  0, /* tp_alloc */
165  0, /* tp_new */
166  0, /* tp_free */
167  0, /* tp_is_gc */
168 #endif
169 };
170 /*@=fullinitblock@*/
171 
172 /* ---------- */
173 
174 rpmalObject *
176 {
177  rpmalObject *s = PyObject_New(rpmalObject, &rpmal_Type);
178  if (s == NULL)
179  return NULL;
180  s->al = al;
181  return s;
182 }
static PyObject * rpmal_AddProvides(rpmalObject *s, PyObject *args, PyObject *kwds)
Definition: rpmal-py.c:59
static PyObject * rpmal_MakeIndex(rpmalObject *s)
Definition: rpmal-py.c:81
PyTypeObject rpmds_Type
Definition: rpmds-py.c:736
static void rpmal_dealloc(rpmalObject *s)
Definition: rpmal-py.c:108
alKey rpmalAdd(rpmal *alistp, alKey pkgKey, fnpyKey key, rpmds provides, rpmfi fi, rpmuint32_t tscolor)
Add package to available list.
Definition: rpmal.c:222
static PyObject * rpmal_Add(rpmalObject *s, PyObject *args, PyObject *kwds)
Definition: rpmal-py.c:20
rpmalObject * rpmal_Wrap(rpmal al)
Definition: rpmal-py.c:175
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
static PyObject * rpmal_Del(rpmalObject *s, PyObject *args, PyObject *kwds)
Definition: rpmal-py.c:42
static char rpmal_doc[]
Definition: rpmal-py.c:120
rpmds ds
Definition: rpmds-py.h:20
void * alKey
An added/available package retrieval key.
Definition: rpmtypes.h:19
PyTypeObject rpmal_Type
Definition: rpmal-py.c:125
PyTypeObject rpmfi_Type
Definition: rpmfi-py.c:531
rpmfi fi
Definition: rpmfi-py.h:20
const char const bson * key
Definition: mongo.h:717
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
rpmal rpmalFree(rpmal al)
Destroy available list.
static struct PyMethodDef rpmal_methods[]
Definition: rpmal-py.c:92
struct rpmalObject_s rpmalObject