Commit be9052ad authored by atsmyles's avatar atsmyles

Initial check-in

This diff is collapsed.
(in-package #:oracle-bdb)
(defstruct (cursor (:constructor nil) (:copier nil)) pointer)
(defmethod initialize-instance ((instance cursor) &key pointer)
(setf (cursor-pointer instance) pointer)
;synonym to db-cursor
(defun cursor (&rest args)
(apply #'db-cursor args))
(defmacro define-cursor-method (name (&rest args) (slot &optional handle-errors) &body body)
`(define-struct-method ,name ,args (,slot __dbc :cstruct-reader cursor-pointer ,@(when handle-errors `(:handle-errors ,handle-errors)))
(define-db-method db-cursor (db &optional txn &rest flags) (cursor t)
(with-foreign-object (result :pointer)
(ff-call :pointer (if txn (txn-pointer txn) (null-pointer))
:pointer result
:uint32 (apply #'logior flags))
(make-instance 'cursor :pointer (mem-aref result :pointer))))
(define-cursor-method cursor-close (cursor) (c_close t)
(define-cursor-method cursor-count (cursor &rest flags) (c_count t)
(with-foreign-object (result :uint32)
(ff-call :pointer result :uint32 (apply #'logior flags))
(mem-aref result :uint32)))
(define-cursor-method cursor-delete (cursor &rest flags) (c_del t)
(ff-call :uint32 (apply #'logior flags)))
(define-cursor-method copy-cursor (cursor &rest flags) (c_dup t)
(with-foreign-object (result :pointer)
(ff-call :pointer result :uint32 (apply #'logior flags))
(make-instance 'cursor :pointer (mem-aref result :pointer))))
(define-cursor-method cursor-get (cursor &optional key data &rest flags) (c_get t)
(unless data (setf data (db-dbt)))
(unless key (setf key (db-dbt)))
(handler-case (ff-call :pointer (dbt-pointer key) :pointer (dbt-pointer data) :uint32 (apply #'logior flags))
(not-found () (values nil nil))
(:no-error (x) (declare (ignore x)) (values data key))))
(define-cursor-method cursor-pget (cursor key &optional data &rest flags &aux (primary (db-dbt))) (c_pget t)
(unless data (setf data (db-dbt)))
(handler-case (ff-call :pointer (dbt-pointer key) :pointer (dbt-pointer primary) :pointer (dbt-pointer data)
:uint32 (apply #'logior flags))
(not-found () (values nil nil nil))
(:no-error (x) (declare (ignore x)) (values data key primary))))
(define-cursor-method cursor-put (cursor key data &rest flags) (c_put t)
(ff-call :pointer (dbt-pointer key) :pointer (dbt-pointer data) :uint32 (apply #'logior flags)))
;These functions are variations of the cursor-get
;TODO add rest of get flag and pget
(defun cursor-get-first (cursor &rest flags)
(cursor-get cursor nil nil (apply #'logior DB_FIRST flags)))
(defun cursor-get-next (cursor &rest flags)
(cursor-get cursor nil nil (apply #'logior DB_NEXT flags)))
(defun cursor-get-last (cursor &rest flags)
(cursor-get cursor nil nil (apply #'logior DB_LAST flags)))
(defun cursor-get-prev (cursor &rest flags)
(cursor-get cursor nil nil (apply #'logior DB_PREV flags)))
(defun cursor-get-current (cursor &rest flags)
(cursor-get cursor nil nil (apply #'logior DB_CURRENT flags)))
(defun cursor-get@ (cursor key &rest flags)
(cursor-get cursor key nil (apply #'logior DB_SET flags)))
(defun cursor-get-both (cursor key data &rest flags)
(cursor-get cursor key data (apply #'logior DB_GET_BOTH flags)))
This diff is collapsed.
(in-package #:oracle-bdb)
;;;; Making the lisp interface to dbt immutable.
(defstruct (dbt (:constructor nil)) pointer)
(defstruct (db-dbt (:constructor nil) (:include dbt)))
(defstruct (data-dbt (:constructor nil) (:include dbt)))
(defstruct (app-dbt (:constructor nil) (:include data-dbt))); used by append_recno function
(defstruct (buffer-dbt (:constructor nil) (:include dbt)))
(defmethod initialize-instance ((instance dbt) &key (offset 0 offset?) (len 0 len?)
(pointer (foreign-alloc '__db_dbt) pointer?) &allow-other-keys)
(setf (dbt-pointer instance) pointer)
(unless pointer?
(with-foreign-slots ((flags doff dlen app_data ulen size data) pointer __db_dbt)
(setf flags (if (or offset? len?) DB_DBT_PARTIAL 0)
doff offset
dlen len
ulen 0
data (null-pointer)
size 0
app_data (null-pointer)))
;(setf app_data (foreign-alloc :uint :initial-element (sb-kernel:get-lisp-obj-address instance)))
(sb-ext:finalize instance
(lambda ()
(foreign-free (foreign-slot-value pointer '__db_dbt 'data))
(foreign-free (foreign-slot-value pointer '__db_dbt 'app_data))
(foreign-free pointer))))
(defmethod initialize-instance ((instance db-dbt) &key &allow-other-keys)
(declare (ignore args))
(let ((instance (call-next-method)))
(with-foreign-slots ((data flags) (dbt-pointer instance) __db_dbt)
(setf flags (logior DB_DBT_MALLOC flags)))
(defmethod initialize-instance ((instance data-dbt) &key bytes &allow-other-keys)
(let ((instance (call-next-method)))
(with-foreign-slots ((data size) (dbt-pointer instance) __db_dbt)
(setf data (foreign-string-alloc bytes)
size (length bytes)))
(defmethod initialize-instance ((instance app-dbt) &key bytes pointer appmalloc &allow-other-keys)
(declare (ignorable bytes))
(with-foreign-slots ((data flags) pointer __db_dbt)
;free the original data
(foreign-free data)
(let ((instance (call-next-method)))
(sb-ext:cancel-finalization instance)
(when appmalloc (setf flags (logior DB_DBT_APPMALLOC flags)))
(defmethod initialize-instance ((instance buffer-dbt) &key size &allow-other-keys)
(let ((instance (call-next-method)))
(with-foreign-slots ((data ulen flags) (dbt-pointer instance) __db_dbt)
(setf data (foreign-alloc :uint8 :initial-element 0 :count size)
ulen size
flags (logior DB_DBT_USERMEM flags))
(defun db-dbt (&optional (offset 0 offset?) (len 0))
(if offset?
(make-instance 'db-dbt :offset offset :len len)
(make-instance 'db-dbt)))
(defun data-dbt (bytes &optional (offset 0 offset?) (len 0))
(if offset?
(make-instance 'data-dbt :bytes bytes :offset offset :len len)
(make-instance 'data-dbt :bytes bytes)))
(defun app-dbt (bytes pointer &optional appmalloc)
(make-instance 'app-dbt :bytes bytes :pointer pointer :appmalloc appmalloc))
(defun buffer-dbt (size &optional (offset 0 offset?) (len 0))
(if offset?
(make-instance 'buffer-dbt :size size :offset offset :len len)
(make-instance 'buffer-dbt :size size)))
(defmacro dbt-slot-function (name slot)
`(defun ,name (dbt) (when dbt (foreign-slot-value (dbt-pointer dbt) '__db_dbt ',slot))))
(defun dbt-data (dbt)
(when dbt
(with-foreign-slots ((data size) (dbt-pointer dbt) __db_dbt)
(byte-vector data size))))
(dbt-slot-function dbt-size size)
(dbt-slot-function dbt-ulen ulen)
(dbt-slot-function dbt-dlen dlen)
(dbt-slot-function dbt-doff doff)
(dbt-slot-function dbt-flags flags)
This diff is collapsed.
(in-package #:oracle-bdb)
(define-condition db-condition () ())
(define-condition db-error (error db-condition)
((code :reader db-error-code :initarg :code))
(:report (lambda (bdb-error stream)
(with-slots (code) bdb-error
(format stream "error-code: ~A~%error-str: ~A"
code (db-error-message bdb-error))))))
(defmacro define-db-error (name code &optional doc)
`(define-condition ,name (db-error)
((code :initform ,code))
,@(when doc `((:documentation ,doc)))))
(define-db-error buffer-small DB_BUFFER_SMALL "User memory too small for return.")
(define-db-error do-not-index DB_DONOTINDEX "\"Null\" return from 2ndary callbk.")
(define-db-error key-empty DB_KEYEMPTY "Key/data deleted or never created.")
(define-db-error key-exist DB_KEYEXIST "The key/data pair already exists.")
(define-db-error lock-deadlock DB_LOCK_DEADLOCK "Deadlock.")
(define-db-error lock-not-granted DB_LOCK_NOTGRANTED "Lock unavailable.")
(define-db-error log-buffer-full DB_LOG_BUFFER_FULL "In-memory log buffer full.")
(define-db-error no-server DB_NOSERVER "Server panic return.")
(define-db-error no-server-home DB_NOSERVER_HOME "Bad home sent to server.")
(define-db-error no-server-id DB_NOSERVER_ID "Bad ID sent to server.")
(define-db-error not-found DB_NOTFOUND "Key/data pair not found (EOF).")
(define-db-error old-version DB_OLD_VERSION "Out-of-date version.")
(define-db-error page-not-found DB_PAGE_NOTFOUND "Requested page not found.")
(define-db-error rep-dup-master DB_REP_DUPMASTER "There are two masters.")
(define-db-error rep-handle-dead DB_REP_HANDLE_DEAD "Rolled back a commit.")
(define-db-error rep-hold-election DB_REP_HOLDELECTION "Time to hold an election.")
(define-db-error rep-ignore DB_REP_IGNORE "This msg should be ignored.")
(define-db-error rep-isperm DB_REP_ISPERM "Cached not written perm written.")
(define-db-error rep-join-failure DB_REP_JOIN_FAILURE "Unable to join replication group.")
(define-db-error rep-lockout DB_REP_LOCKOUT "API/Replication lockout now.")
;TODO this conflicts with the event with same name. Figure out an elegant way to handle it
;(define-db-error rep-new-master DB_REP_NEWMASTER "We have learned of a new master.")
(define-db-error rep-new-site DB_REP_NEWSITE "New site entered system.")
(define-db-error rep-not-perm DB_REP_NOTPERM "Permanent log record not written.")
(define-db-error rep-unavailable DB_REP_UNAVAIL "Site cannot currently be reached.")
(define-db-error run-recovery DB_RUNRECOVERY "Panic return.")
(define-db-error secondary-bad DB_SECONDARY_BAD "Secondary index corrupt.")
(define-db-error verify-bad DB_VERIFY_BAD "Verify failed; bad format.")
(define-db-error version-mismatch DB_VERSION_MISMATCH "Environment version mismatch.")
(defun db-error-type (code)
((eql code DB_BUFFER_SMALL) 'buffer-small)
((eql code DB_DONOTINDEX) 'do-not-index)
((eql code DB_KEYEMPTY) 'key-empty)
((eql code DB_KEYEXIST) 'key-exist)
((eql code DB_LOCK_DEADLOCK) 'lock-deadlock)
((eql code DB_LOCK_NOTGRANTED) 'lock-not-granted)
((eql code DB_LOG_BUFFER_FULL) 'log-buffer-full)
((eql code DB_NOSERVER) 'no-server)
((eql code DB_NOSERVER_HOME) 'no-server-home)
((eql code DB_NOSERVER_ID) 'no-server-id)
((eql code DB_NOTFOUND) 'not-found)
((eql code DB_OLD_VERSION) 'old-version)
((eql code DB_PAGE_NOTFOUND) 'page-not-found)
((eql code DB_REP_DUPMASTER) 'rep-dup-master)
((eql code DB_REP_HANDLE_DEAD) 'rep-handle-dead)
((eql code DB_REP_HOLDELECTION) 'rep-hold-election)
((eql code DB_REP_IGNORE) 'rep-ignore)
((eql code DB_REP_ISPERM) 'rep-isperm)
((eql code DB_REP_JOIN_FAILURE) 'rep-join-failure)
((eql code DB_REP_LOCKOUT) 'rep-lockout)
((eql code DB_REP_NEWMASTER) 'rep-new-master)
((eql code DB_REP_NEWSITE) 'rep-new-site)
((eql code DB_REP_NOTPERM) 'rep-not-perm)
((eql code DB_REP_UNAVAIL) 'rep-unavailable)
((eql code DB_RUNRECOVERY) 'run-recovery)
((eql code DB_SECONDARY_BAD) 'secondary-bad)
((eql code DB_VERIFY_BAD) 'verify-bad)
((eql code DB_VERSION_MISMATCH) 'version-mismatch)
(t 'db-error)))
(defun db-error-message (err)
(db_strerror (db-error-code err)))
(defmacro handle-db-error (&body body)
`(let ((result (progn ,@body)))
(or (zerop result) (error (db-error-type result) :code result))))
(defsystem #:oracle-bdb
:author "Arthur Smyles"
:version "0.1"
:depends-on (:cffi :trivial-garbage)
:components((:file "package")
(:file "cffi-oracle-bdb" :depends-on ("package"))
(:file "error" :depends-on ("cffi-oracle-bdb"))
(:file "dbt" :depends-on ("cffi-oracle-bdb"))
(:file "environment" :depends-on ("cffi-oracle-bdb" "error"))
(:file "transaction" :depends-on ("environment"))
(:file "database" :depends-on ("transaction" "dbt"))
(:file "cursor" :depends-on ("database"))
(:file "utils" :depends-on ("transaction" "cursor"))
(defpackage #:oracle-bdb
(:use #:cffi #:cl)
(:shadow #:close #:open #:abort)
(:nicknames #:bdb)
;verbose flags
(:export #:db-dbt #:data-dbt #:app-dbt #:buffer-dbt #:dbt-data #:dbt-size #:dbt-ulen #:dbt-dlen #:dbt-doff #:dbt-flags)
(:export #:buffer-small #:do-not-index #:key-empty #:key-exist #:lock-deadlock #:lock-not-granted #:log-buffer-full #:no-server #:no-server-home #:no-server-id #:not-found #:old-version #:page-not-found #:rep-dup-master #:rep-handle-dead #:rep-hold-election #:rep-ignore #:rep-isperm #:rep-join-failure #:rep-lockout #:rep-new-master #:rep-new-site #:rep-not-perm #:rep-unavailable #:run-recovery #:secondary-bad #:verify-bad #:version-mismatch #:db-error)
(:export #:cursor #:db-cursor #:cursor-close #:cursor-count #:cursor-delete #:copy-cursor #:cursor-get #:cursor-pget #:cursor-put)
;cursor-get functions
(:export #:cursor-get-first #:cursor-get-next #:cursor-get-prev #:cursor-get-last #:cursor-get-current #:cursor-get@ #:cursor-get-both)
;cursor get flags
;cursor put flags
(:export #:txn #:env-txn-checkpoint #:env-print-txn-stats #:env-timeout #:env-tx-max #:env-tx-timestamp
#:env-txn-begin #:txn-abort #:txn-commit #:txn-discard #:txn-id #:txn-prepare #:txn-name #:txn-timeout)
;transaction flags
(:export #:env #:env-error-fn #:env-message-fn #:env-event-notify #:env-is-alive #:env-current-thread #:env-thread-name #:env-feedback #:db-event #:panic #:rep-client #:rep-master #:rep-new-master #:rep-startup-done #:write-failed #:env-close #:env-db-remove #:env-db-rename #:env-err #:env-errx #:env-fail-check #:env-fileid-reset #:env-home #:env-open-flags #:env-lsn-reset #:env-open #:env-open* #:env-remove #:env-stat-print #:env-app-dispatch #:env-cache-size #:env-add-data-dir #:env-data-dirs #:env-encrypt #:env-encrypt-flags #:env-error-prefix #:env-flags #:env-rpc-server #:env-shm-key #:env-thread-count #:env-timout #:env-temp-dir #:env-verbose)
(:export #:db #:btree #:hash #:recno #:queue #:db-associate-fn #:db-data-compare-fn #:db-feedback #:db-append-recno-fn #:btree-key-compare-fn #:btree-key-prefix-fn #:hash-fn #:db-env #:db-associate #:db-close #:db-delete #:db-fd #:db-get #:db-pget #:db-byteswapped #:db-type #:db-join #:db-key-range #:db-open #:db-open* #:db-name #:db-open-flags #:db-transactional #:db-put #:db-remove #:db-stat-print #:db-sync #:db-truncate #:db-upgrade #:db-cache-size #:db-encrypt #:db-encrypt-flags #:db-error-prefix #:db-lorder #:db-page-size #:btree-min-key #:recno-delim #:db-record-length #:db-pad #:recno-source #:hash-ffactor #:hash-size #:queue-extent-size)
(:export #:with-transaction #:with-cursor))
(in-package #:oracle-bdb)
;load the library
(define-foreign-library oracle-bdb (t "/usr/lib/"))
(load-foreign-library 'oracle-bdb)
;;utility methods used by the other files
;TODO replace with cffi equivalent
(defun byte-vector (pointer size)
(unless (null-pointer-p pointer)
(let ((result (make-array size :element-type '(unsigned-byte 8) :initial-element 0)))
(sb-kernel:copy-ub8-from-system-area pointer 0 result 0 size)
(defmacro define-struct-method (name (&rest args) (slot type &key cstruct-reader handle-errors) &body body)
(let ((ff-call 'ff-call)
(cstruct (if cstruct-reader
(list cstruct-reader (if (atom name)
(first args)
(second args)))
(if (atom name)
(first args)
(second args))))
(cargs (if (atom name) args (list (cdr args) (first args)))))
`(defun ,name ,args
(declare (ignorable ,@(remove-if (lambda (x) (member x lambda-list-keywords))
(mapcar (lambda (x) (if (atom x) x (first x))) args))))
(macrolet ((,ff-call (&rest args)
`(,',(if (eq handle-errors t) 'handle-db-error 'progn)
(cffi:foreign-funcall-pointer (cffi:foreign-slot-value ,',cstruct ',',type ',',slot)
(:cconv :cdecl)
:pointer ,',cstruct
,',(case handle-errors
((t) :int)
((nil) :void)
(otherwise handle-errors))))))
(defmacro override (name (&rest args) &body body)
`(let ((super (function ,name)))
(defun ,name ,args
(flet ((call-next-method (&rest args) (apply super args)))
%module "cffi-oracle-bdb"
%insert("lisphead") %{
(in-package #:oracle-bdb)
%insert("swiglisp") %{
%import <sys/types.h>
%insert("swiglisp") %{
;from inttypes.h
%import <inttypes.h>
%insert("swiglisp") %{
;from stdint.h
%import <stdint.h>
%insert("swiglisp") %{
;from stddef.h.h
%import <stddef.h>
%import <stdio.h>
%import <unistd.h>
%import <pthread.h>
%insert("swiglisp") %{
/*Swig doesn't handle these well because they have internal structs and defs */
%ignore __db_txn;
%ignore __db_env;
%ignore __dbc;
%ignore __db;
%ignore __db_ilock;
%include db.h
%include db_txn.i
%include db.i
%include dbc.i
%include db_env.i
%insert("swiglisp") %{
;dbt constants
(cl:defconstant DB_DBT_APPMALLOC #x001 "Callback allocated memory.")
(cl:defconstant DB_DBT_ISSET #x002 "Lower level calls set value.")
(cl:defconstant DB_DBT_MALLOC #x004 "Return in malloc'd memory.")
(cl:defconstant DB_DBT_PARTIAL #x008 "Partial put/get.")
(cl:defconstant DB_DBT_REALLOC #x010 "Return in realloc'd memory.")
(cl:defconstant DB_DBT_USERCOPY #x020 "Use the user-supplied callback.")
(cl:defconstant DB_DBT_USERMEM #x040 "Return in user's memory.")
(cl:defconstant DB_DBT_DUPOK #x080 "Insert if duplicate.")
;;;; Footer functions and declarations
(defctype lisp-object :pointer)
(defmethod translate-to-foreign (value (name (eql 'lisp-object)))
(foreign-alloc :int :initial-element (sb-kernel:get-lisp-obj-address value)))
(defmethod translate-from-foreign (value (name (eql 'lisp-object)))
(sb-kernel:make-lisp-obj (mem-aref value :int)))
swig -cffi -importall -I/usr/include -I/usr/include/linux -I/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include -generate-typedef bdb.i
ex cffi-oracle-bdb.lisp -s << EOF
:/;;;SWIG wrapper code starts here/,/;;;SWIG wrapper code ends here/d
mv cffi-oracle-bdb.lisp ..
#swig -cffi -importall -I/usr/include -I/usr/include/linux -I/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include -generate-typedef -dump_top db.i
#swig -sexp -importall -I/usr/include -I/usr/include/linux -I/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include db2.i
%insert("swiglisp") %{
(cffi:defcstruct __db
(pgsize :unsigned-int)
(db_append_recno :pointer)
(db_feedback :pointer)
(dup_compare :pointer)
(app_private :pointer)
(dbenv :pointer)
(type DBTYPE)
(mpf :pointer)
(mutex :unsigned-int)
(fname :string)
(dname :string)
(open_flags :unsigned-int)
(fileid :uint8 :count #.DB_FILE_ID_LEN)
(adj_fileid :unsigned-int)
(log_filename :pointer)
(meta_pgno :unsigned-int)
(lid :unsigned-int)
(cur_lid :unsigned-int)
(associate_lid :unsigned-int)
(handle_lock __db_lock_u)
(cl_id :unsigned-int)
(timestamp :long)
(fid_gen :unsigned-int)
(my_rskey __db_dbt)
(my_rkey __db_dbt)
(my_rdata __db_dbt)
(saved_open_fhp :pointer)
(dblistlinks __db_dblistlinks)
(free_queue __db_free_queue)
(active_queue __db_active_queue)
(join_queue __db_join_queue)
(s_secondaries __db_s_secondaries)
(s_links __db_s_links)
(s_refcnt :unsigned-int)
(s_callback :pointer)
(s_primary :pointer)
(s_assoc_flags :unsigned-int)
(api_internal :pointer)
(bt_internal :pointer)
(h_internal :pointer)
(q_internal :pointer)
(xa_internal :pointer)
(associate :pointer)
(close :pointer)
(compact :pointer)
(cursor :pointer)
(del :pointer)
(err :pointer)
(errx :pointer)
(fd :pointer)
(get :pointer)
(get_bt_minkey :pointer)
(get_byteswapped :pointer)
(get_cachesize :pointer)
(get_dbname :pointer)
(get_encrypt_flags :pointer)
(get_env :pointer)
(get_errfile :pointer)
(get_errpfx :pointer)
(get_flags :pointer)
(get_h_ffactor :pointer)
(get_h_nelem :pointer)
(get_lorder :pointer)
(get_mpf :pointer)
(get_msgfile :pointer)
(get_open_flags :pointer)
(get_pagesize :pointer)
(get_q_extentsize :pointer)
(get_re_delim :pointer)
(get_re_len :pointer)
(get_re_pad :pointer)
(get_re_source :pointer)
(get_transactional :pointer)
(get_type :pointer)
(join :pointer)
(key_range :pointer)
(open :pointer)
(pget :pointer)
(put :pointer)
(remove :pointer)
(rename :pointer)
(set_alloc :pointer)
(set_append_recno :pointer)
(set_bt_compare :pointer)
(set_bt_minkey :pointer)
(set_bt_prefix :pointer)
(set_cachesize :pointer)
(set_dup_compare :pointer)
(set_encrypt :pointer)
(set_errcall :pointer)
(set_errfile :pointer)
(set_errpfx :pointer)
(set_feedback :pointer)
(set_flags :pointer)
(set_h_ffactor :pointer)
(set_h_hash :pointer)
(set_h_nelem :pointer)
(set_lorder :pointer)
(set_msgcall :pointer)
(set_msgfile :pointer)
(set_pagesize :pointer)
(set_paniccall :pointer)
(set_q_extentsize :pointer)
(set_re_delim :pointer)
(set_re_len :pointer)
(set_re_pad :pointer)
(set_re_source :pointer)
(stat :pointer)
(stat_print :pointer)
(sync :pointer)
(truncate :pointer)
(upgrade :pointer)
(verify :pointer)
(dump :pointer)
(db_am_remove :pointer)
(db_am_rename :pointer)
(stored_get :pointer)
(stored_close :pointer)
(am_ok :unsigned-int)
(preserve_fid :int)
(orig_flags :unsigned-int)
(flags :unsigned-int))
%insert("swiglisp") %{
;verbose constants
(cl:defconstant DB_VERB_DEADLOCK #x0001 "Deadlock detection information.")
(cl:defconstant DB_VERB_RECOVERY #x0002 "Recovery information.")
(cl:defconstant DB_VERB_REGISTER #x0004 "Dump waits-for table.")
(cl:defconstant DB_VERB_REPLICATION #x0008 "Replication information.")
(cl:defconstant DB_VERB_WAITSFOR #x0010 "Dump waits-for table.")
(cffi:defcstruct __db_env
(db_errcall :pointer) (db_errfile :pointer) (db_errpfx :string) (db_msgfile :pointer) (db_msgcall :pointer)
(db_feedback :pointer) (db_paniccall :pointer) (db_event_func :pointer) (db_malloc :pointer) (db_realloc :pointer)
(db_free :pointer) (dbt_usercopy :pointer) (verbose :unsigned-int) (app_private :pointer) (app_dispatch :pointer)
(mutex_align :unsigned-int) (mutex_cnt :unsigned-int) (mutex_inc :unsigned-int) (mutex_tas_spins :unsigned-int)
(mutex_iq :pointer) (mutex_iq_next :unsigned-int) (mutex_iq_max :unsigned-int) (lk_conflicts :pointer)
(lk_modes :int) (lk_max :unsigned-int) (lk_max_lockers :unsigned-int) (lk_max_objects :unsigned-int) (lk_detect :unsigned-int)
(lk_timeout :unsigned-int) (lg_bsize :unsigned-int) (lg_size :unsigned-int) (lg_regionmax :unsigned-int)
(lg_filemode :int) (mp_gbytes :unsigned-int) (mp_bytes :unsigned-int) (mp_ncache :unsigned-int)
(mp_mmapsize :unsigned-int) (mp_maxopenfd :int) (mp_maxwrite :int) (mp_maxwrite_sleep :int) (tx_max :unsigned-int)
(tx_timestamp :long) (tx_timeout :unsigned-int) (thr_nbucket :unsigned-int) (thr_max :unsigned-int) (thr_hashtab :pointer)
(pid_cache :int) (db_home :string) (db_log_dir :string) (db_tmp_dir :string) (db_data_dir :pointer) (data_cnt :int)
(data_next :int) (db_mode :int) (dir_mode :int) (env_lref :pointer) (open_flags :unsigned-int) (reginfo :pointer)
(lockfhp :pointer) (registry :pointer) (registry_off :unsigned-int) (thread_id :pointer) (is_alive :pointer) (thread_id_string :pointer)
(recover_dtab :pointer) (recover_dtab_size :unsigned-int) (cl_handle :pointer) (cl_id :unsigned-int)
(db_ref :int) (shm_key :long) (mtx_dblist :unsigned-int) (dblist __db_env_dblist) (links __db_env_links)
(xa_txn __db_env_xa_txn) (xa_rmid :int) (passwd :string) (passwd_len :pointer) (crypto_handle :pointer)
(mtx_mt :unsigned-int) (mti :int) (mt :pointer) (api1_internal :pointer) (api2_internal :pointer) (lk_handle :pointer)
(lg_handle :pointer) (mp_handle :pointer) (mutex_handle :pointer) (rep_handle :pointer) (tx_handle :pointer)
(cdsgroup_begin :pointer) (close :pointer) (dbremove :pointer) (dbrename :pointer) (err :pointer) (errx :pointer)
(failchk :pointer) (fileid_reset :pointer) (get_cachesize :pointer) (get_data_dirs :pointer) (get_encrypt_flags :pointer)
(get_errfile :pointer) (get_errpfx :pointer) (get_flags :pointer) (get_home :pointer) (get_lg_bsize :pointer)
(get_lg_dir :pointer) (get_lg_filemode :pointer) (get_lg_max :pointer) (get_lg_regionmax :pointer) (get_lk_conflicts :pointer)
(get_lk_detect :pointer) (get_lk_max_lockers :pointer) (get_lk_max_locks :pointer) (get_lk_max_objects :pointer) (get_mp_max_openfd :pointer)
(get_mp_max_write :pointer) (get_mp_mmapsize :pointer) (get_msgfile :pointer) (get_open_flags :pointer) (get_shm_key :pointer)
(get_timeout :pointer) (get_tmp_dir :pointer) (get_tx_max :pointer) (get_tx_timestamp :pointer) (get_verbose :pointer)
(is_bigendian :pointer) (lock_detect :pointer) (lock_get :pointer) (lock_id :pointer) (lock_id_free :pointer)
(lock_put :pointer) (lock_stat :pointer) (lock_stat_print :pointer) (lock_vec :pointer) (log_archive :pointer)
(log_cursor :pointer) (log_file :pointer) (log_flush :pointer) (log_printf :pointer) (log_put :pointer) (log_stat :pointer)
(log_stat_print :pointer) (lsn_reset :pointer) (memp_fcreate :pointer) (memp_register :pointer) (memp_stat :pointer)
(memp_stat_print :pointer) (memp_sync :pointer) (memp_trickle :pointer) (mutex_alloc :pointer) (mutex_free :pointer)
(mutex_get_align :pointer) (mutex_get_increment :pointer) (mutex_get_max :pointer) (mutex_get_tas_spins :pointer)
(mutex_lock :pointer) (mutex_set_align :pointer) (mutex_set_increment :pointer) (mutex_set_max :pointer) (mutex_set_tas_spins :pointer)
(mutex_stat :pointer) (mutex_stat_print :pointer) (mutex_unlock :pointer) (open :pointer) (remove :pointer) (rep_elect :pointer)
(rep_flush :pointer) (rep_get_config :pointer) (rep_get_limit :pointer) (rep_get_nsites :pointer) (rep_get_priority :pointer)
(rep_get_timeout :pointer) (rep_process_message :pointer) (rep_set_config :pointer) (rep_set_limit :pointer) (rep_set_nsites :pointer)
(rep_set_priority :pointer) (rep_set_timeout :pointer) (rep_set_transport :pointer) (rep_start :pointer) (rep_stat :pointer)
(rep_stat_print :pointer) (rep_sync :pointer) (repmgr_add_remote_site :pointer) (repmgr_get_ack_policy :pointer) (repmgr_set_ack_policy :pointer)
(repmgr_set_local_site :pointer) (repmgr_site_list :pointer) (repmgr_start :pointer) (set_alloc :pointer) (set_app_dispatch :pointer)
(set_cachesize :pointer) (set_data_dir :pointer) (set_encrypt :pointer) (set_errcall :pointer) (set_errfile :pointer)
(set_errpfx :pointer) (set_event_notify :pointer) (set_feedback :pointer) (set_flags :pointer) (set_intermediate_dir :pointer)
(set_isalive :pointer) (set_lg_bsize :pointer) (set_lg_dir :pointer) (set_lg_filemode :pointer) (set_lg_max :pointer) (set_lg_regionmax :pointer)
(set_lk_conflicts :pointer) (set_lk_detect :pointer) (set_lk_max_lockers :pointer) (set_lk_max_locks :pointer) (set_lk_max_objects :pointer)
(set_mp_max_openfd :pointer) (set_mp_max_write :pointer) (set_mp_mmapsize :pointer) (set_msgcall :pointer) (set_msgfile :pointer)
(set_paniccall :pointer) (set_rep_request :pointer) (set_rpc_server :pointer) (set_shm_key :pointer) (set_thread_count :pointer)
(set_thread_id :pointer) (set_thread_id_string :pointer) (set_timeout :pointer) (set_tmp_dir :pointer) (set_tx_max :pointer)
(set_tx_timestamp :pointer) (set_verbose :pointer) (stat_print :pointer) (txn_begin :pointer) (txn_checkpoint :pointer)
(txn_recover :pointer) (txn_stat :pointer) (txn_stat_print :pointer) (prdbt :pointer) (test_abort :int) (test_check :int)
(test_copy :int) (flags :unsigned-int))
%insert("swiglisp") %{
(cl:defconstant TXN_CHILDCOMMIT #x0001 " Txn has committed. ")
(cl:defconstant TXN_CDSGROUP #x0002 " CDS group handle. ")
(cl:defconstant TXN_COMPENSATE #x0004 " Compensating transaction. ")
(cl:defconstant TXN_DEADLOCK #x0008 " Txn has deadlocked. ")
(cl:defconstant TXN_LOCKTIMEOUT #x0010 " Txn has a lock timeout. ")
(cl:defconstant TXN_MALLOC #x0020 " Structure allocated by TXN system. ")
(cl:defconstant TXN_NOSYNC #x0040 " Do not sync on prepare and commit. ")
(cl:defconstant TXN_NOWAIT #x0080 " Do not wait on locks. ")
(cl:defconstant TXN_PRIVATE #x0100 " Txn owned by cursor.. ")
(cl:defconstant TXN_READ_COMMITTED #x0200 " Txn has degree 2 isolation. ")
(cl:defconstant TXN_READ_UNCOMMITTED #x0400 " Txn has degree 1 isolation. ")
(cl:defconstant TXN_RESTORED #x0800 " Txn has been restored. ")
(cl:defconstant TXN_SNAPSHOT #x1000 " Snapshot Isolation. ")
(cl:defconstant TXN_SYNC #x2000 " Write and sync on prepare/commit. ")
(cl:defconstant TXN_WRITE_NOSYNC #x4000 " Write only on prepare/commit. ")
(cffi:defcstruct __db_txn
(mgrp :pointer)
(parent :pointer)
(txnid :unsigned-int)
(name :string)
(tid :unsigned-long)
(td :pointer)
(lock_timeout :unsigned-int)
(expire :unsigned-int)
(txn_list :pointer)
(links __db_txn_links)
(xalinks __db_txn_xalinks)
(kids __db_txn_kids)
(events __db_txn_events)
(logs __db_txn_logs)
(klinks __db_txn_klinks)
(api_internal :pointer)
(xml_internal :pointer)
(cursors :unsigned-int)
(abort :pointer)
(commit :pointer)
(discard :pointer)
(get_name :pointer)
(id :pointer)
(prepare :pointer)
(set_name :pointer)
(set_timeout :pointer)
(set_txn_lsnp :pointer)
(flags :unsigned-int))
* Need this file because swig does not handle nested struct defs properly