| |
@@ -56,18 +56,24 @@
|
| |
struct format_choice *next;
|
| |
};
|
| |
|
| |
- static int format_expand(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ static int format_expand(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *fmt, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *fmt,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list);
|
| |
+ struct format_choice **outbuf_choices);
|
| |
+
|
| |
+ static char *
|
| |
+ format_format(struct format_state *st, Slapi_Entry *e,
|
| |
+ const char *group, const char *set,
|
| |
+ const char *fmt,
|
| |
+ struct format_choice **choices,
|
| |
+ unsigned int *data_length);
|
| |
+
|
| |
+ static char **
|
| |
+ format_get_data_set_int(struct format_state *st, Slapi_Entry *e,
|
| |
+ const char *group, const char *set,
|
| |
+ const char *fmt,
|
| |
+ unsigned int **data_lengths);
|
| |
|
| |
static char *
|
| |
xstrndup(const char *start, size_t length)
|
| |
@@ -288,14 +294,50 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_check_entry_exists(Slapi_PBlock *pb, const char *dn, char *filter,
|
| |
- void *identity)
|
| |
+ format_search_get_entry_cb(Slapi_Entry *e, void *cb)
|
| |
+ {
|
| |
+ Slapi_Entry **ret = cb;
|
| |
+ if (*ret) {
|
| |
+ slapi_entry_free(*ret);
|
| |
+ }
|
| |
+ *ret = slapi_entry_dup(e);
|
| |
+ return 0;
|
| |
+ }
|
| |
+
|
| |
+ static int
|
| |
+ format_search_get_entry(struct format_state *st,
|
| |
+ Slapi_DN *dn, char *filter, char **attrs,
|
| |
+ Slapi_Entry **ret_entry)
|
| |
+ {
|
| |
+ Slapi_PBlock *pb;
|
| |
+ int ret;
|
| |
+
|
| |
+ *ret_entry = NULL;
|
| |
+ pb = slapi_pblock_new();
|
| |
+ if (pb == NULL) {
|
| |
+ return -1;
|
| |
+ }
|
| |
+ slapi_search_internal_set_pb(pb, slapi_sdn_get_dn(dn), LDAP_SCOPE_BASE,
|
| |
+ filter ? filter : "(objectClass=*)", attrs,
|
| |
+ FALSE, NULL, NULL, st->plugin_identity, 0);
|
| |
+ ret = st->search_callback_pb(st, pb, ret_entry,
|
| |
+ NULL,
|
| |
+ format_search_get_entry_cb,
|
| |
+ NULL);
|
| |
+ slapi_pblock_destroy(pb);
|
| |
+ return ret;
|
| |
+ }
|
| |
+
|
| |
+ static int
|
| |
+ format_check_entry_exists(struct format_state *st, const char *dn, char *filter)
|
| |
{
|
| |
Slapi_DN *sdn;
|
| |
Slapi_Entry *entry;
|
| |
|
| |
sdn = slapi_sdn_new_dn_byval(dn);
|
| |
- wrap_search_internal_get_entry(pb, sdn, filter, NULL, &entry, identity);
|
| |
+ /* pblock used in wrap_search_internal_get_entry() is a new one, it never
|
| |
+ * gets generated from the one we pass */
|
| |
+ format_search_get_entry(st, sdn, filter, NULL, &entry);
|
| |
slapi_sdn_free(&sdn);
|
| |
if (entry != NULL) {
|
| |
slapi_entry_free(entry);
|
| |
@@ -306,29 +348,27 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_check_sdn_location(const Slapi_DN *sdn,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees)
|
| |
+ format_check_sdn_location(struct format_state *st, const Slapi_DN *sdn)
|
| |
{
|
| |
int i;
|
| |
|
| |
- if (restrict_subtrees != NULL) {
|
| |
- for (i = 0; restrict_subtrees[i] != NULL; i++) {
|
| |
+ if (st->config.restrict_subtrees != NULL) {
|
| |
+ for (i = 0; st->config.restrict_subtrees[i] != NULL; i++) {
|
| |
if (slapi_sdn_scope_test(sdn,
|
| |
- restrict_subtrees[i],
|
| |
+ st->config.restrict_subtrees[i],
|
| |
LDAP_SCOPE_SUBTREE) != 0) {
|
| |
break;
|
| |
}
|
| |
}
|
| |
- if (restrict_subtrees[i] == NULL) {
|
| |
+ if (st->config.restrict_subtrees[i] == NULL) {
|
| |
/* Non-empty list, but no match. */
|
| |
return ENOENT;
|
| |
}
|
| |
}
|
| |
- if (ignore_subtrees != NULL) {
|
| |
- for (i = 0; ignore_subtrees[i] != NULL; i++) {
|
| |
+ if (st->config.ignore_subtrees != NULL) {
|
| |
+ for (i = 0; st->config.ignore_subtrees[i] != NULL; i++) {
|
| |
if (slapi_sdn_scope_test(sdn,
|
| |
- ignore_subtrees[i],
|
| |
+ st->config.ignore_subtrees[i],
|
| |
LDAP_SCOPE_SUBTREE) != 0) {
|
| |
return ENOENT;
|
| |
}
|
| |
@@ -338,29 +378,25 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_check_dn_location(const char *dn,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees)
|
| |
+ format_check_dn_location(struct format_state *st, const char *dn)
|
| |
{
|
| |
int ret = ENOENT;
|
| |
Slapi_DN *sdn;
|
| |
|
| |
sdn = slapi_sdn_new_dn_byref(dn);
|
| |
if (sdn != NULL) {
|
| |
- ret = format_check_sdn_location(sdn,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees);
|
| |
+ ret = format_check_sdn_location(st, sdn);
|
| |
slapi_sdn_free(&sdn);
|
| |
}
|
| |
return ret;
|
| |
}
|
| |
|
| |
static void
|
| |
- format_maybe_add_sdn_list(Slapi_PBlock *pb,
|
| |
+ format_maybe_add_sdn_list(struct format_state *st,
|
| |
struct slapi_dn ***list, struct slapi_dn ***list2,
|
| |
- const char *dn, char *filter, void *identity)
|
| |
+ const char *dn, char *filter)
|
| |
{
|
| |
- if (format_check_entry_exists(pb, dn, filter, identity) == 0) {
|
| |
+ if (format_check_entry_exists(st, dn, filter) == 0) {
|
| |
format_add_sdn_list(list, list2, dn);
|
| |
}
|
| |
}
|
| |
@@ -909,7 +945,7 @@
|
| |
free(argv);
|
| |
}
|
| |
static int
|
| |
- format_parse_args(struct plugin_state *state, const char *args,
|
| |
+ format_parse_args(struct format_state *st, const char *args,
|
| |
int *pargc, char ***pargv)
|
| |
{
|
| |
int i, dq, argc;
|
| |
@@ -965,33 +1001,28 @@
|
| |
return 0;
|
| |
}
|
| |
|
| |
+
|
| |
/* Choose the first value of the set of results for the first argument, and if
|
| |
* we get no results, return the second argument. */
|
| |
static int
|
| |
- format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_first(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, i, argc, first, common_length;
|
| |
char **argv, **values;
|
| |
const char *value_format, *default_value;
|
| |
unsigned int *lengths;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"first: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"first: error parsing arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
@@ -1004,30 +1035,23 @@
|
| |
default_value = argv[1];
|
| |
}
|
| |
ret = -ENOENT;
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- value_format, disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ value_format,
|
| |
+ &lengths);
|
| |
if (values == NULL) {
|
| |
if (default_value == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"first: no values for ->%s<-, "
|
| |
"and no default value provided\n",
|
| |
value_format);
|
| |
ret = -ENOENT;
|
| |
} else {
|
| |
- i = format_expand(state, pb, e,
|
| |
+ i = format_expand(st, e,
|
| |
group, set,
|
| |
- default_value, NULL,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ default_value,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
ret = i;
|
| |
}
|
| |
} else {
|
| |
@@ -1060,18 +1084,12 @@
|
| |
* argument, pull out the values for the attribute named by the second
|
| |
* argument, and return a list of those values. */
|
| |
static int
|
| |
- format_deref_x(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref_x(struct format_state *st, Slapi_Entry *e,
|
| |
const char *fname, const char *group, const char *set,
|
| |
char *ref_attr, char *target_attr,
|
| |
- char *filter, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ char *filter,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int i, j;
|
| |
Slapi_Entry *ref;
|
| |
@@ -1084,12 +1102,12 @@
|
| |
const struct berval *val;
|
| |
struct berval **choices;
|
| |
/* Note that this map cares about this attribute. */
|
| |
- if (rel_attrs != NULL) {
|
| |
- format_add_attrlist(rel_attrs, ref_attr);
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.rel_attrs, ref_attr);
|
| |
}
|
| |
/* Note that the attribute in this entry refers to other entries. */
|
| |
- if (ref_attrs != NULL) {
|
| |
- format_add_attrlist(ref_attrs, ref_attr);
|
| |
+ if (st->config.ref_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.ref_attrs, ref_attr);
|
| |
}
|
| |
/* Get the values of the reference attribute from this entry. */
|
| |
if (slapi_vattr_values_get(e, ref_attr, &ref_values,
|
| |
@@ -1114,39 +1132,36 @@
|
| |
refdn = slapi_sdn_new_dn_byval(cref);
|
| |
if (refdn == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: internal error parsing name "
|
| |
"\"%s\"\n", fname, cref);
|
| |
continue;
|
| |
}
|
| |
- if (format_check_sdn_location(refdn,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees) != 0) {
|
| |
+ if (format_check_sdn_location(st, refdn) != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: entry \"%s\" is in a location "
|
| |
"where we don't look\n", fname, cref);
|
| |
slapi_sdn_free(&refdn);
|
| |
continue;
|
| |
}
|
| |
- wrap_search_internal_get_entry(pb, refdn, filter, attrs, &ref,
|
| |
- state->plugin_identity);
|
| |
+ format_search_get_entry(st, refdn, filter, attrs, &ref);
|
| |
if (ref == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: failure reading entry \"%s\"\n",
|
| |
fname, slapi_sdn_get_ndn(refdn));
|
| |
slapi_sdn_free(&refdn);
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: reading \"%s\" from \"%s\"\n",
|
| |
fname, target_attr, slapi_sdn_get_ndn(refdn));
|
| |
slapi_sdn_free(&refdn);
|
| |
/* Note that this map cares about this attribute. */
|
| |
- if (rel_attrs != NULL) {
|
| |
- format_add_attrlist(rel_attrs, target_attr);
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.rel_attrs, target_attr);
|
| |
}
|
| |
/* Pull out the attribute from the referred-to entry. */
|
| |
if (slapi_vattr_values_get(ref, target_attr, &values,
|
| |
@@ -1182,34 +1197,28 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int argc, ret;
|
| |
char **argv, *ref_attr, *target_attr;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc != 2) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref: requires two arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1217,45 +1226,36 @@
|
| |
}
|
| |
ref_attr = argv[0];
|
| |
target_attr = argv[1];
|
| |
- ret = format_deref_x(state, pb, e, "deref", group, set,
|
| |
- ref_attr, target_attr, NULL, disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ ret = format_deref_x(st, e, "deref", group, set,
|
| |
+ ref_attr, target_attr, NULL,
|
| |
+ outbuf, outbuf_len, outbuf_choices);
|
| |
format_free_parsed_args(argv);
|
| |
return ret;
|
| |
}
|
| |
|
| |
static int
|
| |
- format_deref_f(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref_f(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int argc, ret;
|
| |
char **argv, *ref_attr, *filter, *target_attr;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_f: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc != 3) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_f: requires three arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_f: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1264,12 +1264,9 @@
|
| |
ref_attr = argv[0];
|
| |
filter = argv[1];
|
| |
target_attr = argv[2];
|
| |
- ret = format_deref_x(state, pb, e, "deref_f", group, set,
|
| |
- ref_attr, target_attr, filter, disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ ret = format_deref_x(st, e, "deref_f", group, set,
|
| |
+ ref_attr, target_attr, filter,
|
| |
+ outbuf, outbuf_len, outbuf_choices);
|
| |
format_free_parsed_args(argv);
|
| |
return ret;
|
| |
}
|
| |
@@ -1279,18 +1276,11 @@
|
| |
* at last, pull out the values for the attribute named by the last argument,
|
| |
* and return a list of those values. */
|
| |
static int
|
| |
- format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref_rx(struct format_state *st, Slapi_Entry *e,
|
| |
const char *fname, const char *group, const char *set,
|
| |
const char **attributes, const char **filters,
|
| |
- const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int i, j, k;
|
| |
Slapi_Entry *entry;
|
| |
@@ -1305,16 +1295,17 @@
|
| |
struct format_ref_attr_list *list;
|
| |
|
| |
/* Note that this map cares about all of these attributes. */
|
| |
- if (rel_attrs != NULL) {
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
for (i = 0; attributes[i] != NULL; i++) {
|
| |
- format_add_attrlist(rel_attrs, attributes[i]);
|
| |
+ format_add_attrlist(st->config.rel_attrs, attributes[i]);
|
| |
}
|
| |
}
|
| |
|
| |
/* Note that this list of attributes is used for pulling up data. */
|
| |
- format_add_ref_attr_list(ref_attr_list, group, set,
|
| |
+ format_add_ref_attr_list(st->config.ref_attr_list, group, set,
|
| |
attributes, filters);
|
| |
- list = format_find_ref_attr_list(*ref_attr_list, group, set,
|
| |
+ list = format_find_ref_attr_list(*(st->config.ref_attr_list),
|
| |
+ group, set,
|
| |
attributes, filters);
|
| |
|
| |
/* Follow the chain: set up the first link. */
|
| |
@@ -1342,7 +1333,7 @@
|
| |
dn = slapi_sdn_get_ndn(these[j]);
|
| |
slapi_sdn_get_parent(these[j], parent);
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: noting parent "
|
| |
"\"%s\" for \"%s\"\n",
|
| |
fname, slapi_sdn_get_ndn(parent),
|
| |
@@ -1352,31 +1343,28 @@
|
| |
slapi_sdn_get_ndn(parent));
|
| |
/* Check if the referred-to entry is in a location that
|
| |
* we care about. */
|
| |
- if (format_check_sdn_location(these[j],
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees) != 0) {
|
| |
+ if (format_check_sdn_location(st, these[j]) != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: entry \"%s\" is in a location "
|
| |
"where we don't look\n", fname,
|
| |
slapi_sdn_get_ndn(these[j]));
|
| |
continue;
|
| |
}
|
| |
/* Pull up the named entry. */
|
| |
- wrap_search_internal_get_entry(pb, these[j],
|
| |
- NULL,
|
| |
- attrs, &entry,
|
| |
- state->plugin_identity);
|
| |
+ format_search_get_entry(st, these[j],
|
| |
+ NULL,
|
| |
+ attrs, &entry);
|
| |
if (entry == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: error reading entry "
|
| |
"\"%s\"\n", fname,
|
| |
slapi_sdn_get_dn(these[j]));
|
| |
continue;
|
| |
} else {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: reading entry "
|
| |
"\"%s\" (%d)\n", fname,
|
| |
slapi_sdn_get_dn(these[j]), i);
|
| |
@@ -1387,7 +1375,7 @@
|
| |
&actual_attr,
|
| |
0, &buffer_flags) != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: entry \"%s\" has no "
|
| |
"values for \"%s\"\n", fname,
|
| |
slapi_entry_get_dn(entry),
|
| |
@@ -1407,23 +1395,19 @@
|
| |
}
|
| |
/* If it's in an area that we're
|
| |
* ignoring, then ignore it already. */
|
| |
- if (format_check_dn_location(cvalue,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees) != 0) {
|
| |
+ if (format_check_dn_location(st, cvalue) != 0) {
|
| |
continue;
|
| |
}
|
| |
/* Let's visit the named entry this
|
| |
* time, in case we're nesting. */
|
| |
- format_maybe_add_sdn_list(pb, &these, &these2,
|
| |
+ format_maybe_add_sdn_list(st, &these, &these2,
|
| |
cvalue,
|
| |
- list->links[i + 1].filter_str,
|
| |
- state->plugin_identity);
|
| |
+ list->links[i + 1].filter_str);
|
| |
/* We need to visit the named entry
|
| |
* next time. */
|
| |
- format_maybe_add_sdn_list(pb, &next, &next2,
|
| |
+ format_maybe_add_sdn_list(st, &next, &next2,
|
| |
cvalue,
|
| |
- list->links[i + 1].filter_str,
|
| |
- state->plugin_identity);
|
| |
+ list->links[i + 1].filter_str);
|
| |
} else {
|
| |
/* Get the value. */
|
| |
bval = slapi_value_get_berval(value);
|
| |
@@ -1433,7 +1417,7 @@
|
| |
}
|
| |
format_add_bv_list(&choices, bval);
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%s: found value "
|
| |
"\"%.*s\" in \"%s\"\n",
|
| |
fname,
|
| |
@@ -1467,82 +1451,66 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_deref_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref_r(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc;
|
| |
char **argv;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_r: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 2) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_r: requires at least two arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_r: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
- ret = format_deref_rx(state, pb, e, "deref_r",
|
| |
+ ret = format_deref_rx(st, e, "deref_r",
|
| |
group, set,
|
| |
(const char **) argv, NULL,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
format_free_parsed_args(argv);
|
| |
return ret;
|
| |
}
|
| |
|
| |
static int
|
| |
- format_deref_rf(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_deref_rf(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, n, i;
|
| |
char **argv, **attrs, **filters;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_rf: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 3) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_rf: requires at least three "
|
| |
"arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_rf: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1552,7 +1520,7 @@
|
| |
n = (argc + 1) / 2;
|
| |
attrs = malloc(sizeof(char *) * (n + 1));
|
| |
if (attrs == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_rf: out of memory\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -ENOMEM;
|
| |
@@ -1560,7 +1528,7 @@
|
| |
memset(attrs, 0, sizeof(char *) * (n + 1));
|
| |
filters = malloc(sizeof(char *) * (n + 1));
|
| |
if (filters == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"deref_rf: out of memory\n");
|
| |
free(attrs);
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1573,15 +1541,11 @@
|
| |
filters[i + 1] = argv[i * 2 + 1];
|
| |
}
|
| |
}
|
| |
- ret = format_deref_rx(state, pb, e, "deref_rf",
|
| |
+ ret = format_deref_rx(st, e, "deref_rf",
|
| |
group, set,
|
| |
(const char **) attrs, (const char **) filters,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
free(filters);
|
| |
free(attrs);
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1593,7 +1557,7 @@
|
| |
* the values for the attribute named by the third argument, and return a list
|
| |
* of those values. */
|
| |
struct format_referred_cbdata {
|
| |
- struct plugin_state *state;
|
| |
+ struct format_state *st;
|
| |
char *attr;
|
| |
struct berval **choices;
|
| |
};
|
| |
@@ -1610,7 +1574,7 @@
|
| |
cbdata = callback_data;
|
| |
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- cbdata->state->plugin_desc->spd_id,
|
| |
+ cbdata->st->plugin_desc->spd_id,
|
| |
"referred: examining \"%s\" in \%s\"\n",
|
| |
cbdata->attr, slapi_entry_get_ndn(e));
|
| |
|
| |
@@ -1619,7 +1583,7 @@
|
| |
&disposition, &actual_attr,
|
| |
0, &buffer_flags) != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- cbdata->state->plugin_desc->spd_id,
|
| |
+ cbdata->st->plugin_desc->spd_id,
|
| |
"referred: no values for \"%s\" in \"%s\"\n",
|
| |
cbdata->attr, slapi_entry_get_ndn(e));
|
| |
return 0;
|
| |
@@ -1633,7 +1597,7 @@
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- cbdata->state->plugin_desc->spd_id,
|
| |
+ cbdata->st->plugin_desc->spd_id,
|
| |
"referred: got %d-byte value for \"%s\"\n",
|
| |
(int) val->bv_len, actual_attr);
|
| |
/* Add it to the list of values we've retrieved. */
|
| |
@@ -1643,17 +1607,11 @@
|
| |
return 0;
|
| |
}
|
| |
static int
|
| |
- format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_referred(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int i, ret, argc;
|
| |
Slapi_PBlock *local_pb;
|
| |
@@ -1661,20 +1619,20 @@
|
| |
char *other_set, *set_filter, **set_bases, *use_filter;
|
| |
struct format_referred_cbdata cbdata;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc != 3) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred: requires 3 arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred: returns a list, but a list would "
|
| |
"not be appropriate here\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1685,7 +1643,7 @@
|
| |
attr = argv[2];
|
| |
|
| |
/* Set up to search for matches. */
|
| |
- cbdata.state = state;
|
| |
+ cbdata.st = st;
|
| |
cbdata.attr = attr;
|
| |
cbdata.choices = NULL;
|
| |
|
| |
@@ -1693,27 +1651,27 @@
|
| |
* examine. */
|
| |
set_filter = NULL;
|
| |
set_bases = NULL;
|
| |
- backend_get_set_config(pb, state, group, other_set,
|
| |
- &set_bases, &set_filter);
|
| |
+ st->get_bases_filter(st, group, other_set,
|
| |
+ &set_bases, &set_filter);
|
| |
if (set_bases == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"no search bases defined for \"%s\"/\"%s\"?\n",
|
| |
group, other_set);
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
format_free_parsed_args(argv);
|
| |
return -ENOENT;
|
| |
}
|
| |
|
| |
/* Note that this map cares about both attributes. */
|
| |
- if (rel_attrs != NULL) {
|
| |
- format_add_attrlist(rel_attrs, other_attr);
|
| |
- format_add_attrlist(rel_attrs, attr);
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.rel_attrs, other_attr);
|
| |
+ format_add_attrlist(st->config.rel_attrs, attr);
|
| |
}
|
| |
|
| |
/* Note that the attribute in this map refers to this entry. */
|
| |
- if (inref_attrs != NULL) {
|
| |
- format_add_inref_attrs(inref_attrs, group,
|
| |
+ if (st->config.inref_attrs != NULL) {
|
| |
+ format_add_inref_attrs(st->config.inref_attrs, group,
|
| |
other_set, other_attr);
|
| |
}
|
| |
|
| |
@@ -1722,9 +1680,9 @@
|
| |
tndn = format_escape_for_filter(slapi_entry_get_ndn(e));
|
| |
if (tndn == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"referred: out of memory\n");
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
format_free_parsed_args(argv);
|
| |
return -ENOMEM;
|
| |
}
|
| |
@@ -1732,10 +1690,10 @@
|
| |
filter = malloc(strlen(use_filter) + strlen(other_attr) +
|
| |
strlen(tndn) + 7);
|
| |
if (filter == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred: out of memory\n");
|
| |
free(tndn);
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
format_free_parsed_args(argv);
|
| |
return -ENOMEM;
|
| |
}
|
| |
@@ -1747,26 +1705,28 @@
|
| |
attrs[1] = NULL;
|
| |
for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) {
|
| |
/* Set up the search. */
|
| |
- local_pb = wrap_pblock_new(pb);
|
| |
+ local_pb = slapi_pblock_new();
|
| |
slapi_search_internal_set_pb(local_pb,
|
| |
set_bases[i], LDAP_SCOPE_SUBTREE,
|
| |
filter, attrs, FALSE,
|
| |
NULL, NULL,
|
| |
- state->plugin_identity, 0);
|
| |
+ st->plugin_identity, 0);
|
| |
/* Let the callback do the work of saving a value. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"searching under \"%s\" for \"%s\"\n",
|
| |
set_bases[i], filter);
|
| |
- slapi_search_internal_callback_pb(local_pb, &cbdata,
|
| |
- NULL,
|
| |
- format_referred_entry_cb,
|
| |
- NULL);
|
| |
+ (void) st->search_callback_pb(st,
|
| |
+ local_pb,
|
| |
+ &cbdata,
|
| |
+ NULL,
|
| |
+ format_referred_entry_cb,
|
| |
+ NULL);
|
| |
slapi_pblock_destroy(local_pb);
|
| |
}
|
| |
free(filter);
|
| |
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
format_free_parsed_args(argv);
|
| |
|
| |
/* Return any values we found. */
|
| |
@@ -1780,7 +1740,7 @@
|
| |
|
| |
/* Add the name of this entry to the DN list in the cbdata. */
|
| |
struct format_referred_r_entry_cbdata {
|
| |
- struct plugin_state *state;
|
| |
+ struct format_state *st;
|
| |
char *attribute;
|
| |
struct berval ***choices;
|
| |
Slapi_DN ***sdn_list, ***sdn_list2;
|
| |
@@ -1798,7 +1758,7 @@
|
| |
char *actual_attr;
|
| |
|
| |
/* Note that we visited this entry. */
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, cbdata->state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, cbdata->st->plugin_desc->spd_id,
|
| |
"search matched entry \"%s\"\n", slapi_entry_get_dn(e));
|
| |
format_add_sdn_list(cbdata->sdn_list, cbdata->sdn_list2,
|
| |
slapi_entry_get_dn(e));
|
| |
@@ -1812,7 +1772,7 @@
|
| |
&actual_attr,
|
| |
0, &buffer_flags) != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- cbdata->state->plugin_desc->spd_id,
|
| |
+ cbdata->st->plugin_desc->spd_id,
|
| |
"referred_r: entry \"%s\" has no "
|
| |
"values for \"%s\"\n",
|
| |
slapi_sdn_get_dn(sdn),
|
| |
@@ -1830,7 +1790,7 @@
|
| |
}
|
| |
format_add_bv_list(cbdata->choices, bval);
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- cbdata->state->plugin_desc->spd_id,
|
| |
+ cbdata->st->plugin_desc->spd_id,
|
| |
"referred_r: found value "
|
| |
"\"%.*s\" in \"%s\"\n",
|
| |
(int) bval->bv_len,
|
| |
@@ -1850,17 +1810,11 @@
|
| |
* get to the last argument, at which point we return the value of the
|
| |
* attribute named by the final argument. */
|
| |
static int
|
| |
- format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_referred_r(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int i, j, k, ret, argc, attrs_list_length;
|
| |
Slapi_PBlock *local_pb;
|
| |
@@ -1873,27 +1827,27 @@
|
| |
char *set_filter, **set_bases;
|
| |
const char **attr_links, *ndn;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred_r: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 3) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred_r: requires at least 3 arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if ((argc % 2) != 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred_r: requires an odd number of "
|
| |
"arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred_r: returns a list, but a list would "
|
| |
"not be appropriate here\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -1906,7 +1860,7 @@
|
| |
attrs_list_length = (argc + 1) / 2;
|
| |
attr_links = malloc((attrs_list_length + 1) * sizeof(char *));
|
| |
if (attr_links == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"referred_r: out of memory\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -ENOMEM;
|
| |
@@ -1921,33 +1875,35 @@
|
| |
attr_links[i] = NULL;
|
| |
|
| |
/* Note that this map cares about these attributes. */
|
| |
- if (rel_attrs != NULL) {
|
| |
- format_add_attrlist(rel_attrs, attr);
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.rel_attrs, attr);
|
| |
for (i = 0; attr_links[i] != NULL; i++) {
|
| |
- format_add_attrlist(rel_attrs, attr_links[i]);
|
| |
+ format_add_attrlist(st->config.rel_attrs, attr_links[i]);
|
| |
}
|
| |
}
|
| |
|
| |
/* Note this list of attributes. */
|
| |
- format_add_ref_attr_list(inref_attr_list, group, set, attr_links, NULL);
|
| |
- list = format_find_ref_attr_list(*inref_attr_list, group, set,
|
| |
+ format_add_ref_attr_list(st->config.inref_attr_list, group, set, attr_links, NULL);
|
| |
+ list = format_find_ref_attr_list(*(st->config.inref_attr_list), group, set,
|
| |
attr_links, NULL);
|
| |
free(attr_links);
|
| |
|
| |
/* 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(pb, state, group, set,
|
| |
- &set_bases, &set_filter);
|
| |
+ /* wrap_pblock_new() ignores its argument */
|
| |
+ st->get_bases_filter(st, 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),
|
| |
&(list->links[0].base_sdn_list2),
|
| |
set_bases[i]);
|
| |
}
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
for (i = 0; i < list->n_links - 1; i++) {
|
| |
- backend_get_set_config(pb, state, group, argv[i * 2],
|
| |
- &set_bases, &set_filter);
|
| |
+ /* wrap_pblock_new() ignores its argument */
|
| |
+ st->get_bases_filter(st, group, argv[i * 2],
|
| |
+ &set_bases, &set_filter);
|
| |
for (j = 0;
|
| |
(set_bases != NULL) && (set_bases[j] != NULL);
|
| |
j++) {
|
| |
@@ -1955,7 +1911,7 @@
|
| |
&(list->links[i + 1].base_sdn_list2),
|
| |
set_bases[j]);
|
| |
}
|
| |
- backend_free_set_config(set_bases, set_filter);
|
| |
+ st->free_bases_filter(st, &set_bases, &set_filter);
|
| |
}
|
| |
|
| |
/* Walk the chain, searching for entries which refer to entries at
|
| |
@@ -2001,29 +1957,30 @@
|
| |
ndn = slapi_sdn_get_dn(these_bases[k]);
|
| |
/* Search for referrers under this tree. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"referred_r: searching under %s"
|
| |
" for \"%s\" (link=1.%d)\n",
|
| |
ndn, filter, i);
|
| |
- local_pb = wrap_pblock_new(pb);
|
| |
+ local_pb = slapi_pblock_new();
|
| |
slapi_search_internal_set_pb(local_pb,
|
| |
ndn,
|
| |
LDAP_SCOPE_SUBTREE,
|
| |
filter, attrs,
|
| |
FALSE,
|
| |
NULL, NULL,
|
| |
- state->plugin_identity,
|
| |
+ st->plugin_identity,
|
| |
0);
|
| |
- entry_cbdata.state = state;
|
| |
+ entry_cbdata.st = st;
|
| |
entry_cbdata.attribute = attr;
|
| |
entry_cbdata.choices = &choices;
|
| |
entry_cbdata.sdn_list = &these_entries;
|
| |
entry_cbdata.sdn_list2 = &these_entries2;
|
| |
- slapi_search_internal_callback_pb(local_pb,
|
| |
- &entry_cbdata,
|
| |
- NULL,
|
| |
- format_referred_r_entry_cb,
|
| |
- NULL);
|
| |
+ (void) st->search_callback_pb(st,
|
| |
+ local_pb,
|
| |
+ &entry_cbdata,
|
| |
+ NULL,
|
| |
+ format_referred_r_entry_cb,
|
| |
+ NULL);
|
| |
slapi_pblock_destroy(local_pb);
|
| |
}
|
| |
free(filter);
|
| |
@@ -2042,29 +1999,30 @@
|
| |
ndn = slapi_sdn_get_dn(next_bases[k]);
|
| |
/* Search for referrers under that tree. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"referred_r: searching under %s"
|
| |
" for \"%s\" (link=2.%d)\n",
|
| |
ndn, filter, i);
|
| |
- local_pb = wrap_pblock_new(pb);
|
| |
+ local_pb = slapi_pblock_new();
|
| |
slapi_search_internal_set_pb(local_pb,
|
| |
ndn,
|
| |
LDAP_SCOPE_SUBTREE,
|
| |
filter, attrs,
|
| |
FALSE,
|
| |
NULL, NULL,
|
| |
- state->plugin_identity,
|
| |
+ st->plugin_identity,
|
| |
0);
|
| |
- entry_cbdata.state = state;
|
| |
+ entry_cbdata.st = st;
|
| |
entry_cbdata.attribute = attr;
|
| |
entry_cbdata.choices = &choices;
|
| |
entry_cbdata.sdn_list = &next_entries;
|
| |
entry_cbdata.sdn_list2 = &next_entries2;
|
| |
- slapi_search_internal_callback_pb(local_pb,
|
| |
- &entry_cbdata,
|
| |
- NULL,
|
| |
- format_referred_r_entry_cb,
|
| |
- NULL);
|
| |
+ (void) st->search_callback_pb(st,
|
| |
+ local_pb,
|
| |
+ &entry_cbdata,
|
| |
+ NULL,
|
| |
+ format_referred_r_entry_cb,
|
| |
+ NULL);
|
| |
slapi_pblock_destroy(local_pb);
|
| |
}
|
| |
free(filter);
|
| |
@@ -2093,31 +2051,25 @@
|
| |
/* Evaluate each argument's list of results, after the first, in turn, and
|
| |
* merge them, using the first argument as a separator. */
|
| |
static int
|
| |
- format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_merge(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, i, j, argc, slen, count;
|
| |
unsigned int *lengths;
|
| |
char **argv, **values;
|
| |
const char *sep;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"merge: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"merge: requires at least one argument\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
@@ -2126,17 +2078,14 @@
|
| |
slen = strlen(sep);
|
| |
for (i = 1, ret = 0, count = 0; i < argc; i++) {
|
| |
/* Expand this argument. */
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"merge: expanding ->%s<-\n", argv[i]);
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[i], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[i],
|
| |
+ &lengths);
|
| |
if (values == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"merge: no values for ->%s<-\n",
|
| |
argv[i]);
|
| |
continue;
|
| |
@@ -2146,7 +2095,7 @@
|
| |
if (ret + lengths[j] + (count ? slen : 0) >
|
| |
(unsigned int) outbuf_len) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"merge: out of space\n");
|
| |
format_free_data_set(values, lengths);
|
| |
format_free_parsed_args(argv);
|
| |
@@ -2154,7 +2103,7 @@
|
| |
}
|
| |
/* Log this value. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"merge: got %d-byte value for ->%s<\n",
|
| |
lengths[j], argv[i]);
|
| |
/* If this isn't the first result, fill in the
|
| |
@@ -2179,20 +2128,11 @@
|
| |
* of the default_arg'th argument if given, or return everything if no
|
| |
* default_arg'th argument was given. */
|
| |
static int
|
| |
- format_match_generic(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_match_generic(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
const char *args, int min_args, int default_arg,
|
| |
- const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
char *outbuf, int outbuf_len,
|
| |
struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list,
|
| |
const char *fnname,
|
| |
char * (*match_fn)(const char *pattern, const char *value,
|
| |
char **argv))
|
| |
@@ -2201,8 +2141,8 @@
|
| |
int i, count, argc, ret, len;
|
| |
unsigned int *lengths, default_length;
|
| |
|
| |
- plugin_id = state->plugin_desc->spd_id;
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ plugin_id = st->plugin_desc->spd_id;
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_id,
|
| |
"%s: error parsing arguments\n", fnname);
|
| |
@@ -2219,12 +2159,9 @@
|
| |
matches = NULL;
|
| |
count = 0;
|
| |
lengths = NULL;
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[0], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[0],
|
| |
+ &lengths);
|
| |
if (values != NULL) {
|
| |
for (i = 0; values[i] != NULL; i++) {
|
| |
continue;
|
| |
@@ -2273,18 +2210,11 @@
|
| |
* many matches to store. */
|
| |
default_value = NULL;
|
| |
if ((default_arg >= 0) && (argv[default_arg] != NULL)) {
|
| |
- default_value = format_get_data(state, pb, e,
|
| |
- group, set,
|
| |
- argv[default_arg],
|
| |
- disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
- rel_attrs,
|
| |
- ref_attrs,
|
| |
- inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list,
|
| |
- &default_length);
|
| |
+ default_value = format_format(st, e,
|
| |
+ group, set,
|
| |
+ argv[default_arg],
|
| |
+ NULL,
|
| |
+ &default_length);
|
| |
}
|
| |
if (default_arg < 0) {
|
| |
/* Return all of the matches as a list. */
|
| |
@@ -2384,47 +2314,25 @@
|
| |
return (fnmatch(pattern, value, 0) == 0) ? strdup(value) : NULL;
|
| |
}
|
| |
static int
|
| |
- format_match(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_match(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, 2,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, 2,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_match", format_match_cb);
|
| |
}
|
| |
static int
|
| |
- format_mmatch(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_mmatch(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, -1,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, -1,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_mmatch", format_match_cb);
|
| |
}
|
| |
|
| |
@@ -2450,47 +2358,25 @@
|
| |
return format_regmatch_base_cb(pattern, 0, value, argv);
|
| |
}
|
| |
static int
|
| |
- format_regmatch(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_regmatch(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, 2,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, 2,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_regmatch", format_regmatch_cb);
|
| |
}
|
| |
static int
|
| |
- format_mregmatch(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_mregmatch(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, -1,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, -1,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_mregmatch", format_regmatch_cb);
|
| |
}
|
| |
static char *
|
| |
@@ -2499,47 +2385,25 @@
|
| |
return format_regmatch_base_cb(pattern, REG_ICASE, value, argv);
|
| |
}
|
| |
static int
|
| |
- format_regmatchi(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_regmatchi(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, 2,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, 2,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_regmatchi", format_regmatchi_cb);
|
| |
}
|
| |
static int
|
| |
- format_mregmatchi(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_mregmatchi(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 2, -1,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 2, -1,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_mregmatchi", format_regmatchi_cb);
|
| |
}
|
| |
|
| |
@@ -2658,47 +2522,25 @@
|
| |
return format_regsub_base_cb(pattern, 0, value, argv);
|
| |
}
|
| |
static int
|
| |
- format_regsub(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_regsub(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 3, 3,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 3, 3,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_regsub", format_regsub_cb);
|
| |
}
|
| |
static int
|
| |
- format_mregsub(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_mregsub(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 3, -1,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 3, -1,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_mregsub", format_regsub_cb);
|
| |
}
|
| |
static char *
|
| |
@@ -2707,47 +2549,25 @@
|
| |
return format_regsub_base_cb(pattern, REG_ICASE, value, argv);
|
| |
}
|
| |
static int
|
| |
- format_regsubi(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_regsubi(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 3, 3,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 3, 3,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_regsubi", format_regsubi_cb);
|
| |
}
|
| |
static int
|
| |
- format_mregsubi(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_mregsubi(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
- return format_match_generic(state, pb, e, group, set, args, 3, -1,
|
| |
- disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
+ return format_match_generic(st, e, group, set, args, 3, -1,
|
| |
outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
"format_mregsubi", format_regsubi_cb);
|
| |
}
|
| |
|
| |
@@ -2757,17 +2577,11 @@
|
| |
* exactly we needed to do the comparison check (specifically,
|
| |
* case-sensitivity). */
|
| |
static int
|
| |
- format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_ifeq(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, i;
|
| |
unsigned int *lengths;
|
| |
@@ -2776,20 +2590,20 @@
|
| |
struct berval bv;
|
| |
Slapi_Value *value;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"ifeq: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"ifeq: error parsing arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc != 4) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"ifeq: expected four arguments (got %d)\n",
|
| |
argc);
|
| |
format_free_parsed_args(argv);
|
| |
@@ -2797,24 +2611,21 @@
|
| |
}
|
| |
|
| |
/* Note that this map cares about the tested attribute. */
|
| |
- if (rel_attrs != NULL) {
|
| |
- format_add_attrlist(rel_attrs, argv[0]);
|
| |
+ if (st->config.rel_attrs != NULL) {
|
| |
+ format_add_attrlist(st->config.rel_attrs, argv[0]);
|
| |
}
|
| |
|
| |
/* Evaluate the value expression to get a list of candidate values. */
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[1], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[1],
|
| |
+ &lengths);
|
| |
if (values == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"ifeq: error evaluating \"%s\"\n", argv[1]);
|
| |
format_free_parsed_args(argv);
|
| |
- /* Shouldn't be necessary, since format_get_data_set() should
|
| |
- * only ever return a NULL lengths list when it returns NULL,
|
| |
- * but it'll make tools happy. */
|
| |
+ /* Shouldn't be necessary, since format_get_data_set_int()
|
| |
+ * should only ever return a NULL lengths list when it returns
|
| |
+ * NULL, but it'll make tools happy. */
|
| |
free(lengths);
|
| |
return -EINVAL;
|
| |
}
|
| |
@@ -2837,7 +2648,7 @@
|
| |
}
|
| |
}
|
| |
slapi_value_free(&value);
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"ifeq: \"%s\" %s \"%s\"\n",
|
| |
argv[0], matched ? "matches" : "doesn't match",
|
| |
argv[1]);
|
| |
@@ -2845,14 +2656,10 @@
|
| |
|
| |
/* Evaluate the argument which corresponds to the output expression and
|
| |
* return its values. */
|
| |
- ret = format_expand(state, pb, e, group, set,
|
| |
- argv[matched ? 2 : 3], disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ ret = format_expand(st, e, group, set,
|
| |
+ argv[matched ? 2 : 3],
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
format_free_parsed_args(argv);
|
| |
return ret;
|
| |
}
|
| |
@@ -2860,29 +2667,23 @@
|
| |
/* If the expression given as the first argument returns any values, return
|
| |
* them. Otherwise, return the second expression. */
|
| |
static int
|
| |
- format_default(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_default(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, i;
|
| |
char **argv;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"default: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 2) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"default: expected at least two arguments "
|
| |
"(got %d)\n",
|
| |
argc);
|
| |
@@ -2891,14 +2692,10 @@
|
| |
}
|
| |
/* Evaluate expressions until we run out of them or succeed. */
|
| |
for (i = 0; i < argc; i++) {
|
| |
- ret = format_expand(state, pb, e, group, set,
|
| |
- argv[i], disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ ret = format_expand(st, e, group, set,
|
| |
+ argv[i],
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
if (ret >= 0) {
|
| |
break;
|
| |
}
|
| |
@@ -2934,43 +2731,37 @@
|
| |
}
|
| |
|
| |
static int
|
| |
- format_sort(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_sort(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, i;
|
| |
unsigned int *lengths;
|
| |
char **argv, **values;
|
| |
struct berval bv, **choices;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"sort: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"sort: one argument is required\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc > 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"sort: only one argument is allowed\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"sort: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -2979,12 +2770,9 @@
|
| |
|
| |
/* Evaluate this argument. */
|
| |
choices = NULL;
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[0], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[0],
|
| |
+ &lengths);
|
| |
if (values != NULL) {
|
| |
/* Walk the list of values. */
|
| |
for (i = 0; values[i] != NULL; i++) {
|
| |
@@ -2992,20 +2780,20 @@
|
| |
bv.bv_val = values[i];
|
| |
bv.bv_len = lengths[i];
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"sort: input %d = \"%.*s\"\n",
|
| |
i + 1, (int) bv.bv_len, bv.bv_val);
|
| |
format_add_bv_list(&choices, &bv);
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"sort: expanded \"%s\" to produce "
|
| |
"%d values for \"%s\"\n", argv[0], i,
|
| |
slapi_entry_get_dn(e));
|
| |
format_free_data_set(values, lengths);
|
| |
} else {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"sort: expanding \"%s\" produced "
|
| |
"no values for \"%s\"\n", argv[0],
|
| |
slapi_entry_get_dn(e));
|
| |
@@ -3016,7 +2804,7 @@
|
| |
qsort(choices, i, sizeof(choices[0]), format_compare_bv);
|
| |
for (i = 0; choices[i] != NULL; i++) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"sort: returning \"%.*s\" as a "
|
| |
"value for \"%s\"\n",
|
| |
(int) choices[i]->bv_len,
|
| |
@@ -3025,7 +2813,7 @@
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"sort: returning %d values for \"%s\"\n", i,
|
| |
slapi_entry_get_dn(e));
|
| |
format_add_choice(outbuf_choices, outbuf, &choices);
|
| |
@@ -3039,40 +2827,34 @@
|
| |
return ret;
|
| |
}
|
| |
|
| |
- /* Evaluate all of the arguments, and concatentate all of the lists of results
|
| |
+ /* Evaluate all of the arguments, and concatenate all of the lists of results
|
| |
* to produce one long list. */
|
| |
static int
|
| |
- format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_collect(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, i, j;
|
| |
unsigned int *lengths;
|
| |
char **argv, **values;
|
| |
struct berval bv, **choices;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"collect: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"collect: error parsing arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"collect: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -3083,12 +2865,9 @@
|
| |
choices = NULL;
|
| |
for (i = 0; i < argc; i++) {
|
| |
/* Evaluate this argument. */
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[i], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[i],
|
| |
+ &lengths);
|
| |
if (values != NULL) {
|
| |
/* Walk the list of values. */
|
| |
for (j = 0; values[j] != NULL; j++) {
|
| |
@@ -3096,20 +2875,20 @@
|
| |
bv.bv_val = values[j];
|
| |
bv.bv_len = lengths[j];
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"collect: \"%.*s\"\n",
|
| |
(int) bv.bv_len, bv.bv_val);
|
| |
format_add_bv_list(&choices, &bv);
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"collect: expanded \"%s\" to produce "
|
| |
"%d values for \"%s\"\n", argv[i], j,
|
| |
slapi_entry_get_dn(e));
|
| |
format_free_data_set(values, lengths);
|
| |
} else {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"collect: expanding \"%s\" produced "
|
| |
"no values for \"%s\"\n", argv[i],
|
| |
slapi_entry_get_dn(e));
|
| |
@@ -3119,7 +2898,7 @@
|
| |
if (choices != NULL) {
|
| |
for (i = 0; choices[i] != NULL; i++) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"collect: returning \"%.*s\" as a "
|
| |
"value for \"%s\"\n",
|
| |
(int) choices[i]->bv_len,
|
| |
@@ -3128,7 +2907,7 @@
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"collect: returning %d values for \"%s\"\n", i,
|
| |
slapi_entry_get_dn(e));
|
| |
format_add_choice(outbuf_choices, outbuf, &choices);
|
| |
@@ -3142,47 +2921,41 @@
|
| |
return ret;
|
| |
}
|
| |
|
| |
- /* Evaluate all of the arguments, and concatentate sets of entries from each
|
| |
+ /* Evaluate all of the arguments, and concatenate sets of entries from each
|
| |
* list, separating them with an optional separator, padding the lists with a
|
| |
* specified value until all of the elements of all lists have been used. */
|
| |
static int
|
| |
- format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_link(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, argc, i, j, *n_items, l, result_n, n_lists, n_done;
|
| |
unsigned int **lengths, length, max_length;
|
| |
char **argv, ***values, *buffer, *p;
|
| |
struct berval bv, **choices;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: error parsing arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (((argc + 1) % 3) != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: wrong number of arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -3194,7 +2967,7 @@
|
| |
lengths = malloc(sizeof(int *) * (((argc + 1) / 3) * 2));
|
| |
n_items = malloc(sizeof(int) * (((argc + 1) / 3) * 2));
|
| |
if ((values == NULL) || (lengths == NULL) || (n_items == NULL)) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: out of memory\n");
|
| |
format_free_parsed_args(argv);
|
| |
free(values);
|
| |
@@ -3207,38 +2980,26 @@
|
| |
choices = NULL;
|
| |
n_lists = 0;
|
| |
for (i = 0; i < argc; i += 3) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: evaluating \"%s\"\n", argv[i]);
|
| |
j = (i / 3) * 2;
|
| |
- values[j] = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[i], disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list,
|
| |
- &lengths[j]);
|
| |
+ values[j] = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[i],
|
| |
+ &lengths[j]);
|
| |
if (values[j] != NULL) {
|
| |
n_lists++;
|
| |
}
|
| |
j++;
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"link: evaluating \"%s\"\n", argv[i + 1]);
|
| |
- values[j] = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[i + 1], disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list,
|
| |
- &lengths[j]);
|
| |
+ values[j] = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[i + 1],
|
| |
+ &lengths[j]);
|
| |
if (values[j] != NULL) {
|
| |
n_lists++;
|
| |
} else {
|
| |
slapi_log_error(SLAPI_LOG_FATAL,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"link: error evaluating \"%s\" "
|
| |
"for \"%s\"\n",
|
| |
argv[i + 1],
|
| |
@@ -3353,12 +3114,12 @@
|
| |
bv.bv_len = length;
|
| |
if ((p - buffer) != length) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"link: internal error\n");
|
| |
break;
|
| |
} else {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"link: \"%.*s\"\n",
|
| |
(int) bv.bv_len, bv.bv_val);
|
| |
format_add_bv_list(&choices, &bv);
|
| |
@@ -3386,17 +3147,11 @@
|
| |
|
| |
/* Eliminate duplicate values from the list. */
|
| |
static int
|
| |
- format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_unique(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs, struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, i, j, argc;
|
| |
char **argv, **values;
|
| |
@@ -3404,14 +3159,14 @@
|
| |
unsigned int *lengths;
|
| |
struct berval **choices, bv;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"unique: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"unique: error parsing arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
@@ -3424,37 +3179,30 @@
|
| |
default_value = argv[1];
|
| |
}
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"unique: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
}
|
| |
ret = -ENOENT;
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- value_format, disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ value_format,
|
| |
+ &lengths);
|
| |
if (values == NULL) {
|
| |
if (default_value == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"unique: no values for ->%s<-, "
|
| |
"and no default value provided\n",
|
| |
value_format);
|
| |
ret = -ENOENT;
|
| |
} else {
|
| |
- i = format_expand(state, pb, e,
|
| |
+ i = format_expand(st, e,
|
| |
group, set,
|
| |
- default_value, NULL,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ default_value,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
ret = i;
|
| |
}
|
| |
} else {
|
| |
@@ -3479,7 +3227,7 @@
|
| |
if (choices != NULL) {
|
| |
for (i = 0; choices[i] != NULL; i++) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"unique: returning \"%.*s\" as a "
|
| |
"value for \"%s\"\n",
|
| |
(int) choices[i]->bv_len,
|
| |
@@ -3488,7 +3236,7 @@
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"unique: returning %d values for \"%s\"\n", i,
|
| |
slapi_entry_get_dn(e));
|
| |
format_add_choice(outbuf_choices, outbuf, &choices);
|
| |
@@ -3504,19 +3252,11 @@
|
| |
|
| |
/* Produce an internal sequence number. */
|
| |
static int
|
| |
- format_internal_sequence_number(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_internal_sequence_number(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
static int sequence;
|
| |
char *buf;
|
| |
@@ -3538,10 +3278,10 @@
|
| |
ret = -ENOENT;
|
| |
}
|
| |
if (ret == 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"internal_sequence_number: ->%s<-\n", buf);
|
| |
} else {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"internal_sequence_number: error building result\n");
|
| |
}
|
| |
free(buf);
|
| |
@@ -3551,19 +3291,11 @@
|
| |
/* Condense the list as much as possible, but possibly still produce multiple
|
| |
* values. */
|
| |
static int
|
| |
- format_dribble_merge(struct plugin_state *state, Slapi_PBlock *pb,
|
| |
- Slapi_Entry *e,
|
| |
+ format_dribble_merge(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int ret, i, j, argc, slen, count, buf_used = 0;
|
| |
unsigned int *lengths, max;
|
| |
@@ -3572,14 +3304,14 @@
|
| |
char *buf = NULL;
|
| |
struct berval **choices, bv;
|
| |
|
| |
- ret = format_parse_args(state, args, &argc, &argv);
|
| |
+ ret = format_parse_args(st, args, &argc, &argv);
|
| |
if (ret != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"dribble_merge: error parsing arguments\n");
|
| |
return -EINVAL;
|
| |
}
|
| |
if (argc < 2) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"dribble_merge: requires at least "
|
| |
"two arguments\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -3587,7 +3319,7 @@
|
| |
}
|
| |
max = atoi(argv[0]);
|
| |
if (max < 1) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"dribble_merge: small maximum group size\n");
|
| |
format_free_parsed_args(argv);
|
| |
return -EINVAL;
|
| |
@@ -3596,7 +3328,7 @@
|
| |
slen = strlen(sep);
|
| |
choices = NULL;
|
| |
if (outbuf_choices == NULL) {
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"dribble_merge: returns a list, but a list "
|
| |
"would not be appropriate\n");
|
| |
format_free_parsed_args(argv);
|
| |
@@ -3604,17 +3336,14 @@
|
| |
}
|
| |
for (i = 2, ret = 0, count = 0; i < argc; i++) {
|
| |
/* Expand this argument. */
|
| |
- slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
|
| |
+ slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id,
|
| |
"dribble_merge: expanding ->%s<-\n", argv[i]);
|
| |
- values = format_get_data_set(state, pb, e, group, set,
|
| |
- argv[i], disallowed,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- &lengths);
|
| |
+ values = format_get_data_set_int(st, e, group, set,
|
| |
+ argv[i],
|
| |
+ &lengths);
|
| |
if (values == NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"dribble_merge: no values for "
|
| |
"->%s<-\n", argv[i]);
|
| |
continue;
|
| |
@@ -3645,7 +3374,7 @@
|
| |
/* If the value's just too big, return an error. */
|
| |
if (lengths[j] > max) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"dribble_merge: value \"%.*s\""
|
| |
" was too big for ->%s<\n",
|
| |
lengths[j], values[j],
|
| |
@@ -3658,7 +3387,7 @@
|
| |
} else {
|
| |
/* Log this value. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"dribble_merge: got %d-byte "
|
| |
"value for ->%s<\n",
|
| |
lengths[j], argv[i]);
|
| |
@@ -3687,7 +3416,7 @@
|
| |
if (choices != NULL) {
|
| |
for (i = 0; choices[i] != NULL; i++) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"dribble_merge: returning \"%.*s\" "
|
| |
"as a value for \"%s\"\n",
|
| |
(int) choices[i]->bv_len,
|
| |
@@ -3696,7 +3425,7 @@
|
| |
continue;
|
| |
}
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"dribble_merge: returning %d values for "
|
| |
"\"%s\"\n", i, slapi_entry_get_dn(e));
|
| |
format_add_choice(outbuf_choices, outbuf, &choices);
|
| |
@@ -3714,19 +3443,11 @@
|
| |
unsigned int i;
|
| |
struct {
|
| |
const char *name;
|
| |
- int (*fct_ptr)(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ int (*fct_ptr)(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list);
|
| |
+ struct format_choice **outbuf_choices);
|
| |
} fns[] = {
|
| |
{"first", format_first},
|
| |
{"deref", format_deref},
|
| |
@@ -3824,9 +3545,9 @@
|
| |
* than one, return NULL. If there's more than one, store the values in the
|
| |
* array argument. */
|
| |
static struct berval
|
| |
- format_single(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
- const char *attr, const char *disallowed,
|
| |
- char ***attrlist, struct berval ***values)
|
| |
+ format_single(struct format_state *st, Slapi_Entry *e,
|
| |
+ const char *attr, char ***attrlist,
|
| |
+ struct berval ***values)
|
| |
{
|
| |
Slapi_ValueSet *value_set;
|
| |
Slapi_Value *value;
|
| |
@@ -3848,10 +3569,10 @@
|
| |
if (count == 1) {
|
| |
if (slapi_valueset_first_value(value_set, &value) != -1) {
|
| |
val = slapi_value_get_berval(value);
|
| |
- d = format_check_disallowed(val, disallowed);
|
| |
+ d = format_check_disallowed(val, st->config.disallowed_chars);
|
| |
if (d != NULL) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"value for \"%s\" "
|
| |
"contains disallowed "
|
| |
"character \"%c\", "
|
| |
@@ -3871,7 +3592,7 @@
|
| |
/* Either no results, or too many results with no place
|
| |
* to put them. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"%d values for \"%s\"\n", count, attr);
|
| |
} else {
|
| |
/* Return the list of values. */
|
| |
@@ -3884,7 +3605,7 @@
|
| |
if (val->bv_len == 0) {
|
| |
continue;
|
| |
}
|
| |
- d = format_check_disallowed(val, disallowed);
|
| |
+ d = format_check_disallowed(val, st->config.disallowed_chars);
|
| |
if (d == NULL) {
|
| |
format_add_bv_list(values, val);
|
| |
}
|
| |
@@ -3929,7 +3650,7 @@
|
| |
/* Trim off prefixes or suffixes which match the given patterns, free the
|
| |
* original, and return the result. */
|
| |
static struct berval
|
| |
- format_trim_value(struct plugin_state *state, struct berval input,
|
| |
+ format_trim_value(struct format_state *st, struct berval input,
|
| |
const char *shortstart, const char *longstart,
|
| |
const char *shortend, const char *longend,
|
| |
const char *replace, const char *replaceall,
|
| |
@@ -3954,7 +3675,7 @@
|
| |
ret.bv_val = buf;
|
| |
ret.bv_len = input.bv_len - i;
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"trim-ss: ->%.*s<- => "
|
| |
"->%.*s<-\n",
|
| |
(int) input.bv_len,
|
| |
@@ -3981,7 +3702,7 @@
|
| |
ret.bv_val = buf;
|
| |
ret.bv_len = input.bv_len - i;
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"trim-se: ->%.*s<- => "
|
| |
"->%.*s<-\n",
|
| |
(int) input.bv_len,
|
| |
@@ -4006,7 +3727,7 @@
|
| |
ret.bv_val = buf;
|
| |
ret.bv_len = input.bv_len - i;
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"trim-ls: ->%.*s<- => "
|
| |
"->%.*s<-\n",
|
| |
(int) input.bv_len,
|
| |
@@ -4031,7 +3752,7 @@
|
| |
ret.bv_val = buf;
|
| |
ret.bv_len = input.bv_len - i;
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"trim-le: ->%.*s<- => "
|
| |
"->%.*s<-\n",
|
| |
(int) input.bv_len,
|
| |
@@ -4061,19 +3782,11 @@
|
| |
* attribute value, perhaps with a default or alternate value, perhaps with a
|
| |
* prefix or suffix stripped, perhaps with internal replacements made. */
|
| |
static int
|
| |
- format_expand_simple(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_expand_simple(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *fmt, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *fmt,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
char *shortstart, *longstart, *shortend, *longend;
|
| |
struct berval tmp, **values;
|
| |
@@ -4168,8 +3881,9 @@
|
| |
}
|
| |
/* Retrieve the value. */
|
| |
values = NULL;
|
| |
- tmp = format_single(state, pb, e, attribute, disallowed,
|
| |
- rel_attrs, outbuf_choices ? &values : NULL);
|
| |
+ tmp = format_single(st, e, attribute,
|
| |
+ st->config.rel_attrs,
|
| |
+ outbuf_choices ? &values : NULL);
|
| |
if (tmp.bv_val == NULL) {
|
| |
/* The attribute is undefined, or we're treating it as if it
|
| |
* is. */
|
| |
@@ -4177,17 +3891,11 @@
|
| |
if (default_value != NULL) {
|
| |
/* Supply the default value, expanding it if
|
| |
* needed. */
|
| |
- i = format_expand(state, pb, e,
|
| |
+ i = format_expand(st, e,
|
| |
group, set,
|
| |
- default_value, NULL,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ default_value,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
free(expr);
|
| |
return i;
|
| |
} else {
|
| |
@@ -4198,17 +3906,11 @@
|
| |
} else {
|
| |
if (alternate_value != NULL) {
|
| |
/* Supply the alternate value. */
|
| |
- i = format_expand(state, pb, e,
|
| |
+ i = format_expand(st, e,
|
| |
group, set,
|
| |
- alternate_value, NULL,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ alternate_value,
|
| |
outbuf, outbuf_len,
|
| |
- outbuf_choices,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
free(expr);
|
| |
format_free_bv_list(values);
|
| |
return i;
|
| |
@@ -4230,18 +3932,15 @@
|
| |
/* There's a suitable single value available. */
|
| |
if (alternate_value != NULL) {
|
| |
/* Supply the alternate value. */
|
| |
- i = format_expand(state, pb, e,
|
| |
- group, set, alternate_value, NULL,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- outbuf, outbuf_len, outbuf_choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
+ i = format_expand(st, e,
|
| |
+ group, set, alternate_value,
|
| |
+ outbuf, outbuf_len, outbuf_choices);
|
| |
free(tmp.bv_val);
|
| |
free(expr);
|
| |
return i;
|
| |
} else {
|
| |
/* Munge up the looked-up value. */
|
| |
- tmp = format_trim_value(state, tmp,
|
| |
+ tmp = format_trim_value(st, tmp,
|
| |
shortstart, longstart,
|
| |
shortend, longend,
|
| |
replace, replaceall,
|
| |
@@ -4268,37 +3967,24 @@
|
| |
* will also be an expression, treat the entire result as an attribute
|
| |
* specifier and evaluate it, otherwise return it. */
|
| |
static int
|
| |
- format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_expand(struct format_state *st,
|
| |
+ Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *fmt, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *fmt,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list)
|
| |
+ struct format_choice **outbuf_choices)
|
| |
{
|
| |
int i, j, used;
|
| |
const char *fmtstart, *fmtend, *match, *pair;
|
| |
char *subexp, *fnname, *params, *spd_id;
|
| |
const char *paramstart, *paramend;
|
| |
- int (*formatfn)(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ int (*formatfn)(struct format_state *st, Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *args, const char *disallowed,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
+ const char *args,
|
| |
char *outbuf, int outbuf_len,
|
| |
- struct format_choice **outbuf_choices,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list);
|
| |
+ struct format_choice **outbuf_choices);
|
| |
|
| |
- spd_id = state->plugin_desc->spd_id;
|
| |
+ spd_id = st->plugin_desc->spd_id;
|
| |
|
| |
/* Expand any subexpressions and call any "functions". */
|
| |
i = 0;
|
| |
@@ -4344,22 +4030,14 @@
|
| |
return -ENOMEM;
|
| |
}
|
| |
/* Expand the simple expression. */
|
| |
- used = format_expand_simple(state,
|
| |
- pb, e,
|
| |
+ used = format_expand_simple(st,
|
| |
+ e,
|
| |
group,
|
| |
set,
|
| |
subexp,
|
| |
- disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
outbuf + j,
|
| |
outbuf_len - j,
|
| |
- outbuf_choices,
|
| |
- rel_attrs,
|
| |
- ref_attrs,
|
| |
- inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
if (used < 0) {
|
| |
/* Some failure, FAIL. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
@@ -4455,17 +4133,11 @@
|
| |
return -ENOSYS;
|
| |
}
|
| |
/* Call the "function". */
|
| |
- used = (*formatfn)(state, pb, e,
|
| |
+ used = (*formatfn)(st, e,
|
| |
group, set,
|
| |
- params, disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
+ params,
|
| |
outbuf + j, outbuf_len - j,
|
| |
- outbuf_choices,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list,
|
| |
- inref_attr_list);
|
| |
+ outbuf_choices);
|
| |
if (used < 0) {
|
| |
/* Error in function, FAIL. */
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
@@ -4516,24 +4188,17 @@
|
| |
}
|
| |
|
| |
static char *
|
| |
- format_format(struct plugin_state *state,
|
| |
- Slapi_PBlock *parent_pb, Slapi_Entry *e,
|
| |
+ format_format(struct format_state *st,
|
| |
+ Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
- const char *fmt, const char *disallowed,
|
| |
+ const char *fmt,
|
| |
struct format_choice **choices,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
- char ***rel_attrs, char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list,
|
| |
unsigned int *data_length)
|
| |
{
|
| |
- Slapi_PBlock *pb;
|
| |
char *buf, *ret, *spd_id;
|
| |
int i, buflen;
|
| |
|
| |
- spd_id = state->plugin_desc->spd_id;
|
| |
+ spd_id = st->plugin_desc->spd_id;
|
| |
buflen = DEFAULT_BUFFER_SIZE;
|
| |
do {
|
| |
buf = malloc(buflen);
|
| |
@@ -4547,15 +4212,9 @@
|
| |
return NULL;
|
| |
}
|
| |
|
| |
- pb = wrap_pblock_new(parent_pb);
|
| |
- i = format_expand(state, pb, e, group, set,
|
| |
- fmt, disallowed,
|
| |
- restrict_subtrees,
|
| |
- ignore_subtrees,
|
| |
- buf, buflen, choices,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list);
|
| |
- slapi_pblock_destroy(pb);
|
| |
+ i = format_expand(st, e, group, set,
|
| |
+ fmt,
|
| |
+ buf, buflen, choices);
|
| |
if ((i >= 0) && (i < buflen)) {
|
| |
buf[i] = '\0';
|
| |
ret = xmemdup(buf, i);
|
| |
@@ -4609,9 +4268,131 @@
|
| |
free(data);
|
| |
}
|
| |
}
|
| |
+
|
| |
+ void format_free_state(struct format_state **state)
|
| |
+ {
|
| |
+ if (state && *state) {
|
| |
+ if ((*state)->free_config) {
|
| |
+ (*state)->free_config(*state);
|
| |
+ }
|
| |
+ free(*state);
|
| |
+ *state = NULL;
|
| |
+ }
|
| |
+ }
|
| |
+
|
| |
+ char *format__get_data(struct format_state *state,
|
| |
+ const char *group, const char *set,
|
| |
+ struct slapi_entry *e,
|
| |
+ const char *fmt,
|
| |
+ unsigned int *data_length)
|
| |
+ {
|
| |
+ unsigned int ignored;
|
| |
+ return format_format(state, e, group, set, fmt,
|
| |
+ NULL,
|
| |
+ data_length ? data_length : &ignored);
|
| |
+ }
|
| |
+
|
| |
+ /* TODO: A stub for now */
|
| |
+ char **format__get_data_set(struct format_state *state,
|
| |
+ const char *group, const char *set,
|
| |
+ struct slapi_entry *e,
|
| |
+ const char *fmt,
|
| |
+ unsigned int **data_lengths)
|
| |
+ {
|
| |
+ return format_get_data_set_int(state, e,
|
| |
+ group, set,
|
| |
+ fmt,
|
| |
+ data_lengths);
|
| |
+ }
|
| |
+
|
| |
+ struct format_set_internal_struct {
|
| |
+ struct format_set_config config;
|
| |
+ struct plugin_state *plugin_state;
|
| |
+ };
|
| |
+
|
| |
+ /* Internal helpers to avoid disrupting formatter engine API users for now */
|
| |
+ void __format_state_init_config(struct format_state *state, Slapi_PBlock *pb)
|
| |
+ {
|
| |
+ struct format_set_internal_struct *st;
|
| |
+
|
| |
+ /* If we are initialized already, return */
|
| |
+ if (!state || state->initialized) {
|
| |
+ return;
|
| |
+ }
|
| |
+
|
| |
+ /* After initialize step we'll have state->cbdata pointing to
|
| |
+ * a plugin state, so we wouldn't be able to recover access
|
| |
+ * to the 'struct format_set_internal_struct' anymore. */
|
| |
+ st = state->caller_data;
|
| |
+ state->config = st->config;
|
| |
+ state->caller_data = st->plugin_state;
|
| |
+ state->initialized = TRUE;
|
| |
+ }
|
| |
+
|
| |
+ void __format_state_free_config(struct format_state *state)
|
| |
+ {
|
| |
+ /* we don't free the config ourselves here as our
|
| |
+ * callers provided separate elements of it already */
|
| |
+ }
|
| |
+
|
| |
+
|
| |
+ void __format_state_get_bases_filter(struct format_state *state,
|
| |
+ const char *group, const char *set,
|
| |
+ char ***bases, char **filter)
|
| |
+ {
|
| |
+ backend_get_set_config(NULL, state->caller_data,
|
| |
+ group, set,
|
| |
+ bases, filter);
|
| |
+ }
|
| |
+
|
| |
+ void __format_state_free_bases_filter(struct format_state *state,
|
| |
+ char ***bases, char **filter)
|
| |
+ {
|
| |
+ backend_free_set_config(*bases, *filter);
|
| |
+ *bases = NULL;
|
| |
+ *filter = NULL;
|
| |
+ }
|
| |
+
|
| |
+ int __format_state_internal_search_cb(struct format_state *state,
|
| |
+ Slapi_PBlock *pb,
|
| |
+ void *callback_data,
|
| |
+ format_result_callback prc,
|
| |
+ format_search_entry_callback psec,
|
| |
+ format_referral_entry_callback prec)
|
| |
+ {
|
| |
+ return slapi_search_internal_callback_pb(pb, callback_data, prc, psec, prec);
|
| |
+ }
|
| |
+
|
| |
+ struct format_state *
|
| |
+ format_create_state(Slapi_ComponentId *plugin_identity,
|
| |
+ Slapi_PluginDesc *plugin_desc,
|
| |
+ format_state_init_config init_config,
|
| |
+ format_state_free_config free_config,
|
| |
+ format_state_get_bases_filter get_bases_filter,
|
| |
+ format_state_free_bases_filter free_bases_filter,
|
| |
+ format_state_search_callback_pb search_callback_pb,
|
| |
+ void *caller_data)
|
| |
+ {
|
| |
+ struct format_state *state = NULL;
|
| |
+ state = calloc(1, sizeof(*state));
|
| |
+ if (!state) {
|
| |
+ return NULL;
|
| |
+ }
|
| |
+
|
| |
+ state->plugin_identity = plugin_identity;
|
| |
+ state->plugin_desc = plugin_desc;
|
| |
+ state->caller_data = caller_data;
|
| |
+ state->init_config = init_config;
|
| |
+ state->free_config = free_config;
|
| |
+ state->get_bases_filter = get_bases_filter;
|
| |
+ state->free_bases_filter = free_bases_filter;
|
| |
+ state->search_callback_pb = search_callback_pb;
|
| |
+ return state;
|
| |
+ }
|
| |
+
|
| |
char *
|
| |
- format_get_data(struct plugin_state *state,
|
| |
- Slapi_PBlock *pb, Slapi_Entry *e,
|
| |
+ format_get_data(struct plugin_state *state, Slapi_PBlock *pb /*unused*/,
|
| |
+ Slapi_Entry *e,
|
| |
const char *group, const char *set,
|
| |
const char *fmt, const char *disallowed,
|
| |
const struct slapi_dn **restrict_subtrees,
|
| |
@@ -4624,13 +4405,34 @@
|
| |
unsigned int *data_length)
|
| |
{
|
| |
unsigned int ignored;
|
| |
- return format_format(state, pb, e, group, set, fmt,
|
| |
- disallowed, NULL,
|
| |
- restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs,
|
| |
- ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
- data_length ? data_length : &ignored);
|
| |
+ char *result = NULL;
|
| |
+ struct format_state *st = NULL;
|
| |
+ struct format_set_internal_struct cbdata;
|
| |
+
|
| |
+ st = format_create_state(state->plugin_identity, state->plugin_desc,
|
| |
+ __format_state_init_config,
|
| |
+ __format_state_free_config,
|
| |
+ __format_state_get_bases_filter,
|
| |
+ __format_state_free_bases_filter,
|
| |
+ __format_state_internal_search_cb,
|
| |
+ &cbdata);
|
| |
+ if (!st) {
|
| |
+ return NULL;
|
| |
+ }
|
| |
+
|
| |
+ cbdata.config.disallowed_chars = disallowed;
|
| |
+ cbdata.config.restrict_subtrees = restrict_subtrees;
|
| |
+ cbdata.config.ignore_subtrees = ignore_subtrees;
|
| |
+ cbdata.config.rel_attrs = rel_attrs;
|
| |
+ cbdata.config.ref_attrs = ref_attrs;
|
| |
+ cbdata.config.inref_attrs = inref_attrs;
|
| |
+ cbdata.config.ref_attr_list = ref_attr_list;
|
| |
+ cbdata.config.inref_attr_list = inref_attr_list;
|
| |
+ st->init_config(st, pb);
|
| |
+ result = format_format(st, e, group, set, fmt, NULL,
|
| |
+ data_length ? data_length : &ignored);
|
| |
+ format_free_state(&st);
|
| |
+ return result;
|
| |
}
|
| |
|
| |
void
|
| |
@@ -4645,19 +4447,12 @@
|
| |
}
|
| |
free(data_lengths);
|
| |
}
|
| |
- char **
|
| |
- 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,
|
| |
- const struct slapi_dn **restrict_subtrees,
|
| |
- const struct slapi_dn **ignore_subtrees,
|
| |
- char ***rel_attrs,
|
| |
- char ***ref_attrs,
|
| |
- struct format_inref_attr ***inref_attrs,
|
| |
- struct format_ref_attr_list ***ref_attr_list,
|
| |
- struct format_ref_attr_list ***inref_attr_list,
|
| |
- unsigned int **data_lengths)
|
| |
+
|
| |
+ static char **
|
| |
+ format_get_data_set_int(struct format_state *st, Slapi_Entry *e,
|
| |
+ const char *group, const char *set,
|
| |
+ const char *fmt,
|
| |
+ unsigned int **data_lengths)
|
| |
{
|
| |
struct format_choice *choices, *this_choice;
|
| |
struct berval *val;
|
| |
@@ -4665,10 +4460,8 @@
|
| |
int combinations, groupsize, i, j, k, offset, length, prev_offset;
|
| |
unsigned int template_len;
|
| |
choices = NULL;
|
| |
- template = format_format(state, pb, e, group, set, fmt, disallowed,
|
| |
- &choices, restrict_subtrees, ignore_subtrees,
|
| |
- rel_attrs, ref_attrs, inref_attrs,
|
| |
- ref_attr_list, inref_attr_list,
|
| |
+ template = format_format(st, e, group, set, fmt,
|
| |
+ &choices,
|
| |
&template_len);
|
| |
if (template == NULL) {
|
| |
format_free_choices(choices);
|
| |
@@ -4682,7 +4475,7 @@
|
| |
this_choice = this_choice->next) {
|
| |
if ((this_choice->offset - template) > prev_offset) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"choice: fixed \"%.*s\" at %d\n",
|
| |
(int) (this_choice->offset - template) -
|
| |
prev_offset,
|
| |
@@ -4692,7 +4485,7 @@
|
| |
}
|
| |
for (i = 0; i < this_choice->n_values; i++) {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"choice: option \"%.*s\" at %ld\n",
|
| |
(int) this_choice->values[i]->bv_len,
|
| |
(char *) this_choice->values[i]->bv_val,
|
| |
@@ -4703,7 +4496,7 @@
|
| |
}
|
| |
if (template[prev_offset] != '\0') {
|
| |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
| |
- state->plugin_desc->spd_id,
|
| |
+ st->plugin_desc->spd_id,
|
| |
"choice: fixed \"%s\" at %d\n",
|
| |
template + prev_offset,
|
| |
prev_offset);
|
| |
@@ -4775,6 +4568,52 @@
|
| |
return ret;
|
| |
}
|
| |
|
| |
+ char **
|
| |
+ format_get_data_set(struct plugin_state *state, Slapi_PBlock *pb /*unused*/,
|
| |
+ Slapi_Entry *e,
|
| |
+ const char *group, const char *set,
|
| |
+ const char *fmt, const char *disallowed,
|
| |
+ const struct slapi_dn **restrict_subtrees,
|
| |
+ const struct slapi_dn **ignore_subtrees,
|
| |
+ char ***rel_attrs,
|
| |
+ char ***ref_attrs,
|
| |
+ struct format_inref_attr ***inref_attrs,
|
| |
+ struct format_ref_attr_list ***ref_attr_list,
|
| |
+ struct format_ref_attr_list ***inref_attr_list,
|
| |
+ unsigned int **data_lengths)
|
| |
+ {
|
| |
+ char **result = NULL;
|
| |
+ struct format_state *st = NULL;
|
| |
+ struct format_set_internal_struct cbdata;
|
| |
+
|
| |
+ st = format_create_state(state->plugin_identity, state->plugin_desc,
|
| |
+ __format_state_init_config,
|
| |
+ __format_state_free_config,
|
| |
+ __format_state_get_bases_filter,
|
| |
+ __format_state_free_bases_filter,
|
| |
+ __format_state_internal_search_cb,
|
| |
+ &cbdata);
|
| |
+ if (!st) {
|
| |
+ return NULL;
|
| |
+ }
|
| |
+
|
| |
+ cbdata.config.disallowed_chars = disallowed;
|
| |
+ cbdata.config.restrict_subtrees = restrict_subtrees;
|
| |
+ cbdata.config.ignore_subtrees = ignore_subtrees;
|
| |
+ cbdata.config.rel_attrs = rel_attrs;
|
| |
+ cbdata.config.ref_attrs = ref_attrs;
|
| |
+ cbdata.config.inref_attrs = inref_attrs;
|
| |
+ cbdata.config.ref_attr_list = ref_attr_list;
|
| |
+ cbdata.config.inref_attr_list = inref_attr_list;
|
| |
+ st->init_config(st, pb);
|
| |
+ result = format_get_data_set_int(st, e,
|
| |
+ group, set,
|
| |
+ fmt,
|
| |
+ data_lengths);
|
| |
+ format_free_state(&st);
|
| |
+ return result;
|
| |
+ }
|
| |
+
|
| |
char *
|
| |
format_escape_for_filter(const char *unescaped)
|
| |
{
|
| |