/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2015 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
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
*/
/*
* Functions necessary to access vCard files. vCard files are used
* by GnomeCard for addressbook, and Netscape for sending business
- * card information. Refer to RFC2426 for more information.
+ * card information. Refer to http://www.imc.org/pdi/vcard-21.txt and
+ * RFC2426 for more information.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#include "claws-features.h"
+#endif
+
#include <glib.h>
#include <sys/stat.h>
#include <string.h>
#include "utils.h"
#include "codeconv.h"
#include "quoted-printable.h"
+#include "file-utils.h"
#define GNOMECARD_DIR ".gnome"
#define GNOMECARD_FILE "GnomeCard"
cm_return_if_fail( cardFile != NULL );
/* Close file */
- if( cardFile->file ) fclose( cardFile->file );
+ if( cardFile->file ) claws_fclose( cardFile->file );
/* Clear cache */
addrcache_clear( cardFile->addressCache );
/* g_print( "Opening file\n" ); */
cardFile->addressCache->dataRead = FALSE;
if( cardFile->path ) {
- cardFile->file = g_fopen( cardFile->path, "rb" );
+ cardFile->file = claws_fopen( cardFile->path, "rb" );
if( ! cardFile->file ) {
/* g_printerr( "can't open %s\n", cardFile->path ); */
cardFile->retVal = MGU_OPEN_FILE;
*/
static void vcard_close_file( VCardFile *cardFile ) {
cm_return_if_fail( cardFile != NULL );
- if( cardFile->file ) fclose( cardFile->file );
+ if( cardFile->file ) claws_fclose( cardFile->file );
cardFile->file = NULL;
}
*/
static gchar *vcard_read_line( VCardFile *cardFile ) {
while( *cardFile->bufptr == '\n' || *cardFile->bufptr == '\0' ) {
- if( fgets( cardFile->buffer, VCARDBUFSIZE, cardFile->file ) == NULL )
+ if( claws_fgets( cardFile->buffer, VCARDBUFSIZE, cardFile->file ) == NULL )
return NULL;
g_strstrip( cardFile->buffer );
cardFile->bufptr = cardFile->buffer;
start = cardFile->bufptr;
len = strlen( start );
end = start + len;
- strncpy( buf, start, len );
+ memcpy( buf, start, len );
buf[ len ] = '\0';
g_strstrip(buf);
cardFile->bufptr = end + 1;
* Free linked lists of character strings.
*/
static void vcard_free_lists( GSList *listName, GSList *listAddr, GSList *listRem, GSList* listID ) {
- mgu_free_list( listName );
- mgu_free_list( listAddr );
- mgu_free_list( listRem );
- mgu_free_list( listID );
+ g_slist_free_full( listName, g_free );
+ g_slist_free_full( listAddr, g_free );
+ g_slist_free_full( listRem, g_free );
+ g_slist_free_full( listID, g_free );
}
/*
line = mgu_list_coalesce( listQP );
/* Clean up */
- mgu_free_list( listQP );
+ g_slist_free_full( listQP, g_free );
listQP = NULL;
return line;
}
/* g_print( "\ttype: %s\n", tagtype ); */
/* g_print( "\tvalue: %s\n", tagvalue ); */
- if( g_utf8_collate( tagtype, VCARD_TYPE_QP ) == 0 ) {
+ if( g_utf8_collate( tagtype, VCARD_TYPE_QP ) == 0
+ || g_utf8_collate( tagtype, VCARD_TYPE_E_QP ) == 0
+ || g_utf8_collate( tagtype, VCARD_TYPE_CS_UTF8_E_QP ) == 0) {
gchar *tmp;
/* Quoted-Printable: could span multiple lines */
tagvalue = vcard_read_qp( cardFile, tagvalue );
strncat( str, GNOMECARD_FILE, WORK_BUFLEN - strlen(str) );
fileSpec = NULL;
- if( ( fp = g_fopen( str, "rb" ) ) != NULL ) {
+ if( ( fp = claws_fopen( str, "rb" ) ) != NULL ) {
/* Read configuration file */
lenlbl = strlen( GNOMECARD_SECTION );
- while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
+ while( claws_fgets( buf, sizeof( buf ), fp ) != NULL ) {
if( 0 == g_ascii_strncasecmp( buf, GNOMECARD_SECTION, lenlbl ) ) {
break;
}
}
- while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
+ while( claws_fgets( buf, sizeof( buf ), fp ) != NULL ) {
g_strchomp( buf );
if( buf[0] == '[' ) break;
for( i = 0; i < lenlbl; i++ ) {
}
}
}
- fclose( fp );
+ claws_fclose( fp );
}
if( fileSpec == NULL ) {