summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--examples/librpm.php6
-rw-r--r--rpminfo.c29
-rw-r--r--tests/008-rpmdbsearch.phpt6
4 files changed, 24 insertions, 23 deletions
diff --git a/README.md b/README.md
index 9f5e430..1615626 100644
--- a/README.md
+++ b/README.md
@@ -108,7 +108,7 @@ Retrieve information from rpm database about installed packages using glob or re
The return value is an array of hash tables, or false if it fails.
$ php -a
- php > print_r(rpmdbsearch("php-pecl-r*", RPM_TAG_NAME, RPM_MATCH_GLOB));
+ php > print_r(rpmdbsearch("php-pecl-r*", RPMTAG_NAME, RPMMIRE_GLOB));
Array
(
[0] => Array
@@ -138,7 +138,7 @@ The return value is an array of hash tables, or false if it fails.
)
$ php -a
- php > print_r(rpmdbsearch("^php-pecl-r", RPM_TAG_NAME, RPM_MATCH_REGEX));
+ php > print_r(rpmdbsearch("^php-pecl-r", RPMTAG_NAME, RPMMIRE_REGEX));
Array
(
[0] => Array
@@ -168,7 +168,7 @@ The return value is an array of hash tables, or false if it fails.
)
$ php -a
- php > print_r(rpmdbsearch(PHP_BINARY, RPM_TAG_INSTFILENAMES));
+ php > print_r(rpmdbsearch(PHP_BINARY, RPMTAG_INSTFILENAMES));
Array
(
[0] => Array
diff --git a/examples/librpm.php b/examples/librpm.php
index 3106b8b..98a7f8d 100644
--- a/examples/librpm.php
+++ b/examples/librpm.php
@@ -137,9 +137,9 @@ class Package extends Common {
**/
function WhatProvides($crit) {
if (file_exists($crit)) {
- $a = \rpmdbsearch($crit, RPM_TAG_INSTFILENAMES);
+ $a = \rpmdbsearch($crit, RPMTAG_INSTFILENAMES);
} else {
- $a = \rpmdbsearch($crit, RPM_TAG_PROVIDES);
+ $a = \rpmdbsearch($crit, RPMTAG_PROVIDES);
}
$r = [];
if (is_array($a)) {
@@ -157,7 +157,7 @@ function WhatProvides($crit) {
* print_r($a[0]->NEVRA);
**/
function WhatRequires($crit) {
- $a = \rpmdbsearch($crit, RPM_TAG_REQUIRES);
+ $a = \rpmdbsearch($crit, RPMTAG_REQUIRES);
$r = [];
if (is_array($a)) {
diff --git a/rpminfo.c b/rpminfo.c
index ffe907a..45c25b5 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -292,7 +292,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_rpmdbsearch, 0, 0, 1)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO()
-/* {{{ proto array rpmdbsearch(string pattern [, integer tag_name = RPM_TAG_NAME [, integer mode]])
+/* {{{ proto array rpmdbsearch(string pattern [, integer tag_name = RPMTAG_NAME [, integer mode]])
Search information from installed RPMs */
PHP_FUNCTION(rpmdbsearch)
{
@@ -425,6 +425,9 @@ PHP_FUNCTION(rpmvercmp)
*/
PHP_MINIT_FUNCTION(rpminfo)
{
+ const char *tagname;
+ rpmtd names;
+
REGISTER_STRING_CONSTANT("RPMVERSION", (char *)RPMVERSION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RPMSENSE_ANY", RPMSENSE_ANY, CONST_CS | CONST_PERSISTENT);
@@ -451,19 +454,17 @@ PHP_MINIT_FUNCTION(rpminfo)
REGISTER_LONG_CONSTANT("RPMSENSE_KEYRING", RPMSENSE_KEYRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RPMSENSE_CONFIG", RPMSENSE_CONFIG, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_MATCH_DEFAULT", RPMMIRE_DEFAULT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_MATCH_STRCMP", RPMMIRE_STRCMP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_MATCH_REGEX", RPMMIRE_REGEX, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_MATCH_GLOB", RPMMIRE_GLOB, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("RPM_TAG_NAME", RPMTAG_NAME, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_INSTFILENAMES", RPMTAG_INSTFILENAMES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_REQUIRES", RPMTAG_REQUIRES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_PROVIDES", RPMTAG_PROVIDES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_RECOMMENDS", RPMTAG_RECOMMENDS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_SUGGESTS", RPMTAG_SUGGESTS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_ENHANCES", RPMTAG_ENHANCES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("RPM_TAG_SUPPLEMENTS", RPMTAG_SUPPLEMENTS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("RPMMIRE_DEFAULT", RPMMIRE_DEFAULT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("RPMMIRE_STRCMP", RPMMIRE_STRCMP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("RPMMIRE_REGEX", RPMMIRE_REGEX, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("RPMMIRE_GLOB", RPMMIRE_GLOB, CONST_CS | CONST_PERSISTENT);
+
+ names = rpmtdNew();
+ rpmTagGetNames(names, 1);
+ while ((tagname = rpmtdNextString(names))) {
+ zend_register_long_constant(tagname, strlen(tagname), rpmTagGetValue(tagname+7), CONST_CS | CONST_PERSISTENT, module_number);
+ }
+ rpmtdFree(names);
return SUCCESS;
}
diff --git a/tests/008-rpmdbsearch.phpt b/tests/008-rpmdbsearch.phpt
index 09800a6..28357e0 100644
--- a/tests/008-rpmdbsearch.phpt
+++ b/tests/008-rpmdbsearch.phpt
@@ -4,13 +4,13 @@ Check for rpmdbinfo function
<?php if (!extension_loaded("rpminfo")) print "skip"; ?>
--FILE--
<?php
-$a = rpmdbsearch('php*', RPM_TAG_NAME , RPM_MATCH_GLOB);
+$a = rpmdbsearch('php*', RPMTAG_NAME , RPMMIRE_GLOB);
var_dump(count($a) > 1);
-$a = rpmdbsearch('^php', RPM_TAG_NAME, RPM_MATCH_REGEX);
+$a = rpmdbsearch('^php', RPMTAG_NAME, RPMMIRE_REGEX);
var_dump(count($a) > 1);
-$a = rpmdbsearch(PHP_BINARY, RPM_TAG_INSTFILENAMES);
+$a = rpmdbsearch(PHP_BINARY, RPMTAG_INSTFILENAMES);
var_dump(count($a) == 1);
?>