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

rpmal-py.c

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

Generated on Mon Jun 13 13:44:57 2005 for rpm by  doxygen 1.3.9.1