- Adding support for integer keys in ts.dbMatch().
- Adding readHeaderFromFD(). CVS patchset: 7247 CVS date: 2004/05/04 21:12:04
This commit is contained in:
parent
bd7c49f4e0
commit
96063191fc
|
@ -975,6 +975,49 @@ PyObject * rpmMergeHeadersFromFD(PyObject * self, PyObject * args)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args)
|
||||||
|
{
|
||||||
|
FD_t fd;
|
||||||
|
int fileno;
|
||||||
|
off_t offset;
|
||||||
|
PyObject * tuple;
|
||||||
|
Header h;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "i", &fileno)) return NULL;
|
||||||
|
|
||||||
|
offset = lseek(fileno, 0, SEEK_CUR);
|
||||||
|
|
||||||
|
fd = fdDup(fileno);
|
||||||
|
|
||||||
|
if (!fd) {
|
||||||
|
PyErr_SetFromErrno(pyrpmError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
h = headerRead(fd, HEADER_MAGIC_YES);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
Fclose(fd);
|
||||||
|
|
||||||
|
tuple = PyTuple_New(2);
|
||||||
|
|
||||||
|
if (h && tuple) {
|
||||||
|
PyTuple_SET_ITEM(tuple, 0, (PyObject *) hdr_Wrap(h));
|
||||||
|
PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(offset));
|
||||||
|
h = headerFree(h);
|
||||||
|
} else {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
PyTuple_SET_ITEM(tuple, 0, Py_None);
|
||||||
|
PyTuple_SET_ITEM(tuple, 1, Py_None);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tuple;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
PyObject * versionCompare (PyObject * self, PyObject * args)
|
PyObject * versionCompare (PyObject * self, PyObject * args)
|
||||||
|
|
|
@ -37,6 +37,8 @@ PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args)
|
||||||
/*@*/;
|
/*@*/;
|
||||||
PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args)
|
PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args)
|
||||||
/*@*/;
|
/*@*/;
|
||||||
|
PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args)
|
||||||
|
/*@*/;
|
||||||
PyObject * rpmReadHeaders (FD_t fd)
|
PyObject * rpmReadHeaders (FD_t fd)
|
||||||
/*@*/;
|
/*@*/;
|
||||||
PyObject * rhnLoad(PyObject * self, PyObject * args)
|
PyObject * rhnLoad(PyObject * self, PyObject * args)
|
||||||
|
|
|
@ -139,6 +139,8 @@ static PyMethodDef rpmModuleMethods[] = {
|
||||||
NULL },
|
NULL },
|
||||||
{ "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS,
|
{ "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS,
|
||||||
NULL },
|
NULL },
|
||||||
|
{ "readHeaderFromFD", (PyCFunction) rpmSingleHeaderFromFD, METH_VARARGS,
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ "setLogFile", (PyCFunction) setLogFile, METH_VARARGS,
|
{ "setLogFile", (PyCFunction) setLogFile, METH_VARARGS,
|
||||||
NULL },
|
NULL },
|
||||||
|
@ -433,8 +435,9 @@ void initrpm(void)
|
||||||
REGISTER_ENUM(TR_ADDED);
|
REGISTER_ENUM(TR_ADDED);
|
||||||
REGISTER_ENUM(TR_REMOVED);
|
REGISTER_ENUM(TR_REMOVED);
|
||||||
|
|
||||||
PyDict_SetItemString(d, "RPMAL_NOMATCH", o=PyInt_FromLong( (long)RPMAL_NOMATCH ));
|
REGISTER_ENUM(RPMDBI_PACKAGES);
|
||||||
Py_DECREF(o);
|
|
||||||
|
REGISTER_ENUM(RPMAL_NOMATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
|
@ -1300,14 +1300,16 @@ rpmts_Match(rpmtsObject * s, PyObject * args)
|
||||||
/*@modifies s, rpmGlobalMacroContext @*/
|
/*@modifies s, rpmGlobalMacroContext @*/
|
||||||
{
|
{
|
||||||
PyObject *TagN = NULL;
|
PyObject *TagN = NULL;
|
||||||
|
PyObject *Key = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
long lkey = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int tag = RPMDBI_PACKAGES;
|
int tag = RPMDBI_PACKAGES;
|
||||||
|
|
||||||
if (_rpmts_debug)
|
if (_rpmts_debug)
|
||||||
fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
|
fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|Ozi", &TagN, &key, &len))
|
if (!PyArg_ParseTuple(args, "|OO", &TagN, &Key))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) {
|
if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) {
|
||||||
|
@ -1315,6 +1317,20 @@ fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Key) {
|
||||||
|
if (PyString_Check(Key)) {
|
||||||
|
key = PyString_AsString(Key);
|
||||||
|
len = PyString_Size(Key);
|
||||||
|
} else if (PyInt_Check(Key)) {
|
||||||
|
lkey = PyInt_AsLong(Key);
|
||||||
|
key = (char *)&lkey;
|
||||||
|
len = sizeof(lkey);
|
||||||
|
} else {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "unknown key type");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX If not already opened, open the database O_RDONLY now. */
|
/* XXX If not already opened, open the database O_RDONLY now. */
|
||||||
if (s->ts->rdb == NULL) {
|
if (s->ts->rdb == NULL) {
|
||||||
int rc = rpmtsOpenDB(s->ts, O_RDONLY);
|
int rc = rpmtsOpenDB(s->ts, O_RDONLY);
|
||||||
|
|
Loading…
Reference in New Issue