这篇教程C++ test_filter函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中test_filter函数的典型用法代码示例。如果您正苦于以下问题:C++ test_filter函数的具体用法?C++ test_filter怎么用?C++ test_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了test_filter函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: calculate_bounding_rectangle/** * /brief Calculates the smallest rectangle that will encompass the logo region. * * /param filter This image contains the logo around which the rectangle will * will be fitted. * * The bounding rectangle is calculated by testing successive lines (from the four * sides of the rectangle) until no more can be removed without removing logo * pixels. The results are returned by reference to posx1, posy1, posx2, and * posy2. */static void calculate_bounding_rectangle(int * posx1, int * posy1, int * posx2, int * posy2, pgm_structure * filter){ int x; /* Temporary variables to run */ int y; /* through each row or column. */ int start_x; int start_y; int end_x = filter->width - 1; int end_y = filter->height - 1; int did_we_find_a_logo_pixel = 0; /* Let's find the top bound first. */ for (start_x = 0; start_x < filter->width && !did_we_find_a_logo_pixel; start_x++) { for (y = 0; y < filter->height; y++) { did_we_find_a_logo_pixel |= test_filter(filter, start_x, y); } } start_x--; /* Now the bottom bound. */ did_we_find_a_logo_pixel = 0; for (end_x = filter->width - 1; end_x > start_x && !did_we_find_a_logo_pixel; end_x--) { for (y = 0; y < filter->height; y++) { did_we_find_a_logo_pixel |= test_filter(filter, end_x, y); } } end_x++; /* Left bound. */ did_we_find_a_logo_pixel = 0; for (start_y = 0; start_y < filter->height && !did_we_find_a_logo_pixel; start_y++) { for (x = 0; x < filter->width; x++) { did_we_find_a_logo_pixel |= test_filter(filter, x, start_y); } } start_y--; /* Right bound. */ did_we_find_a_logo_pixel = 0; for (end_y = filter->height - 1; end_y > start_y && !did_we_find_a_logo_pixel; end_y--) { for (x = 0; x < filter->width; x++) { did_we_find_a_logo_pixel |= test_filter(filter, x, end_y); } } end_y++; *posx1 = start_x; *posy1 = start_y; *posx2 = end_x; *posy2 = end_y; return;}
开发者ID:NeeMeese,项目名称:mplayer-ce,代码行数:71,
示例2: op ifilter_iterator<Operator, List0>::ifilter_iterator(Operator _op, List0 &_seq) : op(_op), iter(_seq.begin()), iter_end(_seq.end()) { if (!test_filter(std::is_same<types::none_type, Operator>())) next_value(); }
开发者ID:artas360,项目名称:pythran,代码行数:7,
示例3: mainintmain (int argc, char **argv){ int i; camel_test_init(argc, argv); camel_test_start("HTML Stream filtering"); for (i=0;i<100;i++) { char inname[32], outname[32]; CamelMimeFilter *f; struct stat st; sprintf(inname, "data/html.%d.in", i); sprintf(outname, "data/html.%d.out", i); if (stat(inname, &st) == -1) break; f = camel_mime_filter_tohtml_new(CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); test_filter(f, inname, outname); check_unref(f, 1); } camel_test_end(); return 0;}
开发者ID:nobled,项目名称:evolution-data-server.svn-import,代码行数:31,
示例4: slap_compare_entryint slap_compare_entry( Operation *op, Entry *e, AttributeAssertion *ava ){ int rc = LDAP_COMPARE_FALSE; Attribute *a; if ( ! access_allowed( op, e, ava->aa_desc, &ava->aa_value, ACL_COMPARE, NULL ) ) { rc = LDAP_INSUFFICIENT_ACCESS; goto done; } if ( get_assert( op ) && ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE )) { rc = LDAP_ASSERTION_FAILED; goto done; } a = attrs_find( e->e_attrs, ava->aa_desc ); if( a == NULL ) { rc = LDAP_NO_SUCH_ATTRIBUTE; goto done; } for(; a != NULL; a = attrs_find( a->a_next, ava->aa_desc )) { if (( ava->aa_desc != a->a_desc ) && ! access_allowed( op, e, a->a_desc, &ava->aa_value, ACL_COMPARE, NULL ) ) { rc = LDAP_INSUFFICIENT_ACCESS; break; } if ( attr_valfind( a, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, &ava->aa_value, NULL, op->o_tmpmemctx ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } }done: if( rc != LDAP_COMPARE_TRUE && rc != LDAP_COMPARE_FALSE ) { if ( ! access_allowed( op, e, slap_schema.si_ad_entry, NULL, ACL_DISCLOSE, NULL ) ) { rc = LDAP_NO_SUCH_OBJECT; } } return rc;}
开发者ID:Joywar,项目名称:openldap,代码行数:60,
示例5: while void ifilter_iterator<Operator, List0>::next_value() { while (++iter != iter_end) { if (test_filter(std::is_same<types::none_type, Operator>())) return; } }
开发者ID:artas360,项目名称:pythran,代码行数:7,
示例6: pwdfile_searchstatic voidpwdfile_search( struct ldop *op, FILE *ofp ){ struct passwd *pw; struct ldentry *entry; int oneentry; oneentry = ( strchr( op->ldop_dn, '@' ) != NULL ); for ( pw = getpwent(); pw != NULL; pw = getpwent()) { if (( entry = pw2entry( op, pw )) != NULL ) { if ( oneentry ) { if ( strcasecmp( op->ldop_dn, entry->lde_dn ) == 0 ) { write_entry( op, entry, ofp ); break; } } else if ( test_filter( op, entry ) == LDAP_COMPARE_TRUE ) { write_entry( op, entry, ofp ); } free_entry( entry ); } } endpwent(); write_result( ofp, LDAP_SUCCESS, NULL, NULL );}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:26,
示例7: test_filter_orstatic inttest_filter_or( Operation *op, Entry *e, Filter *flist ){ Filter *f; int rtn = LDAP_COMPARE_FALSE; /* False if empty */ Debug( LDAP_DEBUG_FILTER, "=> test_filter_or/n", 0, 0, 0 ); for ( f = flist; f != NULL; f = f->f_next ) { int rc = test_filter( op, e, f ); if ( rc == LDAP_COMPARE_TRUE ) { /* filter is True */ rtn = rc; break; } if ( rc != LDAP_COMPARE_FALSE ) { /* filter is Undefined unless later elements are True */ rtn = rc; } } Debug( LDAP_DEBUG_FILTER, "<= test_filter_or %d/n", rtn, 0, 0 ); return rtn;}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:29,
示例8: autogroup_add_entry/*** When adding a group, we first strip any existing members,** and add all which match the filters ourselfs.*/static intautogroup_add_entry( Operation *op, SlapReply *rs){ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; autogroup_info_t *agi = (autogroup_info_t *)on->on_bi.bi_private; autogroup_def_t *agd = agi->agi_def; autogroup_entry_t *age = agi->agi_entry; autogroup_filter_t *agf; int rc = 0; Debug( LDAP_DEBUG_TRACE, "==> autogroup_add_entry <%s>/n", op->ora_e->e_name.bv_val, 0, 0); ldap_pvt_thread_mutex_lock( &agi->agi_mutex ); /* Check if it's a group. */ for ( ; agd ; agd = agd->agd_next ) { if ( is_entry_objectclass_or_sub( op->ora_e, agd->agd_oc ) ) { Modification mod; const char *text = NULL; char textbuf[1024]; mod.sm_op = LDAP_MOD_DELETE; mod.sm_desc = agd->agd_member_ad; mod.sm_type = agd->agd_member_ad->ad_cname; mod.sm_values = NULL; mod.sm_nvalues = NULL; /* We don't want any member attributes added by the user. */ modify_delete_values( op->ora_e, &mod, /* permissive */ 1, &text, textbuf, sizeof( textbuf ) ); autogroup_add_group( op, agi, agd, op->ora_e, NULL, 1 , 0); ldap_pvt_thread_mutex_unlock( &agi->agi_mutex ); return SLAP_CB_CONTINUE; } } for ( ; age ; age = age->age_next ) { ldap_pvt_thread_mutex_lock( &age->age_mutex ); /* Check if any of the filters are the suffix to the entry DN. If yes, we can test that filter against the entry. */ for ( agf = age->age_filter; agf ; agf = agf->agf_next ) { if ( dnIsSuffix( &op->o_req_ndn, &agf->agf_ndn ) ) { rc = test_filter( op, op->ora_e, agf->agf_filter ); if ( rc == LDAP_COMPARE_TRUE ) { autogroup_add_member_to_group( op, &op->ora_e->e_name, &op->ora_e->e_nname, age ); break; } } } ldap_pvt_thread_mutex_unlock( &age->age_mutex ); } ldap_pvt_thread_mutex_unlock( &agi->agi_mutex ); return SLAP_CB_CONTINUE;}
开发者ID:ystk,项目名称:debian-openldap,代码行数:63,
示例9: op ifilter_iterator<ResultType, Operator, List0>::ifilter_iterator(Operator _op, List0 _seq) : op(_op), iter(const_cast<sequence_type&>(_seq).begin()), iter_end(const_cast<sequence_type &>(_seq).end()) { if (!test_filter(std::is_same<types::none_type, Operator>())) next_value(); }
开发者ID:coyotte508,项目名称:pythran,代码行数:8,
示例10: constraint_check_restrictstatic intconstraint_check_restrict( Operation *op, constraint *c, Entry *e ){ assert( c->restrict_lud != NULL ); if ( c->restrict_lud->lud_dn != NULL ) { int diff = e->e_nname.bv_len - c->restrict_ndn.bv_len; if ( diff < 0 ) { return 0; } if ( c->restrict_lud->lud_scope == LDAP_SCOPE_BASE ) { return bvmatch( &e->e_nname, &c->restrict_ndn ); } if ( !dnIsSuffix( &e->e_nname, &c->restrict_ndn ) ) { return 0; } if ( c->restrict_lud->lud_scope != LDAP_SCOPE_SUBTREE ) { struct berval pdn; if ( diff == 0 ) { return 0; } dnParent( &e->e_nname, &pdn ); if ( c->restrict_lud->lud_scope == LDAP_SCOPE_ONELEVEL && pdn.bv_len != c->restrict_ndn.bv_len ) { return 0; } } } if ( c->restrict_filter != NULL ) { int rc; struct berval save_dn = op->o_dn, save_ndn = op->o_ndn; op->o_dn = op->o_bd->be_rootdn; op->o_ndn = op->o_bd->be_rootndn; rc = test_filter( op, e, c->restrict_filter ); op->o_dn = save_dn; op->o_ndn = save_ndn; if ( rc != LDAP_COMPARE_TRUE ) { return 0; } } return 1;}
开发者ID:dago,项目名称:openldap,代码行数:54,
示例11: test_opstatic int test_op(struct event_format *event, struct filter_arg *arg, struct pevent_record *record){ switch (arg->op.type) { case FILTER_OP_AND: return test_filter(event, arg->op.left, record) && test_filter(event, arg->op.right, record); case FILTER_OP_OR: return test_filter(event, arg->op.left, record) || test_filter(event, arg->op.right, record); case FILTER_OP_NOT: return !test_filter(event, arg->op.right, record); default: /* ?? */ return 0; }}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:20,
示例12: strcpyvoid DeleteAllIndexes::run(){ char string[BCTEXTLEN], string1[BCTEXTLEN], string2[BCTEXTLEN];// prepare directory strcpy(string1, pwindow->thread->preferences->index_directory); FileSystem dir; dir.update(pwindow->thread->preferences->index_directory); dir.complete_path(string1);// prepare filter const char *filter1 = ".idx"; const char *filter2 = ".toc";// pwindow->disable_window(); sprintf(string, _("Delete all indexes in %s?"), string1);// QuestionWindow confirm(mwindow);// confirm.create_objects(string, 0);// int result = confirm.run_window(); int result = 0; if(!result) { static int i, j, k; for(i = 0; i < dir.dir_list.total; i++) { result = 1; sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);// test filter if(test_filter(string2, filter1) || test_filter(string2, filter2)) { remove(string2);printf("DeleteAllIndexes::run %s/n", string2); } } } pwindow->thread->redraw_indexes = 1;// pwindow->enable_window();}
开发者ID:petterreinholdtsen,项目名称:cinelerra-hv,代码行数:41,
示例13: get_blur/** * /brief Our blurring function. * * /param vf Stores persistant data. In this function we are interested in the * array of masks. * /param value_out The properly blurred and delogoed pixel is outputted here. * /param logo_mask Tells us which pixels are in the logo and which aren't. * /param image The image that is having its logo removed. * /param x x-coordinate of the pixel to blur. * /param y y-coordinate of the pixel to blur. * /param plane 0 = luma, 1 = blue chroma, 2 = red chroma (YUV). * * This function is the core of the filter. It takes a pixel that is inside the * logo and blurs it. It does so by finding the average of all the pixels within * the mask and outside of the logo. */static void get_blur(const vf_instance_t * const vf, unsigned int * const value_out, const pgm_structure * const logo_mask, const mp_image_t * const image, const int x, const int y, const int plane){ int mask_size; /* Mask size tells how large a circle to use. The radius is about (slightly larger than) mask size. */ /* Get values from vf->priv for faster dereferencing. */ int * * * mask = vf->priv->mask; int start_posx, start_posy, end_posx, end_posy; int i, j; unsigned int accumulator = 0, divisor = 0; const unsigned char * mask_read_position; /* What pixel we are reading out of the circular blur mask. */ const unsigned char * logo_mask_read_position; /* What pixel we are reading out of the filter image. */ /* Prepare our bounding rectangle and clip it if need be. */ mask_size = test_filter(logo_mask, x, y); start_posx = max(0, x - mask_size); start_posy = max(0, y - mask_size); end_posx = min(image->width - 1, x + mask_size); end_posy = min(image->height - 1, y + mask_size); mask_read_position = image->planes[plane] + (image->stride[plane] * start_posy) + start_posx; logo_mask_read_position = logo_mask->pixel + (start_posy * logo_mask->width) + start_posx; for (j = start_posy; j <= end_posy; j++) { for (i = start_posx; i <= end_posx; i++) { if (!(*logo_mask_read_position) && mask[mask_size][i - start_posx][j - start_posy]) { /* Check to see if this pixel is in the logo or not. Only use the pixel if it is not. */ accumulator += *mask_read_position; divisor++; } mask_read_position++; logo_mask_read_position++; } mask_read_position += (image->stride[plane] - ((end_posx + 1) - start_posx)); logo_mask_read_position += (logo_mask->width - ((end_posx + 1) - start_posx)); } if (divisor == 0) /* This means that not a single pixel is outside of the logo, so we have no data. */ { /* We should put some eye catching value here, to indicate the flaw to the user. */ *value_out = 255; } else /* Else we need to normalise the data using the divisor. */ { *value_out = (accumulator + (divisor / 2)) / divisor; /* Divide, taking into account average rounding error. */ } return;}
开发者ID:NeeMeese,项目名称:mplayer-ce,代码行数:68,
示例14: dynlist_is_dynlist_nextstatic dynlist_info_t *dynlist_is_dynlist_next( Operation *op, SlapReply *rs, dynlist_info_t *old_dli ){ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; dynlist_info_t *dli; Attribute *a; if ( old_dli == NULL ) { dli = (dynlist_info_t *)on->on_bi.bi_private; } else { dli = old_dli->dli_next; } a = attrs_find( rs->sr_entry->e_attrs, slap_schema.si_ad_objectClass ); if ( a == NULL ) { /* FIXME: objectClass must be present; for non-storage * backends, like back-ldap, it needs to be added * to the requested attributes */ return NULL; } for ( ; dli; dli = dli->dli_next ) { if ( dli->dli_lud != NULL ) { /* check base and scope */ if ( !BER_BVISNULL( &dli->dli_uri_nbase ) && !dnIsSuffixScope( &rs->sr_entry->e_nname, &dli->dli_uri_nbase, dli->dli_lud->lud_scope ) ) { continue; } /* check filter */ if ( dli->dli_uri_filter && test_filter( op, rs->sr_entry, dli->dli_uri_filter ) != LDAP_COMPARE_TRUE ) { continue; } } if ( attr_valfind( a, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, &dli->dli_oc->soc_cname, NULL, op->o_tmpmemctx ) == 0 ) { return dli; } } return NULL;}
开发者ID:cptaffe,项目名称:openldap,代码行数:52,
示例15: get_test_setint get_test_set(int *test_set, int limit, const char *test, struct test_list_t *tests){ int start, end; int idx = 0; if (test == NULL) { /* Default: Run all tests. */ for (;idx < limit; idx++) test_set[idx] = idx; return (limit); } if (*test >= '0' && *test <= '9') { const char *vp = test; start = 0; while (*vp >= '0' && *vp <= '9') { start *= 10; start += *vp - '0'; ++vp; } if (*vp == '/0') { end = start; } else if (*vp == '-') { ++vp; if (*vp == '/0') { end = limit - 1; } else { end = 0; while (*vp >= '0' && *vp <= '9') { end *= 10; end += *vp - '0'; ++vp; } } } else return (-1); if (start < 0 || end >= limit || start > end) return (-1); while (start <= end) test_set[idx++] = start++; } else { for (start = 0; start < limit; ++start) { const char *name = tests[start].name; if (test_filter(test, name)) test_set[idx++] = start; } } return ((idx == 0)?-1:idx);}
开发者ID:0mp,项目名称:freebsd,代码行数:49,
示例16: retcode_send_onelevelstatic intretcode_send_onelevel( Operation *op, SlapReply *rs ){ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; retcode_t *rd = (retcode_t *)on->on_bi.bi_private; retcode_item_t *rdi; for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) { if ( op->o_abandon ) { return rs->sr_err = SLAPD_ABANDON; } rs->sr_err = test_filter( op, &rdi->rdi_e, op->ors_filter ); if ( rs->sr_err == LDAP_COMPARE_TRUE ) { /* safe default */ rs->sr_attrs = op->ors_attrs; rs->sr_operational_attrs = NULL; rs->sr_ctrls = NULL; rs->sr_flags = 0; rs->sr_err = LDAP_SUCCESS; rs->sr_entry = &rdi->rdi_e; rs->sr_err = send_search_entry( op, rs ); rs->sr_flags = 0; rs->sr_entry = NULL; rs->sr_attrs = NULL; switch ( rs->sr_err ) { case LDAP_UNAVAILABLE: /* connection closed */ rs->sr_err = LDAP_OTHER; /* fallthru */ case LDAP_SIZELIMIT_EXCEEDED: goto done; } } rs->sr_err = LDAP_SUCCESS; }done:; send_ldap_result( op, rs ); return rs->sr_err;}
开发者ID:verter2015,项目名称:ReOpenLDAP,代码行数:45,
示例17: generate_map/** * Performs code-generation for a map statement. */int generate_map(Pool *pool, FILE *out, AstMap *p){ ListNode *line; /* Match against the map: */ for (line = p->lines; line; line = line->next) { AstMapLine *l = ast_to_map_line(line->d); if (test_filter(l->filter, p->item)) { CHECK(generate_code(pool, out, l->code)); return 1; } } /* Nothing matched: */ fprintf(stderr, "error: Could not match item /"%s/" against map./n", string_copy(pool, p->item->name).p); return 0;}
开发者ID:swansontec,项目名称:outline2c,代码行数:21,
示例18: generate_for_itemint generate_for_item(Pool *pool, FILE *out, AstFor *p, ListNode *item, int *need_comma){ Scope *scope = scope_new(pool, p->scope); ListBuilder code = list_builder_init(pool); if (dynamic_ok(p->filter) && !test_filter(p->filter, ast_to_outline_item(item->d))) return 1; if (p->list && *need_comma) CHECK(file_putc(out, ',')); *need_comma = 1; scope_add(scope, pool, p->item, item->d); CHECK(parse_code(pool, &p->code, scope, out_list_builder(&code))); CHECK(generate_code(pool, out, code.first)); return 1;}
开发者ID:swansontec,项目名称:outline2c,代码行数:18,
示例19: pevent_filter_match/** * pevent_filter_match - test if a record matches a filter * @filter: filter struct with filter information * @record: the record to test against the filter * * Returns: * 1 - filter found for event and @record matches * 0 - filter found for event and @record does not match * -1 - no filter found for @record's event * -2 - if no filters exist */int pevent_filter_match(struct event_filter *filter, struct pevent_record *record){ struct pevent *pevent = filter->pevent; struct filter_type *filter_type; int event_id; if (!filter->filters) return FILTER_NONE; event_id = pevent_data_type(pevent, record); filter_type = find_filter_type(filter, event_id); if (!filter_type) return FILTER_NOEXIST; return test_filter(filter_type->event, filter_type->filter, record) ? FILTER_MATCH : FILTER_MISS;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:31,
示例20: fe_op_searchintfe_op_search( Operation *op, SlapReply *rs ){ BackendDB *bd = op->o_bd; if ( op->ors_scope == LDAP_SCOPE_BASE ) { Entry *entry = NULL; if ( BER_BVISEMPTY( &op->o_req_ndn ) ) {#ifdef LDAP_CONNECTIONLESS /* Ignore LDAPv2 CLDAP Root DSE queries */ if (op->o_protocol == LDAP_VERSION2 && op->o_conn->c_is_udp) { goto return_results; }#endif /* check restrictions */ if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) { send_ldap_result( op, rs ); goto return_results; } rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text ); } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) { /* check restrictions */ if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) { send_ldap_result( op, rs ); goto return_results; } rs->sr_err = schema_info( &entry, &rs->sr_text ); } if( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); goto return_results; } else if ( entry != NULL ) { if ( get_assert( op ) && ( test_filter( op, entry, get_assertion( op )) != LDAP_COMPARE_TRUE )) { rs->sr_err = LDAP_ASSERTION_FAILED; goto fail1; } rs->sr_err = test_filter( op, entry, op->ors_filter ); if( rs->sr_err == LDAP_COMPARE_TRUE ) { /* note: we set no limits because either * no limit is specified, or at least 1 * is specified, and we're going to return * at most one entry */ op->ors_slimit = SLAP_NO_LIMIT; op->ors_tlimit = SLAP_NO_LIMIT; rs->sr_entry = entry; rs->sr_attrs = op->ors_attrs; rs->sr_operational_attrs = NULL; rs->sr_flags = 0; send_search_entry( op, rs ); rs->sr_entry = NULL; rs->sr_operational_attrs = NULL; } rs->sr_err = LDAP_SUCCESS;fail1: entry_free( entry ); send_ldap_result( op, rs ); goto return_results; } } if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &default_search_nbase ) ) { slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx ); slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); ber_dupbv_x( &op->o_req_dn, &default_search_base, op->o_tmpmemctx ); ber_dupbv_x( &op->o_req_ndn, &default_search_nbase, op->o_tmpmemctx ); } /* * We could be serving multiple database backends. Select the * appropriate one, or send a referral to our "referral server" * if we don't hold it. */ op->o_bd = select_backend( &op->o_req_ndn, 1 ); if ( op->o_bd == NULL ) { rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, op->ors_scope ); if (!rs->sr_ref) rs->sr_ref = default_referral; rs->sr_err = LDAP_REFERRAL; op->o_bd = bd; send_ldap_result( op, rs ); if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; goto return_results; }//.........这里部分代码省略.........
开发者ID:RevanthPar,项目名称:openldap,代码行数:101,
示例21: mdb_search//.........这里部分代码省略......... ber_dupbv( &matched_dn, &e->e_name ); erefs = get_entry_referrals( op, e ); rs->sr_err = LDAP_REFERRAL; mdb_entry_return( op, e ); e = NULL; if ( erefs ) { rs->sr_ref = referral_rewrite( erefs, &matched_dn, &op->o_req_dn, op->oq_search.rs_scope ); ber_bvarray_free( erefs ); if ( !rs->sr_ref ) { rs->sr_text = "bad_referral object"; } } Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(mdb_search) ": entry is referral/n", 0, 0, 0 ); rs->sr_matched = matched_dn.bv_val; send_ldap_result( op, rs ); ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; ber_memfree( matched_dn.bv_val ); rs->sr_matched = NULL; goto done; } if ( get_assert( op ) && ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE )) { rs->sr_err = LDAP_ASSERTION_FAILED; mdb_entry_return( op,e); send_ldap_result( op, rs ); goto done; } /* compute it anyway; root does not use it */ stoptime = op->o_time + op->ors_tlimit; base = e; e = NULL; /* select candidates */ if ( op->oq_search.rs_scope == LDAP_SCOPE_BASE ) { rs->sr_err = base_candidate( op->o_bd, base, candidates ); scopes[0].mid = 0; ncand = 1; } else { if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) { size_t nkids; MDB_val key, data; key.mv_data = &base->e_id; key.mv_size = sizeof( ID ); mdb_cursor_get( mcd, &key, &data, MDB_SET ); mdb_cursor_count( mcd, &nkids ); nsubs = nkids - 1; } else if ( !base->e_id ) { /* we don't maintain nsubs for entryID 0. * just grab entry count from id2entry stat */
开发者ID:swinkelhofer,项目名称:ad2openldap,代码行数:67,
示例22: test_filterinttest_filter( Operation *op, Entry *e, Filter *f ){ int rc; Debug( LDAP_DEBUG_FILTER, "=> test_filter/n", 0, 0, 0 ); if ( f->f_choice & SLAPD_FILTER_UNDEFINED ) { Debug( LDAP_DEBUG_FILTER, " UNDEFINED/n", 0, 0, 0 ); rc = SLAPD_COMPARE_UNDEFINED; goto out; } switch ( f->f_choice ) { case SLAPD_FILTER_COMPUTED: Debug( LDAP_DEBUG_FILTER, " COMPUTED %s (%d)/n", f->f_result == LDAP_COMPARE_FALSE ? "false" : f->f_result == LDAP_COMPARE_TRUE ? "true" : f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" : "error", f->f_result, 0 ); rc = f->f_result; break; case LDAP_FILTER_EQUALITY: Debug( LDAP_DEBUG_FILTER, " EQUALITY/n", 0, 0, 0 ); rc = test_ava_filter( op, e, f->f_ava, LDAP_FILTER_EQUALITY ); break; case LDAP_FILTER_SUBSTRINGS: Debug( LDAP_DEBUG_FILTER, " SUBSTRINGS/n", 0, 0, 0 ); rc = test_substrings_filter( op, e, f ); break; case LDAP_FILTER_GE: Debug( LDAP_DEBUG_FILTER, " GE/n", 0, 0, 0 ); rc = test_ava_filter( op, e, f->f_ava, LDAP_FILTER_GE ); break; case LDAP_FILTER_LE: Debug( LDAP_DEBUG_FILTER, " LE/n", 0, 0, 0 ); rc = test_ava_filter( op, e, f->f_ava, LDAP_FILTER_LE ); break; case LDAP_FILTER_PRESENT: Debug( LDAP_DEBUG_FILTER, " PRESENT/n", 0, 0, 0 ); rc = test_presence_filter( op, e, f->f_desc ); break; case LDAP_FILTER_APPROX: Debug( LDAP_DEBUG_FILTER, " APPROX/n", 0, 0, 0 ); rc = test_ava_filter( op, e, f->f_ava, LDAP_FILTER_APPROX ); break; case LDAP_FILTER_AND: Debug( LDAP_DEBUG_FILTER, " AND/n", 0, 0, 0 ); rc = test_filter_and( op, e, f->f_and ); break; case LDAP_FILTER_OR: Debug( LDAP_DEBUG_FILTER, " OR/n", 0, 0, 0 ); rc = test_filter_or( op, e, f->f_or ); break; case LDAP_FILTER_NOT: Debug( LDAP_DEBUG_FILTER, " NOT/n", 0, 0, 0 ); rc = test_filter( op, e, f->f_not ); /* Flip true to false and false to true * but leave Undefined alone. */ switch( rc ) { case LDAP_COMPARE_TRUE: rc = LDAP_COMPARE_FALSE; break; case LDAP_COMPARE_FALSE: rc = LDAP_COMPARE_TRUE; break; } break; case LDAP_FILTER_EXT: Debug( LDAP_DEBUG_FILTER, " EXT/n", 0, 0, 0 ); rc = test_mra_filter( op, e, f->f_mra ); break; default: Debug( LDAP_DEBUG_ANY, " unknown filter type %lu/n", f->f_choice, 0, 0 ); rc = LDAP_PROTOCOL_ERROR; }out: Debug( LDAP_DEBUG_FILTER, "<= test_filter %d/n", rc, 0, 0 ); return( rc );}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:97,
示例23: backsql_deleteintbacksql_delete( Operation *op, SlapReply *rs ){ SQLHDBC dbh = SQL_NULL_HDBC; SQLHSTMT sth = SQL_NULL_HSTMT; backsql_oc_map_rec *oc = NULL; backsql_srch_info bsi = { 0 }; backsql_entryID e_id = { 0 }; Entry d = { 0 }, p = { 0 }, *e = NULL; struct berval pdn = BER_BVNULL; int manageDSAit = get_manageDSAit( op ); Debug( LDAP_DEBUG_TRACE, "==>backsql_delete(): deleting entry /"%s/"/n", op->o_req_ndn.bv_val, 0, 0 ); rs->sr_err = backsql_get_db_conn( op, &dbh ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "could not get connection handle - exiting/n", 0, 0, 0 ); rs->sr_text = ( rs->sr_err == LDAP_OTHER ) ? "SQL-backend error" : NULL; e = NULL; goto done; } /* * Get the entry */ bsi.bsi_e = &d; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY | BACKSQL_ISF_GET_OC ) ); switch ( rs->sr_err ) { case LDAP_SUCCESS: break; case LDAP_REFERRAL: if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) && dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) ) { rs->sr_err = LDAP_SUCCESS; rs->sr_text = NULL; rs->sr_matched = NULL; if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } break; } e = &d; /* fallthru */ default: Debug( LDAP_DEBUG_TRACE, "backsql_delete(): " "could not retrieve deleteDN ID - no such entry/n", 0, 0, 0 ); if ( !BER_BVISNULL( &d.e_nname ) ) { /* FIXME: should always be true! */ e = &d; } else { e = NULL; } goto done; } if ( get_assert( op ) && ( test_filter( op, &d, get_assertion( op ) ) != LDAP_COMPARE_TRUE ) ) { rs->sr_err = LDAP_ASSERTION_FAILED; e = &d; goto done; } if ( !access_allowed( op, &d, slap_schema.si_ad_entry, NULL, ACL_WDEL, NULL ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_delete(): " "no write access to entry/n", 0, 0, 0 ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; e = &d; goto done; } rs->sr_err = backsql_has_children( op, dbh, &op->o_req_ndn ); switch ( rs->sr_err ) { case LDAP_COMPARE_FALSE: rs->sr_err = LDAP_SUCCESS; break; case LDAP_COMPARE_TRUE:#ifdef SLAP_CONTROL_X_TREE_DELETE if ( get_treeDelete( op ) ) { rs->sr_err = LDAP_SUCCESS; break; }//.........这里部分代码省略.........
开发者ID:cptaffe,项目名称:openldap,代码行数:101,
示例24: ndb_back_modify//.........这里部分代码省略......... goto return_results;#if 0 case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: goto retry;#endif case LDAP_BUSY: rs->sr_text = "ldap server busy"; goto return_results; default: rs->sr_err = LDAP_OTHER; rs->sr_text = "internal error"; goto return_results; } /* acquire and lock entry */ rs->sr_err = ndb_entry_get_data( op, &NA, 1 ); if ( !manageDSAit && is_entry_referral( &e ) ) { /* entry is a referral, don't allow modify */ rs->sr_ref = get_entry_referrals( op, &e ); Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(ndb_back_modify) ": entry is referral/n", 0, 0, 0 ); rs->sr_err = LDAP_REFERRAL; rs->sr_matched = e.e_name.bv_val; rs->sr_flags = REP_REF_MUSTBEFREED; goto return_results; } if ( get_assert( op ) && ( test_filter( op, &e, (Filter*)get_assertion( op )) != LDAP_COMPARE_TRUE )) { rs->sr_err = LDAP_ASSERTION_FAILED; goto return_results; } if( op->o_preread ) { if( preread_ctrl == NULL ) { preread_ctrl = &ctrls[num_ctrls++]; ctrls[num_ctrls] = NULL; } if ( slap_read_controls( op, rs, &e, &slap_pre_read_bv, preread_ctrl ) ) { Debug( LDAP_DEBUG_TRACE, "<=- " LDAP_XSTRING(ndb_back_modify) ": pre-read " "failed!/n", 0, 0, 0 ); if ( op->o_preread & SLAP_CONTROL_CRITICAL ) { /* FIXME: is it correct to abort * operation if control fails? */ goto return_results; } } } /* Modify the entry */ rs->sr_err = ndb_modify_internal( op, &NA, &rs->sr_text, textbuf, textlen ); if( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(ndb_back_modify) ": modify failed (%d)/n", rs->sr_err, 0, 0 );#if 0
开发者ID:Distrotech,项目名称:openldap,代码行数:67,
示例25: passwd_back_searchintpasswd_back_search( Operation *op, SlapReply *rs ){ struct passwd *pw; time_t stoptime = (time_t)-1; LDAPRDN rdn = NULL; struct berval parent = BER_BVNULL; AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; if ( op->ors_tlimit != SLAP_NO_LIMIT ) { stoptime = op->o_time + op->ors_tlimit; } /* Handle a query for the base of this backend */ if ( be_issuffix( op->o_bd, &op->o_req_ndn ) ) { struct berval val; rs->sr_matched = op->o_req_dn.bv_val; if( op->ors_scope != LDAP_SCOPE_ONELEVEL ) { AttributeDescription *desc = NULL; char *next; Entry e = { 0 }; /* Create an entry corresponding to the base DN */ e.e_name.bv_val = ch_strdup( op->o_req_dn.bv_val ); e.e_name.bv_len = op->o_req_dn.bv_len; e.e_nname.bv_val = ch_strdup( op->o_req_ndn.bv_val ); e.e_nname.bv_len = op->o_req_ndn.bv_len; /* Use the first attribute of the DN * as an attribute within the entry itself. */ if( ldap_bv2rdn( &op->o_req_dn, &rdn, &next, LDAP_DN_FORMAT_LDAP ) ) { rs->sr_err = LDAP_INVALID_DN_SYNTAX; goto done; } if( slap_bv2ad( &rdn[0]->la_attr, &desc, &rs->sr_text )) { rs->sr_err = LDAP_NO_SUCH_OBJECT; ldap_rdnfree(rdn); goto done; } attr_merge_normalize_one( &e, desc, &rdn[0]->la_value, NULL ); ldap_rdnfree(rdn); rdn = NULL; /* Every entry needs an objectclass. We don't really * know if our hardcoded choice here agrees with the * DN that was configured for this backend, but it's * better than nothing. * * should be a configuratable item */ BER_BVSTR( &val, "organizationalUnit" ); attr_merge_one( &e, ad_objectClass, &val, NULL ); if ( test_filter( op, &e, op->ors_filter ) == LDAP_COMPARE_TRUE ) { rs->sr_entry = &e; rs->sr_attrs = op->ors_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); rs->sr_flags = 0; rs->sr_attrs = NULL; } entry_clean( &e ); } if ( op->ors_scope != LDAP_SCOPE_BASE ) { /* check all our "children" */ ldap_pvt_thread_mutex_lock( &passwd_mutex ); pw_start( op->o_bd ); for ( pw = getpwent(); pw != NULL; pw = getpwent() ) { Entry e = { 0 }; /* check for abandon */ if ( op->o_abandon ) { endpwent(); ldap_pvt_thread_mutex_unlock( &passwd_mutex ); return( SLAPD_ABANDON ); } /* check time limit */ if ( op->ors_tlimit != SLAP_NO_LIMIT && slap_get_time() > stoptime ) { send_ldap_error( op, rs, LDAP_TIMELIMIT_EXCEEDED, NULL ); endpwent(); ldap_pvt_thread_mutex_unlock( &passwd_mutex ); return( 0 );//.........这里部分代码省略.........
开发者ID:winlibs,项目名称:openldap,代码行数:101,
示例26: backsql_modrdnintbacksql_modrdn( Operation *op, SlapReply *rs ){ backsql_info *bi = (backsql_info*)op->o_bd->be_private; SQLHDBC dbh = SQL_NULL_HDBC; SQLHSTMT sth = SQL_NULL_HSTMT; RETCODE rc; backsql_entryID e_id = BACKSQL_ENTRYID_INIT, n_id = BACKSQL_ENTRYID_INIT; backsql_srch_info bsi = { 0 }; backsql_oc_map_rec *oc = NULL; struct berval pdn = BER_BVNULL, pndn = BER_BVNULL, *new_pdn = NULL, *new_npdn = NULL, new_dn = BER_BVNULL, new_ndn = BER_BVNULL, realnew_dn = BER_BVNULL; Entry r = { 0 }, p = { 0 }, n = { 0 }, *e = NULL; int manageDSAit = get_manageDSAit( op ); struct berval *newSuperior = op->oq_modrdn.rs_newSup; Debug( LDAP_DEBUG_TRACE, "==>backsql_modrdn() renaming entry /"%s/", " "newrdn=/"%s/", newSuperior=/"%s/"/n", op->o_req_dn.bv_val, op->oq_modrdn.rs_newrdn.bv_val, newSuperior ? newSuperior->bv_val : "(NULL)" ); rs->sr_err = backsql_get_db_conn( op, &dbh ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "could not get connection handle - exiting/n" ); rs->sr_text = ( rs->sr_err == LDAP_OTHER ) ? "SQL-backend error" : NULL; e = NULL; goto done; } bsi.bsi_e = &r; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY | BACKSQL_ISF_GET_OC ) ); switch ( rs->sr_err ) { case LDAP_SUCCESS: break; case LDAP_REFERRAL: if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) && dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) ) { rs->sr_err = LDAP_SUCCESS; rs->sr_text = NULL; rs->sr_matched = NULL; if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } break; } e = &r; /* fallthru */ default: Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): " "could not retrieve modrdnDN ID - no such entry/n" ); if ( !BER_BVISNULL( &r.e_nname ) ) { /* FIXME: should always be true! */ e = &r; } else { e = NULL; } goto done; } Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): entry id=" BACKSQL_IDFMT "/n", BACKSQL_IDARG(e_id.eid_id) ); if ( get_assert( op ) && ( test_filter( op, &r, get_assertion( op ) ) != LDAP_COMPARE_TRUE ) ) { rs->sr_err = LDAP_ASSERTION_FAILED; e = &r; goto done; } if ( backsql_has_children( op, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "entry /"%s/" has children/n", op->o_req_dn.bv_val ); rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF; rs->sr_text = "subtree rename not supported"; e = &r; goto done; } /*//.........这里部分代码省略.........
开发者ID:verter2015,项目名称:ReOpenLDAP,代码行数:101,
示例27: bdb_addintbdb_add(Operation *op, SlapReply *rs ){ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; struct berval pdn; Entry *p = NULL, *oe = op->ora_e; EntryInfo *ei; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; AttributeDescription *children = slap_schema.si_ad_children; AttributeDescription *entry = slap_schema.si_ad_entry; DB_TXN *ltid = NULL, *lt2; ID eid = NOID; struct bdb_op_info opinfo = {{{ 0 }}}; int subentry; DB_LOCK lock; int num_retries = 0; int success; LDAPControl **postread_ctrl = NULL; LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS]; int num_ctrls = 0;#ifdef LDAP_X_TXN int settle = 0;#endif Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_add) ": %s/n", op->ora_e->e_name.bv_val, 0, 0);#ifdef LDAP_X_TXN if( op->o_txnSpec ) { /* acquire connection lock */ ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); if( op->o_conn->c_txn == CONN_TXN_INACTIVE ) { rs->sr_text = "invalid transaction identifier"; rs->sr_err = LDAP_X_TXN_ID_INVALID; goto txnReturn; } else if( op->o_conn->c_txn == CONN_TXN_SETTLE ) { settle=1; goto txnReturn; } if( op->o_conn->c_txn_backend == NULL ) { op->o_conn->c_txn_backend = op->o_bd; } else if( op->o_conn->c_txn_backend != op->o_bd ) { rs->sr_text = "transaction cannot span multiple database contexts"; rs->sr_err = LDAP_AFFECTS_MULTIPLE_DSAS; goto txnReturn; } /* insert operation into transaction */ rs->sr_text = "transaction specified"; rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;txnReturn: /* release connection lock */ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); if( !settle ) { send_ldap_result( op, rs ); return rs->sr_err; } }#endif ctrls[num_ctrls] = 0; /* check entry's schema */ rs->sr_err = entry_schema_check( op, op->ora_e, NULL, get_relax(op), 1, NULL, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_add) ": entry failed schema check: " "%s (%d)/n", rs->sr_text, rs->sr_err, 0 ); goto return_results; } /* add opattrs to shadow as well, only missing attrs will actually * be added; helps compatibility with older OL versions */ rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_add) ": entry failed op attrs add: " "%s (%d)/n", rs->sr_text, rs->sr_err, 0 ); goto return_results; } if ( get_assert( op ) && ( test_filter( op, op->ora_e, get_assertion( op )) != LDAP_COMPARE_TRUE )) { rs->sr_err = LDAP_ASSERTION_FAILED; goto return_results; } subentry = is_entry_subentry( op->ora_e );//.........这里部分代码省略.........
开发者ID:DanahBlanahaseth,项目名称:cniiag_ldap,代码行数:101,
示例28: slapcatintslapcat( int argc, char **argv ){ ID id; int rc = EXIT_SUCCESS; Operation op = {0}; const char *progname = "slapcat"; int requestBSF; int doBSF = 0; slap_tool_init( progname, SLAPCAT, argc, argv ); requestBSF = ( sub_ndn.bv_len || filter );#ifdef SIGPIPE (void) SIGNAL( SIGPIPE, slapcat_sig );#endif#ifdef SIGHUP (void) SIGNAL( SIGHUP, slapcat_sig );#endif (void) SIGNAL( SIGINT, slapcat_sig ); (void) SIGNAL( SIGTERM, slapcat_sig ); if( !be->be_entry_open || !be->be_entry_close || !( be->be_entry_first_x || be->be_entry_first ) || !be->be_entry_next || !be->be_entry_get ) { fprintf( stderr, "%s: database doesn't support necessary operations./n", progname ); exit( EXIT_FAILURE ); } if( be->be_entry_open( be, 0 ) != 0 ) { fprintf( stderr, "%s: could not open database./n", progname ); exit( EXIT_FAILURE ); } op.o_bd = be; if ( !requestBSF && be->be_entry_first ) { id = be->be_entry_first( be ); } else { if ( be->be_entry_first_x ) { id = be->be_entry_first_x( be, sub_ndn.bv_len ? &sub_ndn : NULL, scope, filter ); } else { assert( be->be_entry_first != NULL ); doBSF = 1; id = be->be_entry_first( be ); } } for ( ; id != NOID; id = be->be_entry_next( be ) ) { char *data; int len; Entry* e; if ( gotsig ) break; e = be->be_entry_get( be, id ); if ( e == NULL ) { printf("# no data for entry id=%08lx/n/n", (long) id ); rc = EXIT_FAILURE; if ( continuemode == 0 ) { break; } else if ( continuemode == 1 ) { continue; } /* this is a last resort: linearly scan all ids * trying to recover as much as possible (ITS#6482) */ while ( ++id != NOID ) { e = be->be_entry_get( be, id ); if ( e != NULL ) break; printf("# no data for entry id=%08lx/n/n", (long) id ); } if ( e == NULL ) break; } if ( doBSF ) { if ( sub_ndn.bv_len && !dnIsSuffixScope( &e->e_nname, &sub_ndn, scope ) ) { be_entry_release_r( &op, e ); continue; } if ( filter != NULL ) { int rc = test_filter( NULL, e, filter ); if ( rc != LDAP_COMPARE_TRUE ) { be_entry_release_r( &op, e ); continue;//.........这里部分代码省略.........
开发者ID:dago,项目名称:openldap,代码行数:101,
示例29: dnssrv_back_search//.........这里部分代码省略......... bv.bv_len = strlen( refdn ); rc = dnNormalize( 0, NULL, NULL, &bv, &nrefdn, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { send_ldap_error( op, rs, LDAP_OTHER, "DNS SRV problem processing manageDSAit control" ); goto done; } } if( !dn_match( &nrefdn, &op->o_req_ndn ) ) { /* requested dn is subordinate */ Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=/"%s/" subordinate to refdn=/"%s/"/n", op->o_req_dn.bv_len ? op->o_req_dn.bv_val : "", refdn == NULL ? "" : refdn ); rs->sr_matched = refdn; rs->sr_err = LDAP_NO_SUCH_OBJECT; send_ldap_result( op, rs ); rs->sr_matched = NULL; } else if ( op->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL ) { send_ldap_error( op, rs, LDAP_SUCCESS, NULL ); } else { Entry e = { 0 }; AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; AttributeDescription *ad_ref = slap_schema.si_ad_ref; e.e_name.bv_val = ch_strdup( op->o_req_dn.bv_val ); e.e_name.bv_len = op->o_req_dn.bv_len; e.e_nname.bv_val = ch_strdup( op->o_req_ndn.bv_val ); e.e_nname.bv_len = op->o_req_ndn.bv_len; e.e_attrs = NULL; e.e_private = NULL; attr_merge_one( &e, ad_objectClass, &slap_schema.si_oc_referral->soc_cname, NULL ); attr_merge_one( &e, ad_objectClass, &slap_schema.si_oc_extensibleObject->soc_cname, NULL ); if ( ad_dc ) { char *p; struct berval bv; bv.bv_val = domain; p = strchr( bv.bv_val, '.' ); if ( p == bv.bv_val ) { bv.bv_len = 1; } else if ( p != NULL ) { bv.bv_len = p - bv.bv_val; } else { bv.bv_len = strlen( bv.bv_val ); } attr_merge_normalize_one( &e, ad_dc, &bv, NULL ); } if ( ad_associatedDomain ) { struct berval bv; ber_str2bv( domain, 0, 0, &bv ); attr_merge_normalize_one( &e, ad_associatedDomain, &bv, NULL ); } attr_merge_normalize_one( &e, ad_ref, urls, NULL ); rc = test_filter( op, &e, op->oq_search.rs_filter ); if( rc == LDAP_COMPARE_TRUE ) { rs->sr_entry = &e; rs->sr_attrs = op->oq_search.rs_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; send_search_entry( op, rs ); rs->sr_entry = NULL; rs->sr_attrs = NULL; rs->sr_flags = 0; } entry_clean( &e ); rs->sr_err = LDAP_SUCCESS; send_ldap_result( op, rs ); } free( refdn ); if ( nrefdn.bv_val ) free( nrefdn.bv_val );done: if( domain != NULL ) ch_free( domain ); if( hostlist != NULL ) ch_free( hostlist ); if( hosts != NULL ) ldap_charray_free( hosts ); if( urls != NULL ) ber_bvarray_free( urls ); return 0;}
开发者ID:openldap,项目名称:openldap,代码行数:101,
示例30: slapschemaintslapschema( int argc, char **argv ){ ID id; int rc = EXIT_SUCCESS; const char *progname = "slapschema"; Connection conn = { 0 }; OperationBuffer opbuf; Operation *op = NULL; void *thrctx; int requestBSF = 0; int doBSF = 0; slap_tool_init( progname, SLAPCAT, argc, argv ); requestBSF = ( sub_ndn.bv_len || filter );#ifdef SIGPIPE (void) SIGNAL( SIGPIPE, slapcat_sig );#endif#ifdef SIGHUP (void) SIGNAL( SIGHUP, slapcat_sig );#endif (void) SIGNAL( SIGINT, slapcat_sig ); (void) SIGNAL( SIGTERM, slapcat_sig ); if( !be->be_entry_open || !be->be_entry_close || !( be->be_entry_first || be->be_entry_first_x ) || !be->be_entry_next || !be->be_entry_get ) { fprintf( stderr, "%s: database doesn't support necessary operations./n", progname ); exit( EXIT_FAILURE ); } if( be->be_entry_open( be, 0 ) != 0 ) { fprintf( stderr, "%s: could not open database./n", progname ); exit( EXIT_FAILURE ); } thrctx = ldap_pvt_thread_pool_context(); connection_fake_init( &conn, &opbuf, thrctx ); op = &opbuf.ob_op; op->o_tmpmemctx = NULL; op->o_bd = be; if ( !requestBSF && be->be_entry_first ) { id = be->be_entry_first( be ); } else { if ( be->be_entry_first_x ) { id = be->be_entry_first_x( be, sub_ndn.bv_len ? &sub_ndn : NULL, scope, filter ); } else { assert( be->be_entry_first != NULL ); doBSF = 1; id = be->be_entry_first( be ); } } for ( ; id != NOID; id = be->be_entry_next( be ) ) { Entry* e; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof(textbuf); const char *text = NULL; if ( gotsig ) break; e = be->be_entry_get( be, id ); if ( e == NULL ) { printf("# no data for entry id=%08lx/n/n", (long) id ); rc = EXIT_FAILURE; if( continuemode ) continue; break; } if ( doBSF ) { if ( sub_ndn.bv_len && !dnIsSuffixScope( &e->e_nname, &sub_ndn, scope ) ) { be_entry_release_r( op, e ); continue; } if ( filter != NULL ) { int rc = test_filter( NULL, e, filter ); if ( rc != LDAP_COMPARE_TRUE ) { be_entry_release_r( op, e ); continue; } } } if( verbose ) {//.........这里部分代码省略.........
开发者ID:cptaffe,项目名称:openldap,代码行数:101,
注:本文中的test_filter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ test_function函数代码示例 C++ test_file函数代码示例 |