]> git.datanom.net - vcard-parser.git/blobdiff - src/vcard-parser.c
Support private extensions (X-PRIVATE)
[vcard-parser.git] / src / vcard-parser.c
index 056adbd6191f4840d1446cdf3a1951ccc52d0c5b..e35dba85f9cdc4075c20da5b736f1aee81b895ba 100644 (file)
@@ -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]);
This page took 0.042366 seconds and 5 git commands to generate.