Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

python/rpmal-py.c

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

Generated on Sun Oct 26 13:02:02 2003 for rpm by doxygen1.2.18