Make MIME types case insensitive
authorDarko Koruga <darko@users.sourceforge.net>
Fri, 29 Jun 2001 07:48:04 +0000 (07:48 +0000)
committerDarko Koruga <darko@users.sourceforge.net>
Fri, 29 Jun 2001 07:48:04 +0000 (07:48 +0000)
ChangeLog.claws
src/procmime.c

index 5a1d05f1de59f1ad648c4a4bdad74761fcb474d2..a80ae633e9f22edd08e2aa3fd1cf595b038bb7ad 100644 (file)
@@ -1,3 +1,8 @@
+2001-06-29 [darko]
+
+       * src/procmime.c
+               make MIME types case insensitive
+
 2001-06-28 [alfons]
 
        * po/nl.po
index af71a81e392d645311049d261496322854b5c870..4b80c2fa93aea478641cc774d4c7a3569903bbe7 100644 (file)
@@ -753,6 +753,27 @@ gchar *procmime_get_mime_type(const gchar *filename)
        return NULL;
 }
 
+static guint procmime_str_hash(gconstpointer gptr)
+{
+       guint hash_result = 0;
+       const char *str;
+
+       for (str = gptr; str && *str; str++) {
+               if (isupper(*str)) hash_result += (*str + ' ');
+               else hash_result += *str;
+       }
+
+       return hash_result;
+}
+
+static gint procmime_str_equal(gconstpointer gptr1, gconstpointer gptr2)
+{
+       const char *str1 = gptr1;
+       const char *str2 = gptr2;
+
+       return !strcasecmp(str1, str2);
+}
+
 static GHashTable *procmime_get_mime_type_table(void)
 {
        GHashTable *table = NULL;
@@ -765,7 +786,7 @@ static GHashTable *procmime_get_mime_type_table(void)
                if (!mime_type_list) return NULL;
        }
 
-       table = g_hash_table_new(g_str_hash, g_str_equal);
+       table = g_hash_table_new(procmime_str_hash, procmime_str_equal);
 
        for (cur = mime_type_list; cur != NULL; cur = cur->next) {
                gint i;