X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=filter.c;h=dca51b804e79495580c3af03dedfcf477e7a0cf4;hb=b8891aaf2714831bd2148cf8833b065c6aaf178a;hp=338c6402bad0a824f1a80d9b871fcd7861d262df;hpb=8fd8454f3ee9d12dc5ffca25308c1054aeb2fb59;p=pkg%2Fabook.git diff --git a/filter.c b/filter.c index 338c640..dca51b8 100644 --- 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",