From db906dee39b83ffc6db249753cc9eda76c0b3f79 Mon Sep 17 00:00:00 2001 From: Cristian Gafton Date: Thu, 16 Sep 1999 21:15:42 +0000 Subject: more meningfull error messgaes --- rpmmodule/rpmmodule.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rpmmodule/rpmmodule.c b/rpmmodule/rpmmodule.c index 6138a4ae4..53022dd2a 100644 --- a/rpmmodule/rpmmodule.c +++ b/rpmmodule/rpmmodule.c @@ -424,9 +424,25 @@ static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) { o = PyObject_NEW(rpmdbObject, &rpmdbType); o->db = NULL; + + /* XXX --gafton + * I would like this root argument to behave like the --dbpath in the plain + * rpm command line. What it does now it re-roots the /var/lib/rpm to whatever + * I am passing on, so if I pass in /ftp/updates/rpmdb/i386 it will end up looking + * for the rpm database in /ftp/updates/rpmdb/i386/var/lib/rpm. + * I'm stuck. + */ if (rpmdbOpen(root, &o->db, forWrite ? O_RDWR | O_CREAT: O_RDONLY, 0)) { + char * errmsg = "cannot open database in %s"; + char * errstr = NULL; + int errsize; + Py_DECREF(o); - PyErr_SetString(pyrpmError, "cannot open database in /var/lib/rpm"); + /* PyErr_SetString should take varargs... */ + errsize = strlen(errmsg) + *root == '\0' ? 15 /* "/var/lib/rpm" */ : strlen(root); + errstr = alloca(errsize); + snprintf(errstr, errsize, errmsg, *root == '\0' ? "/var/lib/rpm" : root); + PyErr_SetString(pyrpmError, errstr); return NULL; } -- cgit