/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2009 Match Grun and the Claws Mail team
+ * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
*
* 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
#include "addritem.h"
#include "addrcache.h"
-#include "base64.h"
#include "utils.h"
#define LDIF_SEP_TAG ':'
*/
static gint ldif_hash_free_vis( gpointer key, gpointer value, gpointer data ) {
ldif_free_fieldrec( ( Ldif_FieldRec * ) value );
- value = NULL;
- key = NULL;
return -1;
}
gchar *tag = NULL;
gchar *lptr = line;
gchar *sptr = NULL;
- gchar *down = NULL;
+
while( *lptr++ ) {
/* Check for language tag */
if( *lptr == LDIF_LANG_TAG ) {
tag = g_strndup( line, len+1 );
tag[ len ] = '\0';
- down = g_utf8_strdown( tag, -1 );
- g_free(tag);
- return down;
+ return tag;
}
}
return tag;
{
gchar *nm, *val;
- nm = g_strdup( tagName );
- g_utf8_strdown( nm, -1 );
+ nm = g_utf8_strdown( tagName, -1 );
if( tagValue ) {
val = g_strdup( tagValue );
}
}
g_strstrip( val );
- if( g_utf8_collate( nm, LDIF_TAG_COMMONNAME ) == 0 ) {
+ if( g_utf8_collate( nm, g_utf8_strdown( LDIF_TAG_COMMONNAME, -1 ) ) == 0 ) {
rec->listCName = g_slist_append( rec->listCName, val );
}
- else if( g_utf8_collate( nm, LDIF_TAG_FIRSTNAME ) == 0 ) {
+ else if( g_utf8_collate( nm, g_utf8_strdown( LDIF_TAG_FIRSTNAME, -1 ) ) == 0 ) {
rec->listFName = g_slist_append( rec->listFName, val );
}
- else if( g_utf8_collate( nm, LDIF_TAG_LASTNAME ) == 0 ) {
+ else if( g_utf8_collate( nm, g_utf8_strdown( LDIF_TAG_LASTNAME, -1 ) ) == 0 ) {
rec->listLName = g_slist_append( rec->listLName, val );
}
- else if( g_utf8_collate( nm, LDIF_TAG_NICKNAME ) == 0 ) {
+ else if( g_utf8_collate( nm, g_utf8_strdown( LDIF_TAG_NICKNAME, -1 ) ) == 0 ) {
rec->listNName = g_slist_append( rec->listNName, val );
}
- else if( g_utf8_collate( nm, LDIF_TAG_EMAIL ) == 0 ) {
+ else if( g_utf8_collate( nm, g_utf8_strdown( LDIF_TAG_EMAIL, -1 ) ) == 0 ) {
rec->listAddress = g_slist_append( rec->listAddress, val );
}
else {
long posEnd = 0L;
long posCur = 0L;
GHashTable *hashField;
+ gsize len;
hashField = ldifFile->hashFields;
rec = g_new0( Ldif_ParsedRec, 1 );
/* Save record */
fullValue = mgu_list_coalesce( listValue );
if (fullValue && last64) {
- gchar *out = g_malloc(strlen(fullValue));
- int len = 0;
- if ((len = base64_decode(out, fullValue,
- strlen(fullValue))) >= 0) {
- g_free(fullValue);
- fullValue = out;
- fullValue[len] = '\0';
- } else
- g_free(out);
- }
- /* Base-64 encoded data */
- /*
- if( last64 ) {
- ldif_dump_b64( fullValue );
+ gchar *tmp = g_base64_decode_zero(fullValue, &len);
+ g_free(fullValue);
+ fullValue = tmp;
}
- */
ldif_add_value( rec, lastTag, fullValue, hashField );
/* ldif_print_record( rec, stdout ); */
ldif_clear_rec( rec );
g_free( lastTag );
mgu_free_list( listValue );
+ g_free(fullValue);
lastTag = NULL;
listValue = NULL;
last64 = FALSE;
fullValue =
mgu_list_coalesce( listValue );
if (fullValue && last64) {
- gchar *out = g_malloc(strlen(fullValue));
- int len = 0;
- if ((len = base64_decode(out, fullValue,
- strlen(fullValue))) >= 0) {
- g_free(fullValue);
- fullValue = out;
- fullValue[len] = '\0';
- } else
- g_free(out);
+ gchar *tmp = g_base64_decode_zero(fullValue, &len);
+ g_free(fullValue);
+ fullValue = tmp;
}
/* Base-64 encoded data */
/*
mgu_free_list( listValue );
lastTag = NULL;
listValue = NULL;
- last64 = FALSE;
}
lastTag = g_strdup( tagName );
gchar *tag = node->data;
if( ! g_hash_table_lookup( table, tag ) ) {
Ldif_FieldRec *rec = NULL;
- gchar *key = g_strdup( tag );
+ gchar *key = g_utf8_strdown( tag, -1 );
rec = ldif_create_fieldrec( tag );
- if( g_utf8_collate( tag, LDIF_TAG_DN ) == 0 ) {
+ if( g_utf8_collate( key, LDIF_TAG_DN ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( "dn" );
}
- else if( g_utf8_collate( tag, LDIF_TAG_COMMONNAME ) == 0 ) {
+ else if( g_utf8_collate( key, g_utf8_strdown( LDIF_TAG_COMMONNAME, -1 ) ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( _( "Display Name" ) );
}
- else if( g_utf8_collate( tag, LDIF_TAG_FIRSTNAME ) == 0 ) {
+ else if( g_utf8_collate( key, g_utf8_strdown( LDIF_TAG_FIRSTNAME, -1 ) ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( _( "First Name" ) );
}
- else if( g_utf8_collate( tag, LDIF_TAG_LASTNAME ) == 0 ) {
+ else if( g_utf8_collate( key, g_utf8_strdown( LDIF_TAG_LASTNAME, -1 ) ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( _( "Last Name" ) );
}
- else if( g_utf8_collate( tag, LDIF_TAG_NICKNAME ) == 0 ) {
+ else if( g_utf8_collate( key, g_utf8_strdown( LDIF_TAG_NICKNAME, -1 ) ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( _( "Nick Name" ) );
}
- else if( g_utf8_collate( tag, LDIF_TAG_EMAIL ) == 0 ) {
+ else if( g_utf8_collate( key, g_utf8_strdown( LDIF_TAG_EMAIL, -1 ) ) == 0 ) {
rec->reserved = rec->selected = TRUE;
rec->userName = g_strdup( _( "Email Address" ) );
}