X-Git-Url: http://git.datanom.net/vcard-parser.git/blobdiff_plain/b782cff090f5fa5c04596469e686f9847fa3445a..766f8acf743a7e678ad02a8e5d084309c36702e2:/src/vcard-parser.c diff --git a/src/vcard-parser.c b/src/vcard-parser.c index 056adbd..e35dba8 100644 --- a/src/vcard-parser.c +++ b/src/vcard-parser.c @@ -89,23 +89,6 @@ static void vcard_property_free(gpointer data) { } static Property get_property(const gchar* property) { -/* Property p = VCARD_PROPERTIES; - gchar* lookup = NULL; - - if (g_strcmp0("ORG-DIRECTORY", property) == 0) - lookup = g_strdup("ORG_DIRECTORY"); - else if (g_strcmp0("SORT-STRING", property) == 0) - lookup = g_strdup("SORT_STRING"); - else - lookup = g_strdup(property); - - for (int i = 0; i < VCARD_PROPERTIES; i++) { - if (g_strcmp0(Properties[i], lookup) == 0) { - p = i; - break; - } - } - g_free(lookup);*/ for (Property i = N; i < VCARD_PROPERTIES; i++) { if (g_strcmp0(Properties[i], property) == 0) return i; } @@ -122,7 +105,7 @@ static gboolean check_support(Property property, VCardVersion version) { support = property <= IMPP ? TRUE : FALSE; } else if (version == VCARD_VERSION_4_0) { support = property <= VCARD_PROPERTIES ? TRUE : FALSE; - }; + } return support; } @@ -235,6 +218,7 @@ static void init_g_hash_table(GHashTable** ht, VCardVersion version) { static VCardParserResponse vcard_parse(gchar** text, VCardVersion version, GHashTable** vcard) { VCardParserResponse r = VCARD_PARSER_ERROR; guint l = g_strv_length(text); + gboolean support; for (guint i = 0; i < l; i++) { gchar** b = g_strsplit(text[i], ":", 2); @@ -252,8 +236,13 @@ static VCardParserResponse vcard_parse(gchar** text, VCardVersion version, GHash g_strfreev(b); continue; } - Property property = get_property(c[0]); - if (check_support(property, version)) { + if (g_str_has_prefix(c[0], "X-")) { + support = TRUE; + } else { + Property property = get_property(c[0]); + support = check_support(property, version); + } + if (support) { GSList* value = g_hash_table_lookup(*vcard, c[0]); VCardProperty* vp = g_new(VCardProperty, 1); vp->name = g_strdup(b[0]);