Hi all, I wrote the attached patch for rra to add support for vcard with multiline value. I need to it for sync my contact with evolution.
What do you think about? Regards Sergio
--- ./lib/contact.c.orig 2005-10-27 17:55:18.000000000 +0200 +++ ./lib/contact.c 2005-10-28 11:10:16.000000000 +0200 @@ -700,6 +700,7 @@ VCARD_STATE_NAME, VCARD_STATE_TYPE, VCARD_STATE_VALUE, + VCARD_STATE_MULTILINE, } VcardState; #define myisblank(c) ((c) == ' ' || (c) == '\t') @@ -1248,6 +1249,7 @@ const char* type_end = NULL; const char* value = NULL; const char* value_end = NULL; + char* value_ml = NULL; struct FieldStrings *tel_work = malloc( MAX_TEL_WORK * sizeof( struct FieldStrings ) ); struct FieldStrings *tel_home = malloc( MAX_TEL_HOME * sizeof( struct FieldStrings ) ); @@ -1270,7 +1272,7 @@ case VCARD_STATE_NEWLINE:/*{{{*/ if (myisblank(*p)) { - synce_error("Can't handle multiline values"); + synce_error("Failed to handle multiline values"); goto exit; } @@ -1286,6 +1288,7 @@ type_end = NULL; value = NULL; value_end = NULL; + value_ml = NULL; state = VCARD_STATE_NAME; } @@ -1322,6 +1325,21 @@ { value_end = p; + if (*(p+2) && myisblank(*(p+2))) + { + value_ml = malloc(strlen(vcard) - (value - vcard)); + value_ml[0] = '\0'; + + strncat(value_ml, value, value_end - value); + + p = p + 3; + value = p; + + state = VCARD_STATE_MULTILINE; + + break; + } + /* We have to queue tel and email fields, as there may be more than one, and we have to find out, which one is the preferred. Unfortunately there may be none, or many preferred fields :( @@ -1329,7 +1347,10 @@ tmp_field->name = strndup(name, name_end - name); tmp_field->type = type ? strndup(type, type_end - type) : strdup(""); - tmp_field->value = strndup(value, value_end - value); + if (value_ml) + tmp_field->value = value_ml; + else + tmp_field->value = strndup(value, value_end - value); tmp_field->pref = STR_IN_STR(tmp_field->type, "PREF"); if (STR_IN_STR(tmp_field->name, "TEL") && STR_IN_STR(tmp_field->type, "WORK")) { @@ -1354,6 +1375,25 @@ p++; break;/*}}}*/ + case VCARD_STATE_MULTILINE:/*{{{*/ + if (myisnewline(*p)) + { + value_end = p; + + strncat(value_ml, value, value_end - value); + + if (*(p+2) && myisblank(*(p+2))) + { + p = p + 3; + value = p; + } + else + state = VCARD_STATE_VALUE; + } + else + p++; + break;/*}}}*/ + default: synce_error("Unknown state: %i", state); goto exit;