summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorgrant <grant@pkgsrc.org>2003-01-07 06:42:28 +0000
committergrant <grant@pkgsrc.org>2003-01-07 06:42:28 +0000
commit6917a552fa7602554020a02bb3370ad378fb926a (patch)
tree2bd8df710cda10c6ba7ad23531c87eb75b7f34ef /pkgtools
parentf5c14886af74640dca7bdda86b3cf5a4a446ee00 (diff)
downloadpkgsrc-6917a552fa7602554020a02bb3370ad378fb926a.tar.gz
sync with src:
In pkgdb_remove(), use the return value from (*db->del), rather than explicitly setting and checking errno. Do some CSE in pkgdb_iter(). Use the db access functions in the proper manner. Also fix some whitespace nits.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/lib/pkgdb.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/pkgtools/pkg_install/files/lib/pkgdb.c b/pkgtools/pkg_install/files/lib/pkgdb.c
index b81d2718857..6d3e0237365 100644
--- a/pkgtools/pkg_install/files/lib/pkgdb.c
+++ b/pkgtools/pkg_install/files/lib/pkgdb.c
@@ -1,9 +1,9 @@
-/* $NetBSD: pkgdb.c,v 1.2 2003/01/06 04:34:17 jschauma Exp $ */
+/* $NetBSD: pkgdb.c,v 1.3 2003/01/07 06:42:28 grant Exp $ */
#if 0
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pkgdb.c,v 1.2 2003/01/06 04:34:17 jschauma Exp $");
+__RCSID("$NetBSD: pkgdb.c,v 1.3 2003/01/07 06:42:28 grant Exp $");
#endif
#endif
@@ -109,7 +109,7 @@ pkgdb_close(void)
{
#if defined(HAVE_DBOPEN)
if (pkgdbp != NULL) {
- (void) (pkgdbp->close) (pkgdbp);
+ (void) (*pkgdbp->close) (pkgdbp);
pkgdbp = NULL;
}
#endif /* HAVE_DBOPEN */
@@ -139,7 +139,7 @@ pkgdb_store(const char *key, const char *val)
if (keyd.size > FILENAME_MAX || vald.size > FILENAME_MAX)
return -1;
- return (pkgdbp->put) (pkgdbp, &keyd, &vald, R_NOOVERWRITE);
+ return (*pkgdbp->put) (pkgdbp, &keyd, &vald, R_NOOVERWRITE);
#else
return 0;
#endif /* HAVE_DBOPEN */
@@ -167,7 +167,7 @@ pkgdb_retrieve(const char *key)
vald.data = (void *)NULL;
vald.size = 0;
- status = (pkgdbp->get) (pkgdbp, &keyd, &vald, 0);
+ status = (*pkgdbp->get) (pkgdbp, &keyd, &vald, 0);
if (status) {
vald.data = NULL;
vald.size = 0;
@@ -191,7 +191,6 @@ pkgdb_remove(const char *key)
{
#if defined(HAVE_DBOPEN)
DBT keyd;
- int status;
if (pkgdbp == NULL)
return -1;
@@ -201,15 +200,7 @@ pkgdb_remove(const char *key)
if (keyd.size > FILENAME_MAX)
return -1;
- errno = 0;
- status = (pkgdbp->del) (pkgdbp, &keyd, 0);
- if (status) {
- if (errno)
- return -1; /* error */
- else
- return 1; /* key not present */
- } else
- return 0; /* everything fine */
+ return (*pkgdbp->del) (pkgdbp, &keyd, 0);
#else
return 0;
#endif /* HAVE_DBOPEN */
@@ -226,17 +217,17 @@ pkgdb_iter(void)
{
#if defined(HAVE_DBOPEN)
DBT key, val;
- int status;
+ int type;
if (pkgdb_iter_flag == 0) {
pkgdb_iter_flag = 1;
-
- status = (pkgdbp->seq) (pkgdbp, &key, &val, R_FIRST);
+ type = R_FIRST;
} else
- status = (pkgdbp->seq) (pkgdbp, &key, &val, R_NEXT);
+ type = R_NEXT;
- if (status)
+ if ((*pkgdbp->seq)(pkgdbp, &key, &val, type) != 0) {
key.data = NULL;
+ }
return (char *) key.data;
#else
@@ -262,7 +253,9 @@ _pkgdb_getPKGDB_DIR(void)
{
char *tmp;
static char *cache = NULL;
+
if (cache == NULL)
cache = (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR;
+
return cache;
}