]> git.datanom.net - vcard-parser.git/commitdiff
New function master
authorMichael Rasmussen <mir@datanom.net>
Tue, 31 Dec 2019 12:34:36 +0000 (13:34 +0100)
committerMichael Rasmussen <mir@datanom.net>
Tue, 31 Dec 2019 12:34:36 +0000 (13:34 +0100)
Signed-off-by: Michael Rasmussen <mir@datanom.net>
src/vcard-parser.c
src/vcard-parser.h
src/vcard.c

index e35dba85f9cdc4075c20da5b736f1aee81b895ba..a62d8d34d6c043c552970c03c6fe5484d845c57c 100644 (file)
@@ -175,46 +175,6 @@ static gchar** vcard_text_normalize(const gchar** text) {
        return new;
 }
 
-Property vcard_max_property(VCardVersion version) {
-       Property p = VCARD_PROPERTIES;
-
-       if (version == VCARD_VERSION_2_1) {
-               p = TZ;
-       } else if (version == VCARD_VERSION_3_0) {
-               p = IMPP;
-       } else if (version == VCARD_VERSION_4_0) {
-               p = VCARD_PROPERTIES - 1;
-       }
-
-       return p;
-}
-
-void destroy_hash_table(GHashTable* ht) {
-       GHashTableIter iter;
-       gpointer key, value;
-
-       g_hash_table_iter_init (&iter, ht);
-       while (g_hash_table_iter_next(&iter, &key, &value)) {
-               if (value)
-                       g_slist_free_full((GSList *) value, vcard_property_free);
-       }
-
-       g_hash_table_destroy(ht);
-}
-
-static void init_g_hash_table(GHashTable** ht, VCardVersion version) {
-       if (!ht) return;
-
-       Property property = vcard_max_property(version);
-       if (property < VCARD_PROPERTIES) {
-               *ht = g_hash_table_new_full(
-                       g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
-               for (Property i = N; i <= property; i++) {
-                       g_hash_table_insert(*ht, g_strdup(Properties[i]), NULL);
-               }
-       }
-}
-
 static VCardParserResponse vcard_parse(gchar** text, VCardVersion version, GHashTable** vcard) {
        VCardParserResponse r = VCARD_PARSER_ERROR;
        guint l = g_strv_length(text);
@@ -264,6 +224,46 @@ static VCardParserResponse vcard_parse(gchar** text, VCardVersion version, GHash
        return r;
 }
 
+Property vcard_max_property(VCardVersion version) {
+       Property p = VCARD_PROPERTIES;
+
+       if (version == VCARD_VERSION_2_1) {
+               p = TZ;
+       } else if (version == VCARD_VERSION_3_0) {
+               p = IMPP;
+       } else if (version == VCARD_VERSION_4_0) {
+               p = VCARD_PROPERTIES - 1;
+       }
+
+       return p;
+}
+
+void destroy_hash_table(GHashTable* ht) {
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_hash_table_iter_init (&iter, ht);
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+               if (value)
+                       g_slist_free_full((GSList *) value, vcard_property_free);
+       }
+
+       g_hash_table_destroy(ht);
+}
+
+void init_g_hash_table(GHashTable** ht, VCardVersion version) {
+       if (!ht) return;
+
+       Property property = vcard_max_property(version);
+       if (property < VCARD_PROPERTIES) {
+               *ht = g_hash_table_new_full(
+                       g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
+               for (Property i = N; i <= property; i++) {
+                       g_hash_table_insert(*ht, g_strdup(Properties[i]), NULL);
+               }
+       }
+}
+
 VCardVersion str_2_vcard_version(const gchar* version) {
        VCardVersion vv = VCARD_VERSION_DETECT;
 
index 0eb4670425d35fe8a951c002d6bbe97aab80a34d..d812ab8a01c70d4e6ba8fee91dd8a678ad2f9e74 100644 (file)
@@ -111,6 +111,7 @@ VCardVersion str_2_vcard_version(const gchar* version);
 gchar* vcard_version_2_str(VCardVersion version);
 Property vcard_max_property(VCardVersion version);
 VCardParserResponse vcard_parse_text(const gchar* text, VCardVersion* version, GHashTable** vcard);
+void init_g_hash_table(GHashTable** ht, VCardVersion version);
 void destroy_hash_table(GHashTable* ht);
 
 G_END_DECLS
index e9881f91d85aaf526e68a5d8cb3d391f90a801c3..cba62add6f3bc94fd00a7dd71a9da0ab3d5ca839 100644 (file)
@@ -135,14 +135,12 @@ void VCard_list_free(GSList* list) {
                g_slist_free(list);
 }
 
-/*
 VCard* VCard_new(VCardVersion version) {
        VCard* vc = g_new0(VCard, 1);
        vc->version = version;
 
        return vc;
 }
-*/
 
 GSList* VCard_new_from_text(const gchar* text, VCardVersion version, gboolean skip_broken) {
        GSList* list = NULL;
This page took 0.052999 seconds and 5 git commands to generate.