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     pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi);
00045 
00046     return Py_BuildValue("i", pkgKey);
00047 }
00048 
00049 static PyObject *
00050 rpmal_Del(rpmalObject * s, PyObject * args)
00051         /*@globals _Py_NoneStruct @*/
00052         /*@modifies s, _Py_NoneStruct @*/
00053 {
00054     alKey pkgKey;
00055 
00056     if (!PyArg_ParseTuple(args, "i:Del", &pkgKey))
00057         return NULL;
00058 
00059     rpmalDel(s->al, pkgKey);
00060 
00061     Py_INCREF(Py_None);
00062     return Py_None;
00063 }
00064 
00065 static PyObject *
00066 rpmal_AddProvides(rpmalObject * s, PyObject * args)
00067         /*@globals _Py_NoneStruct @*/
00068         /*@modifies s, _Py_NoneStruct @*/
00069 {
00070     rpmdsObject * dso;
00071     alKey pkgKey;
00072 
00073     if (!PyArg_ParseTuple(args, "iOO!O!:AddProvides", &pkgKey, &rpmds_Type, &dso))
00074         return NULL;
00075 
00076     rpmalAddProvides(s->al, pkgKey, dso->ds);
00077 
00078     Py_INCREF(Py_None);
00079     return Py_None;
00080 }
00081 
00082 static PyObject *
00083 rpmal_MakeIndex(rpmalObject * s, PyObject * args)
00084         /*@globals _Py_NoneStruct @*/
00085         /*@modifies s, _Py_NoneStruct @*/
00086 {
00087     if (!PyArg_ParseTuple(args, ":MakeIndex"))
00088         return NULL;
00089 
00090     rpmalMakeIndex(s->al);
00091 
00092     Py_INCREF(Py_None);
00093     return Py_None;
00094 }
00095 
00096 /*@-fullinitblock@*/
00097 /*@unchecked@*/ /*@observer@*/
00098 static struct PyMethodDef rpmal_methods[] = {
00099  {"Debug",      (PyCFunction)rpmal_Debug,       METH_VARARGS,
00100         NULL},
00101  {"add",        (PyCFunction)rpmal_Add,         METH_VARARGS,
00102         NULL},
00103  {"delete",     (PyCFunction)rpmal_Del,         METH_VARARGS,
00104         NULL},
00105  {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS,
00106         NULL},
00107  {"makeIndex",(PyCFunction)rpmal_MakeIndex,     METH_VARARGS,
00108         NULL},
00109  {NULL,         NULL }          /* sentinel */
00110 };
00111 /*@=fullinitblock@*/
00112 
00113 /* ---------- */
00114 
00115 static void
00116 rpmal_dealloc(rpmalObject * s)
00117         /*@modifies s @*/
00118 {
00119     if (s) {
00120         s->al = rpmalFree(s->al);
00121         PyMem_DEL(s);
00122     }
00123 }
00124 
00125 static PyObject *
00126 rpmal_getattr(rpmalObject * s, char * name)
00127         /*@*/
00128 {
00129     return Py_FindMethod(rpmal_methods, (PyObject *)s, name);
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)rpmal_getattr,     /* 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         0,                              /* tp_getattro */
00160         0,                              /* 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 }

Generated on Wed Sep 4 12:49:54 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002