summaryrefslogtreecommitdiffstats
path: root/src/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.c')
-rw-r--r--src/format.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/format.c b/src/format.c
index 66a8940..9eb8978 100644
--- a/src/format.c
+++ b/src/format.c
@@ -410,7 +410,14 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data)
int i, j, disposition, buffer_flags, len, slen;
char *actual_attr;
const char *cvalue;
- struct format_referred_cbdata *cbdata = callback_data;
+ struct format_referred_cbdata *cbdata;
+
+ cbdata = callback_data;
+
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata->state->plugin_desc->spd_id,
+ "referred: examining \"%s\" in \%s\"\n",
+ cbdata->attr, slapi_entry_get_ndn(e));
/* Iterate through the values for the specified attribute. */
if (slapi_vattr_values_get(e, cbdata->attr, &values,
@@ -434,6 +441,9 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data)
if (len == 0) {
continue;
}
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata->state->plugin_desc->spd_id,
+ "referred: got value \"%s\"\n", cvalue);
slen = strlen(cbdata->separator);
/* Check if there's space for the value. */
if (len + (cbdata->count ? slen : 0) > cbdata->outbuf_len) {
@@ -454,6 +464,9 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data)
cvalue, len);
cbdata->outbuf += (len + (cbdata->count ? slen : 0));
cbdata->outbuf_len -= (len + (cbdata->count ? slen : 0));
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata->state->plugin_desc->spd_id,
+ "referred: stored value \"%s\"\n", cvalue);
cbdata->count++;
}
slapi_vattr_values_free(&values, &actual_attr, buffer_flags);
@@ -473,7 +486,8 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_PBlock *local_pb;
int disposition, ref_disposition, buffer_flags, ref_buffer_flags;
char **argv, *attrs[2], *actual_attr, *actual_ref_attr, *filter;
- const char *sep, *cvalue, *cref, *map_filter, **map_bases;
+ const char *sep, *cvalue, *cref;
+ char *map_filter, **map_bases;
struct format_referred_cbdata cbdata;
ret = format_parse_args(state, args, &argc, &argv);
@@ -512,10 +526,16 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
/* Retrieve the map-specific paramters. */
map_filter = NULL;
map_bases = NULL;
- backend_get_map_config(state, domain, map, &map_bases, &map_filter);
+ backend_get_map_config(state, domain, argv[1], &map_bases, &map_filter);
if (map_filter == NULL) {
map_filter = "(objectClass=*)";
}
+ if (map_bases == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "no search bases defined for \"%s\"/\"%s\"?\n",
+ domain, argv[1]);
+ }
/* Now just search through the entries used for the map. */
for (i = 0; (map_bases != NULL) && (map_bases[i] != NULL); i++) {
@@ -526,6 +546,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"referred: out of memory\n");
+ backend_free_map_config(map_bases, map_filter);
slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOMEM;
@@ -539,7 +560,11 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
NULL, NULL,
state->plugin_identity, 0);
/* Let the callback do the work. */
- slapi_search_internal_callback_pb(local_pb, state,
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "searching under \"%s\" for \"%s\"\n",
+ map_bases[i], filter);
+ slapi_search_internal_callback_pb(local_pb, &cbdata,
NULL,
format_referred_entry_cb,
NULL);
@@ -550,9 +575,10 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
}
}
+ backend_free_map_config(map_bases, map_filter);
slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
- return cbdata.ret;
+ return cbdata.outbuf - outbuf;
}
/* Evaluate each argument, after the first, in turn, and merge them, using the