- address_field = value;
- for(i=k=0; value[i]; i++) {
- if(value[i] == ';') {
- value[i] = '\0';
- if(vcard_address_fields[k] >= 0) {
- item[vcard_address_fields[k]] = xstrdup(address_field);
- }
- address_field = &value[i+1];
- k++;
- if((k+1)==(sizeof(vcard_address_fields)/sizeof(*vcard_address_fields)))
- break;
- }
- }
- item[vcard_address_fields[k]] = xstrdup(address_field);
- xfree(value);
+ // vCard(post office box) - not used
+ strsep(&value, ";");
+ // vCard(the extended address)
+ item_fput(item, ADDRESS2, xstrdup(strsep(&value, ";")));
+ // vCard(the street address)
+ item_fput(item, ADDRESS, xstrdup(strsep(&value, ";")));
+ // vCard(the locality)
+ item_fput(item, CITY, xstrdup(strsep(&value, ";")));
+ // vCard(the region)
+ item_fput(item, STATE, xstrdup(strsep(&value, ";")));
+ // vCard(the postal code)
+ item_fput(item, ZIP, xstrdup(strsep(&value, ";")));
+ // vCard(the country name)
+ item_fput(item, COUNTRY, xstrdup(strsep(&value, ";")));
+
+ if(*value) xfree(value);