]> git.deb.at Git - pkg/abook.git/commitdiff
ldif: export all available emails for an entry
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Wed, 19 Dec 2012 01:53:05 +0000 (02:53 +0100)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Wed, 19 Dec 2012 12:33:01 +0000 (13:33 +0100)
All available emails are now part of the LDIF output
in the form of multiple "email:" attributes.

filter.c

index 31b6f2d259fab66e7a4c58fe4705b87541409310..c8b3d9ea6d82b02f59fb9030919dbaad70b0379c 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -998,6 +998,7 @@ static int
 ldif_export_database(FILE *out, struct db_enumerator e)
 {
        char email[MAX_EMAILSTR_LEN];
+       abook_list *emails, *em;
 
        fprintf(out, "version: 1\n");
 
@@ -1018,10 +1019,15 @@ ldif_export_database(FILE *out, struct db_enumerator e)
 
                for(j = 0; j < ITEM_FIELDS; j++) {
                        if(j == EMAIL) {
-                               if(*email) // don't dump an empty email field
-                                       ldif_fput_type_and_value(out,
-                                                                ldif_field_names[j],
-                                                                email);
+                               if(*email) {
+                                       tmp = db_email_get(e.item);
+                                       emails = csv_to_abook_list(tmp);
+                                       free(tmp);
+                                       for(em = emails; em; em = em->next)
+                                               ldif_fput_type_and_value(out,
+                                                                        ldif_field_names[EMAIL],
+                                                                        em->data);
+                               }
                        }
                        else if(db_fget(e.item,j)) {
                                ldif_fput_type_and_value(out,