#![allow(non_camel_case_types)]
#![allow(dead_code)]
extern crate libc;
use libc::{c_int, c_uchar, c_uint, c_void};
#[repr(C)]
pub struct cdb {
pub cdb_fd: c_int,
cdb_fsize: c_uint,
cdb_dend: c_uint,
cdb_mem: *const c_uchar,
cdb_vpos: c_uint,
cdb_vlen: c_uint,
cdb_kpos: c_uint,
cdb_klen: c_uint,
}
impl cdb {
#[inline]
pub fn cdb_datapos(&self) -> c_uint {
self.cdb_vpos
}
#[inline]
pub fn cdb_datalen(&self) -> c_uint {
self.cdb_vlen
}
#[inline]
pub fn cdb_keypos(&self) -> c_uint {
self.cdb_kpos
}
#[inline]
pub fn cdb_keylen(&self) -> c_uint {
self.cdb_klen
}
}
#[repr(C)]
pub struct cdb_find {
cdb_cdbp: *mut cdb,
cdb_hval: c_uint,
cdb_htp: *const c_uchar,
cdb_htab: *const c_uchar,
cdb_htend: *const c_uchar,
cdb_httodo: c_uint,
cdb_key: *const c_void,
cdb_klen: c_uint,
}
#[repr(C)]
pub struct cdb_make {
pub cdb_fd: c_int,
cdb_dpos: c_uint,
cdb_rcnt: c_uint,
cdb_buf: [c_uchar; 4096],
cdb_bpos: *mut c_uchar,
cdb_rec: [*mut c_void; 256],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CdbPutMode {
Add = 0,
Replace = 1,
Insert = 2,
Warn = 3,
Replace0 = 4,
}
#[repr(C)]
pub enum CdbFindMode {
Find = 0, Remove = 1, Fill0 = 4, }
extern "C" {
pub fn cdb_init(cdbp: *mut cdb, fd: c_int) -> c_int;
pub fn cdb_free(cdbp: *mut cdb);
pub fn cdb_read(cdbp: *const cdb, buf: *mut c_void, len: c_uint, pos: c_uint) -> c_int;
pub fn cdb_get(cdbp: *const cdb, len: c_uint, pos: c_uint) -> *const c_void;
pub fn cdb_find(cdbp: *mut cdb, key: *const c_void, klen: c_uint) -> c_int;
pub fn cdb_findinit(cdbfp: *mut cdb_find, cdb: *mut cdb, key: *const c_void, klen: c_uint) -> c_int;
pub fn cdb_findnext(cdbfp: *mut cdb_find) -> c_int;
pub fn cdb_make_start(cdbmp: *mut cdb_make, fd: c_int) -> c_int;
pub fn cdb_make_add(cdbmp: *mut cdb_make, key: *const c_void, klen: c_uint, val: *const c_void, vlen: c_uint) -> c_int;
pub fn cdb_make_exists(cdbmp: *mut cdb_make, key: *const c_void, klen: c_uint) -> c_int;
pub fn cdb_make_find(cdbmp: *mut cdb_make, key: *const c_void, klen: c_uint, mode: CdbFindMode) -> c_int;
pub fn cdb_make_put(cdbmp: *mut cdb_make, key: *const c_void, klen: c_uint, val: *const c_void, vlen: c_uint, mode: CdbPutMode) -> c_int;
pub fn cdb_make_finish(cdbmp: *mut cdb_make) -> c_int;
pub fn cdb_seqnext(cptr: *mut c_uint, cdbp: *mut cdb) -> c_int;
}
pub unsafe fn cdb_seqinit(cptr: *mut c_uint, _cdbp: *mut cdb) {
*cptr = 2048;
}