Back to index

openldap  2.4.31
mdb.h
Go to the documentation of this file.
00001 
00063 #ifndef _MDB_H_
00064 #define _MDB_H_
00065 
00066 #include <sys/types.h>
00067 
00075 #define MDB_VERSION_MAJOR   0
00076 
00077 #define MDB_VERSION_MINOR   9
00078 
00079 #define MDB_VERSION_PATCH   0
00080 
00082 #define MDB_VERINT(a,b,c)   (((a) << 24) | ((b) << 16) | (c))
00083 
00085 #define MDB_VERSION_FULL    \
00086        MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
00087 
00089 #define MDB_VERSION_DATE    "September 1, 2011"
00090 
00092 #define MDB_VERSTR(a,b,c,d) "MDB " #a "." #b "." #c ": (" #d ")"
00093 
00095 #define MDB_VERFOO(a,b,c,d) MDB_VERSTR(a,b,c,d)
00096 
00098 #define       MDB_VERSION_STRING   \
00099        MDB_VERFOO(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH,MDB_VERSION_DATE)
00100 
00107 typedef struct MDB_env MDB_env;
00108 
00114 typedef struct MDB_txn MDB_txn;
00115 
00117 typedef unsigned int MDB_dbi;
00118 
00120 typedef struct MDB_cursor MDB_cursor;
00121 
00123 typedef struct MDB_val {
00124        size_t         mv_size;     
00125        void          *mv_data;     
00126 } MDB_val;
00127 
00129 typedef int  (MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
00130 
00145 typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *relctx);
00146 
00151 #define MDB_FIXEDMAP 0x01
00152 
00153 #define MDB_NOSUBDIR 0x02
00154 
00155 #define MDB_NOSYNC          0x10000
00156 
00157 #define MDB_RDONLY          0x20000
00158 
00164 #define MDB_REVERSEKEY      0x02
00165 
00166 #define MDB_DUPSORT         0x04
00167 
00169 #define MDB_INTEGERKEY      0x08
00170 
00171 #define MDB_DUPFIXED 0x10
00172 
00173 #define MDB_INTEGERDUP      0x20
00174 
00175 #define MDB_REVERSEDUP      0x40
00176 
00177 #define MDB_CREATE          0x40000
00178 
00184 #define MDB_NOOVERWRITE     0x10
00185 
00189 #define MDB_NODUPDATA       0x20
00190 
00191 #define MDB_CURRENT  0x40
00192 
00195 #define MDB_RESERVE  0x10000
00196 
00197 #define MDB_APPEND   0x20000
00198 
00199 #define MDB_MULTIPLE 0x40000
00200 /*     @} */
00201 
00207 typedef enum MDB_cursor_op {
00208        MDB_FIRST,                         
00209        MDB_FIRST_DUP,                     
00211        MDB_GET_BOTH,               
00212        MDB_GET_BOTH_RANGE,         
00213        MDB_GET_MULTIPLE,           
00215        MDB_LAST,                          
00216        MDB_LAST_DUP,               
00218        MDB_NEXT,                          
00219        MDB_NEXT_DUP,               
00221        MDB_NEXT_MULTIPLE,          
00223        MDB_NEXT_NODUP,                    
00225        MDB_PREV,                          
00226        MDB_PREV_DUP,               
00228        MDB_PREV_NODUP,                    
00230        MDB_SET,                           
00231        MDB_SET_RANGE               
00232 } MDB_cursor_op;
00233 
00240 #define MDB_SUCCESS   0
00241 
00242 #define MDB_KEYEXIST (-30799)
00243 
00244 #define MDB_NOTFOUND (-30798)
00245 
00246 #define MDB_PAGE_NOTFOUND   (-30797)
00247 
00248 #define MDB_CORRUPTED       (-30796)
00249 
00250 #define MDB_PANIC           (-30795)
00251 
00252 #define MDB_VERSION_MISMATCH       (-30794)
00253 
00256 typedef struct MDB_stat {
00257        unsigned int  ms_psize;                   
00259        unsigned int  ms_depth;                   
00260        size_t        ms_branch_pages;     
00261        size_t        ms_leaf_pages;              
00262        size_t        ms_overflow_pages;   
00263        size_t        ms_entries;                 
00264 } MDB_stat;
00265 
00273 char *mdb_version(int *major, int *minor, int *patch);
00274 
00285 char *mdb_strerror(int err);
00286 
00298 int  mdb_env_create(MDB_env **env);
00299 
00349 int  mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode);
00350 
00357 int  mdb_env_stat(MDB_env *env, MDB_stat *stat);
00358 
00376 int  mdb_env_sync(MDB_env *env, int force);
00377 
00386 void mdb_env_close(MDB_env *env);
00387 
00402 int  mdb_env_set_flags(MDB_env *env, unsigned int flags, int onoff);
00403 
00414 int  mdb_env_get_flags(MDB_env *env, unsigned int *flags);
00415 
00428 int  mdb_env_get_path(MDB_env *env, const char **path);
00429 
00445 int  mdb_env_set_mapsize(MDB_env *env, size_t size);
00446 
00460 int  mdb_env_set_maxreaders(MDB_env *env, unsigned int readers);
00461 
00472 int  mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers);
00473 
00488 int  mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs);
00489 
00520 int  mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn);
00521 
00536 int  mdb_txn_commit(MDB_txn *txn);
00537 
00544 void mdb_txn_abort(MDB_txn *txn);
00545 
00561 void mdb_txn_reset(MDB_txn *txn);
00562 
00577 int  mdb_txn_renew(MDB_txn *txn);
00578 
00628 int  mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi);
00629 
00642 int  mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat);
00643 
00652 void mdb_close(MDB_env *env, MDB_dbi dbi);
00653 
00664 int  mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del);
00665 
00685 int  mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
00686 
00708 int  mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
00709 
00728 int  mdb_set_relfunc(MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel);
00729 
00744 int  mdb_set_relctx(MDB_txn *txn, MDB_dbi dbi, void *ctx);
00745 
00770 int  mdb_get(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
00771 
00805 int  mdb_put(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data,
00806                          unsigned int flags);
00807 
00830 int  mdb_del(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
00831 
00845 int  mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor);
00846 
00852 void mdb_cursor_close(MDB_cursor *cursor);
00853 
00858 MDB_txn *mdb_cursor_txn(MDB_cursor *cursor);
00859 
00864 MDB_dbi mdb_cursor_dbi(MDB_cursor *cursor);
00865 
00884 int  mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
00885                          MDB_cursor_op op);
00886 
00919 int  mdb_cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
00920                             unsigned int flags);
00921 
00939 int  mdb_cursor_del(MDB_cursor *cursor, unsigned int flags);
00940 
00953 int  mdb_cursor_count(MDB_cursor *cursor, size_t *countp);
00954 
00965 int  mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);
00966 
00977 int  mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);
00979 #endif /* _MDB_H_ */