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

# python/rpmal-py.c

Go to the documentation of this file.

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