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
00016 static PyObject *
00017 rpmal_Debug( rpmalObject * s, PyObject * args)
00018
00019
00020 {
00021 if (!PyArg_ParseTuple(args, "i", &_rpmal_debug)) return NULL;
00022 Py_INCREF(Py_None);
00023 return Py_None;
00024 }
00025
00026
00027 static PyObject *
00028 rpmal_Add(rpmalObject * s, PyObject * args)
00029
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
00040
00041 pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi, 0);
00042
00043 return Py_BuildValue("i", pkgKey);
00044 }
00045
00046
00047 static PyObject *
00048 rpmal_Del(rpmalObject * s, PyObject * args)
00049
00050
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
00064 static PyObject *
00065 rpmal_AddProvides(rpmalObject * s, PyObject * args)
00066
00067
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
00076 rpmalAddProvides(s->al, pkgKey, dso->ds, 0);
00077
00078 Py_INCREF(Py_None);
00079 return Py_None;
00080 }
00081
00082
00083 static PyObject *
00084 rpmal_MakeIndex(rpmalObject * s, PyObject * args)
00085
00086
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
00098
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 }
00111 };
00112
00113
00114
00115
00116 static void
00117 rpmal_dealloc(rpmalObject * s)
00118
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
00141 static char rpmal_doc[] =
00142 "";
00143
00144
00145
00146 PyTypeObject rpmal_Type = {
00147 PyObject_HEAD_INIT(&PyType_Type)
00148 0,
00149 "rpm.al",
00150 sizeof(rpmalObject),
00151 0,
00152
00153 (destructor) rpmal_dealloc,
00154 (printfunc)0,
00155 (getattrfunc)0,
00156 (setattrfunc)0,
00157 (cmpfunc)0,
00158 (reprfunc)0,
00159 0,
00160 0,
00161 0,
00162 (hashfunc)0,
00163 (ternaryfunc)0,
00164 (reprfunc)0,
00165 (getattrofunc) rpmal_getattro,
00166 (setattrofunc) rpmal_setattro,
00167 0,
00168 Py_TPFLAGS_DEFAULT,
00169 rpmal_doc,
00170 #if Py_TPFLAGS_HAVE_ITER
00171 0,
00172 0,
00173 0,
00174 0,
00175 (getiterfunc)0,
00176 (iternextfunc)0,
00177 rpmal_methods,
00178 0,
00179 0,
00180 0,
00181 0,
00182 0,
00183 0,
00184 0,
00185 0,
00186 0,
00187 0,
00188 0,
00189 0,
00190 #endif
00191 };
00192
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 }