Back to index

openldap  2.4.31
idl.h
Go to the documentation of this file.
00001 /* idl.h - ldap bdb back-end ID list header file */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2000-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef _BDB_IDL_H_
00018 #define _BDB_IDL_H_
00019 
00020 /* IDL sizes - likely should be even bigger
00021  *   limiting factors: sizeof(ID), thread stack size
00022  */
00023 #define       BDB_IDL_LOGN  16     /* DB_SIZE is 2^16, UM_SIZE is 2^17 */
00024 #define BDB_IDL_DB_SIZE            (1<<BDB_IDL_LOGN)
00025 #define BDB_IDL_UM_SIZE            (1<<(BDB_IDL_LOGN+1))
00026 #define BDB_IDL_UM_SIZEOF   (BDB_IDL_UM_SIZE * sizeof(ID))
00027 
00028 #define BDB_IDL_DB_MAX             (BDB_IDL_DB_SIZE-1)
00029 
00030 #define BDB_IDL_UM_MAX             (BDB_IDL_UM_SIZE-1)
00031 
00032 #define BDB_IDL_IS_RANGE(ids)      ((ids)[0] == NOID)
00033 #define BDB_IDL_RANGE_SIZE         (3)
00034 #define BDB_IDL_RANGE_SIZEOF       (BDB_IDL_RANGE_SIZE * sizeof(ID))
00035 #define BDB_IDL_SIZEOF(ids)        ((BDB_IDL_IS_RANGE(ids) \
00036        ? BDB_IDL_RANGE_SIZE : ((ids)[0]+1)) * sizeof(ID))
00037 
00038 #define BDB_IDL_RANGE_FIRST(ids)   ((ids)[1])
00039 #define BDB_IDL_RANGE_LAST(ids)           ((ids)[2])
00040 
00041 #define BDB_IDL_RANGE( ids, f, l ) \
00042        do { \
00043               (ids)[0] = NOID; \
00044               (ids)[1] = (f);  \
00045               (ids)[2] = (l);  \
00046        } while(0)
00047 
00048 #define BDB_IDL_ZERO(ids) \
00049        do { \
00050               (ids)[0] = 0; \
00051               (ids)[1] = 0; \
00052               (ids)[2] = 0; \
00053        } while(0)
00054 
00055 #define BDB_IDL_IS_ZERO(ids) ( (ids)[0] == 0 )
00056 #define BDB_IDL_IS_ALL( range, ids ) ( (ids)[0] == NOID \
00057        && (ids)[1] <= (range)[1] && (range)[2] <= (ids)[2] )
00058 
00059 #define BDB_IDL_CPY( dst, src ) (AC_MEMCPY( dst, src, BDB_IDL_SIZEOF( src ) ))
00060 
00061 #define BDB_IDL_ID( bdb, ids, id ) BDB_IDL_RANGE( ids, id, ((bdb)->bi_lastid) )
00062 #define BDB_IDL_ALL( bdb, ids ) BDB_IDL_RANGE( ids, 1, ((bdb)->bi_lastid) )
00063 
00064 #define BDB_IDL_FIRST( ids )       ( (ids)[1] )
00065 #define BDB_IDL_LAST( ids )        ( BDB_IDL_IS_RANGE(ids) \
00066        ? (ids)[2] : (ids)[(ids)[0]] )
00067 
00068 #define BDB_IDL_N( ids )           ( BDB_IDL_IS_RANGE(ids) \
00069        ? ((ids)[2]-(ids)[1])+1 : (ids)[0] )
00070 
00071 LDAP_BEGIN_DECL
00072 LDAP_END_DECL
00073 
00074 #endif