summaryrefslogtreecommitdiff
path: root/lib/db3.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-03-27 15:55:07 +0000
committerjbj <devnull@localhost>2000-03-27 15:55:07 +0000
commit353a2811a4173728aae666217dde44880654531d (patch)
tree8cd356324e5dd5e58042e27ef0a1e33d5ec6bed5 /lib/db3.c
parent62381feb62bc1980a24069386060bad917baf901 (diff)
downloadlibrpm-tizen-353a2811a4173728aae666217dde44880654531d.tar.gz
librpm-tizen-353a2811a4173728aae666217dde44880654531d.tar.bz2
librpm-tizen-353a2811a4173728aae666217dde44880654531d.zip
add db3 to the pile, isolate all with incremental link and vectors.
CVS patchset: 3643 CVS date: 2000/03/27 15:55:07
Diffstat (limited to 'lib/db3.c')
-rw-r--r--lib/db3.c128
1 files changed, 67 insertions, 61 deletions
diff --git a/lib/db3.c b/lib/db3.c
index ffd2f44bf..acc8f318d 100644
--- a/lib/db3.c
+++ b/lib/db3.c
@@ -10,8 +10,6 @@ static int _debug = 1;
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
-#include "db3.h"
-
static const char * dberrpfx = "rpmdb";
static int dbcachesize = 1024 * 1024;
static int dbpagesize = 32 * 1024; /* 0 - 64K */
@@ -192,62 +190,8 @@ errxit:
}
#endif /* __USE_DB2 || __USE_DB3 */
-int db3open(dbiIndex dbi)
+static int db3close(dbiIndex dbi, unsigned int flags)
{
- int rc = 0;
-
-#if defined(__USE_DB2) || defined(__USE_DB3)
- char * dbhome = NULL;
- DB * db = NULL;
- DB_ENV * dbenv = NULL;
- void * dbinfo = NULL;
- u_int32_t dbflags;
-
- dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
- ((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
-
- rc = db_init(dbi, dbhome, dbflags, &dbenv, &dbinfo);
-
- if (rc == 0) {
-#if defined(__USE_DB3)
- rc = db_create(&db, dbenv, 0);
- rc = cvtdberr(dbi, "db_create", rc, _debug);
- if (rc == 0) {
- int xx;
- rc = db->open(db, dbi->dbi_file, NULL, dbi_to_dbtype(dbi->dbi_type),
- dbflags, dbi->dbi_perms);
- rc = cvtdberr(dbi, "db->open", rc, _debug);
- xx = db->set_pagesize(db, dbpagesize);
- xx = cvtdberr(dbi, "db->set_pagesize", xx, _debug);
- }
-#else
- rc = db_open(dbi->dbi_file, dbi_to_dbtype(dbi->dbi_type), dbflags,
- dbi->dbi_perms, dbenv, dbinfo, &db);
- rc = cvtdberr(dbi, "db_open", rc, _debug);
-#endif /* __USE_DB3 */
- }
-
- dbi->dbi_db = db;
- dbi->dbi_dbenv = dbenv;
- dbi->dbi_dbinfo = dbinfo;
-
-#else
- dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_flags, dbi->dbi_perms,
- dbi_to_dbtype(dbi->dbi_type), dbi->dbi_openinfo);
-#endif /* __USE_DB2 || __USE_DB3 */
-
- if (rc == 0 && dbi->dbi_db != NULL) {
- rc = 0;
- dbi->dbi_major = DB_VERSION_MAJOR;
- dbi->dbi_minor = DB_VERSION_MINOR;
- dbi->dbi_patch = DB_VERSION_PATCH;
- } else
- rc = 1;
-
- return rc;
-}
-
-int db3close(dbiIndex dbi, unsigned int flags) {
DB * db = GetDB(dbi);
int rc = 0, xx;
@@ -289,7 +233,8 @@ int db3close(dbiIndex dbi, unsigned int flags) {
return rc;
}
-int db3sync(dbiIndex dbi, unsigned int flags) {
+static int db3sync(dbiIndex dbi, unsigned int flags)
+{
DB * db = GetDB(dbi);
int rc;
@@ -303,7 +248,8 @@ int db3sync(dbiIndex dbi, unsigned int flags) {
return rc;
}
-int db3GetFirstKey(dbiIndex dbi, const char ** keyp) {
+static int db3GetFirstKey(dbiIndex dbi, const char ** keyp)
+{
DBT key, data;
DB * db;
int rc, xx;
@@ -349,7 +295,8 @@ int db3GetFirstKey(dbiIndex dbi, const char ** keyp) {
return rc;
}
-int db3SearchIndex(dbiIndex dbi, const char * str, dbiIndexSet * set) {
+static int db3SearchIndex(dbiIndex dbi, const char * str, dbiIndexSet * set)
+{
DBT key, data;
DB * db = GetDB(dbi);
int rc;
@@ -380,7 +327,8 @@ int db3SearchIndex(dbiIndex dbi, const char * str, dbiIndexSet * set) {
}
/*@-compmempass@*/
-int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
+static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
+{
DBT key;
DB * db = GetDB(dbi);
int rc;
@@ -417,4 +365,62 @@ int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
return rc;
}
/*@=compmempass@*/
+
+static int db3open(dbiIndex dbi)
+{
+ int rc = 0;
+
+#if defined(__USE_DB2) || defined(__USE_DB3)
+ char * dbhome = NULL;
+ DB * db = NULL;
+ DB_ENV * dbenv = NULL;
+ void * dbinfo = NULL;
+ u_int32_t dbflags;
+
+ dbflags = ( !(dbi->dbi_flags & O_RDWR) ? DB_RDONLY :
+ ((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
+
+ rc = db_init(dbi, dbhome, dbflags, &dbenv, &dbinfo);
+
+ if (rc == 0) {
+#if defined(__USE_DB3)
+ rc = db_create(&db, dbenv, 0);
+ rc = cvtdberr(dbi, "db_create", rc, _debug);
+ if (rc == 0) {
+ int xx;
+ rc = db->open(db, dbi->dbi_file, NULL, dbi_to_dbtype(dbi->dbi_type),
+ dbflags, dbi->dbi_perms);
+ rc = cvtdberr(dbi, "db->open", rc, _debug);
+ xx = db->set_pagesize(db, dbpagesize);
+ xx = cvtdberr(dbi, "db->set_pagesize", xx, _debug);
+ }
+#else
+ rc = db_open(dbi->dbi_file, dbi_to_dbtype(dbi->dbi_type), dbflags,
+ dbi->dbi_perms, dbenv, dbinfo, &db);
+ rc = cvtdberr(dbi, "db_open", rc, _debug);
+#endif /* __USE_DB3 */
+ }
+
+ dbi->dbi_db = db;
+ dbi->dbi_dbenv = dbenv;
+ dbi->dbi_dbinfo = dbinfo;
+
+#else
+ dbi->dbi_db = dbopen(dbi->dbi_file, dbi->dbi_flags, dbi->dbi_perms,
+ dbi_to_dbtype(dbi->dbi_type), dbi->dbi_openinfo);
+#endif /* __USE_DB2 || __USE_DB3 */
+
+ if (rc == 0 && dbi->dbi_db != NULL)
+ rc = 0;
+ else
+ rc = 1;
+
+ return rc;
+}
+
+struct _dbiVec db3vec = {
+ DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
+ db3open, db3close, db3sync, db3GetFirstKey, db3SearchIndex, db3UpdateIndex
+};
+
#endif /* DB_VERSION_MAJOR == 3 */