summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-15 13:34:46 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-15 13:34:46 -0400
commitf6a1ac6c7fd179d985886de726a4c9233fa1c909 (patch)
treec1c4046b87ebcf4407c4f5d7afd757dbc90c3469
parente848b4f90c2423e84c16d2f20474bbe1927081e7 (diff)
downloadslapi-nis-f6a1ac6c7fd179d985886de726a4c9233fa1c909.tar.gz
slapi-nis-f6a1ac6c7fd179d985886de726a4c9233fa1c909.tar.xz
slapi-nis-f6a1ac6c7fd179d985886de726a4c9233fa1c909.zip
- reorganize the source, just a bit
-rw-r--r--src/format.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/format.c b/src/format.c
index 27e6f6c..0c7739b 100644
--- a/src/format.c
+++ b/src/format.c
@@ -86,6 +86,22 @@ xstrndupp(const char *start, const char *end)
return xstrndup(start, end - start);
}
+static void *
+xmemdup(char *region, int size)
+{
+ char *ret;
+ ret = malloc(size + 1);
+ if (ret != NULL) {
+ if (size > 0) {
+ memcpy(ret, region, size);
+ }
+ ret[size] = '\0';
+ }
+ return ret;
+}
+
+/* Maintain an attribute list, which is really just a string list. Entries
+ * named by an attribute in the list carry "interesting" information. */
char **
format_dup_attr_list(char **attr_list)
{
@@ -98,6 +114,15 @@ format_free_attr_list(char **attr_list)
return backend_shr_free_strlist(attr_list);
}
+void
+format_add_attrlist(char ***attrlist, const char *attribute)
+{
+ backend_shr_add_strlist(attrlist, attribute);
+}
+
+/* Maintain an inref attribute list, which tracks a group and set name and an
+ * attribute. If an entry in the group and set contains this entry's name in
+ * the named attribute, then it's "interesting". */
struct format_inref_attr **
format_dup_inref_attrs(struct format_inref_attr **attrs)
{
@@ -183,20 +208,7 @@ format_free_inref_attrs(struct format_inref_attr **attrs)
}
}
-static void *
-xmemdup(char *region, int size)
-{
- char *ret;
- ret = malloc(size + 1);
- if (ret != NULL) {
- if (size > 0) {
- memcpy(ret, region, size);
- }
- ret[size] = '\0';
- }
- return ret;
-}
-
+/* Maintain berval lists. */
static int
format_count_bv_list(struct berval **bvlist)
{
@@ -209,7 +221,6 @@ format_count_bv_list(struct berval **bvlist)
}
return 0;
}
-
static void
format_free_bv_list(struct berval **bvlist)
{
@@ -372,6 +383,8 @@ format_add_choice(struct format_choice **choices, char *offset,
}
}
}
+
+/* Convert a strlist to a berval list. */
static struct berval **
format_strlist_to_bv_list(char **values)
{
@@ -580,7 +593,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
target_attr = argv[1];
/* Note that the attribute in this entry refers to other entries. */
if (ref_attrs != NULL) {
- backend_shr_add_strlist(ref_attrs, ref_attr);
+ format_add_attrlist(ref_attrs, ref_attr);
}
/* Get the values of the reference attribute from this entry. */
if (slapi_vattr_values_get(e, ref_attr, &ref_values,