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( rpmalObject * s, PyObject * args)
00023
00024
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
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
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
00052
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
00068
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
00085
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
00097
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 }
00110 };
00111
00112
00113
00114
00115 static void
00116 rpmal_dealloc(rpmalObject * s)
00117
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
00135 static char rpmal_doc[] =
00136 "";
00137
00138
00139
00140 PyTypeObject rpmal_Type = {
00141 PyObject_HEAD_INIT(&PyType_Type)
00142 0,
00143 "rpm.al",
00144 sizeof(rpmalObject),
00145 0,
00146
00147 (destructor)rpmal_dealloc,
00148 (printfunc)0,
00149 (getattrfunc)rpmal_getattr,
00150 (setattrfunc)0,
00151 (cmpfunc)0,
00152 (reprfunc)0,
00153 0,
00154 0,
00155 0,
00156 (hashfunc)0,
00157 (ternaryfunc)0,
00158 (reprfunc)0,
00159 0,
00160 0,
00161 0,
00162 Py_TPFLAGS_DEFAULT,
00163 rpmal_doc,
00164 #if Py_TPFLAGS_HAVE_ITER
00165 0,
00166 0,
00167 0,
00168 0,
00169 (getiterfunc)0,
00170 (iternextfunc)0,
00171 rpmal_methods,
00172 0,
00173 0,
00174 0,
00175 0,
00176 0,
00177 0,
00178 0,
00179 0,
00180 0,
00181 0,
00182 0,
00183 0,
00184 #endif
00185 };
00186
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 }