From a4547135db29233dedc4b6bf429d3cfe89182e75 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Mon, 16 Jan 2012 14:17:28 -0500 Subject: - in callbacks, only use pblocks that are built from pblocks that we already have, so that we can pass the transaction ID around; this includes additional parameters for a number of functions and a new callback data type for backend_set_config_entry_add_cb() --- src/format.c | 61 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'src/format.c') diff --git a/src/format.c b/src/format.c index ba09b41..60c3bf6 100644 --- a/src/format.c +++ b/src/format.c @@ -286,13 +286,14 @@ format_add_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, } static int -format_check_entry(const char *dn, char *filter, void *identity) +format_check_entry(Slapi_PBlock *pb, const char *dn, char *filter, + void *identity) { Slapi_DN *sdn; Slapi_Entry *entry; sdn = slapi_sdn_new_dn_byval(dn); - wrap_search_internal_get_entry(sdn, filter, NULL, &entry, identity); + wrap_search_internal_get_entry(pb, sdn, filter, NULL, &entry, identity); slapi_sdn_free(&sdn); if (entry != NULL) { slapi_entry_free(entry); @@ -303,10 +304,11 @@ format_check_entry(const char *dn, char *filter, void *identity) } static void -format_add_filtered_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, +format_add_filtered_sdn_list(Slapi_PBlock *pb, + struct slapi_dn ***list, struct slapi_dn ***list2, const char *dn, char *filter, void *identity) { - if (format_check_entry(dn, filter, identity) == 0) { + if (format_check_entry(pb, dn, filter, identity) == 0) { format_add_sdn_list(list, list2, dn); } } @@ -947,7 +949,7 @@ format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, default_value = argv[1]; } ret = -ENOENT; - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, value_format, disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -1057,7 +1059,7 @@ format_deref_x(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "\"%s\"\n", fname, cref); continue; } - wrap_search_internal_get_entry(refdn, filter, attrs, &ref, + wrap_search_internal_get_entry(pb, refdn, filter, attrs, &ref, state->plugin_identity); if (ref == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -1271,7 +1273,7 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, &list->links[i].base_sdn_list2, slapi_sdn_get_ndn(parent)); /* Pull up the named entry. */ - wrap_search_internal_get_entry(these[j], + wrap_search_internal_get_entry(pb, these[j], NULL, attrs, &entry, state->plugin_identity); @@ -1315,13 +1317,13 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Let's visit the named entry this * time, in case we're nesting. */ - format_add_filtered_sdn_list(&these, &these2, + format_add_filtered_sdn_list(pb, &these, &these2, cvalue, list->links[i + 1].filter_str, state->plugin_identity); /* We need to visit the named entry * next time. */ - format_add_filtered_sdn_list(&next, &next2, + format_add_filtered_sdn_list(pb, &next, &next2, cvalue, list->links[i + 1].filter_str, state->plugin_identity); @@ -1586,7 +1588,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * examine. */ set_filter = NULL; set_bases = NULL; - backend_get_set_config(state, group, other_set, + backend_get_set_config(pb, state, group, other_set, &set_bases, &set_filter); if (set_bases == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -1640,7 +1642,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, attrs[1] = NULL; for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) { /* Set up the search. */ - local_pb = slapi_pblock_new(); + local_pb = wrap_pblock_new(pb); slapi_search_internal_set_pb(local_pb, set_bases[i], LDAP_SCOPE_SUBTREE, filter, attrs, FALSE, @@ -1828,7 +1830,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Get the searching parameters for the set which contains the entry, * and all of the referred-to sets, and save them for use at the last * link in the chain. */ - backend_get_set_config(state, group, set, + backend_get_set_config(pb, state, group, set, &set_bases, &set_filter); for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) { format_add_sdn_list(&(list->links[0].base_sdn_list), @@ -1837,7 +1839,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } backend_free_set_config(set_bases, set_filter); for (i = 0; i < list->n_links - 1; i++) { - backend_get_set_config(state, group, argv[i * 2], + backend_get_set_config(pb, state, group, argv[i * 2], &set_bases, &set_filter); for (j = 0; (set_bases != NULL) && (set_bases[j] != NULL); @@ -1896,7 +1898,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "referred_r: searching under %s" " for \"%s\" (link=1.%d)\n", ndn, filter, i); - local_pb = slapi_pblock_new(); + local_pb = wrap_pblock_new(pb); slapi_search_internal_set_pb(local_pb, ndn, LDAP_SCOPE_SUBTREE, @@ -1937,7 +1939,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "referred_r: searching under %s" " for \"%s\" (link=2.%d)\n", ndn, filter, i); - local_pb = slapi_pblock_new(); + local_pb = wrap_pblock_new(pb); slapi_search_internal_set_pb(local_pb, ndn, LDAP_SCOPE_SUBTREE, @@ -2017,7 +2019,7 @@ format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, argv[i], disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -2105,7 +2107,7 @@ format_match_generic(struct plugin_state *state, matches = NULL; count = 0; lengths = NULL; - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, argv[0], disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -2157,7 +2159,7 @@ format_match_generic(struct plugin_state *state, /* Either no matches, or too many matches to store. */ default_value = NULL; if ((default_arg >= 0) && (argv[default_arg] != NULL)) { - default_value = format_get_data(state, e, + default_value = format_get_data(state, pb, e, group, set, argv[default_arg], disallowed, @@ -2553,7 +2555,7 @@ format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Evaluate the value expression to get a list of candidate values. */ - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, argv[1], disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -2636,7 +2638,7 @@ format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, choices = NULL; for (i = 0; i < argc; i++) { /* Evaluate this argument. */ - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, argv[i], disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -2752,7 +2754,7 @@ format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, for (i = 0; i < argc; i += 3) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i]); - values[i / 3] = format_get_data_set(state, e, group, set, + values[i / 3] = format_get_data_set(state, pb, e, group, set, argv[i], disallowed, rel_attrs, ref_attrs, inref_attrs, @@ -2925,7 +2927,7 @@ format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, default_value = argv[1]; } ret = -ENOENT; - values = format_get_data_set(state, e, group, set, + values = format_get_data_set(state, pb, e, group, set, value_format, disallowed, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -3821,7 +3823,8 @@ format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static char * -format_format(struct plugin_state *state, Slapi_Entry *e, +format_format(struct plugin_state *state, + Slapi_PBlock *parent_pb, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, struct format_choice **choices, @@ -3849,7 +3852,7 @@ format_format(struct plugin_state *state, Slapi_Entry *e, return NULL; } - pb = slapi_pblock_new(); + pb = wrap_pblock_new(parent_pb); i = format_expand(state, pb, e, group, set, fmt, disallowed, buf, buflen, choices, @@ -3909,7 +3912,8 @@ format_free_data(char *data) } } char * -format_get_data(struct plugin_state *state, Slapi_Entry *e, +format_get_data(struct plugin_state *state, + Slapi_PBlock *pb, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, char ***rel_attrs, @@ -3920,7 +3924,7 @@ format_get_data(struct plugin_state *state, Slapi_Entry *e, unsigned int *data_length) { unsigned int ignored; - return format_format(state, e, group, set, fmt, + return format_format(state, pb, e, group, set, fmt, disallowed, NULL, rel_attrs, ref_attrs, inref_attrs, @@ -3941,7 +3945,8 @@ format_free_data_set(char **data, unsigned int *data_lengths) free(data_lengths); } char ** -format_get_data_set(struct plugin_state *state, Slapi_Entry *e, +format_get_data_set(struct plugin_state *state, + Slapi_PBlock *pb, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, char ***rel_attrs, @@ -3957,7 +3962,7 @@ format_get_data_set(struct plugin_state *state, Slapi_Entry *e, int combinations, groupsize, i, j, k, offset, length, prev_offset; unsigned int template_len; choices = NULL; - template = format_format(state, e, group, set, fmt, disallowed, + template = format_format(state, pb, e, group, set, fmt, disallowed, &choices, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, -- cgit