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