*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
#include "addrcache.h"
#include "base64.h"
+#include "utils.h"
#define LDIF_SEP_TAG ':'
#define LDIF_LANG_TAG ';'
static gint ldif_open_file( LdifFile* ldifFile ) {
/* printf( "Opening file\n" ); */
if( ldifFile->path ) {
- ldifFile->file = fopen( ldifFile->path, "rb" );
+ ldifFile->file = g_fopen( ldifFile->path, "rb" );
if( ! ldifFile->file ) {
/* printf( "can't open %s\n", ldifFile->path ); */
ldifFile->retVal = MGU_OPEN_FILE;
static gchar *ldif_get_line( LdifFile *ldifFile ) {
gchar buf[ LDIFBUFSIZE ];
gint ch;
- gchar *ptr;
+ int i = 0;
- if( feof( ldifFile->file ) ) return NULL;
+ if( feof( ldifFile->file ) )
+ return NULL;
- ptr = buf;
- while( TRUE ) {
- *ptr = '\0';
+ while( i < LDIFBUFSIZE-1 ) {
ch = fgetc( ldifFile->file );
if( ch == '\0' || ch == EOF ) {
- if( *buf == '\0' ) return NULL;
+ if( i == 0 ) return NULL;
break;
}
#if HAVE_DOSISH_SYSTEM
#else
- if( ch == '\r' ) continue;
+ if( ch == '\r' )
+ continue;
#endif
- if( ch == '\n' ) break;
- *ptr = ch;
- ptr++;
+ if( ch == '\n' )
+ break;
+ buf[i] = ch;
+ i++;
}
+ buf[i] = '\0';
/* Return a copy of buffer */
return g_strdup( buf );
fullName = g_strdup_printf( "%s", lastName );
}
}
+
+ if (!fullName || strlen(fullName) == 0) {
+ g_free(fullName);
+ fullName = NULL;
+ if (rec->listCName)
+ fullName = g_strdup(rec->listCName->data);
+ }
+
if( fullName ) {
g_strchug( fullName ); g_strchomp( fullName );
}
if( lastTag ) {
/* 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 ) {
/* Save data */
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 ) {
/* Process file */
while( ! flagEOF ) {
gchar *line = ldif_get_line( ldifFile );
-
posCur = ftell( ldifFile->file );
if( ldifFile->cbProgress ) {
/* Call progress indicator */
if( tagName ) {
/* Add tag to list */
listTags = g_slist_append( listTags, tagName );
+
if( g_utf8_collate(
tagName, LDIF_TAG_EMAIL ) == 0 )
{