rpm 5.2.1

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

- File List
- Globals

python/rpmal-py.c
Go to the documentation of this file.

    00001
    00005 #include "system.h"
    00006
    00007 #include <rpmio.h>              /* XXX rpmRC returns */
    00008 #include <rpmiotypes.h>         /* XXX fnpyKey */
    00009 #include <rpmtypes.h>
    00010 #include <rpmtag.h>
    00011
    00012 #include "rpmal-py.h"
    00013 #include "rpmds-py.h"
    00014 #include "rpmfi-py.h"
    00015
    00016 #include "debug.h"
    00017
    00018 /*@null@*/
    00019 static PyObject *
    00020 rpmal_Add(rpmalObject * s, PyObject * args, PyObject * kwds)
    00021         /*@modifies s @*/
    00022 {
    00023     rpmdsObject * dso;
    00024     rpmfiObject * fio;
    00025     PyObject * key;
    00026     alKey pkgKey;
    00027     char * kwlist[] = {"packageKey", "key", "dso", "fileInfo", NULL};
    00028
    00029     if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:Add", kwlist,
    00030             &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio))
    00031         return NULL;
    00032
    00033     /* XXX errors */
    00034     /* XXX transaction colors */
    00035     pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi, 0);
    00036
    00037     return Py_BuildValue("i", pkgKey);
    00038 }
    00039
    00040 /*@null@*/
    00041 static PyObject *
    00042 rpmal_Del(rpmalObject * s, PyObject * args, PyObject * kwds)
    00043         /*@globals _Py_NoneStruct @*/
    00044         /*@modifies s, _Py_NoneStruct @*/
    00045 {
    00046     alKey pkgKey;
    00047     char * kwlist[] = {"key", NULL};
    00048
    00049     if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Del", kwlist, &pkgKey))
    00050         return NULL;
    00051
    00052     rpmalDel(s->al, pkgKey);
    00053
    00054     Py_INCREF(Py_None);
    00055     return Py_None;
    00056 }
    00057
    00058 /*@null@*/
    00059 static PyObject *
    00060 rpmal_AddProvides(rpmalObject * s, PyObject * args, PyObject * kwds)
    00061         /*@globals _Py_NoneStruct @*/
    00062         /*@modifies s, _Py_NoneStruct @*/
    00063 {
    00064     rpmdsObject * dso;
    00065     alKey pkgKey;
    00066     char * kwlist[] = {"index", "packageIndex", "dso", NULL};
    00067
    00068     /* XXX: why is there an argument listed in the format string that
    00069      *      isn't handled?  Is that for transaction color? */
    00070     if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:AddProvides", kwlist,
    00071             &pkgKey, &rpmds_Type, &dso))
    00072         return NULL;
    00073
    00074     /* XXX transaction colors */
    00075     rpmalAddProvides(s->al, pkgKey, dso->ds, 0);
    00076
    00077     Py_INCREF(Py_None);
    00078     return Py_None;
    00079 }
    00080
    00081 /*@null@*/
    00082 static PyObject *
    00083 rpmal_MakeIndex(rpmalObject * s)
    00084         /*@globals _Py_NoneStruct @*/
    00085         /*@modifies s, _Py_NoneStruct @*/
    00086 {
    00087     rpmalMakeIndex(s->al);
    00088
    00089     Py_INCREF(Py_None);
    00090     return Py_None;
    00091 }
    00092
    00093 /*@-fullinitblock@*/
    00094 /*@unchecked@*/ /*@observer@*/
    00095 static struct PyMethodDef rpmal_methods[] = {
    00096  {"add",        (PyCFunction)rpmal_Add,         METH_VARARGS|METH_KEYWORDS,
    00097         NULL},
    00098  {"delete",     (PyCFunction)rpmal_Del,         METH_VARARGS|METH_KEYWORDS,
    00099         NULL},
    00100  {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS|METH_KEYWORDS,
    00101         NULL},
    00102  {"makeIndex",(PyCFunction)rpmal_MakeIndex,     METH_NOARGS,
    00103         NULL},
    00104  {NULL,         NULL }          /* sentinel */
    00105 };
    00106 /*@=fullinitblock@*/
    00107
    00108 /* ---------- */
    00109
    00110 static void
    00111 rpmal_dealloc(rpmalObject * s)
    00112         /*@modifies s @*/
    00113 {
    00114     if (s) {
    00115         s->al = rpmalFree(s->al);
    00116         PyObject_Del(s);
    00117     }
    00118 }
    00119
    00120 static PyObject * rpmal_getattro(PyObject * o, PyObject * n)
    00121         /*@*/
    00122 {
    00123     return PyObject_GenericGetAttr(o, n);
    00124 }
    00125
    00126 static int rpmal_setattro(PyObject * o, PyObject * n, PyObject * v)
    00127         /*@*/
    00128 {
    00129     return PyObject_GenericSetAttr(o, n, v);
    00130 }
    00131
    00134 /*@unchecked@*/ /*@observer@*/
    00135 static char rpmal_doc[] =
    00136 "";
    00137
    00138 /*@-fullinitblock@*/
    00139 /*@unchecked@*/
    00140 PyTypeObject rpmal_Type = {
    00141         PyObject_HEAD_INIT(&PyType_Type)
    00142         0,                              /* ob_size */
    00143         "rpm.al",                       /* tp_name */
    00144         sizeof(rpmalObject),            /* tp_basicsize */
    00145         0,                              /* tp_itemsize */
    00146         /* methods */
    00147         (destructor) rpmal_dealloc,     /* tp_dealloc */
    00148         (printfunc)0,                   /* tp_print */
    00149         (getattrfunc)0,                 /* tp_getattr */
    00150         (setattrfunc)0,                 /* tp_setattr */
    00151         (cmpfunc)0,                     /* tp_compare */
    00152         (reprfunc)0,                    /* tp_repr */
    00153         0,                              /* tp_as_number */
    00154         0,                              /* tp_as_sequence */
    00155         0,                              /* tp_as_mapping */
    00156         (hashfunc)0,                    /* tp_hash */
    00157         (ternaryfunc)0,                 /* tp_call */
    00158         (reprfunc)0,                    /* tp_str */
    00159         (getattrofunc) rpmal_getattro,  /* tp_getattro */
    00160         (setattrofunc) rpmal_setattro,  /* tp_setattro */
    00161         0,                              /* tp_as_buffer */
    00162         Py_TPFLAGS_DEFAULT,             /* tp_flags */
    00163         rpmal_doc,                      /* tp_doc */
    00164 #if Py_TPFLAGS_HAVE_ITER
    00165         0,                              /* tp_traverse */
    00166         0,                              /* tp_clear */
    00167         0,                              /* tp_richcompare */
    00168         0,                              /* tp_weaklistoffset */
    00169         (getiterfunc)0,                 /* tp_iter */
    00170         (iternextfunc)0,                /* tp_iternext */
    00171         rpmal_methods,                  /* tp_methods */
    00172         0,                              /* tp_members */
    00173         0,                              /* tp_getset */
    00174         0,                              /* tp_base */
    00175         0,                              /* tp_dict */
    00176         0,                              /* tp_descr_get */
    00177         0,                              /* tp_descr_set */
    00178         0,                              /* tp_dictoffset */
    00179         0,                              /* tp_init */
    00180         0,                              /* tp_alloc */
    00181         0,                              /* tp_new */
    00182         0,                              /* tp_free */
    00183         0,                              /* tp_is_gc */
    00184 #endif
    00185 };
    00186 /*@=fullinitblock@*/
    00187
    00188 /* ---------- */
    00189
    00190 rpmalObject *
    00191 rpmal_Wrap(rpmal al)
    00192 {
    00193     rpmalObject *s = PyObject_New(rpmalObject, &rpmal_Type);
    00194     if (s == NULL)
    00195         return NULL;
    00196     s->al = al;
    00197     return s;
    00198 }