]> git.deb.at Git - pkg/abook.git/blobdiff - filter.c
autotools update: 1/2: configure.ac compatibility with automake 1.13
[pkg/abook.git] / filter.c
index 338c6402bad0a824f1a80d9b871fcd7861d262df..dca51b804e79495580c3af03dedfcf477e7a0cf4 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -1557,8 +1557,9 @@ static char *vcard_fields[] = {
        "NICKNAME",             /* NICK */
        "URL",                  /* URL */
        "NOTE",                 /* NOTES */
+       "BDAY",                 /* ANNIVERSARY */
        "N",                    /* NAME: special case/mapping in vcard_parse_line() */
-       NULL                    /* not implemented: ANNIVERSARY, ITEM_FIELDS */
+       NULL                    /* ITEM_FIELDS */
 };
 
 enum {
@@ -1660,20 +1661,33 @@ vcard_parse_address(list_item item, char *line)
 
        // vCard(post office box) - not used
        strsep(&value, ";");
+       if(!value) return;
+
        // vCard(the extended address)
        item_fput(item, ADDRESS2, xstrdup(strsep(&value, ";")));
+       if(!value) return;
+
        // vCard(the street address)
        item_fput(item, ADDRESS, xstrdup(strsep(&value, ";")));
+       if(!value) return;
+
        // vCard(the locality)
        item_fput(item, CITY, xstrdup(strsep(&value, ";")));
+       if(!value) return;
+
        // vCard(the region)
        item_fput(item, STATE, xstrdup(strsep(&value, ";")));
+       if(!value) return;
+
        // vCard(the postal code)
        item_fput(item, ZIP, xstrdup(strsep(&value, ";")));
+       if(!value) return;
+
        // vCard(the country name)
        item_fput(item, COUNTRY, xstrdup(strsep(&value, ";")));
 
-       if(*value) xfree(value);
+       // support of optional trailing ";" to the ADR field
+       if(value && *value) xfree(value);
 }
 
 static void
@@ -2052,6 +2066,13 @@ vcard_export_item(FILE *out, int item)
 
        free(name);
 
+       if(db_fget(item, NICK))
+         fprintf(out, "NICKNAME:%s\r\n",
+                 safe_str(db_fget(item, NICK)));
+       if(db_fget(item, ANNIVERSARY))
+         fprintf(out, "BDAY:%s\r\n",
+                 safe_str(db_fget(item, ANNIVERSARY)));
+
        // see rfc6350 section 6.3.1
        if(db_fget(item, ADDRESS)) {
                fprintf(out, "ADR:;%s;%s;%s;%s;%s;%s\r\n",