diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-15 13:52:12 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-15 13:52:12 -0400 |
| commit | 102a1f5707d15adb2d36cc46493ec80fe5038f0f (patch) | |
| tree | fa10af84ea5b94a2a736efd72dd9813858be1071 /src/format.c | |
| parent | f6a1ac6c7fd179d985886de726a4c9233fa1c909 (diff) | |
- first pass at creating an entry list
Diffstat (limited to 'src/format.c')
| -rw-r--r-- | src/format.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/format.c b/src/format.c index 0c7739b..29e2fc6 100644 --- a/src/format.c +++ b/src/format.c @@ -100,6 +100,71 @@ xmemdup(char *region, int size) return ret; } +/* Maintain an entry list. The list takes ownership of entries which are + * passed to it. */ +struct entry_list { + Slapi_Entry *entry; + struct entry_list *next; +}; +static struct entry_list * +format_entry_list_remove_one(struct entry_list *list) +{ + struct entry_list *next; + if (list == NULL) { + next = NULL; + } else { + next = list->next; + slapi_entry_free(list->entry); + free(list); + } + return next; +} +static struct entry_list * +format_add_entry_list(struct entry_list *list, Slapi_Entry *entry) +{ + struct entry_list *next, *tail; + next = malloc(sizeof(*next)); + if (next == NULL) { + return list; + } else { + next->entry = entry; + next->next = NULL; + if (list == NULL) { + return next; + } else { + for (tail = list; + tail->next != NULL; + tail = tail->next) { + continue; + } + tail->next = next; + return list; + } + } +} +static struct entry_list * +format_add_entry_list_dn(struct entry_list *list, + const char *dn, char **attributes, + void *plugin_identity) +{ + Slapi_Entry *entry; + Slapi_DN *sdn; + sdn = slapi_sdn_new_dn_byval(dn); + if (sdn != NULL) { + entry = NULL; + slapi_search_internal_get_entry(sdn, attributes, &entry, + plugin_identity); + slapi_sdn_free(&sdn); + if (entry != NULL) { + return format_add_entry_list(list, entry); + } else { + return list; + } + } else { + return NULL; + } +} + /* Maintain an attribute list, which is really just a string list. Entries * named by an attribute in the list carry "interesting" information. */ char ** |
