2004-12-01 [paul] 0.9.12cvs177.2
[claws.git] / src / addrharvest.c
index 4a7516332626298f4dd303a4c35a9737ebdf9b85..c71ef48f33e59e4f094532a19e9fe5b28e4f842e 100644 (file)
@@ -19,7 +19,6 @@
 
 /*
  * Functions for an E-Mail address harvester.
- * Code still needs some work. Address parsing not strictly correct.
  */
 
 #include <sys/stat.h>
@@ -68,7 +67,7 @@ struct _HeaderEntry {
  * Enter: harvester Harvester object.
  *        name      Header name.
  */
-static void *addrharvest_build_entry(
+static void addrharvest_build_entry(
                AddressHarvester* harvester, gchar *name )
 {
        HeaderEntry *entry;
@@ -81,12 +80,6 @@ static void *addrharvest_build_entry(
        harvester->headerTable = g_list_append( harvester->headerTable, entry );
 }
 
-static void addrharvest_print_hdrentry( HeaderEntry *entry, FILE *stream ) {
-       fprintf( stream, "Header Entry\n" );
-       fprintf( stream, "    name : %s\n", entry->header );
-       fprintf( stream, "selected : %s\n", entry->selected ? "yes" : "no" );
-}
-
 /*
  * Free key in table.
  */
@@ -208,7 +201,8 @@ static HeaderEntry *addrharvest_find(
                HeaderEntry *entry;
 
                entry = node->data;
-               if( g_strcasecmp( entry->header, name ) == 0 ) {
+               if (g_ascii_strncasecmp(entry->header, name,
+                                       sizeof(entry->header)) == 0 ) {
                        retVal = entry;
                        break;
                }
@@ -376,7 +370,7 @@ static void addrharvest_del_email( gchar *name, gchar *str ) {
        gint lenn, lenr;
 
        lenr = strlen( str );
-       while( p = strcasestr( name, str )  ) {
+       while((p = strcasestr( name, str )) != NULL) {
                lenn = strlen( p );
                memmove( p, p + lenr, lenn );
        }
@@ -526,7 +520,7 @@ static void addrharvest_parse_address(
        gint bufLen;
 
        /* Search for an address */
-       while( atCh = addrharvest_find_at( hdrBuf ) ) {
+       while((atCh = addrharvest_find_at( hdrBuf )) != NULL) {
                /* Find addres string */
                addrharvest_find_address( hdrBuf, atCh, &bp, &ep );
 
@@ -557,11 +551,12 @@ static void addrharvest_parse_address(
                        mgu_str_ltc2space( buffer, '(', ')' );
                        g_strstrip( buffer );
 
-                       if( g_strcasecmp( buffer, email ) == 0 ) {
+                       if( g_ascii_strcasecmp( buffer, email ) == 0 ) {
                                name = "";
                        }
                        else {
                                name = buffer;
+                               conv_unmime_header_overwrite(name);
                        }
 
                        /* Insert into address book */
@@ -593,7 +588,7 @@ static gboolean addrharvest_check_hdr( GList *listHdr, gchar *buf ) {
                node = listHdr;
                while( node ) {
                        nhdr = node->data;
-                       if( g_strcasecmp( nhdr, hdr ) == 0 ) {
+                       if (g_ascii_strncasecmp(nhdr, hdr, sizeof(nhdr)) == 0 ) {
                                retVal = TRUE;
                                break;
                        }