summaryrefslogtreecommitdiff
path: root/python/rpmmodule.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-12-30 19:01:23 +0000
committerjbj <devnull@localhost>2000-12-30 19:01:23 +0000
commite5899585adb06bc6d934b6a571c6778710a334a6 (patch)
treebd079fb121979a0128b2ab85d0b280a7de108ba0 /python/rpmmodule.c
parent23f9e46a3394fbe6687a1c0446c9a2ae393cc515 (diff)
downloadrpm-e5899585adb06bc6d934b6a571c6778710a334a6.tar.gz
rpm-e5899585adb06bc6d934b6a571c6778710a334a6.tar.bz2
rpm-e5899585adb06bc6d934b6a571c6778710a334a6.zip
- (non-linux): move stubs.c to rpmio (#21132).
- (python): bind initdb (#20988). CVS patchset: 4389 CVS date: 2000/12/30 19:01:23
Diffstat (limited to 'python/rpmmodule.c')
-rw-r--r--python/rpmmodule.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 04558a834..034f62d35 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -60,6 +60,7 @@ void initrpm(void);
/* global module functions */
static PyObject * doAddMacro(PyObject * self, PyObject * args);
static PyObject * doDelMacro(PyObject * self, PyObject * args);
+static PyObject * rpmInitDB(PyObject * self, PyObject * args);
static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args);
static PyObject * hdrLoad(PyObject * self, PyObject * args);
static PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args);
@@ -147,6 +148,7 @@ static PyMethodDef rpmModuleMethods[] = {
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL },
+ { "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL },
{ "rebuilddb", (PyCFunction) rebuildDB, METH_VARARGS, NULL },
{ "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS, NULL },
@@ -526,7 +528,27 @@ static PyObject * findUpgradeSet(PyObject * self, PyObject * args) {
return result;
}
+static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
+ char *root;
+ int forWrite = 0;
+
+ if (!PyArg_ParseTuple(args, "i|s", &forWrite, &root)) return NULL;
+
+ if (rpmdbInit(root, forWrite ? O_RDWR | O_CREAT: O_RDONLY)) {
+ char * errmsg = "cannot initialize database in %s";
+ char * errstr = NULL;
+ int errsize;
+
+ errsize = strlen(errmsg) + strlen(root);
+ errstr = alloca(errsize);
+ snprintf(errstr, errsize, errmsg, root);
+ PyErr_SetString(pyrpmError, errstr);
+ return NULL;
+ }
+ Py_INCREF(Py_None);
+ return(Py_None);
+}
static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) {
rpmdbObject * o;