/* * metaconn_alloc * * Allocates a connection structure, making room for all the referenced targets */ static struct metaconn * metaconn_alloc( int ntargets ) { struct metaconn *lc; assert( ntargets > 0 ); lc = ch_calloc( sizeof( struct metaconn ), 1 ); if ( lc == NULL ) { return NULL; } /* * make it a null-terminated array ... */ lc->conns = ch_calloc( sizeof( struct metasingleconn ), ntargets+1 ); if ( lc->conns == NULL ) { free( lc ); return NULL; } lc->conns[ ntargets ].candidate = META_LAST_CONN; lc->bound_target = META_BOUND_NONE; return lc; }
static int sssvlv_db_open( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; sssvlv_info *si = on->on_bi.bi_private; int rc; int conn_index; /* If not set, default to 1/2 of available threads */ if ( !si->svi_max ) si->svi_max = connection_pool_max / 2; if ( dtblsize && !sort_conns ) { ldap_pvt_thread_mutex_init( &sort_conns_mutex ); /* accommodate for c_conn_idx == -1 */ sort_conns = ch_calloc( dtblsize + 1, sizeof(sort_op **) ); for ( conn_index = 0 ; conn_index < dtblsize + 1 ; conn_index++ ) { sort_conns[conn_index] = ch_calloc( si->svi_max_percon, sizeof(sort_op *) ); } sort_conns++; } rc = overlay_register_control( be, LDAP_CONTROL_SORTREQUEST ); if ( rc == LDAP_SUCCESS ) rc = overlay_register_control( be, LDAP_CONTROL_VLVREQUEST ); return rc; }
void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping **m ) { struct ldapmapping *mapping; assert( m != NULL ); *m = NULL; mapping = (struct ldapmapping *)ch_calloc( 2, sizeof( struct ldapmapping ) ); if ( mapping == NULL ) { return; } ber_str2bv( "objectclass", STRLENOF("objectclass"), 1, &mapping[0].src); ber_dupbv( &mapping[0].dst, &mapping[0].src ); mapping[1].src = mapping[0].src; mapping[1].dst = mapping[0].dst; avl_insert( &lm->map, (caddr_t)&mapping[0], mapping_cmp, mapping_dup ); avl_insert( &lm->remap, (caddr_t)&mapping[1], mapping_cmp, mapping_dup ); *m = mapping; }
static int mdb_db_init( BackendDB *be, ConfigReply *cr ) { struct mdb_info *mdb; int rc; Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(mdb_db_init) ": Initializing mdb database\n", 0, 0, 0 ); /* allocate backend-database-specific stuff */ mdb = (struct mdb_info *) ch_calloc( 1, sizeof(struct mdb_info) ); /* DBEnv parameters */ mdb->mi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR ); mdb->mi_dbenv_flags = 0; mdb->mi_dbenv_mode = SLAPD_DEFAULT_DB_MODE; mdb->mi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH; mdb->mi_search_stack = NULL; mdb->mi_mapsize = DEFAULT_MAPSIZE; be->be_private = mdb; be->be_cf_ocs = be->bd_info->bi_cf_ocs; #ifndef MDB_MULTIPLE_SUFFIXES SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_ONE_SUFFIX; #endif rc = mdb_monitor_db_init( be ); return rc; }
Operation * slap_op_alloc( BerElement *ber, ber_int_t msgid, ber_tag_t tag, ber_int_t id ) { Operation *op; ldap_pvt_thread_mutex_lock( &slap_op_mutex ); if (op = LDAP_STAILQ_FIRST( &slap_free_ops )) { LDAP_STAILQ_REMOVE_HEAD( &slap_free_ops, o_next ); } ldap_pvt_thread_mutex_unlock( &slap_op_mutex ); if (!op) op = (Operation *) ch_calloc( 1, sizeof(Operation) ); op->o_ber = ber; op->o_msgid = msgid; op->o_tag = tag; op->o_time = slap_get_time(); op->o_opid = id; #ifdef LDAP_CONNECTIONLESS op->o_res_ber = NULL; #endif #if defined( LDAP_SLAPI ) op->o_pb = slapi_pblock_new(); #endif /* defined( LDAP_SLAPI ) */ return( op ); }
static char * rwm_suffix_massage_patternize( const char *s, const char *p ) { ber_len_t len; char *res, *ptr; len = strlen( p ); if ( s[ 0 ] == '\0' ) { len++; } res = ch_calloc( sizeof( char ), len + STRLENOF( "%1" ) + 1 ); if ( res == NULL ) { return NULL; } ptr = lutil_strcopy( res, ( p[0] == '\0' ? "%2" : "%1" ) ); if ( s[ 0 ] == '\0' ) { ptr[ 0 ] = ','; ptr++; } lutil_strcopy( ptr, p ); return res; }
static int nssov_db_init( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; nssov_info *ni; nssov_mapinfo *mi; int rc; rc = nssov_pam_init(); if (rc) return rc; ni = ch_calloc( 1, sizeof(nssov_info) ); on->on_bi.bi_private = ni; /* set up map keys */ nssov_alias_init(ni); nssov_ether_init(ni); nssov_group_init(ni); nssov_host_init(ni); nssov_netgroup_init(ni); nssov_network_init(ni); nssov_passwd_init(ni); nssov_protocol_init(ni); nssov_rpc_init(ni); nssov_service_init(ni); nssov_shadow_init(ni); ni->ni_db = be->bd_self; ni->ni_pam_opts = NI_PAM_UID2DN; return 0; }
static int vernum_db_init( BackendDB *be, ConfigReply *cr) { slap_overinst *on = (slap_overinst *) be->bd_info; vernum_t *vn = NULL; if ( SLAP_ISGLOBALOVERLAY( be ) ) { Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR, "vernum_db_init: vernum cannot be used as global overlay.\n" ); return 1; } if ( be->be_nsuffix == NULL ) { Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR, "vernum_db_init: database must have suffix\n" ); return 1; } if ( BER_BVISNULL( &be->be_rootndn ) || BER_BVISEMPTY( &be->be_rootndn ) ) { Log1( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR, "vernum_db_init: missing rootdn for database DN=\"%s\", YMMV\n", be->be_suffix[ 0 ].bv_val ); } vn = (vernum_t *)ch_calloc( 1, sizeof( vernum_t ) ); on->on_bi.bi_private = (void *)vn; return 0; }
static int ndb_db_init( BackendDB *be, ConfigReply *cr ) { struct ndb_info *ni; int rc = 0; Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(ndb_db_init) ": Initializing ndb database\n", 0, 0, 0 ); /* allocate backend-database-specific stuff */ ni = (struct ndb_info *) ch_calloc( 1, sizeof(struct ndb_info) ); be->be_private = ni; be->be_cf_ocs = be->bd_info->bi_cf_ocs; ni->ni_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH; ldap_pvt_thread_rdwr_init( &ni->ni_ai_rwlock ); ldap_pvt_thread_rdwr_init( &ni->ni_oc_rwlock ); ldap_pvt_thread_mutex_init( &ni->ni_conn_mutex ); #ifdef DO_MONITORING rc = ndb_monitor_db_init( be ); #endif return rc; }
int entry_prealloc( int num ) { Entry *e, **prev, *tmp; slap_list *s; int i, j; if (!num) return 0; #if STRIDE_FACTOR > 1 /* Round up to our stride factor */ num += STRIDE_FACTOR-1; num /= STRIDE_FACTOR; num *= STRIDE_FACTOR; #endif s = ch_calloc( 1, sizeof(slap_list) + num * sizeof(Entry)); s->next = entry_chunks; entry_chunks = s; prev = &tmp; for (i=0; i<STRIPE; i++) { e = (Entry *)(s+1); e += i; for (j=i; j<num; j+= STRIDE) { *prev = e; prev = (Entry **)&e->e_private; e += STRIDE; } } *prev = entry_list; entry_list = (Entry *)(s+1); return 0; }
int kinit_initialize(void) { Log( LDAP_DEBUG_TRACE, LDAP_LEVEL_DEBUG, "kinit_initialize\n" ); krb5_error_code rc; struct re_s *task = NULL; kid = ch_calloc(1, sizeof(kinit_data) ); rc = krb5_init_context( &kid->ctx ); if ( !rc ) rc = krb5_cc_default(kid->ctx, &kid->ccache ); if ( !rc ) { if (!principal) { int len=STRLENOF("ldap/")+global_host_bv.bv_len+1; principal=ch_calloc(len, 1); snprintf(principal, len, "ldap/%s", global_host_bv.bv_val); Log(LDAP_DEBUG_TRACE, LDAP_LEVEL_DEBUG, "Principal <%s>\n", principal ); } rc = krb5_parse_name(kid->ctx, principal, &kid->princ); } if ( !rc && kt_name) { rc = krb5_kt_resolve(kid->ctx, kt_name, &kid->keytab); } if ( !rc ) rc = krb5_get_init_creds_opt_alloc(kid->ctx, &kid->opts); if ( !rc ) rc = krb5_get_init_creds_opt_set_out_ccache( kid->ctx, kid->opts, kid->ccache); if ( !rc ) { ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); task = ldap_pvt_runqueue_insert( &slapd_rq, 10, kinit_qtask, (void*)kid, "kinit_qtask", "ldap/[email protected]" ); ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } if (rc) { log_krb5_errmsg(kid->ctx, "kinit_initialize", rc); rc = -1; } return rc; }
int meta_back_db_init( Backend *be, ConfigReply *cr) { metainfo_t *mi; int i; BackendInfo *bi; bi = backend_info( "ldap" ); if ( !bi || !bi->bi_extra ) { Debug( LDAP_DEBUG_ANY, "meta_back_db_init: needs back-ldap\n" ); return 1; } mi = ch_calloc( 1, sizeof( metainfo_t ) ); if ( mi == NULL ) { return -1; } /* set default flags */ mi->mi_flags = META_BACK_F_DEFER_ROOTDN_BIND | META_BACK_F_PROXYAUTHZ_ALWAYS | META_BACK_F_PROXYAUTHZ_ANON | META_BACK_F_PROXYAUTHZ_NOANON; /* * At present the default is no default target; * this may change */ mi->mi_defaulttarget = META_DEFAULT_TARGET_NONE; mi->mi_bind_timeout.tv_sec = 0; mi->mi_bind_timeout.tv_usec = META_BIND_TIMEOUT; mi->mi_rebind_f = meta_back_default_rebind; mi->mi_urllist_f = meta_back_default_urllist; ldap_pvt_thread_mutex_init( &mi->mi_conninfo.lai_mutex ); ldap_pvt_thread_mutex_init( &mi->mi_cache.mutex ); /* safe default */ mi->mi_nretries = META_RETRY_DEFAULT; mi->mi_version = LDAP_VERSION3; for ( i = LDAP_BACK_PCONN_FIRST; i < LDAP_BACK_PCONN_LAST; i++ ) { mi->mi_conn_priv[ i ].mic_num = 0; LDAP_TAILQ_INIT( &mi->mi_conn_priv[ i ].mic_priv ); } mi->mi_conn_priv_max = LDAP_BACK_CONN_PRIV_DEFAULT; mi->mi_ldap_extra = (ldap_extra_t *)bi->bi_extra; be->be_private = mi; be->be_cf_ocs = be->bd_info->bi_cf_ocs; return 0; }
int ch_init_plugin_out(struct ch_device *device, struct ch_dl_cx *cx) { cx->b_per_pix = avpicture_get_size(cx->out_pixfmt, 1, 1); // If the output stride was uninitialized by the plugin, use the width. if (cx->out_stride == 0) cx->out_stride = device->framesize.width * cx->b_per_pix; uint32_t length = cx->out_stride * device->framesize.height; size_t idx; for (idx = 0; idx < CH_DL_NUMBUF; idx++) { // Get size needed for output buffer. cx->out_buffer[idx].length = length; // Allocate output buffer. cx->out_buffer[idx].start = (uint8_t *) ch_calloc(length, sizeof(uint8_t)); if (cx->out_buffer[idx].start == NULL) goto clean; } if (device->calib) { device->calib->temp1 = (uint8_t *) ch_calloc(length, sizeof(uint8_t)); if (device->calib->temp1 == NULL) goto clean; device->calib->temp2 = (uint8_t *) ch_calloc(length, sizeof(uint8_t)); if (device->calib->temp2 == NULL) goto clean; } cx->frame_out = av_frame_alloc(); if (cx->frame_out == NULL) { ch_error("Failed to allocated output frame."); goto clean; } return (0); clean: ch_destroy_plugin_out(cx); return (-1); }
static int example_init(BackendDB *be, ConfigReply *cr) { slap_overinst *on = (slap_overinst *)be->bd_info; example_data *ex = ch_calloc(1, sizeof(example_data)); (void)cr; on->on_bi.bi_private = ex; return LDAP_SUCCESS; }
static int null_back_db_init( BackendDB *be, ConfigReply *cr ) { struct null_info *ni = ch_calloc( 1, sizeof(struct null_info) ); ni->ni_bind_allowed = 0; ni->ni_nextid = 1; be->be_private = ni; be->be_cf_ocs = be->bd_info->bi_cf_ocs; return 0; }
static int autoPosixIds_db_init( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; autoPosixIds_data *ad = ch_calloc(1, sizeof(autoPosixIds_data)); on->on_bi.bi_private = ad; ldap_pvt_thread_mutex_init( &ad->mutex ); ad->max_uid_number = 0; return 0; }
static int mdb_db_init( BackendDB *be, ConfigReply *cr ) { struct mdb_info *mdb; int rc; Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(mdb_db_init) ": Initializing mdb database\n" ); #if MDBX_MODE_ENABLED unsigned flags = mdbx_setup_debug(MDBX_DBG_DNT, mdbx_debug, MDBX_DBG_DNT); flags &= ~(MDBX_DBG_TRACE | MDBX_DBG_EXTRA | MDBX_DBG_ASSERT); if (reopenldap_mode_check()) flags |= MDBX_DBG_ASSERT; # if LDAP_DEBUG > 1 flags |= MDBX_DBG_PRINT | MDBX_DBG_TRACE; # endif /* LDAP_DEBUG > 1 */ # if LDAP_DEBUG > 2 flags |= MDBX_DBG_EXTRA; # endif /* LDAP_DEBUG > 2 */ mdbx_setup_debug(flags, (MDBX_debug_func*) MDBX_DBG_DNT, MDBX_DBG_DNT); #endif /* MDBX_MODE_ENABLED */ /* allocate backend-database-specific stuff */ mdb = (struct mdb_info *) ch_calloc( 1, sizeof(struct mdb_info) ); /* DBEnv parameters */ mdb->mi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR ); mdb->mi_dbenv_flags = 0; mdb->mi_dbenv_mode = SLAPD_DEFAULT_DB_MODE; mdb->mi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH; mdb->mi_search_stack = NULL; mdb->mi_mapsize = DEFAULT_MAPSIZE; mdb->mi_rtxn_size = DEFAULT_RTXN_SIZE; be->be_private = mdb; be->be_cf_ocs = be->bd_info->bi_cf_ocs; #ifndef MDB_MULTIPLE_SUFFIXES SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_ONE_SUFFIX; #endif slap_backtrace_set_dir( mdb->mi_dbenv_home ); ldap_pvt_thread_mutex_init( &mdb->mi_ads_mutex ); rc = mdb_monitor_db_init( be ); return rc; }
static void quorum_be_init(BackendDB *bd) { slap_quorum_t *q; assert(quorum_list != QR_POISON); q = ch_calloc(1, sizeof(slap_quorum_t)); q->qr_bd = bd; q->qr_next = quorum_list; bd->bd_quorum = q; bd->bd_quorum_cache = 1; quorum_list = q; }
static int lastbind_db_init( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *) be->bd_info; /* initialize private structure to store configuration */ on->on_bi.bi_private = ch_calloc( 1, sizeof(lastbind_info) ); return 0; }
static int auditlog_db_init( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; auditlog_data *ad = ch_calloc(1, sizeof(auditlog_data)); on->on_bi.bi_private = ad; ldap_pvt_thread_mutex_init( &ad->ad_mutex ); return 0; }
static int gssattr_dynacl_parse( const char *fname, int lineno, const char *opts, slap_style_t style, const char *pattern, void **privp ) { gssattr_t *gssattr; gssattr = (gssattr_t *)ch_calloc( 1, sizeof( gssattr_t ) ); if ( opts == NULL || opts[0] == '\0' ) { fprintf( stderr, "%s line %d: GSS ACL: no attribute specified.\n", fname, lineno ); goto cleanup; } if ( pattern == NULL || pattern[0] == '\0' ) { fprintf( stderr, "%s line %d: GSS ACL: no attribute value specified.\n", fname, lineno ); goto cleanup; } gssattr->gssattr_style = style; switch ( gssattr->gssattr_style ) { case ACL_STYLE_BASE: case ACL_STYLE_REGEX: case ACL_STYLE_EXPAND: break; default: fprintf( stderr, "%s line %d: GSS ACL: unsupported style \"%s\".\n", fname, lineno, style_strings[style] ); goto cleanup; break; } ber_str2bv( opts, 0, 1, &gssattr->gssattr_name ); ber_str2bv( pattern, 0, 1, &gssattr->gssattr_value ); *privp = (void *)gssattr; return 0; cleanup: (void)gssattr_dynacl_destroy( (void *)gssattr ); return 1; }
int shell_back_db_init( Backend *be, ConfigReply *cr ) { struct shellinfo *si; si = (struct shellinfo *) ch_calloc( 1, sizeof(struct shellinfo) ); be->be_private = si; return si == NULL; }
static int bdb_db_init( BackendDB *be, ConfigReply *cr ) { struct bdb_info *bdb; int rc; Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n", 0, 0, 0 ); /* allocate backend-database-specific stuff */ bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) ); /* DBEnv parameters */ bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR ); bdb->bi_dbenv_xflags = DB_TIME_NOTGRANTED; bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE; bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE; bdb->bi_cache.c_minfree = 1; bdb->bi_lock_detect = DB_LOCK_DEFAULT; bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH; bdb->bi_search_stack = NULL; ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex ); #ifdef BDB_HIER ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex ); #endif ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_lru_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_count_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_eifree_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex ); ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock ); ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock ); ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock ); be->be_private = bdb; be->be_cf_ocs = be->bd_info->bi_cf_ocs; #ifndef BDB_MULTIPLE_SUFFIXES SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_ONE_SUFFIX; #endif rc = bdb_monitor_db_init( be ); return rc; }
/* we assume be_extra_anlist are already mapped */ for ( x = 0; !BER_BVISNULL( &op->o_bd->be_extra_anlist[x].an_name ); x++ ) { BER_BVZERO( &(*anp)[j].an_name ); if ( op->o_bd->be_extra_anlist[x].an_desc && ad_inlist( op->o_bd->be_extra_anlist[x].an_desc, *anp ) ) { continue; } (*anp)[j] = op->o_bd->be_extra_anlist[x]; j++; } } if ( j == 0 && ( i != 0 || x != 0 ) ) { memset( &(*anp)[0], 0, sizeof( AttributeName ) ); (*anp)[0].an_name = *slap_bv_no_attrs; j = 1; } memset( &(*anp)[j], 0, sizeof( AttributeName ) ); return LDAP_SUCCESS; } #if 0 /* unused! */ int rwm_map_attrs( struct ldapmap *at_map, AttributeName *an, int remap, char ***mapped_attrs ) { int i, j; char **na; if ( an == NULL ) { *mapped_attrs = NULL; return LDAP_SUCCESS; } for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ); i++ ) /* count'em */ ; na = (char **)ch_calloc( i + 1, sizeof( char * ) ); if ( na == NULL ) { *mapped_attrs = NULL; return LDAP_NO_MEMORY; } for ( i = j = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) { struct ldapmapping *mapping; if ( rwm_mapping( at_map, &an[i].an_name, &mapping, remap ) ) { continue; } if ( !mapping ) { na[ j++ ] = an[ i ].an_name.bv_val; } else if ( !BER_BVISNULL( &mapping->m_dst ) ) { na[ j++ ] = mapping->m_dst.bv_val; } } if ( j == 0 && i != 0 ) { na[ j++ ] = LDAP_NO_ATTRS; } na[ j ] = NULL; *mapped_attrs = na; return LDAP_SUCCESS; }
int sock_back_db_init( Backend *be, struct config_reply_s *cr ) { struct sockinfo *si; si = (struct sockinfo *) ch_calloc( 1, sizeof(struct sockinfo) ); be->be_private = si; be->be_cf_ocs = be->bd_info->bi_cf_ocs; return si == NULL; }
static int seqmod_db_open( BackendDB *be, ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; seqmod_info *sm; sm = ch_calloc(1, sizeof(seqmod_info)); on->on_bi.bi_private = sm; ldap_pvt_thread_mutex_init( &sm->sm_mutex ); return 0; }
int backsql_db_init( BackendDB *bd ) { backsql_info *si; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_init()\n", 0, 0, 0 ); si = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) ); memset( si, '\0', sizeof( backsql_info ) ); ldap_pvt_thread_mutex_init( &si->dbconn_mutex ); ldap_pvt_thread_mutex_init( &si->schema_mutex ); backsql_init_db_env( si ); bd->be_private = si; Debug( LDAP_DEBUG_TRACE, "<==backsql_db_init()\n", 0, 0, 0 ); return 0; }
monitor_entry_t * monitor_back_entrypriv_create( void ) { monitor_entry_t *mp; mp = ( monitor_entry_t * )ch_calloc( sizeof( monitor_entry_t ), 1 ); mp->mp_next = NULL; mp->mp_children = NULL; mp->mp_info = NULL; mp->mp_flags = MONITOR_F_NONE; mp->mp_cb = NULL; ldap_pvt_thread_mutex_init( &mp->mp_mutex ); return mp; }
extern "C" int ndb_aset_get( struct ndb_info *ni, struct berval *sname, struct berval *attrs, NdbOcInfo **ret ) { NdbOcInfo *oci, octmp; int i, rc; octmp.no_name = *sname; oci = (NdbOcInfo *)avl_find( ni->ni_oc_tree, &octmp, ndb_name_cmp ); if ( oci ) return LDAP_ALREADY_EXISTS; for ( i=0; !BER_BVISNULL( &attrs[i] ); i++ ) { if ( !at_bvfind( &attrs[i] )) return LDAP_NO_SUCH_ATTRIBUTE; } i++; oci = (NdbOcInfo *)ch_calloc( 1, sizeof( NdbOcInfo ) + sizeof( ObjectClass ) + i*sizeof(AttributeType *) + sname->bv_len+1 ); oci->no_oc = (ObjectClass *)(oci+1); oci->no_oc->soc_required = (AttributeType **)(oci->no_oc+1); oci->no_table.bv_val = (char *)(oci->no_oc->soc_required+i); for ( i=0; !BER_BVISNULL( &attrs[i] ); i++ ) oci->no_oc->soc_required[i] = at_bvfind( &attrs[i] ); strcpy( oci->no_table.bv_val, sname->bv_val ); oci->no_table.bv_len = sname->bv_len; oci->no_name = oci->no_table; oci->no_oc->soc_cname = oci->no_name; oci->no_flag = NDB_INFO_ATSET; if ( !ber_bvcmp( sname, &slap_schema.si_oc_extensibleObject->soc_cname )) oci->no_oc->soc_kind = slap_schema.si_oc_extensibleObject->soc_kind; rc = ndb_oc_create( ni, oci, 0 ); if ( !rc ) rc = avl_insert( &ni->ni_oc_tree, oci, ndb_name_cmp, avl_dup_error ); if ( rc ) { ch_free( oci ); } else { *ret = oci; } return rc; }
int meta_back_db_init( Backend *be, ConfigReply *cr) { metainfo_t *mi; int i; mi = ch_calloc( 1, sizeof( metainfo_t ) ); if ( mi == NULL ) { return -1; } /* set default flags */ mi->mi_flags = META_BACK_F_DEFER_ROOTDN_BIND; /* * At present the default is no default target; * this may change */ mi->mi_defaulttarget = META_DEFAULT_TARGET_NONE; mi->mi_bind_timeout.tv_sec = 0; mi->mi_bind_timeout.tv_usec = META_BIND_TIMEOUT; mi->mi_rebind_f = meta_back_default_rebind; mi->mi_urllist_f = meta_back_default_urllist; ldap_pvt_thread_mutex_init( &mi->mi_conninfo.lai_mutex ); ldap_pvt_thread_mutex_init( &mi->mi_cache.mutex ); /* safe default */ mi->mi_nretries = META_RETRY_DEFAULT; mi->mi_version = LDAP_VERSION3; for ( i = LDAP_BACK_PCONN_FIRST; i < LDAP_BACK_PCONN_LAST; i++ ) { mi->mi_conn_priv[ i ].mic_num = 0; LDAP_TAILQ_INIT( &mi->mi_conn_priv[ i ].mic_priv ); } mi->mi_conn_priv_max = LDAP_BACK_CONN_PRIV_DEFAULT; be->be_private = mi; return 0; }