Removed references to LDAP constants.
authorMatch Grun <match@dimensional.com>
Sun, 26 Jan 2003 05:12:00 +0000 (05:12 +0000)
committerMatch Grun <match@dimensional.com>
Sun, 26 Jan 2003 05:12:00 +0000 (05:12 +0000)
src/addrbook.c
src/addressbook.c
src/addrindex.c
src/importldif.c
src/importldif.h
src/mgutils.c
src/mgutils.h
src/syldap.h

index 0af9e01da7959604f68fa4f2784ec9fd653325f5..8df82763b09c93fe9d2f64407295d054f12aa010 100644 (file)
@@ -233,10 +233,9 @@ void addrbook_print_book(AddressBookFile *book, FILE *stream)
        g_return_if_fail(book != NULL);
 
        fprintf(stream, "AddressBook:\n");
-       fprintf(stream, "\tpath : '%s'\n", book->path);
-       fprintf(stream, "\tfile : '%s'\n", book->fileName);
-       fprintf(stream, "\tstatus : %d : '%s'\n", book->retVal,
-               mgu_error2string(book->retVal));
+       fprintf(stream, "\t  path : '%s'\n", book->path);
+       fprintf(stream, "\t  file : '%s'\n", book->fileName);
+       fprintf(stream, "\tstatus : %d\n",   book->retVal );
        addrcache_print(book->addressCache, stream);
 }
 
index 970174284db2ddc8a5a47fdbbe9e7ef5235ff968..39d0479e7d9a460917d3b8635b34579703c2a2f2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -408,6 +408,79 @@ static GtkItemFactoryEntry addressbook_list_popup_entries[] =
        {N_("/Pa_ste Address"), NULL, addressbook_clip_paste_address_cb,     0, NULL}
 };
 
+/**
+ * Structure of error message table.
+ */
+typedef struct _ErrMsgTableEntry ErrMsgTableEntry;
+struct _ErrMsgTableEntry {
+       gint    code;
+       gchar   *description;
+};
+
+static gchar *_errMsgUnknown_ = N_( "Unknown" );
+
+/**
+ * Lookup table of error messages for general errors. Note that a NULL
+ * description signifies the end of the table.
+ */
+static ErrMsgTableEntry _lutErrorsGeneral_[] = {
+       { MGU_SUCCESS,          N_("Success") },
+       { MGU_BAD_ARGS,         N_("Bad arguments") },
+       { MGU_NO_FILE,          N_("File not specified") },
+       { MGU_OPEN_FILE,        N_("Error opening file") },
+       { MGU_ERROR_READ,       N_("Error reading file") },
+       { MGU_EOF,              N_("End of file encountered") },
+       { MGU_OO_MEMORY,        N_("Error allocating memory") },
+       { MGU_BAD_FORMAT,       N_("Bad file format") },
+       { MGU_ERROR_WRITE,      N_("Error writing to file") },
+       { MGU_OPEN_DIRECTORY,   N_("Error opening directory") },
+       { MGU_NO_PATH,          N_("No path specified") },
+       { 0,                    NULL }
+};
+
+#ifdef USE_LDAP
+/**
+ * Lookup table of error messages for LDAP errors.
+ */
+static ErrMsgTableEntry _lutErrorsLDAP_[] = {
+       { MGU_SUCCESS,          N_("Success") },
+       { MGU_LDAP_CONNECT,     N_("Error connecting to LDAP server") },
+       { MGU_LDAP_INIT,        N_("Error initializing LDAP") },
+       { MGU_LDAP_BIND,        N_("Error binding to LDAP server") },
+       { MGU_LDAP_SEARCH,      N_("Error searching LDAP database") },
+       { MGU_LDAP_TIMEOUT,     N_("Timeout performing LDAP operation") },
+       { MGU_LDAP_CRITERIA,    N_("Error in LDAP search criteria") },
+       { MGU_LDAP_CRITERIA,    N_("Error in LDAP search criteria") },
+       { MGU_LDAP_NOENTRIES,   N_("No LDAP entries found for search criteria") },
+       { 0,                    NULL }
+};
+#endif
+
+/**
+ * Lookup message for specified error code.
+ * \param lut  Lookup table.
+ * \param code Code to lookup.
+ * \return Description associated to code.
+ */
+static gchar *addressbook_err2string( ErrMsgTableEntry lut[], gint code ) {
+        gchar *desc = NULL;
+        ErrMsgTableEntry entry;
+        gint i;
+
+        for( i = 0; ; i++ ) {
+                entry = lut[ i ];
+                if( entry.description == NULL ) break;
+                if( entry.code == code ) {
+                        desc = entry.description;
+                        break;
+                }
+        }
+        if( ! desc ) {
+               desc = _errMsgUnknown_;
+        }
+        return desc;
+}
+
 void addressbook_open(Compose *target)
 {
        /* Initialize all static members */
@@ -816,6 +889,7 @@ static void addressbook_ds_status_message( AddressDataSource *ds, gchar *msg ) {
 static void addressbook_ds_show_message( AddressDataSource *ds ) {
        gint retVal;
        gchar *name;
+       gchar *desc;
        *addressbook_msgbuf = '\0';
        if( ds ) {
                name = addrindex_ds_get_name( ds );
@@ -825,10 +899,10 @@ static void addressbook_ds_show_message( AddressDataSource *ds ) {
                                    sizeof(addressbook_msgbuf), "%s", name );
                }
                else {
+                       desc = addressbook_err2string( _lutErrorsGeneral_, retVal );
                        g_snprintf( addressbook_msgbuf, 
-                                   sizeof(addressbook_msgbuf), "%s: %s", name,
-                                   mgu_error2string( retVal ) );
-               }
+                           sizeof(addressbook_msgbuf), "%s: %s", name, desc );
+                       }
        }
        addressbook_status_show( addressbook_msgbuf );
 }
@@ -3182,6 +3256,7 @@ static void addressbook_new_ldap_cb( gpointer data, guint action, GtkWidget *wid
 
 static void addressbook_ldap_show_message( SyldapServer *svr ) {
        gchar *name;
+       gchar *desc;
        *addressbook_msgbuf = '\0';
        if( svr ) {
                name = syldap_get_name( svr );
@@ -3197,10 +3272,11 @@ static void addressbook_ldap_show_message( SyldapServer *svr ) {
                                            name );
                        }
                        else {
+                               desc = addressbook_err2string(
+                                               _lutErrorsLDAP_, svr->retVal );
                                g_snprintf( addressbook_msgbuf,
                                            sizeof(addressbook_msgbuf),
-                                           "%s: %s", name,
-                                           mgu_error2string( svr->retVal ) );
+                                           "%s: %s", name, desc );
                        }
                }
        }
index fec8d578dc00c3fc2e6e67e4322de422382612e8..f2dd8450ada5d9ae489479f1c3cc024bd3477685 100644 (file)
@@ -572,7 +572,7 @@ void addrindex_print_index( AddressIndex *addrIndex, FILE *stream ) {
        fprintf( stream, "AddressIndex:\n" );
        fprintf( stream, "\tfile path: '%s'\n", addrIndex->filePath );
        fprintf( stream, "\tfile name: '%s'\n", addrIndex->fileName );
-       fprintf( stream, "\t   status: %d : '%s'\n", addrIndex->retVal, mgu_error2string( addrIndex->retVal ) );
+       fprintf( stream, "\t   status: %d\n",   addrIndex->retVal );
        fprintf( stream, "\tconverted: '%s'\n", addrIndex->wasConverted ? "yes" : "no" );
        fprintf( stream, "\tcvt error: '%s'\n", addrIndex->conversionError ? "yes" : "no" );
        fprintf( stream, "\t---\n" );
index ce2d11d70faa25b7c4b31c3d277d67ae2cc22819..c2ba52d1acefc009d03facbab5d1de406cff757b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001 Match Grun
+ * Copyright (C) 2001-2003 Match Grun
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -100,11 +100,69 @@ static LdifFile *_ldifFile_ = NULL;
 static GdkPixmap *markxpm;
 static GdkBitmap *markxpmmask;
 
+/**
+ * Structure of error message table.
+ */
+typedef struct _ErrMsgTableEntry ErrMsgTableEntry;
+struct _ErrMsgTableEntry {
+       gint    code;
+       gchar   *description;
+};
+
+static gchar *_errMsgUnknown_ = N_( "Unknown" );
+
+/**
+ * Lookup table of error messages for general errors. Note that a NULL
+ * description signifies the end of the table.
+ */
+static ErrMsgTableEntry _lutErrorsLDIF_[] = {
+       { MGU_SUCCESS,          N_("Success") },
+       { MGU_BAD_ARGS,         N_("Bad arguments") },
+       { MGU_NO_FILE,          N_("File not specified") },
+       { MGU_OPEN_FILE,        N_("Error opening file") },
+       { MGU_ERROR_READ,       N_("Error reading file") },
+       { MGU_EOF,              N_("End of file encountered") },
+       { MGU_OO_MEMORY,        N_("Error allocating memory") },
+       { MGU_BAD_FORMAT,       N_("Bad file format") },
+       { MGU_ERROR_WRITE,      N_("Error writing to file") },
+       { MGU_OPEN_DIRECTORY,   N_("Error opening directory") },
+       { MGU_NO_PATH,          N_("No path specified") },
+       { 0,                    NULL }
+};
+
+/**
+ * Lookup message for specified error code.
+ * \param lut  Lookup table.
+ * \param code Code to lookup.
+ * \return Description associated to code.
+ */
+static gchar *imp_ldif_err2string( ErrMsgTableEntry lut[], gint code ) {
+        gchar *desc = NULL;
+        ErrMsgTableEntry entry;
+        gint i;
+
+        for( i = 0; ; i++ ) {
+                entry = lut[ i ];
+                if( entry.description == NULL ) break;
+                if( entry.code == code ) {
+                        desc = entry.description;
+                        break;
+                }
+        }
+        if( ! desc ) {
+               desc = _errMsgUnknown_;
+        }
+        return desc;
+}
+
 static void imp_ldif_status_show( gchar *msg ) {
        if( impldif_dlg.statusbar != NULL ) {
-               gtk_statusbar_pop( GTK_STATUSBAR(impldif_dlg.statusbar), impldif_dlg.status_cid );
+               gtk_statusbar_pop( GTK_STATUSBAR(impldif_dlg.statusbar),
+                       impldif_dlg.status_cid );
                if( msg ) {
-                       gtk_statusbar_push( GTK_STATUSBAR(impldif_dlg.statusbar), impldif_dlg.status_cid, msg );
+                       gtk_statusbar_push(
+                               GTK_STATUSBAR(impldif_dlg.statusbar),
+                               impldif_dlg.status_cid, msg );
                }
        }
 }
@@ -176,7 +234,9 @@ static void imp_ldif_load_fields( LdifFile *ldf ) {
                        row = gtk_clist_append( clist, text );
                        gtk_clist_set_row_data( clist, row, rec );
                        if( rec->selected )
-                               gtk_clist_set_pixmap( clist, row, FIELD_COL_SELECT, markxpm, markxpmmask );
+                               gtk_clist_set_pixmap(
+                                       clist, row, FIELD_COL_SELECT, markxpm,
+                                       markxpmmask );
                        impldif_dlg.rowCount++;
                }
                node = g_list_next( node );
@@ -186,7 +246,10 @@ static void imp_ldif_load_fields( LdifFile *ldf ) {
        ldif_set_accessed( ldf, FALSE );
 }
 
-static void imp_ldif_field_list_selected( GtkCList *clist, gint row, gint column, GdkEvent *event, gpointer data ) {
+static void imp_ldif_field_list_selected(
+               GtkCList *clist, gint row, gint column, GdkEvent *event,
+               gpointer data )
+{
        Ldif_FieldRec *rec = gtk_clist_get_row_data( clist, row );
 
        impldif_dlg.rowIndSelect = row;
@@ -194,7 +257,8 @@ static void imp_ldif_field_list_selected( GtkCList *clist, gint row, gint column
        if( rec ) {
                gtk_label_set_text( GTK_LABEL(impldif_dlg.name_ldif), rec->tagName );
                if( rec->userName )
-                       gtk_entry_set_text( GTK_ENTRY(impldif_dlg.name_attrib), rec->userName );
+                       gtk_entry_set_text(
+                               GTK_ENTRY(impldif_dlg.name_attrib), rec->userName );
                gtk_toggle_button_set_active(
                        GTK_TOGGLE_BUTTON( impldif_dlg.check_select),
                        rec->selected );
@@ -202,12 +266,15 @@ static void imp_ldif_field_list_selected( GtkCList *clist, gint row, gint column
        gtk_widget_grab_focus(impldif_dlg.name_attrib);
 }
 
-static void imp_ldif_field_list_toggle( GtkCList *clist, GdkEventButton *event, gpointer data ) {
+static void imp_ldif_field_list_toggle(
+               GtkCList *clist, GdkEventButton *event, gpointer data )
+{
        if( ! event ) return;
        if( impldif_dlg.rowIndSelect < 0 ) return;
        if( event->button == 1 ) {
                if( event->type == GDK_2BUTTON_PRESS ) {
-                       Ldif_FieldRec *rec = gtk_clist_get_row_data( clist, impldif_dlg.rowIndSelect );
+                       Ldif_FieldRec *rec = gtk_clist_get_row_data(
+                               clist, impldif_dlg.rowIndSelect );
                        if( rec ) {
                                rec->selected = ! rec->selected;
                                imp_ldif_update_row( clist );
@@ -226,13 +293,16 @@ static void imp_ldif_modify_pressed( GtkWidget *widget, gpointer data ) {
        rec = gtk_clist_get_row_data( clist, impldif_dlg.rowIndSelect );
 
        g_free( rec->userName );
-       rec->userName = gtk_editable_get_chars( GTK_EDITABLE(impldif_dlg.name_attrib), 0, -1 );
-       rec->selected = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( impldif_dlg.check_select) );
+       rec->userName = gtk_editable_get_chars(
+                               GTK_EDITABLE(impldif_dlg.name_attrib), 0, -1 );
+       rec->selected = gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON( impldif_dlg.check_select) );
        imp_ldif_update_row( clist );
        gtk_clist_select_row( clist, row, 0 );
        gtk_label_set_text( GTK_LABEL(impldif_dlg.name_ldif), "" );
        gtk_entry_set_text( GTK_ENTRY(impldif_dlg.name_attrib), "" );
-       gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( impldif_dlg.check_select), FALSE );
+       gtk_toggle_button_set_active(
+               GTK_TOGGLE_BUTTON( impldif_dlg.check_select), FALSE );
 }
 
 /*
@@ -341,7 +411,7 @@ static void imp_ldif_finish_show() {
                sMsg = _( "LDIF file imported successfully." );
        }
        else {
-               sMsg = mgu_error2string( _ldifFile_->retVal );
+               sMsg = imp_ldif_err2string( _lutErrorsLDIF_, _ldifFile_->retVal );
        }
        imp_ldif_status_show( sMsg );
        gtk_widget_grab_focus(impldif_dlg.btnCancel);
@@ -590,33 +660,40 @@ static void imp_ldif_page_fields( gint pageNum, gchar *pageLbl ) {
        /* First row */
        top = 0;
        label = gtk_label_new(_("LDIF Field"));
-       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
+               GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
        name_ldif = gtk_label_new( "" );
        gtk_misc_set_alignment(GTK_MISC(name_ldif), 0.01, 0.5);
-       gtk_table_attach(GTK_TABLE(table), name_ldif, 1, 3, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), name_ldif, 1, 3, top, (top + 1),
+               GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
 
        /* Second row */
        ++top;
        label = gtk_label_new(_("Attribute"));
-       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
+               GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
        name_attrib = gtk_entry_new();
-       gtk_table_attach(GTK_TABLE(table), name_attrib, 1, 3, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), name_attrib, 1, 3, top, (top + 1),
+               GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
 
        /* Next row */
        ++top;
        label = gtk_label_new(_("Select"));
-       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
+               GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
        check_select = gtk_check_button_new();
-       gtk_table_attach(GTK_TABLE(table), check_select, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), check_select, 1, 2, top, (top + 1),
+               GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
 
        buttonMod = gtk_button_new_with_label( _("Modify"));
-       gtk_table_attach(GTK_TABLE(table), buttonMod, 2, 3, top, (top + 1), GTK_FILL, 0, 3, 0);
+       gtk_table_attach(GTK_TABLE(table), buttonMod, 2, 3, top, (top + 1),
+               GTK_FILL, 0, 3, 0);
 
        gtk_widget_show_all(vbox);
 
@@ -651,7 +728,8 @@ static void imp_ldif_page_finish( gint pageNum, gchar *pageLbl ) {
        gtk_widget_show( label );
        gtk_notebook_set_tab_label(
                GTK_NOTEBOOK( impldif_dlg.notebook ),
-               gtk_notebook_get_nth_page( GTK_NOTEBOOK( impldif_dlg.notebook ), pageNum ), label );
+               gtk_notebook_get_nth_page( GTK_NOTEBOOK( impldif_dlg.notebook ), pageNum ),
+               label );
 
        table = gtk_table_new(3, 2, FALSE);
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
index 5e648b34286aec8d7aeaab04fce2951abace12a0..3522f921b8da19b38015f398a6c7eaac1517431a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001 Match Grun
+ * Copyright (C) 2001-2003 Match Grun
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index ba2e07ec0271a350b223baf9e63a1d965b35bbf1..9094adf660d70e9f08ea4c0d792fdc6d8aa6a6ff 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001 Match Grun
+ * Copyright (C) 2001-2003 Match Grun
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  */
 
 /*
- * General functions for create common address book entries.
+ * Definitions for generic functions.
  */
 
 #include <glib.h>
@@ -111,52 +111,6 @@ gchar *mgu_list_coalesce( GSList *list ) {
        return buf;
 }
 
-struct mgu_error_entry {
-       gint    e_code;
-       gchar   *e_reason;
-};
-
-static const struct mgu_error_entry mgu_error_list[] = {
-       { MGU_SUCCESS,          "Success" },
-       { MGU_BAD_ARGS,         "Bad arguments" },
-       { MGU_NO_FILE,          "File not specified" },
-       { MGU_OPEN_FILE,        "Error opening file" },
-       { MGU_ERROR_READ,       "Error reading file" },
-       { MGU_EOF,              "End of file encountered" },
-       { MGU_OO_MEMORY,        "Error allocating memory" },
-       { MGU_BAD_FORMAT,       "Bad file format" },
-       { MGU_LDAP_CONNECT,     "Error connecting to LDAP server" },
-       { MGU_LDAP_INIT,        "Error initializing LDAP" },
-       { MGU_LDAP_BIND,        "Error binding to LDAP server" },
-       { MGU_LDAP_SEARCH,      "Error searching LDAP database" },
-       { MGU_LDAP_TIMEOUT,     "Timeout performing LDAP operation" },
-       { MGU_LDAP_CRITERIA,    "Error in LDAP search criteria" },
-       { MGU_LDAP_CRITERIA,    "Error in LDAP search criteria" },
-       { MGU_LDAP_NOENTRIES,   "No LDAP entries found for search criteria" },
-       { MGU_ERROR_WRITE,      "Error writing to file" },
-       { MGU_OPEN_DIRECTORY,   "Error opening directory" },
-       { MGU_NO_PATH,          "No path specified" },
-       { -999,                 NULL }
-};
-
-static const struct mgu_error_entry *mgu_error_find( gint err ) {
-       gint i;
-       for ( i = 0; mgu_error_list[i].e_code != -999; i++ ) {
-               if ( err == mgu_error_list[i].e_code )
-                       return & mgu_error_list[i];
-       }
-       return NULL;
-}
-
-/*
-* Return error message for specified error code.
-*/
-gchar *mgu_error2string( gint err ) {
-       const struct mgu_error_entry *e;
-       e = mgu_error_find( err );
-       return ( e != NULL ) ? e->e_reason : "Unknown error";
-}
-
 /*
 * Replace existing string with new string.
 */
@@ -351,6 +305,112 @@ void mgu_str_ltc2space( gchar *str, gchar chlead, gchar chtail ) {
        return;
 }
 
+/*
+ * Return reference to longest entry in the specified linked list.
+ * It is assumed that the list contains only gchar objects.
+ * Enter:  list List of gchar strings to examine.
+ * Return: Reference to longest entry, or NULL if nothing found.
+ */
+gchar *mgu_slist_longest_entry( GSList *list ) {
+       GSList *node;
+       gchar *name = NULL;
+       gint iLen = 0, iLenT = 0;
+
+       node = list;
+       while( node ) {
+               if( name == NULL ) {
+                       name = node->data;
+                       iLen = strlen( name );
+               }
+               else {
+                       iLenT = strlen( node->data );
+                       if( iLenT > iLen ) {
+                               name = node->data;
+                               iLen = iLenT;
+                       }
+               }
+               node = g_slist_next( node );
+       }
+       return name;
+}      
+
+/*
+ * Return reference to longest entry in the specified linked list.
+ * It is assumed that the list contains only gchar objects.
+ * Enter:  list List of gchar strings to examine.
+ * Return: Reference to longest entry, or NULL if nothing found.
+ */
+gchar *mgu_list_longest_entry( GList *list ) {
+       GList *node;
+       gchar *name = NULL;
+       gint iLen = 0, iLenT = 0;
+
+       node = list;
+       while( node ) {
+               if( name == NULL ) {
+                       name = node->data;
+                       iLen = strlen( name );
+               }
+               else {
+                       iLenT = strlen( node->data );
+                       if( iLenT > iLen ) {
+                               name = node->data;
+                               iLen = iLenT;
+                       }
+               }
+               node = g_list_next( node );
+       }
+       return name;
+}      
+
+/*
+ * Test whether string appears in list of strings, ignoring case. NULL or empty
+ * strings will be ignored.
+ * Enter: list List to process.
+ *        str  String to test.
+ * Return: TRUE if string is unique.
+ */
+gboolean mgu_slist_test_unq_nc( GSList *list, gchar *str ) {
+       GSList *node;
+
+       if( str ) {
+               if( strlen( str ) > 0 ) {
+                       node = list;
+                       while( node ) {
+                               if( g_strcasecmp( str, node->data ) == 0 )
+                                       return FALSE;
+                               node = g_slist_next( node );
+                       }
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+/*
+ * Test whether string appears in list of strings, ignoring case. NULL or empty
+ * strings will be ignored.
+ * Enter: list List to process.
+ *        str  String to test.
+ * Return: TRUE if string is unique.
+ */
+gboolean mgu_list_test_unq_nc( GList *list, gchar *str ) {
+       GList *node;
+
+       if( str ) {
+               if( strlen( str ) > 0 ) {
+                       node = list;
+                       while( node ) {
+                               if( g_strcasecmp( str, node->data ) == 0 )
+                                       return FALSE;
+                               node = g_list_next( node );
+                       }
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
 /*
 * End of Source.
 */
index 1a22991e4ceaba7465890c2140831e85365ca770..2fd541ca3ba88b226970d18d715a86ab64c628eb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001 Match Grun
+ * Copyright (C) 2001-2003 Match Grun
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  */
 
 /*
- * General definitions for common address book entries.
+ * Definitions for generic functions.
  */
 
 #ifndef __MGUTILS_H__
 #define MGU_EOF            -5
 #define MGU_OO_MEMORY      -6
 #define MGU_BAD_FORMAT     -7
-#define MGU_LDAP_CONNECT   -8
-#define MGU_LDAP_INIT      -9
-#define MGU_LDAP_BIND      -10
-#define MGU_LDAP_SEARCH    -11
-#define MGU_LDAP_TIMEOUT   -12
-#define MGU_LDAP_CRITERIA  -13
-#define MGU_LDAP_NOENTRIES -14
 #define MGU_ERROR_WRITE    -15
 #define MGU_OPEN_DIRECTORY -16
 #define MGU_NO_PATH        -17
@@ -53,7 +46,6 @@ void mgu_print_dlist          ( GList *list, FILE *stream );
 void mgu_free_list             ( GSList *list );
 void mgu_free_dlist            ( GList *list );
 gchar *mgu_list_coalesce       ( GSList *list );
-gchar *mgu_error2string                ( gint err );
 gchar *mgu_replace_string      ( gchar *str, const gchar *value );
 void mgu_clear_slist           ( GSList *list );
 void mgu_clear_list            ( GList *list );
@@ -62,5 +54,14 @@ GList *mgu_parse_string              ( gchar *line, const gint maxTokens,
                                  gint *tokenCnt );
 void mgu_str_unescape          ( gchar *str );
 void mgu_str_ltc2space         ( gchar *str, gchar chlead, gchar chtail );
+gchar *mgu_slist_longest_entry ( GSList *list );
+gchar *mgu_list_longest_entry  ( GList *list );
+gboolean mgu_slist_test_unq_nc ( GSList *list, gchar *str );
+gboolean mgu_list_test_unq_nc  ( GList *list, gchar *str );
 
 #endif /* __MGUTILS_H__ */
+
+/*
+* End of Source.
+*/
+
index 9e79a96adde622c3165266db4a3f7fcaa7587ae4..50e5f29152ad2c84583531dd0904caff6de2b209 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2002 Match Grun
+ * Copyright (C) 2001-2003 Match Grun
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #define SYLDAP_ATTR_EMAIL      "mail"
 #define SYLDAP_ATTR_UID        "uid"
 
+#define MGU_LDAP_CONNECT   -51
+#define MGU_LDAP_INIT      -52
+#define MGU_LDAP_BIND      -53
+#define MGU_LDAP_SEARCH    -54
+#define MGU_LDAP_TIMEOUT   -55
+#define MGU_LDAP_CRITERIA  -56
+#define MGU_LDAP_NOENTRIES -57
+
 typedef struct _SyldapServer SyldapServer;
 struct _SyldapServer {
        AddressBookType type;