summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.xml1
-rw-r--r--rpminfo.c8
-rw-r--r--tests/008-rpmdbsearch.phpt12
3 files changed, 18 insertions, 3 deletions
diff --git a/package.xml b/package.xml
index 539e090..af5a4f3 100644
--- a/package.xml
+++ b/package.xml
@@ -28,6 +28,7 @@ Available functions:
<license>PHP 3.01</license>
<notes>
- improve search logic, use index when exists and no search mode
+- add 'full' parameter to rpmdbsearch
</notes>
<contents>
<dir name="/">
diff --git a/rpminfo.c b/rpminfo.c
index 2631a3f..0b18644 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -342,9 +342,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_rpmdbsearch, 0, 0, 1)
ZEND_ARG_INFO(0, pattern)
ZEND_ARG_INFO(0, rpmtag)
ZEND_ARG_INFO(0, rpmmire)
+ ZEND_ARG_INFO(0, full)
ZEND_END_ARG_INFO()
-/* {{{ proto array rpmdbsearch(string pattern [, integer tag_name = RPMTAG_NAME [, integer mode]])
+/* {{{ proto array rpmdbsearch(string pattern [, integer tag_name = RPMTAG_NAME [, integer mode = -1 [, bool full = 0]]])
Search information from installed RPMs */
PHP_FUNCTION(rpmdbsearch)
{
@@ -354,13 +355,14 @@ PHP_FUNCTION(rpmdbsearch)
size_t len;
zend_long crit = RPMTAG_NAME;
zend_long mode = -1;
+ zend_bool full = 0;
Header h;
rpmdb db;
rpmdbMatchIterator di;
int useIndex = 1;
rpmts ts = rpminfo_getts(_RPMVSF_NODIGESTS | _RPMVSF_NOSIGNATURES | RPMVSF_NOHDRCHK);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|ll", &name, &len, &crit, &mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|llb", &name, &len, &crit, &mode, &full) == FAILURE) {
return;
}
@@ -413,7 +415,7 @@ PHP_FUNCTION(rpmdbsearch)
array_init_size(return_value, rpmdbGetIteratorCount(di));
while ((h = rpmdbNextIterator(di)) != NULL) {
zval tmp;
- rpm_header_to_zval(&tmp, h, 0);
+ rpm_header_to_zval(&tmp, h, full);
add_next_index_zval(return_value, &tmp);
}
diff --git a/tests/008-rpmdbsearch.phpt b/tests/008-rpmdbsearch.phpt
index d22a4bd..f348b92 100644
--- a/tests/008-rpmdbsearch.phpt
+++ b/tests/008-rpmdbsearch.phpt
@@ -26,6 +26,13 @@ var_dump($a[0]['Name'] == $phprpm);
echo "Hdrid\n";
$a = rpmdbsearch($p[0]['Sha1header'], RPMTAG_HDRID);
var_dump($a[0]['Name'] == $phprpm);
+var_dump(count($a[0]) < 10);
+
+echo "Hdrid (full)\n";
+$a = rpmdbsearch($p[0]['Sha1header'], RPMTAG_HDRID, -1, true);
+var_dump($a[0]['Name'] == $phprpm);
+var_dump($a[0]['Sha1header'] == $p[0]['Sha1header']);
+var_dump(count($a[0]) > 20);
echo "Installtid\n";
$a = rpmdbsearch($p[0]['Installtid'], RPMTAG_INSTALLTID);
@@ -48,6 +55,11 @@ Pkgid
bool(true)
Hdrid
bool(true)
+bool(true)
+Hdrid (full)
+bool(true)
+bool(true)
+bool(true)
Installtid
bool(true)
Version