Lines Matching full:db
101 #include <db.h>
476 mdb_close(krb5_context context, HDB *db) in mdb_close() argument
478 DB *d = (DB*)db->hdb_db; in mdb_close()
484 mdb_destroy(krb5_context context, HDB *db) in mdb_destroy() argument
488 ret = hdb_clear_master_key (context, db); in mdb_destroy()
489 free(db->hdb_name); in mdb_destroy()
490 free(db); in mdb_destroy()
495 mdb_lock(krb5_context context, HDB *db, int operation) in mdb_lock() argument
497 DB *d = (DB*)db->hdb_db; in mdb_lock()
501 "Can't lock database: %s", db->hdb_name); in mdb_lock()
508 mdb_unlock(krb5_context context, HDB *db) in mdb_unlock() argument
510 DB *d = (DB*)db->hdb_db; in mdb_unlock()
514 "Can't unlock database: %s", db->hdb_name); in mdb_unlock()
522 mdb_seq(krb5_context context, HDB *db, in mdb_seq() argument
525 DB *d = (DB*)db->hdb_db; in mdb_seq()
530 code = db->hdb_lock(context, db, HDB_RLOCK); in mdb_seq()
532 krb5_set_error_message(context, HDB_ERR_DB_INUSE, "Database %s in use", db->hdb_name); in mdb_seq()
536 db->hdb_unlock(context, db); /* XXX check value */ in mdb_seq()
540 db->hdb_name, strerror(code)); in mdb_seq()
555 return mdb_seq(context, db, flags, entry, R_NEXT); in mdb_seq()
557 if (db->hdb_master_key_set && (flags & HDB_F_DECRYPT)) { in mdb_seq()
558 code = hdb_unseal_keys (context, db, &entry->entry); in mdb_seq()
568 mdb_firstkey(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry) in mdb_firstkey() argument
570 return mdb_seq(context, db, flags, entry, R_FIRST); in mdb_firstkey()
575 mdb_nextkey(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry) in mdb_nextkey() argument
577 return mdb_seq(context, db, flags, entry, R_NEXT); in mdb_nextkey()
581 mdb_rename(krb5_context context, HDB *db, const char *new_name) in mdb_rename() argument
586 asprintf(&old, "%s.db", db->hdb_name); in mdb_rename()
587 asprintf(&new, "%s.db", new_name); in mdb_rename()
594 free(db->hdb_name); in mdb_rename()
595 db->hdb_name = strdup(new_name); in mdb_rename()
600 mdb__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply) in mdb__get() argument
602 DB *d = (DB*)db->hdb_db; in mdb__get()
608 code = db->hdb_lock(context, db, HDB_RLOCK); in mdb__get()
612 db->hdb_unlock(context, db); in mdb__get()
616 db->hdb_name, strerror(code)); in mdb__get()
629 mdb__put(krb5_context context, HDB *db, int replace, in mdb__put() argument
632 DB *d = (DB*)db->hdb_db; in mdb__put()
640 code = db->hdb_lock(context, db, HDB_WLOCK); in mdb__put()
644 db->hdb_unlock(context, db); in mdb__put()
648 db->hdb_name, strerror(code)); in mdb__put()
659 mdb__del(krb5_context context, HDB *db, krb5_data key) in mdb__del() argument
661 DB *d = (DB*)db->hdb_db; in mdb__del()
666 code = db->hdb_lock(context, db, HDB_WLOCK); in mdb__del()
670 db->hdb_unlock(context, db); in mdb__del()
674 db->hdb_name, strerror(code)); in mdb__del()
683 mdb_fetch_kvno(krb5_context context, HDB *db, krb5_const_principal principal, in mdb_fetch_kvno() argument
692 code = db->hdb__get(context, db, key, &value); in mdb_fetch_kvno()
701 if (db->hdb_master_key_set && (flags & HDB_F_DECRYPT)) { in mdb_fetch_kvno()
702 code = hdb_unseal_keys (context, db, &entry->entry); in mdb_fetch_kvno()
711 mdb_store(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry) in mdb_store() argument
718 mdb_remove(krb5_context context, HDB *db, krb5_const_principal principal) in mdb_remove() argument
723 code = db->hdb__del(context, db, key); in mdb_remove()
729 mdb_open(krb5_context context, HDB *db, int flags, mode_t mode) in mdb_open() argument
734 asprintf(&fn, "%s.db", db->hdb_name); in mdb_open()
739 db->hdb_db = dbopen(fn, flags, mode, DB_BTREE, NULL); in mdb_open()
742 if (db->hdb_db == NULL) { in mdb_open()
748 db->hdb_db = dbopen(fn, flags, mode, DB_BTREE, NULL); in mdb_open()
752 /* try to open without .db extension */ in mdb_open()
753 if(db->hdb_db == NULL && errno == ENOENT) in mdb_open()
754 db->hdb_db = dbopen(db->hdb_name, flags, mode, DB_BTREE, NULL); in mdb_open()
755 if(db->hdb_db == NULL) { in mdb_open()
758 db->hdb_name, strerror(ret)); in mdb_open()
762 ret = hdb_check_db_format(context, db); in mdb_open()
764 ret = hdb_init_db(context, db); in mdb_open()
770 mdb_close(context, db); in mdb_open()
774 db->hdb_name); in mdb_open()
780 hdb_mdb_create(krb5_context context, HDB **db, in hdb_mdb_create() argument
783 *db = calloc(1, sizeof(**db)); in hdb_mdb_create()
784 if (*db == NULL) { in hdb_mdb_create()
789 (*db)->hdb_db = NULL; in hdb_mdb_create()
790 (*db)->hdb_name = strdup(filename); in hdb_mdb_create()
791 if ((*db)->hdb_name == NULL) { in hdb_mdb_create()
792 free(*db); in hdb_mdb_create()
793 *db = NULL; in hdb_mdb_create()
797 (*db)->hdb_master_key_set = 0; in hdb_mdb_create()
798 (*db)->hdb_openp = 0; in hdb_mdb_create()
799 (*db)->hdb_capability_flags = 0; in hdb_mdb_create()
800 (*db)->hdb_open = mdb_open; in hdb_mdb_create()
801 (*db)->hdb_close = mdb_close; in hdb_mdb_create()
802 (*db)->hdb_fetch_kvno = mdb_fetch_kvno; in hdb_mdb_create()
803 (*db)->hdb_store = mdb_store; in hdb_mdb_create()
804 (*db)->hdb_remove = mdb_remove; in hdb_mdb_create()
805 (*db)->hdb_firstkey = mdb_firstkey; in hdb_mdb_create()
806 (*db)->hdb_nextkey= mdb_nextkey; in hdb_mdb_create()
807 (*db)->hdb_lock = mdb_lock; in hdb_mdb_create()
808 (*db)->hdb_unlock = mdb_unlock; in hdb_mdb_create()
809 (*db)->hdb_rename = mdb_rename; in hdb_mdb_create()
810 (*db)->hdb__get = mdb__get; in hdb_mdb_create()
811 (*db)->hdb__put = mdb__put; in hdb_mdb_create()
812 (*db)->hdb__del = mdb__del; in hdb_mdb_create()
813 (*db)->hdb_destroy = mdb_destroy; in hdb_mdb_create()