prefix all struct HDB elements with hdb_

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12880 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2003-09-19 00:25:35 +00:00
parent ef91ed3046
commit 0540f13b86
29 changed files with 372 additions and 385 deletions

View File

@@ -48,11 +48,11 @@ RCSID("$Id$");
static krb5_error_code
DB_close(krb5_context context, HDB *db)
{
DB *d = (DB*)db->db;
DBC *dbcp = (DBC*)db->dbc;
DB *d = (DB*)db->hdb_db;
DBC *dbcp = (DBC*)db->hdb_dbc;
dbcp->c_close(dbcp);
db->dbc = 0;
db->hdb_dbc = 0;
d->close(d, 0);
return 0;
}
@@ -63,7 +63,7 @@ DB_destroy(krb5_context context, HDB *db)
krb5_error_code ret;
ret = hdb_clear_master_key (context, db);
free(db->name);
free(db->hdb_name);
free(db);
return ret;
}
@@ -71,7 +71,7 @@ DB_destroy(krb5_context context, HDB *db)
static krb5_error_code
DB_lock(krb5_context context, HDB *db, int operation)
{
DB *d = (DB*)db->db;
DB *d = (DB*)db->hdb_db;
int fd;
if ((*d->fd)(d, &fd))
return HDB_ERR_CANT_LOCK_DB;
@@ -81,7 +81,7 @@ DB_lock(krb5_context context, HDB *db, int operation)
static krb5_error_code
DB_unlock(krb5_context context, HDB *db)
{
DB *d = (DB*)db->db;
DB *d = (DB*)db->hdb_db;
int fd;
if ((*d->fd)(d, &fd))
return HDB_ERR_CANT_LOCK_DB;
@@ -94,16 +94,16 @@ DB_seq(krb5_context context, HDB *db,
unsigned flags, hdb_entry *entry, int flag)
{
DBT key, value;
DBC *dbcp = db->dbc;
DBC *dbcp = db->hdb_dbc;
krb5_data key_data, data;
int code;
memset(&key, 0, sizeof(DBT));
memset(&value, 0, sizeof(DBT));
if (db->lock(context, db, HDB_RLOCK))
if (db->hdb_lock(context, db, HDB_RLOCK))
return HDB_ERR_DB_INUSE;
code = dbcp->c_get(dbcp, &key, &value, flag);
db->unlock(context, db); /* XXX check value */
db->hdb_unlock(context, db); /* XXX check value */
if (code == DB_NOTFOUND)
return HDB_ERR_NOENTRY;
if (code)
@@ -115,7 +115,7 @@ DB_seq(krb5_context context, HDB *db,
data.length = value.size;
if (hdb_value2entry(context, &data, entry))
return DB_seq(context, db, flags, entry, DB_NEXT);
if (db->master_key_set && (flags & HDB_F_DECRYPT)) {
if (db->hdb_master_key_set && (flags & HDB_F_DECRYPT)) {
code = hdb_unseal_keys (context, db, entry);
if (code)
hdb_free_entry (context, entry);
@@ -153,7 +153,7 @@ DB_rename(krb5_context context, HDB *db, const char *new_name)
int ret;
char *old, *new;
asprintf(&old, "%s.db", db->name);
asprintf(&old, "%s.db", db->hdb_name);
asprintf(&new, "%s.db", new_name);
ret = rename(old, new);
free(old);
@@ -161,15 +161,15 @@ DB_rename(krb5_context context, HDB *db, const char *new_name)
if(ret)
return errno;
free(db->name);
db->name = strdup(new_name);
free(db->hdb_name);
db->hdb_name = strdup(new_name);
return 0;
}
static krb5_error_code
DB__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply)
{
DB *d = (DB*)db->db;
DB *d = (DB*)db->hdb_db;
DBT k, v;
int code;
@@ -178,10 +178,10 @@ DB__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply)
k.data = key.data;
k.size = key.length;
k.flags = 0;
if ((code = db->lock(context, db, HDB_RLOCK)))
if ((code = db->hdb_lock(context, db, HDB_RLOCK)))
return code;
code = d->get(d, NULL, &k, &v, 0);
db->unlock(context, db);
db->hdb_unlock(context, db);
if(code == DB_NOTFOUND)
return HDB_ERR_NOENTRY;
if(code)
@@ -195,7 +195,7 @@ static krb5_error_code
DB__put(krb5_context context, HDB *db, int replace,
krb5_data key, krb5_data value)
{
DB *d = (DB*)db->db;
DB *d = (DB*)db->hdb_db;
DBT k, v;
int code;
@@ -207,10 +207,10 @@ DB__put(krb5_context context, HDB *db, int replace,
v.data = value.data;
v.size = value.length;
v.flags = 0;
if ((code = db->lock(context, db, HDB_WLOCK)))
if ((code = db->hdb_lock(context, db, HDB_WLOCK)))
return code;
code = d->put(d, NULL, &k, &v, replace ? 0 : DB_NOOVERWRITE);
db->unlock(context, db);
db->hdb_unlock(context, db);
if(code == DB_KEYEXIST)
return HDB_ERR_EXISTS;
if(code)
@@ -221,18 +221,18 @@ DB__put(krb5_context context, HDB *db, int replace,
static krb5_error_code
DB__del(krb5_context context, HDB *db, krb5_data key)
{
DB *d = (DB*)db->db;
DB *d = (DB*)db->hdb_db;
DBT k;
krb5_error_code code;
memset(&k, 0, sizeof(DBT));
k.data = key.data;
k.size = key.length;
k.flags = 0;
code = db->lock(context, db, HDB_WLOCK);
code = db->hdb_lock(context, db, HDB_WLOCK);
if(code)
return code;
code = d->del(d, NULL, &k, 0);
db->unlock(context, db);
db->hdb_unlock(context, db);
if(code == DB_NOTFOUND)
return HDB_ERR_NOENTRY;
if(code)
@@ -260,34 +260,34 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
if (flags & O_TRUNC)
myflags |= DB_TRUNCATE;
asprintf(&fn, "%s.db", db->name);
asprintf(&fn, "%s.db", db->hdb_name);
if (fn == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
}
db_create(&d, NULL, 0);
db->db = d;
db->hdb_db = d;
#if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0)
if ((ret = d->open(db->db, NULL, fn, NULL, DB_BTREE, myflags, mode))) {
if ((ret = d->open(db->hdb_db, NULL, fn, NULL, DB_BTREE, myflags, mode))) {
#else
if ((ret = d->open(db->db, fn, NULL, DB_BTREE, myflags, mode))) {
if ((ret = d->open(db->hdb_db, fn, NULL, DB_BTREE, myflags, mode))) {
#endif
if(ret == ENOENT)
/* try to open without .db extension */
#if (DB_VERSION_MAJOR > 3) && (DB_VERSION_MINOR > 0)
if (d->open(db->db, NULL, db->name, NULL, DB_BTREE, myflags, mode)) {
if (d->open(db->hdb_db, NULL, db->hdb_name, NULL, DB_BTREE, myflags, mode)) {
#else
if (d->open(db->db, db->name, NULL, DB_BTREE, myflags, mode)) {
if (d->open(db->hdb_db, db->hdb_name, NULL, DB_BTREE, myflags, mode)) {
#endif
free(fn);
krb5_set_error_string(context, "opening %s: %s",
db->name, strerror(ret));
db->hdb_name, strerror(ret));
return ret;
}
}
free(fn);
ret = d->cursor(d, NULL, (DBC **)&db->dbc, 0);
ret = d->cursor(d, NULL, (DBC **)&db->hdb_dbc, 0);
if (ret) {
krb5_set_error_string(context, "d->cursor: %s", strerror(ret));
return ret;
@@ -312,30 +312,30 @@ hdb_db_create(krb5_context context, HDB **db,
return ENOMEM;
}
(*db)->db = NULL;
(*db)->name = strdup(filename);
if ((*db)->name == NULL) {
(*db)->hdb_db = NULL;
(*db)->hdb_name = strdup(filename);
if ((*db)->hdb_name == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
free(*db);
*db = NULL;
return ENOMEM;
}
(*db)->master_key_set = 0;
(*db)->openp = 0;
(*db)->open = DB_open;
(*db)->close = DB_close;
(*db)->fetch = _hdb_fetch;
(*db)->store = _hdb_store;
(*db)->remove = _hdb_remove;
(*db)->firstkey = DB_firstkey;
(*db)->nextkey= DB_nextkey;
(*db)->lock = DB_lock;
(*db)->unlock = DB_unlock;
(*db)->rename = DB_rename;
(*db)->_get = DB__get;
(*db)->_put = DB__put;
(*db)->_del = DB__del;
(*db)->destroy = DB_destroy;
(*db)->hdb_master_key_set = 0;
(*db)->hdb_openp = 0;
(*db)->hdb_open = DB_open;
(*db)->hdb_close = DB_close;
(*db)->hdb_fetch = _hdb_fetch;
(*db)->hdb_store = _hdb_store;
(*db)->hdb_remove = _hdb_remove;
(*db)->hdb_firstkey = DB_firstkey;
(*db)->hdb_nextkey= DB_nextkey;
(*db)->hdb_lock = DB_lock;
(*db)->hdb_unlock = DB_unlock;
(*db)->hdb_rename = DB_rename;
(*db)->hdb__get = DB__get;
(*db)->hdb__put = DB__put;
(*db)->hdb__del = DB__del;
(*db)->hdb_destroy = DB_destroy;
return 0;
}
#endif /* HAVE_DB3 */