commit c78b4c3c2c462e2d276c23d0a141ddd2dd39ed60
parent 26c4fd851b0c0f0021ede063a901ebede7ee4bdf
Author: Oliver Lowe <o@olowe.co>
Date: Wed, 13 Aug 2025 11:04:09 +1000
Dump stio file wrappers
File locking for performance, apparently. But I'm a one man band so
rather slow and simple than all these wrappers.
Diffstat:
50 files changed, 857 insertions(+), 948 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -341,7 +341,7 @@ AC_CHECK_SIZEOF(unsigned long, 4)
dnl Checks for library functions.
AC_FUNC_ALLOCA
-AC_CHECK_FUNCS(fchmod fgets_unlocked flock lockf strcasestr)
+AC_CHECK_FUNCS(fchmod flock lockf strcasestr)
dnl *****************
dnl ** common code **
diff --git a/src/account.c b/src/account.c
@@ -197,14 +197,14 @@ void account_read_config_all(void)
debug_print("Reading all config for each account...\n");
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
return;
}
g_free(rcpath);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "[Account: ", 10)) {
strretchomp(buf);
memmove(buf, buf + 1, sizeof(buf) - 1);
@@ -214,7 +214,7 @@ void account_read_config_all(void)
g_strdup(buf));
}
}
- claws_fclose(fp);
+ fclose(fp);
/* read config data from file */
cur_account = NULL;
diff --git a/src/addrbook.c b/src/addrbook.c
@@ -965,11 +965,11 @@ static int addrbook_write_elem_s(FILE *fp, gint lvl, gchar *name)
{
gint i;
for (i = 0; i < lvl; i++)
- if (claws_fputs(" ", fp) == EOF)
+ if (fputs(" ", fp) == EOF)
return -1;
- if (claws_fputs("<", fp) == EOF)
+ if (fputs("<", fp) == EOF)
return -1;
- if (claws_fputs(name, fp) == EOF)
+ if (fputs(name, fp) == EOF)
return -1;
return 0;
@@ -985,13 +985,13 @@ static int addrbook_write_elem_e(FILE *fp, gint lvl, gchar *name)
{
gint i;
for(i = 0; i < lvl; i++)
- if (claws_fputs(" ", fp) == EOF)
+ if (fputs(" ", fp) == EOF)
return -1;
- if (claws_fputs("</", fp) == EOF)
+ if (fputs("</", fp) == EOF)
return -1;
- if (claws_fputs(name, fp) == EOF)
+ if (fputs(name, fp) == EOF)
return -1;
- if (claws_fputs(">\n", fp) == EOF)
+ if (fputs(">\n", fp) == EOF)
return -1;
return 0;
@@ -1005,15 +1005,15 @@ static int addrbook_write_elem_e(FILE *fp, gint lvl, gchar *name)
*/
static int addrbook_write_attr(FILE *fp, gchar *name, gchar *value)
{
- if (claws_fputs(" ", fp) == EOF)
+ if (fputs(" ", fp) == EOF)
return -1;
- if (claws_fputs(name, fp) == EOF)
+ if (fputs(name, fp) == EOF)
return -1;
- if (claws_fputs("=\"", fp) == EOF)
+ if (fputs("=\"", fp) == EOF)
return -1;
if (xml_file_put_escape_str(fp, value) < 0)
return -1;
- if (claws_fputs("\"", fp) == EOF)
+ if (fputs("\"", fp) == EOF)
return -1;
return 0;
@@ -1056,13 +1056,13 @@ static void addrbook_write_item_person_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_COMMON_NAME, ADDRITEM_NAME(person)) < 0)
data->error = TRUE;
- if (claws_fputs(" >\n", fp) == EOF)
+ if (fputs(" >\n", fp) == EOF)
data->error = TRUE;
/* Output email addresses */
if (addrbook_write_elem_s(fp, 2, AB_ELTAG_ADDRESS_LIST) < 0)
data->error = TRUE;
- if (claws_fputs(">\n", fp) == EOF)
+ if (fputs(">\n", fp) == EOF)
data->error = TRUE;
node = person->listEMail;
while (node) {
@@ -1077,7 +1077,7 @@ static void addrbook_write_item_person_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_REMARKS, email->remarks) < 0)
data->error = TRUE;
- if (claws_fputs(" />\n", fp) == EOF)
+ if (fputs(" />\n", fp) == EOF)
data->error = TRUE;
node = g_list_next(node);
}
@@ -1087,7 +1087,7 @@ static void addrbook_write_item_person_vis(gpointer key, gpointer value,
/* Output user attributes */
if (addrbook_write_elem_s(fp, 2, AB_ELTAG_ATTRIBUTE_LIST) < 0)
data->error = TRUE;
- if (claws_fputs(">\n", fp) == EOF)
+ if (fputs(">\n", fp) == EOF)
data->error = TRUE;
node = person->listAttrib;
while (node) {
@@ -1098,7 +1098,7 @@ static void addrbook_write_item_person_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_NAME, attrib->name) < 0)
data->error = TRUE;
- if (claws_fputs(" >", fp) == EOF)
+ if (fputs(" >", fp) == EOF)
data->error = TRUE;
if (xml_file_put_escape_str(fp, attrib->value) < 0)
data->error = TRUE;
@@ -1143,13 +1143,13 @@ static void addrbook_write_item_group_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_REMARKS, group->remarks) < 0)
data->error = TRUE;
- if (claws_fputs(" >\n", fp) == EOF)
+ if (fputs(" >\n", fp) == EOF)
data->error = TRUE;
/* Output email address links */
if (addrbook_write_elem_s(fp, 2, AB_ELTAG_MEMBER_LIST) < 0)
data->error = TRUE;
- if (claws_fputs(">\n", fp) == EOF)
+ if (fputs(">\n", fp) == EOF)
data->error = TRUE;
node = group->listEMail;
while (node) {
@@ -1161,7 +1161,7 @@ static void addrbook_write_item_group_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_EID, ADDRITEM_ID(email)) < 0)
data->error = TRUE;
- if (claws_fputs(" />\n", fp) == EOF)
+ if (fputs(" />\n", fp) == EOF)
data->error = TRUE;
node = g_list_next(node);
}
@@ -1201,11 +1201,11 @@ static void addrbook_write_item_folder_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_REMARKS, folder->remarks) < 0)
data->error = TRUE;
- if (claws_fputs(" >\n", fp) == EOF)
+ if (fputs(" >\n", fp) == EOF)
data->error = TRUE;
if (addrbook_write_elem_s(fp, 2, AB_ELTAG_ITEM_LIST) < 0)
data->error = TRUE;
- if (claws_fputs(">\n", fp) == EOF)
+ if (fputs(">\n", fp) == EOF)
data->error = TRUE;
/* Output persons */
@@ -1218,7 +1218,7 @@ static void addrbook_write_item_folder_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_UID, ADDRITEM_ID(item)) < 0)
data->error = TRUE;
- if (claws_fputs(" />\n", fp) == EOF)
+ if (fputs(" />\n", fp) == EOF)
data->error = TRUE;
node = g_list_next(node);
}
@@ -1233,7 +1233,7 @@ static void addrbook_write_item_folder_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_UID, ADDRITEM_ID(item)) < 0)
data->error = TRUE;
- if (claws_fputs(" />\n", fp) == EOF)
+ if (fputs(" />\n", fp) == EOF)
data->error = TRUE;
node = g_list_next(node);
}
@@ -1248,7 +1248,7 @@ static void addrbook_write_item_folder_vis(gpointer key, gpointer value,
data->error = TRUE;
if (addrbook_write_attr(fp, AB_ATTAG_UID, ADDRITEM_ID(item)) < 0)
data->error = TRUE;
- if (claws_fputs(" />\n", fp) == EOF)
+ if (fputs(" />\n", fp) == EOF)
data->error = TRUE;
node = g_list_next(node);
}
@@ -1282,10 +1282,10 @@ static gint addrbook_write_to(AddressBookFile *book, gchar *newFile)
book->retVal = MGU_OPEN_FILE;
#ifdef DEV_STANDALONE
- fp = claws_fopen(fileSpec, "wb");
+ fp = g_fopen(fileSpec, "wb");
g_free(fileSpec);
if (fp) {
- if (claws_fputs("<?xml version=\"1.0\" ?>\n", fp) == EOF) {
+ if (fputs("<?xml version=\"1.0\" ?>\n", fp) == EOF) {
book->retVal = MGU_ERROR_WRITE;
return book->retVal;
}
@@ -1302,7 +1302,7 @@ static gint addrbook_write_to(AddressBookFile *book, gchar *newFile)
if (addrbook_write_attr(fp, AB_ATTAG_NAME,
addrcache_get_name(book->addressCache)) < 0)
goto fail;
- if (claws_fputs(" >\n", fp) == EOF)
+ if (fputs(" >\n", fp) == EOF)
goto fail;
/* Output all persons */
@@ -1333,7 +1333,7 @@ static gint addrbook_write_to(AddressBookFile *book, gchar *newFile)
book->retVal = MGU_SUCCESS;
#ifdef DEV_STANDALONE
- claws_safe_fclose(fp);
+ safe_fclose(fp);
#else
if (prefs_file_close( pfile ) < 0)
book->retVal = MGU_ERROR_WRITE;
diff --git a/src/addressbook.c b/src/addressbook.c
@@ -1875,7 +1875,6 @@ static void addressbook_list_menu_setup( void ) {
gboolean canCut = FALSE;
gboolean canCopy = FALSE;
gboolean canPaste = FALSE;
- gboolean canBrowse = FALSE;
gboolean canMerge = FALSE;
pobj = gtk_cmctree_node_get_row_data( GTK_CMCTREE(addrbook.ctree), addrbook.treeSelected );
@@ -1944,7 +1943,6 @@ static void addressbook_list_menu_setup( void ) {
/* Disable edit or browse if more than one row selected */
if( GTK_CMCLIST(clist)->selection && GTK_CMCLIST(clist)->selection->next ) {
canEdit = FALSE;
- canBrowse = FALSE;
}
/* Allow merging persons or emails are selected */
diff --git a/src/addrharvest.c b/src/addrharvest.c
@@ -590,7 +590,7 @@ static GSList *addrharvest_get_header( FILE *fp, GList *listHdr, gboolean *done
list = NULL;
/* Read line */
- if( claws_fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
+ if( fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
*done = TRUE;
return list;
}
@@ -617,7 +617,7 @@ static GSList *addrharvest_get_header( FILE *fp, GList *listHdr, gboolean *done
ch = fgetc( fp );
if( ch == ' ' || ch == '\t' ) {
/* Continuation character - read into buffer */
- if( claws_fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
+ if( fgets( buf, MSG_BUFFSIZE, fp ) == NULL ) {
break;
}
}
@@ -654,7 +654,7 @@ static gint addrharvest_readfile(
GSList *list;
gboolean done;
- msgFile = claws_fopen( fileName, "rb" );
+ msgFile = g_fopen( fileName, "rb" );
if( ! msgFile ) {
/* Cannot open file */
retVal = MGU_OPEN_FILE;
@@ -693,7 +693,7 @@ static gint addrharvest_readfile(
g_free( buf );
}
- claws_fclose( msgFile );
+ fclose( msgFile );
return MGU_SUCCESS;
}
diff --git a/src/addrindex.c b/src/addrindex.c
@@ -822,11 +822,11 @@ static AddressInterface *addrindex_tag_get_datasource(
static int addrindex_write_elem_s( FILE *fp, const gint lvl, const gchar *name ) {
gint i;
for( i = 0; i < lvl; i++ )
- if (claws_fputs( " ", fp ) == EOF)
+ if (fputs( " ", fp ) == EOF)
return -1;
- if (claws_fputs( "<", fp ) == EOF)
+ if (fputs( "<", fp ) == EOF)
return -1;
- if (claws_fputs( name, fp ) == EOF)
+ if (fputs( name, fp ) == EOF)
return -1;
return 0;
}
@@ -840,13 +840,13 @@ static int addrindex_write_elem_s( FILE *fp, const gint lvl, const gchar *name )
static int addrindex_write_elem_e( FILE *fp, const gint lvl, const gchar *name ) {
gint i;
for( i = 0; i < lvl; i++ )
- if (claws_fputs( " ", fp ) == EOF)
+ if (fputs( " ", fp ) == EOF)
return -1;
- if (claws_fputs( "</", fp ) == EOF)
+ if (fputs( "</", fp ) == EOF)
return -1;
- if (claws_fputs( name, fp ) == EOF)
+ if (fputs( name, fp ) == EOF)
return -1;
- if (claws_fputs( ">\n", fp ) == EOF)
+ if (fputs( ">\n", fp ) == EOF)
return -1;
return 0;
}
@@ -858,15 +858,15 @@ static int addrindex_write_elem_e( FILE *fp, const gint lvl, const gchar *name )
* \param value Attribute value.
*/
static int addrindex_write_attr( FILE *fp, const gchar *name, const gchar *value ) {
- if (claws_fputs( " ", fp ) == EOF)
+ if (fputs( " ", fp ) == EOF)
return -1;
- if (claws_fputs( name, fp ) == EOF)
+ if (fputs( name, fp ) == EOF)
return -1;
- if (claws_fputs( "=\"", fp ) == EOF)
+ if (fputs( "=\"", fp ) == EOF)
return -1;
if (xml_file_put_escape_str( fp, value ) < 0)
return -1;
- if (claws_fputs( "\"", fp ) == EOF)
+ if (fputs( "\"", fp ) == EOF)
return -1;
return 0;
}
@@ -909,7 +909,7 @@ static int addrindex_write_book( FILE *fp, AddressDataSource *ds, gint lvl ) {
return -1;
if (addrindex_write_attr( fp, ATTAG_BOOK_FILE, abf->fileName ) < 0)
return -1;
- if (claws_fputs( " />\n", fp ) == EOF)
+ if (fputs( " />\n", fp ) == EOF)
return -1;
}
return 0;
@@ -947,7 +947,7 @@ static int addrindex_write_vcard( FILE *fp, AddressDataSource *ds, gint lvl ) {
return -1;
if (addrindex_write_attr( fp, ATTAG_VCARD_FILE, vcf->path ) < 0)
return -1;
- if (claws_fputs( " />\n", fp ) == EOF)
+ if (fputs( " />\n", fp ) == EOF)
return -1;
}
return 0;
@@ -1092,7 +1092,7 @@ static int addrindex_write_index( AddressIndex *addrIndex, FILE *fp ) {
nodeDS = iface->listSource;
if (addrindex_write_elem_s( fp, lvlList, iface->listTag ) < 0)
return -1;
- if (claws_fputs( ">\n", fp ) == EOF)
+ if (fputs( ">\n", fp ) == EOF)
return -1;
while( nodeDS ) {
AddressDataSource *ds = nodeDS->data;
@@ -1135,10 +1135,10 @@ static gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile )
fileSpec = g_strconcat( addrIndex->filePath, G_DIR_SEPARATOR_S, newFile, NULL );
addrIndex->retVal = MGU_OPEN_FILE;
#ifdef DEV_STANDALONE
- fp = claws_fopen( fileSpec, "wb" );
+ fp = g_fopen( fileSpec, "wb" );
g_free( fileSpec );
if( fp ) {
- claws_fputs( "<?xml version=\"1.0\" ?>\n", fp );
+ fputs( "<?xml version=\"1.0\" ?>\n", fp );
#else
pfile = prefs_write_open( fileSpec );
g_free( fileSpec );
@@ -1149,7 +1149,7 @@ static gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile )
#endif
if (addrindex_write_elem_s( fp, 0, TAG_ADDRESS_INDEX ) < 0)
goto fail;
- if (claws_fputs( ">\n", fp ) == EOF)
+ if (fputs( ">\n", fp ) == EOF)
goto fail;
if (addrindex_write_index( addrIndex, fp ) < 0)
@@ -1159,7 +1159,7 @@ static gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile )
addrIndex->retVal = MGU_SUCCESS;
#ifdef DEV_STANDALONE
- claws_safe_fclose( fp );
+ safe_fclose( fp );
#else
if( prefs_file_close( pfile ) < 0 ) {
addrIndex->retVal = MGU_ERROR_WRITE;
@@ -1903,12 +1903,9 @@ gint addrindex_setup_search(
*/
static gboolean addrindex_start_dynamic( QueryRequest *req ) {
AddressInterface *iface;
- AddressDataSource *ds;
GList *nodeIf;
GList *nodeDS;
- gint type;
- /* g_print( "addrindex_start_dynamic::%d::\n", req->queryID ); */
nodeIf = _addressIndex_->searchOrder;
while( nodeIf ) {
iface = nodeIf->data;
@@ -1921,10 +1918,8 @@ static gboolean addrindex_start_dynamic( QueryRequest *req ) {
continue;
}
- type = iface->type;
nodeDS = iface->listSource;
while( nodeDS ) {
- ds = nodeDS->data;
nodeDS = g_list_next( nodeDS );
}
}
diff --git a/src/autofaces.c b/src/autofaces.c
@@ -38,20 +38,20 @@ static gint get_content_for_any_face(gchar *buf, gint len, gchar *anyname, gint
xfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, AUTOFACES_DIR,
G_DIR_SEPARATOR_S, anyname, NULL);
buf[0] = '\0';
- if ((xfp = claws_fopen(xfile, "rb")) == NULL) {
+ if ((xfp = g_fopen(xfile, "rb")) == NULL) {
g_free(xfile);
debug_print("header content file '%s' not found\n", anyname);
return -1;
}
- if (claws_fgets(buf, (len < maxlen)? len: maxlen, xfp) == NULL) {
- claws_fclose(xfp);
+ if (fgets(buf, (len < maxlen)? len: maxlen, xfp) == NULL) {
+ fclose(xfp);
g_free(xfile);
g_warning("header content file '%s' read failure", anyname);
return -2;
}
lastc = strlen(buf) - 1; /* remove trailing \n */
buf[lastc] = (buf[lastc] == '\n')? '\0': buf[lastc];
- claws_fclose(xfp);
+ fclose(xfp);
g_free(xfile);
return 0;
diff --git a/src/common/file-utils.c b/src/common/file-utils.c
@@ -42,68 +42,16 @@
gboolean prefs_common_get_flush_metadata(void);
gboolean prefs_common_get_use_shred(void);
-static int safe_fclose(FILE *fp)
+int safe_fclose(FILE *fp)
{
- int r;
- START_TIMING("");
-
if (fflush(fp) != 0) {
return EOF;
}
if (prefs_common_get_flush_metadata() && fsync(fileno(fp)) != 0) {
return EOF;
}
-
- r = fclose(fp);
- END_TIMING();
-
- return r;
-}
-
-/* Unlock, then safe-close a file pointer
- * Safe close is done using fflush + fsync
- * if the according preference says so.
- */
-int claws_safe_fclose(FILE *fp)
-{
-#if HAVE_FGETS_UNLOCKED
- funlockfile(fp);
-#endif
- return safe_fclose(fp);
-}
-
-#if HAVE_FGETS_UNLOCKED
-
-/* Open a file and locks it once
- * so subsequent I/O is faster
- */
-FILE *claws_fopen(const char *file, const char *mode)
-{
- FILE *fp = fopen(file, mode);
- if (!fp)
- return NULL;
- flockfile(fp);
- return fp;
-}
-
-FILE *claws_fdopen(int fd, const char *mode)
-{
- FILE *fp = fdopen(fd, mode);
- if (!fp)
- return NULL;
- flockfile(fp);
- return fp;
-}
-
-/* Unlocks and close a file pointer
- */
-
-int claws_fclose(FILE *fp)
-{
- funlockfile(fp);
return fclose(fp);
}
-#endif
int claws_unlink(const char *filename)
{
@@ -149,27 +97,27 @@ gint file_strip_crs(const gchar *file)
if (file == NULL)
goto freeout;
- fp = claws_fopen(file, "rb");
+ fp = g_fopen(file, "rb");
if (!fp)
goto freeout;
- outfp = claws_fopen(out, "wb");
+ outfp = g_fopen(out, "wb");
if (!outfp) {
- claws_fclose(fp);
+ fclose(fp);
goto freeout;
}
- while (claws_fgets(buf, sizeof (buf), fp) != NULL) {
+ while (fgets(buf, sizeof (buf), fp) != NULL) {
strcrchomp(buf);
- if (claws_fputs(buf, outfp) == EOF) {
- claws_fclose(fp);
- claws_fclose(outfp);
+ if (fputs(buf, outfp) == EOF) {
+ fclose(fp);
+ fclose(outfp);
goto unlinkout;
}
}
- claws_fclose(fp);
- if (claws_safe_fclose(outfp) == EOF) {
+ fclose(fp);
+ if (safe_fclose(outfp) == EOF) {
goto unlinkout;
}
@@ -197,14 +145,14 @@ gint append_file(const gchar *src, const gchar *dest, gboolean keep_backup)
gboolean err = FALSE;
- if ((src_fp = claws_fopen(src, "rb")) == NULL) {
- FILE_OP_ERROR(src, "claws_fopen");
+ if ((src_fp = g_fopen(src, "rb")) == NULL) {
+ FILE_OP_ERROR(src, "g_fopen");
return -1;
}
- if ((dest_fp = claws_fopen(dest, "ab")) == NULL) {
- FILE_OP_ERROR(dest, "claws_fopen");
- claws_fclose(src_fp);
+ if ((dest_fp = g_fopen(dest, "ab")) == NULL) {
+ FILE_OP_ERROR(dest, "g_fopen");
+ fclose(src_fp);
return -1;
}
@@ -213,25 +161,25 @@ gint append_file(const gchar *src, const gchar *dest, gboolean keep_backup)
g_warning("can't change file mode: %s", dest);
}
- while ((n_read = claws_fread(buf, sizeof(gchar), sizeof(buf), src_fp)) > 0) {
- if (n_read < sizeof(buf) && claws_ferror(src_fp))
+ while ((n_read = fread(buf, sizeof(gchar), sizeof(buf), src_fp)) > 0) {
+ if (n_read < sizeof(buf) && ferror(src_fp))
break;
- if (claws_fwrite(buf, 1, n_read, dest_fp) < n_read) {
+ if (fwrite(buf, 1, n_read, dest_fp) < n_read) {
g_warning("writing to %s failed", dest);
- claws_fclose(dest_fp);
- claws_fclose(src_fp);
+ fclose(dest_fp);
+ fclose(src_fp);
claws_unlink(dest);
return -1;
}
}
- if (claws_ferror(src_fp)) {
- FILE_OP_ERROR(src, "claws_fread");
+ if (ferror(src_fp)) {
+ FILE_OP_ERROR(src, "fread");
err = TRUE;
}
- claws_fclose(src_fp);
- if (claws_fclose(dest_fp) == EOF) {
- FILE_OP_ERROR(dest, "claws_fclose");
+ fclose(src_fp);
+ if (fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
@@ -251,23 +199,23 @@ gint copy_file(const gchar *src, const gchar *dest, gboolean keep_backup)
gchar *dest_bak = NULL;
gboolean err = FALSE;
- if ((src_fp = claws_fopen(src, "rb")) == NULL) {
- FILE_OP_ERROR(src, "claws_fopen");
+ if ((src_fp = g_fopen(src, "rb")) == NULL) {
+ FILE_OP_ERROR(src, "g_fopen");
return -1;
}
if (is_file_exist(dest)) {
dest_bak = g_strconcat(dest, ".bak", NULL);
if (rename_force(dest, dest_bak) < 0) {
FILE_OP_ERROR(dest, "rename");
- claws_fclose(src_fp);
+ fclose(src_fp);
g_free(dest_bak);
return -1;
}
}
- if ((dest_fp = claws_fopen(dest, "wb")) == NULL) {
- FILE_OP_ERROR(dest, "claws_fopen");
- claws_fclose(src_fp);
+ if ((dest_fp = g_fopen(dest, "wb")) == NULL) {
+ FILE_OP_ERROR(dest, "g_fopen");
+ fclose(src_fp);
if (dest_bak) {
if (rename_force(dest_bak, dest) < 0)
FILE_OP_ERROR(dest_bak, "rename");
@@ -281,13 +229,13 @@ gint copy_file(const gchar *src, const gchar *dest, gboolean keep_backup)
g_warning("can't change file mode: %s", dest);
}
- while ((n_read = claws_fread(buf, sizeof(gchar), sizeof(buf), src_fp)) > 0) {
- if (n_read < sizeof(buf) && claws_ferror(src_fp))
+ while ((n_read = fread(buf, sizeof(gchar), sizeof(buf), src_fp)) > 0) {
+ if (n_read < sizeof(buf) && ferror(src_fp))
break;
- if (claws_fwrite(buf, 1, n_read, dest_fp) < n_read) {
+ if (fwrite(buf, 1, n_read, dest_fp) < n_read) {
g_warning("writing to %s failed", dest);
- claws_fclose(dest_fp);
- claws_fclose(src_fp);
+ fclose(dest_fp);
+ fclose(src_fp);
if (claws_unlink(dest) < 0)
FILE_OP_ERROR(dest, "claws_unlink");
if (dest_bak) {
@@ -299,13 +247,13 @@ gint copy_file(const gchar *src, const gchar *dest, gboolean keep_backup)
}
}
- if (claws_ferror(src_fp)) {
- FILE_OP_ERROR(src, "claws_fread");
+ if (ferror(src_fp)) {
+ FILE_OP_ERROR(src, "fread");
err = TRUE;
}
- claws_fclose(src_fp);
- if (claws_safe_fclose(dest_fp) == EOF) {
- FILE_OP_ERROR(dest, "claws_fclose");
+ fclose(src_fp);
+ if (safe_fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
@@ -364,10 +312,10 @@ gint copy_file_part_to_fp(FILE *fp, off_t offset, size_t length, FILE *dest_fp)
bytes_left = length;
to_read = MIN(bytes_left, sizeof(buf));
- while ((n_read = claws_fread(buf, sizeof(gchar), to_read, fp)) > 0) {
- if (n_read < to_read && claws_ferror(fp))
+ while ((n_read = fread(buf, sizeof(gchar), to_read, fp)) > 0) {
+ if (n_read < to_read && ferror(fp))
break;
- if (claws_fwrite(buf, 1, n_read, dest_fp) < n_read) {
+ if (fwrite(buf, 1, n_read, dest_fp) < n_read) {
return -1;
}
bytes_left -= n_read;
@@ -376,8 +324,8 @@ gint copy_file_part_to_fp(FILE *fp, off_t offset, size_t length, FILE *dest_fp)
to_read = MIN(bytes_left, sizeof(buf));
}
- if (claws_ferror(fp)) {
- perror("claws_fread");
+ if (ferror(fp)) {
+ perror("fread");
return -1;
}
@@ -389,8 +337,8 @@ gint copy_file_part(FILE *fp, off_t offset, size_t length, const gchar *dest)
FILE *dest_fp;
gboolean err = FALSE;
- if ((dest_fp = claws_fopen(dest, "wb")) == NULL) {
- FILE_OP_ERROR(dest, "claws_fopen");
+ if ((dest_fp = g_fopen(dest, "wb")) == NULL) {
+ FILE_OP_ERROR(dest, "g_fopen");
return -1;
}
@@ -402,8 +350,8 @@ gint copy_file_part(FILE *fp, off_t offset, size_t length, const gchar *dest)
if (copy_file_part_to_fp(fp, offset, length, dest_fp) < 0)
err = TRUE;
- if (claws_safe_fclose(dest_fp) == EOF) {
- FILE_OP_ERROR(dest, "claws_fclose");
+ if (safe_fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
@@ -427,14 +375,14 @@ gint canonicalize_file(const gchar *src, const gchar *dest)
if (src == NULL || dest == NULL)
return -1;
- if ((src_fp = claws_fopen(src, "rb")) == NULL) {
- FILE_OP_ERROR(src, "claws_fopen");
+ if ((src_fp = g_fopen(src, "rb")) == NULL) {
+ FILE_OP_ERROR(src, "g_fopen");
return -1;
}
- if ((dest_fp = claws_fopen(dest, "wb")) == NULL) {
- FILE_OP_ERROR(dest, "claws_fopen");
- claws_fclose(src_fp);
+ if ((dest_fp = g_fopen(dest, "wb")) == NULL) {
+ FILE_OP_ERROR(dest, "g_fopen");
+ fclose(src_fp);
return -1;
}
@@ -443,7 +391,7 @@ gint canonicalize_file(const gchar *src, const gchar *dest)
g_warning("can't change file mode: %s", dest);
}
- while (claws_fgets(buf, sizeof(buf), src_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), src_fp) != NULL) {
gint r = 0;
len = strlen(buf);
@@ -452,40 +400,40 @@ gint canonicalize_file(const gchar *src, const gchar *dest)
if (buf[len - 1] != '\n') {
last_linebreak = TRUE;
- r = claws_fputs(buf, dest_fp);
+ r = fputs(buf, dest_fp);
} else if (len > 1 && buf[len - 1] == '\n' && buf[len - 2] == '\r') {
- r = claws_fputs(buf, dest_fp);
+ r = fputs(buf, dest_fp);
} else {
if (len > 1) {
- r = claws_fwrite(buf, 1, len - 1, dest_fp);
+ r = fwrite(buf, 1, len - 1, dest_fp);
if (r != (len -1))
r = EOF;
}
if (r != EOF)
- r = claws_fputs("\r\n", dest_fp);
+ r = fputs("\r\n", dest_fp);
}
if (r == EOF) {
g_warning("writing to %s failed", dest);
- claws_fclose(dest_fp);
- claws_fclose(src_fp);
+ fclose(dest_fp);
+ fclose(src_fp);
claws_unlink(dest);
return -1;
}
}
if (last_linebreak == TRUE) {
- if (claws_fputs("\r\n", dest_fp) == EOF)
+ if (fputs("\r\n", dest_fp) == EOF)
err = TRUE;
}
- if (claws_ferror(src_fp)) {
- FILE_OP_ERROR(src, "claws_fgets");
+ if (ferror(src_fp)) {
+ FILE_OP_ERROR(src, "fgets");
err = TRUE;
}
- claws_fclose(src_fp);
- if (claws_safe_fclose(dest_fp) == EOF) {
- FILE_OP_ERROR(dest, "claws_fclose");
+ fclose(src_fp);
+ if (safe_fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
@@ -529,32 +477,32 @@ gint str_write_to_file(const gchar *str, const gchar *file, gboolean safe)
cm_return_val_if_fail(str != NULL, -1);
cm_return_val_if_fail(file != NULL, -1);
- if ((fp = claws_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "wb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return -1;
}
len = strlen(str);
if (len == 0) {
- claws_fclose(fp);
+ fclose(fp);
return 0;
}
- if (claws_fwrite(str, 1, len, fp) != len) {
- FILE_OP_ERROR(file, "claws_fwrite");
- claws_fclose(fp);
+ if (fwrite(str, 1, len, fp) != len) {
+ FILE_OP_ERROR(file, "fwrite");
+ fclose(fp);
claws_unlink(file);
return -1;
}
if (safe) {
- r = claws_safe_fclose(fp);
+ r = safe_fclose(fp);
} else {
- r = claws_fclose(fp);
+ r = fclose(fp);
}
if (r == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ FILE_OP_ERROR(file, "fclose");
claws_unlink(file);
return -1;
}
@@ -573,14 +521,14 @@ static gchar *file_read_stream_to_str_full(FILE *fp, gboolean recode)
array = g_byte_array_new();
- while ((n_read = claws_fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
- if (n_read < sizeof(buf) && claws_ferror(fp))
+ while ((n_read = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
+ if (n_read < sizeof(buf) && ferror(fp))
break;
g_byte_array_append(array, buf, n_read);
}
- if (claws_ferror(fp)) {
- FILE_OP_ERROR("file stream", "claws_fread");
+ if (ferror(fp)) {
+ FILE_OP_ERROR("file stream", "fread");
g_byte_array_free(array, TRUE);
return NULL;
}
@@ -627,7 +575,7 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode)
}
#ifdef G_OS_WIN32
- fp = claws_fopen (file, "rb");
+ fp = g_fopen (file, "rb");
if (fp == NULL) {
FILE_OP_ERROR(file, "open");
return NULL;
@@ -668,18 +616,18 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode)
}
/* get the FILE pointer */
- fp = claws_fdopen(fd, "rb");
+ fp = fdopen(fd, "rb");
if (fp == NULL) {
- FILE_OP_ERROR(file, "claws_fdopen");
- close(fd); /* if fp isn't NULL, we'll use claws_fclose instead! */
+ FILE_OP_ERROR(file, "fdopen");
+ close(fd); /* if fp isn't NULL, we'll use fclose instead! */
return NULL;
}
#endif
str = file_read_stream_to_str_full(fp, recode);
- claws_fclose(fp);
+ fclose(fp);
return str;
}
@@ -824,7 +772,7 @@ FILE *my_tmpfile(void)
#endif
- fp = claws_fdopen(fd, "w+b");
+ fp = fdopen(fd, "w+b");
if (!fp)
close(fd);
else {
@@ -842,7 +790,7 @@ FILE *get_tmpfile_in_dir(const gchar *dir, gchar **filename)
fd = g_mkstemp(*filename);
if (fd < 0)
return NULL;
- return claws_fdopen(fd, "w+");
+ return fdopen(fd, "w+");
}
FILE *str_open_as_stream(const gchar *str)
@@ -861,9 +809,9 @@ FILE *str_open_as_stream(const gchar *str)
len = strlen(str);
if (len == 0) return fp;
- if (claws_fwrite(str, 1, len, fp) != len) {
- FILE_OP_ERROR("str_open_as_stream", "claws_fwrite");
- claws_fclose(fp);
+ if (fwrite(str, 1, len, fp) != len) {
+ FILE_OP_ERROR("str_open_as_stream", "fwrite");
+ fclose(fp);
return NULL;
}
diff --git a/src/common/file-utils.h b/src/common/file-utils.h
@@ -26,38 +26,7 @@
#include <stdio.h>
#include <glib.h>
-#if HAVE_FGETS_UNLOCKED
-#define claws_fgets fgets_unlocked
-#define claws_fgetc fgetc_unlocked
-#define claws_fputs fputs_unlocked
-#define claws_fputc fputc_unlocked
-#define claws_fread fread_unlocked
-#define claws_fwrite fwrite_unlocked
-#define claws_feof feof_unlocked
-#define claws_ferror ferror_unlocked
-
-FILE *claws_fopen (const char *file,
- const char *mode);
-FILE *claws_fdopen (int fd,
- const char *mode);
-int claws_fclose (FILE *fp);
-
-#else
-
-#define claws_fgets fgets
-#define claws_fgetc fgetc
-#define claws_fputs fputs
-#define claws_fputc fputc
-#define claws_fread fread
-#define claws_fwrite fwrite
-#define claws_feof feof
-#define claws_ferror ferror
-#define claws_fopen g_fopen
-#define claws_fdopen fdopen
-#define claws_fclose fclose
-#endif
-
-int claws_safe_fclose (FILE *fp);
+int safe_fclose(FILE *fp);
int claws_unlink (const char *filename);
gint file_strip_crs (const gchar *file);
diff --git a/src/common/prefs.c b/src/common/prefs.c
@@ -48,8 +48,8 @@ PrefFile *prefs_read_open(const gchar *path)
cm_return_val_if_fail(path != NULL, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ FILE_OP_ERROR(path, "g_fopen");
return NULL;
}
@@ -85,8 +85,8 @@ PrefFile *prefs_write_open(const gchar *path)
}
tmppath = g_strconcat(path, ".tmp", NULL);
- if ((fp = claws_fopen(tmppath, "wb")) == NULL) {
- FILE_OP_ERROR(tmppath, "claws_fopen");
+ if ((fp = g_fopen(tmppath, "wb")) == NULL) {
+ FILE_OP_ERROR(tmppath, "g_fopen");
g_free(tmppath);
return NULL;
}
@@ -130,17 +130,17 @@ gint prefs_file_close(PrefFile *pfile)
path = pfile->path;
if (!pfile->writing) {
- claws_fclose(fp);
+ fclose(fp);
g_free(pfile);
g_free(path);
return 0;
}
if (orig_fp) {
- while (claws_fgets(buf, sizeof(buf), orig_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
/* next block */
if (buf[0] == '[') {
- if (claws_fputs(buf, fp) == EOF) {
+ if (fputs(buf, fp) == EOF) {
g_warning("failed to write configuration to file");
prefs_file_close_revert(pfile);
@@ -150,20 +150,20 @@ gint prefs_file_close(PrefFile *pfile)
}
}
- while (claws_fgets(buf, sizeof(buf), orig_fp) != NULL)
- if (claws_fputs(buf, fp) == EOF) {
+ while (fgets(buf, sizeof(buf), orig_fp) != NULL)
+ if (fputs(buf, fp) == EOF) {
g_warning("failed to write configuration to file");
prefs_file_close_revert(pfile);
return -1;
}
- claws_fclose(orig_fp);
+ fclose(orig_fp);
}
tmppath = g_strconcat(path, ".tmp", NULL);
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(tmppath, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmppath, "fclose");
claws_unlink(tmppath);
g_free(path);
g_free(tmppath);
@@ -216,10 +216,10 @@ gint prefs_file_close_revert(PrefFile *pfile)
cm_return_val_if_fail(pfile != NULL, -1);
if (pfile->orig_fp)
- claws_fclose(pfile->orig_fp);
+ fclose(pfile->orig_fp);
if (pfile->writing)
tmppath = g_strconcat(pfile->path, ".tmp", NULL);
- claws_fclose(pfile->fp);
+ fclose(pfile->fp);
if (pfile->writing) {
if (claws_unlink(tmppath) < 0) FILE_OP_ERROR(tmppath, "unlink");
g_free(tmppath);
@@ -274,7 +274,7 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
block_label = g_strdup_printf("[%s]", label);
if (!pfile->writing) {
- while (claws_fgets(buf, sizeof(buf), pfile->fp) != NULL) {
+ while (fgets(buf, sizeof(buf), pfile->fp) != NULL) {
gint val;
val = strncmp(buf, block_label, strlen(block_label));
@@ -284,10 +284,10 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
}
}
} else {
- if ((pfile->orig_fp = claws_fopen(pfile->path, "rb")) != NULL) {
+ if ((pfile->orig_fp = g_fopen(pfile->path, "rb")) != NULL) {
gboolean block_matched = FALSE;
- while (claws_fgets(buf, sizeof(buf), pfile->orig_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), pfile->orig_fp) != NULL) {
gint val;
val = strncmp(buf, block_label, strlen(block_label));
@@ -296,7 +296,7 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
block_matched = TRUE;
break;
} else {
- if (claws_fputs(buf, pfile->fp) == EOF) {
+ if (fputs(buf, pfile->fp) == EOF) {
g_warning("failed to write configuration to file");
prefs_file_close_revert(pfile);
g_free(block_label);
@@ -307,13 +307,13 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label)
}
if (!block_matched) {
- claws_fclose(pfile->orig_fp);
+ fclose(pfile->orig_fp);
pfile->orig_fp = NULL;
}
}
- if (claws_fputs(block_label, pfile->fp) == EOF ||
- claws_fputc('\n', pfile->fp) == EOF) {
+ if (fputs(block_label, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
g_warning("failed to write configuration to file");
prefs_file_close_revert(pfile);
g_free(block_label);
diff --git a/src/common/ssl_certificate.c b/src/common/ssl_certificate.c
@@ -180,7 +180,7 @@ static void gnutls_export_X509_fp(FILE *fp, gnutls_x509_crt_t x509_cert, gnutls_
return;
}
debug_print("writing %" G_GSIZE_FORMAT " bytes\n",cert_size);
- if (claws_fwrite(&output, 1, cert_size, fp) < cert_size) {
+ if (fwrite(&output, 1, cert_size, fp) < cert_size) {
g_warning("failed to write cert: %d %s", errno, g_strerror(errno));
}
}
@@ -248,8 +248,8 @@ static int gnutls_import_X509_list_fp(FILE *fp, gnutls_x509_crt_fmt_t format,
tmp.data = malloc(s.st_size);
memset(tmp.data, 0, s.st_size);
tmp.size = s.st_size;
- if (claws_fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
- perror("claws_fread");
+ if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
+ perror("fread");
free(tmp.data);
free(crt_list);
return -EIO;
@@ -307,8 +307,8 @@ static gnutls_x509_privkey_t gnutls_import_key_fp(FILE *fp, gnutls_x509_crt_fmt_
tmp.data = malloc(s.st_size);
memset(tmp.data, 0, s.st_size);
tmp.size = s.st_size;
- if (claws_fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
- perror("claws_fread");
+ if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
+ perror("fread");
free(tmp.data);
return NULL;
}
@@ -338,7 +338,7 @@ static gnutls_pkcs12_t gnutls_import_PKCS12_fp(FILE *fp, gnutls_x509_crt_fmt_t f
tmp.data = malloc(s.st_size);
memset(tmp.data, 0, s.st_size);
tmp.size = s.st_size;
- if (claws_fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
+ if (fread (tmp.data, 1, s.st_size, fp) < s.st_size) {
log_error(LOG_PROTOCOL, _("Cannot read P12 certificate file (%s)\n"),
g_strerror(errno));
free(tmp.data);
@@ -374,7 +374,7 @@ static void ssl_certificate_save (SSLCertificate *cert)
file = get_certificate_path(cert->host, port, cert->fingerprint);
g_free(port);
- fp = claws_fopen(file, "wb");
+ fp = g_fopen(file, "wb");
if (fp == NULL) {
g_free(file);
debug_print("Can't save certificate !\n");
@@ -384,7 +384,7 @@ static void ssl_certificate_save (SSLCertificate *cert)
gnutls_export_X509_fp(fp, cert->x509_cert, GNUTLS_X509_FMT_DER);
g_free(file);
- claws_safe_fclose(fp);
+ safe_fclose(fp);
}
@@ -428,14 +428,14 @@ SSLCertificate *ssl_certificate_find (const gchar *host, gushort port, const gch
if (fingerprint != NULL) {
file = get_certificate_path(host, buf, fingerprint);
- fp = claws_fopen(file, "rb");
+ fp = g_fopen(file, "rb");
}
if (fp == NULL) {
/* see if we have the old one */
debug_print("didn't get %s\n", file);
g_free(file);
file = get_certificate_path(host, buf, NULL);
- fp = claws_fopen(file, "rb");
+ fp = g_fopen(file, "rb");
if (fp) {
debug_print("got %s\n", file);
@@ -456,7 +456,7 @@ SSLCertificate *ssl_certificate_find (const gchar *host, gushort port, const gch
gnutls_x509_crt_deinit(tmp_x509);
}
- claws_fclose(fp);
+ fclose(fp);
g_free(file);
if (must_rename) {
@@ -537,7 +537,7 @@ static guint check_cert(SSLCertificate *cert)
FILE *fp;
if (claws_ssl_get_cert_file())
- fp = claws_fopen(claws_ssl_get_cert_file(), "r");
+ fp = g_fopen(claws_ssl_get_cert_file(), "r");
else
return (guint)-1;
@@ -546,10 +546,10 @@ static guint check_cert(SSLCertificate *cert)
if ((r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &ca_list, &max_ca)) < 0) {
debug_print("CA import failed: %s\n", gnutls_strerror(r));
- claws_fclose(fp);
+ fclose(fp);
return (guint)-1;
}
- claws_fclose(fp);
+ fclose(fp);
fp = NULL;
buf = g_strdup_printf("%d", cert->port);
@@ -560,20 +560,20 @@ static guint check_cert(SSLCertificate *cert)
size_t n = 128;
char *fingerprint;
- fp = claws_fopen(chain_file, "r");
+ fp = g_fopen(chain_file, "r");
if (fp == NULL) {
- debug_print("claws_fopen %s failed: %s\n", chain_file, g_strerror(errno));
+ debug_print("g_fopen %s failed: %s\n", chain_file, g_strerror(errno));
g_free(chain_file);
return (guint)-1;
}
if ((r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &chain, &max_certs)) < 0) {
debug_print("chain import failed: %s\n", gnutls_strerror(r));
- claws_fclose(fp);
+ fclose(fp);
g_free(chain_file);
return (guint)-1;
}
g_free(chain_file);
- claws_fclose(fp);
+ fclose(fp);
fp = NULL;
gnutls_x509_crt_get_fingerprint(chain[0], GNUTLS_DIG_MD5, md, &n);
@@ -676,7 +676,7 @@ static void ssl_certificate_save_chain(gnutls_x509_crt_t *certs, gint len, const
g_free(buf);
- fp = claws_fopen(file, "wb");
+ fp = g_fopen(file, "wb");
if (fp == NULL) {
g_free(file);
debug_print("Can't save certificate !\n");
@@ -689,7 +689,7 @@ static void ssl_certificate_save_chain(gnutls_x509_crt_t *certs, gint len, const
}
if (fp)
- claws_safe_fclose(fp);
+ safe_fclose(fp);
}
gboolean ssl_certificate_check (gnutls_x509_crt_t x509_cert, guint status,
@@ -822,12 +822,12 @@ gboolean ssl_certificate_check_chain(gnutls_x509_crt_t *certs, gint chain_len,
gint status;
if (claws_ssl_get_cert_file()) {
- FILE *fp = claws_fopen(claws_ssl_get_cert_file(), "rb");
+ FILE *fp = g_fopen(claws_ssl_get_cert_file(), "rb");
int r = -errno;
if (fp) {
r = gnutls_import_X509_list_fp(fp, GNUTLS_X509_FMT_PEM, &cas, &ncas);
- claws_fclose(fp);
+ fclose(fp);
}
if (r < 0)
@@ -867,10 +867,10 @@ gnutls_x509_crt_t ssl_certificate_get_x509_from_pem_file(const gchar *file)
return NULL;
if (is_file_exist(file)) {
- FILE *fp = claws_fopen(file, "r");
+ FILE *fp = g_fopen(file, "r");
if (fp) {
x509 = gnutls_import_X509_fp(fp, GNUTLS_X509_FMT_PEM);
- claws_fclose(fp);
+ fclose(fp);
return x509;
} else {
log_error(LOG_PROTOCOL, _("Cannot open certificate file %s: %s\n"),
@@ -890,10 +890,10 @@ gnutls_x509_privkey_t ssl_certificate_get_pkey_from_pem_file(const gchar *file)
return NULL;
if (is_file_exist(file)) {
- FILE *fp = claws_fopen(file, "r");
+ FILE *fp = g_fopen(file, "r");
if (fp) {
key = gnutls_import_key_fp(fp, GNUTLS_X509_FMT_PEM);
- claws_fclose(fp);
+ fclose(fp);
return key;
} else {
log_error(LOG_PROTOCOL, _("Cannot open key file %s (%s)\n"),
@@ -1043,10 +1043,10 @@ void ssl_certificate_get_x509_and_pkey_from_p12_file(const gchar *file, const gc
return;
if (is_file_exist(file)) {
- FILE *fp = claws_fopen(file, "r");
+ FILE *fp = g_fopen(file, "r");
if (fp) {
p12 = gnutls_import_PKCS12_fp(fp, GNUTLS_X509_FMT_DER);
- claws_fclose(fp);
+ fclose(fp);
if (!p12) {
log_error(LOG_PROTOCOL, _("Failed to read P12 certificate file %s\n"), file);
}
diff --git a/src/common/tags.c b/src/common/tags.c
@@ -51,7 +51,7 @@ void tags_read_tags(void)
TAGS_RC, NULL);
gchar tmp[255];
gint id;
- FILE *fp = claws_fopen(file, "rb");
+ FILE *fp = g_fopen(file, "rb");
g_free(file);
@@ -67,10 +67,10 @@ void tags_read_tags(void)
if (!fp)
return;
if (fscanf(fp, "max_id %d\n", &tag_max_id) != 1) {
- claws_fclose(fp);
+ fclose(fp);
return;
}
- while (claws_fgets(tmp, sizeof(tmp), fp) != NULL) {
+ while (fgets(tmp, sizeof(tmp), fp) != NULL) {
gchar *sep = strchr(tmp, '\t');
gchar *tag_name = sep?(sep+1):NULL;
@@ -87,7 +87,7 @@ void tags_read_tags(void)
}
}
- claws_fclose(fp);
+ fclose(fp);
}
typedef struct _TagWriteData
@@ -119,10 +119,10 @@ void tags_write_tags(void)
TAGS_RC, NULL);
TagWriteData data;
- FILE *fp = claws_fopen(file, "wb");
+ FILE *fp = g_fopen(file, "wb");
if (!fp) {
- FILE_OP_ERROR(file, "claws_fopen");
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
g_free(file_new);
return;
@@ -139,14 +139,14 @@ void tags_write_tags(void)
}
if (data.error) {
- claws_fclose(fp);
+ fclose(fp);
g_free(file);
g_free(file_new);
return;
}
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(file, "fclose");
g_free(file);
g_free(file_new);
return;
diff --git a/src/common/template.c b/src/common/template.c
@@ -41,8 +41,8 @@ static Template *template_load(gchar *filename)
gchar buf[BUFFSIZE];
gint bytes_read;
- if ((fp = claws_fopen(filename, "rb")) == NULL) {
- FILE_OP_ERROR(filename, "claws_fopen");
+ if ((fp = g_fopen(filename, "rb")) == NULL) {
+ FILE_OP_ERROR(filename, "g_fopen");
return NULL;
}
@@ -57,7 +57,7 @@ static Template *template_load(gchar *filename)
tmpl->replyto = NULL;
tmpl->value = NULL;
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '\n')
break;
else if (!g_ascii_strncasecmp(buf, "Name:", 5))
@@ -79,19 +79,19 @@ static Template *template_load(gchar *filename)
if (!tmpl->name) {
g_warning("wrong template format");
template_free(tmpl);
- claws_fclose(fp);
+ fclose(fp);
return NULL;
}
- if ((bytes_read = claws_fread(buf, 1, sizeof(buf), fp)) == 0) {
- if (claws_ferror(fp)) {
- FILE_OP_ERROR(filename, "claws_fread");
+ if ((bytes_read = fread(buf, 1, sizeof(buf), fp)) == 0) {
+ if (ferror(fp)) {
+ FILE_OP_ERROR(filename, "fread");
template_free(tmpl);
- claws_fclose(fp);
+ fclose(fp);
return NULL;
}
}
- claws_fclose(fp);
+ fclose(fp);
tmpl->value = g_strndup(buf, bytes_read);
return tmpl;
@@ -204,7 +204,7 @@ GSList *template_read_config(void)
if (!(func)) \
{ \
g_warning("failed to write template to file"); \
- if (fp) claws_fclose(fp); \
+ if (fp) fclose(fp); \
if (new) claws_unlink(new); \
g_free(new); \
g_free(filename); \
@@ -257,8 +257,8 @@ static void template_write_config(GSList *tmpl_list)
new = g_strconcat(filename, ".new", NULL);
}
- if ((fp = claws_fopen(new?new:filename, "wb")) == NULL) {
- FILE_OP_ERROR(new?new:filename, "claws_fopen");
+ if ((fp = g_fopen(new?new:filename, "wb")) == NULL) {
+ FILE_OP_ERROR(new?new:filename, "g_fopen");
g_free(new);
g_free(filename);
return;
@@ -278,14 +278,14 @@ static void template_write_config(GSList *tmpl_list)
if (tmpl->replyto && *tmpl->replyto != '\0')
TRY(fprintf(fp, "Reply-To: %s\n", tmpl->replyto) > 0);
- TRY(claws_fputs("\n", fp) != EOF);
+ TRY(fputs("\n", fp) != EOF);
if (tmpl->value && *tmpl->value != '\0') {
- TRY(claws_fwrite(tmpl->value, sizeof(gchar), strlen(tmpl->value), fp) == strlen(tmpl->value));
+ TRY(fwrite(tmpl->value, sizeof(gchar), strlen(tmpl->value), fp) == strlen(tmpl->value));
} else {
- TRY(claws_fwrite("", sizeof(gchar), 1, fp) == 1);
+ TRY(fwrite("", sizeof(gchar), 1, fp) == 1);
}
- TRY_NO_CLOSE(claws_safe_fclose(fp) != EOF);
+ TRY_NO_CLOSE(safe_fclose(fp) != EOF);
if (new) {
if (rename_force(new, filename) < 0) {
diff --git a/src/common/utils.c b/src/common/utils.c
@@ -2432,7 +2432,7 @@ gchar *get_outgoing_rfc2822_str(FILE *fp)
str = g_string_new(NULL);
/* output header part */
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
if (!g_ascii_strncasecmp(buf, "Bcc:", 4)) {
gint next;
@@ -2445,7 +2445,7 @@ gchar *get_outgoing_rfc2822_str(FILE *fp)
ungetc(next, fp);
break;
}
- if (claws_fgets(buf, sizeof(buf), fp) == NULL)
+ if (fgets(buf, sizeof(buf), fp) == NULL)
break;
}
} else {
@@ -2457,7 +2457,7 @@ gchar *get_outgoing_rfc2822_str(FILE *fp)
}
/* output body part */
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
if (buf[0] == '.')
g_string_append_c(str, '.');
@@ -3787,12 +3787,12 @@ gchar *make_http_string(const gchar *bp, const gchar *ep)
static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type, const gchar *file_to_open)
{
- FILE *fp = claws_fopen(path, "rb");
+ FILE *fp = g_fopen(path, "rb");
gchar buf[BUFFSIZE];
gchar *result = NULL;
if (!fp)
return NULL;
- while (claws_fgets(buf, sizeof (buf), fp) != NULL) {
+ while (fgets(buf, sizeof (buf), fp) != NULL) {
gchar **parts = g_strsplit(buf, ";", 3);
gchar *trimmed = parts[0];
while (trimmed[0] == ' ' || trimmed[0] == '\t')
@@ -3851,7 +3851,7 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type,
trimmed[strlen(trimmed)-1] = '\0';
result = g_strdup(trimmed);
g_strfreev(parts);
- claws_fclose(fp);
+ fclose(fp);
if (needsterminal) {
gchar *tmp = g_strdup_printf("xterm -e %s", result);
g_free(result);
@@ -3861,7 +3861,7 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type,
}
g_strfreev(parts);
}
- claws_fclose(fp);
+ fclose(fp);
return NULL;
}
gchar *mailcap_get_command_for_type(const gchar *type, const gchar *file_to_open)
@@ -3884,13 +3884,13 @@ void mailcap_update_default(const gchar *type, const gchar *command)
gchar *path = NULL, *outpath = NULL;
path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap", NULL);
outpath = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".mailcap.new", NULL);
- FILE *fp = claws_fopen(path, "rb");
+ FILE *fp = g_fopen(path, "rb");
FILE *outfp = NULL;
gchar buf[BUFFSIZE];
gboolean err = FALSE;
if (!fp) {
- fp = claws_fopen(path, "a");
+ fp = g_fopen(path, "a");
if (!fp) {
g_warning("failed to create file %s", path);
g_free(path);
@@ -3906,15 +3906,15 @@ void mailcap_update_default(const gchar *type, const gchar *command)
}
}
- outfp = claws_fopen(outpath, "wb");
+ outfp = g_fopen(outpath, "wb");
if (!outfp) {
g_warning("failed to create file %s", outpath);
g_free(path);
g_free(outpath);
- claws_fclose(fp);
+ fclose(fp);
return;
}
- while (fp && claws_fgets(buf, sizeof (buf), fp) != NULL) {
+ while (fp && fgets(buf, sizeof (buf), fp) != NULL) {
gchar **parts = g_strsplit(buf, ";", 3);
gchar *trimmed = parts[0];
while (trimmed[0] == ' ')
@@ -3927,7 +3927,7 @@ void mailcap_update_default(const gchar *type, const gchar *command)
continue;
}
else {
- if(claws_fputs(buf, outfp) == EOF) {
+ if(fputs(buf, outfp) == EOF) {
err = TRUE;
g_strfreev(parts);
break;
@@ -3939,9 +3939,9 @@ void mailcap_update_default(const gchar *type, const gchar *command)
err = TRUE;
if (fp)
- claws_fclose(fp);
+ fclose(fp);
- if (claws_safe_fclose(outfp) == EOF)
+ if (safe_fclose(outfp) == EOF)
err = TRUE;
if (!err)
@@ -3959,10 +3959,10 @@ gboolean file_is_email (const gchar *filename)
gint score = 0;
if (filename == NULL)
return FALSE;
- if ((fp = claws_fopen(filename, "rb")) == NULL)
+ if ((fp = g_fopen(filename, "rb")) == NULL)
return FALSE;
while (score < 3
- && claws_fgets(buffer, sizeof (buffer), fp) != NULL) {
+ && fgets(buffer, sizeof (buffer), fp) != NULL) {
if (!strncasecmp(buffer, "From:", strlen("From:")))
score++;
else if (!strncasecmp(buffer, "Date:", strlen("Date:")))
@@ -3976,7 +3976,7 @@ gboolean file_is_email (const gchar *filename)
break;
}
}
- claws_fclose(fp);
+ fclose(fp);
return (score >= 3);
}
diff --git a/src/common/xml.c b/src/common/xml.c
@@ -86,7 +86,7 @@ XMLFile *xml_open_file(const gchar *path)
newfile = g_new(XMLFile, 1);
- newfile->fp = claws_fopen(path, "rb");
+ newfile->fp = g_fopen(path, "rb");
if (!newfile->fp) {
FILE_OP_ERROR(path, "fopen");
g_free(newfile);
@@ -113,7 +113,7 @@ void xml_close_file(XMLFile *file)
{
cm_return_if_fail(file != NULL);
- if (file->fp) claws_fclose(file->fp);
+ if (file->fp) fclose(file->fp);
g_string_free(file->buf, TRUE);
@@ -425,7 +425,7 @@ static gint xml_read_line(XMLFile *file)
gchar buf[XMLBUFSIZE];
gint index;
- if (claws_fgets(buf, sizeof(buf), file->fp) == NULL)
+ if (fgets(buf, sizeof(buf), file->fp) == NULL)
return -1;
index = file->bufp - file->buf->str;
@@ -606,22 +606,22 @@ gint xml_file_put_escape_str(FILE *fp, const gchar *str)
for (p = str; *p != '\0'; p++) {
switch (*p) {
case '<':
- result = claws_fputs("<", fp);
+ result = fputs("<", fp);
break;
case '>':
- result = claws_fputs(">", fp);
+ result = fputs(">", fp);
break;
case '&':
- result = claws_fputs("&", fp);
+ result = fputs("&", fp);
break;
case '\'':
- result = claws_fputs("'", fp);
+ result = fputs("'", fp);
break;
case '\"':
- result = claws_fputs(""", fp);
+ result = fputs(""", fp);
break;
default:
- result = claws_fputc(*p, fp);
+ result = fputc(*p, fp);
}
}
@@ -720,7 +720,7 @@ static int xml_write_tree_recursive(GNode *node, FILE *fp)
depth = g_node_depth(node) - 1;
for (i = 0; i < depth; i++)
- TRY(claws_fputs(" ", fp) != EOF);
+ TRY(fputs(" ", fp) != EOF);
tag = ((XMLNode *) node->data)->tag;
@@ -731,13 +731,13 @@ static int xml_write_tree_recursive(GNode *node, FILE *fp)
TRY(fprintf(fp, " %s=\"", attr->name) > 0);
TRY(xml_file_put_escape_str(fp, attr->value) == 0);
- TRY(claws_fputs("\"", fp) != EOF);
+ TRY(fputs("\"", fp) != EOF);
}
if (node->children) {
GNode *child;
- TRY(claws_fputs(">\n", fp) != EOF);
+ TRY(fputs(">\n", fp) != EOF);
child = node->children;
while (child) {
@@ -749,10 +749,10 @@ static int xml_write_tree_recursive(GNode *node, FILE *fp)
}
for (i = 0; i < depth; i++)
- TRY(claws_fputs(" ", fp) != EOF);
+ TRY(fputs(" ", fp) != EOF);
TRY(fprintf(fp, "</%s>\n", tag->tag) > 0);
} else
- TRY(claws_fputs(" />\n", fp) != EOF);
+ TRY(fputs(" />\n", fp) != EOF);
return 0;
}
diff --git a/src/common/xmlprops.c b/src/common/xmlprops.c
@@ -131,12 +131,12 @@ void xmlprops_free( XmlProperty *props ) {
static int xmlprops_write_elem_s( FILE *fp, gint lvl, gchar *name ) {
gint i;
for( i = 0; i < lvl; i++ ) {
- if(claws_fputs( " ", fp ) == EOF)
+ if(fputs( " ", fp ) == EOF)
return -1;
}
- if(claws_fputs( "<", fp ) == EOF)
+ if(fputs( "<", fp ) == EOF)
return -1;
- if(claws_fputs( name, fp ) == EOF)
+ if(fputs( name, fp ) == EOF)
return -1;
return 0;
@@ -145,29 +145,29 @@ static int xmlprops_write_elem_s( FILE *fp, gint lvl, gchar *name ) {
static int xmlprops_write_elem_e( FILE *fp, gint lvl, gchar *name ) {
gint i;
for( i = 0; i < lvl; i++ ) {
- if(claws_fputs( " ", fp ) == EOF)
+ if(fputs( " ", fp ) == EOF)
return -1;
}
- if(claws_fputs( "</", fp ) == EOF)
+ if(fputs( "</", fp ) == EOF)
return -1;
- if(claws_fputs( name, fp ) == EOF)
+ if(fputs( name, fp ) == EOF)
return -1;
- if(claws_fputs( ">\n", fp ) == EOF)
+ if(fputs( ">\n", fp ) == EOF)
return -1;
return 0;
}
static int xmlprops_write_attr( FILE *fp, gchar *name, gchar *value ) {
- if(claws_fputs( " ", fp ) == EOF)
+ if(fputs( " ", fp ) == EOF)
return -1;
- if(claws_fputs( name, fp ) == EOF)
+ if(fputs( name, fp ) == EOF)
return -1;
- if(claws_fputs( "=\"", fp ) == EOF)
+ if(fputs( "=\"", fp ) == EOF)
return -1;
if(xml_file_put_escape_str( fp, value ) < 0)
return -1;
- if(claws_fputs( "\"", fp ) == EOF)
+ if(fputs( "\"", fp ) == EOF)
return -1;
return 0;
@@ -182,7 +182,7 @@ static void xmlprops_write_vis( gpointer key, gpointer value, gpointer d ) {
data->error = 1;
if(xmlprops_write_attr( data->fp, XMLS_ATTAG_VALUE, value ) < 0)
data->error = 1;
- if(claws_fputs( " />\n", data->fp ) == EOF)
+ if(fputs( " />\n", data->fp ) == EOF)
data->error = 1;
}
@@ -205,7 +205,7 @@ static gint xmlprops_write_to( XmlProperty *props, const gchar *fileSpec ) {
goto revert;
if(xmlprops_write_elem_s( fp, 0, XMLS_ELTAG_PROP_LIST ) < 0)
goto revert;
- if(claws_fputs( ">\n", fp ) == EOF)
+ if(fputs( ">\n", fp ) == EOF)
goto revert;
/* Output all properties */
diff --git a/src/compose.c b/src/compose.c
@@ -2448,12 +2448,12 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
gboolean prev_autowrap;
GtkTextBuffer *buffer;
BLOCK_WRAP();
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
gtk_text_buffer_insert(textbuf, &iter, buf, -1);
}
UNBLOCK_WRAP();
- claws_fclose(fp);
+ fclose(fp);
}
compose_attach_parts(compose, msginfo);
@@ -2900,7 +2900,7 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
if ((fp = procmsg_open_message(msginfo, FALSE)) == NULL) return -1;
procheader_get_header_fields(fp, hentry);
- claws_fclose(fp);
+ fclose(fp);
if (hentry[H_REPLY_TO].body != NULL) {
if (hentry[H_REPLY_TO].body[0] != '\0') {
@@ -3028,7 +3028,7 @@ static gint compose_parse_manual_headers(Compose *compose, MsgInfo *msginfo, Hea
if ((fp = procmsg_open_message(msginfo, FALSE)) == NULL) return -1;
procheader_get_header_fields(fp, entries);
- claws_fclose(fp);
+ fclose(fp);
he = entries;
while (he != NULL && he->name != NULL) {
@@ -3698,8 +3698,8 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
}
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return COMPOSE_INSERT_READ_ERROR;
}
@@ -3718,7 +3718,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
cur_encoding = conv_get_locale_charset_str_no_utf8();
file_contents = g_string_new("");
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar *str;
if (g_utf8_validate(buf, -1, NULL) == TRUE)
@@ -3766,7 +3766,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
}
g_string_free(file_contents, TRUE);
- claws_fclose(fp);
+ fclose(fp);
return result;
}
@@ -3818,11 +3818,11 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
return FALSE;
}
}
- if ((fp = claws_fopen(file, "rb")) == NULL) {
+ if ((fp = g_fopen(file, "rb")) == NULL) {
alertpanel_error(_("Can't read %s."), filename);
return FALSE;
}
- claws_fclose(fp);
+ fclose(fp);
ainfo = g_new0(AttachInfo, 1);
auto_ainfo = g_auto_pointer_new_with_free
@@ -5569,7 +5569,7 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
return -1;
/* separator between header and body */
- err |= (claws_fputs("\n", fp) == EOF);
+ err |= (fputs("\n", fp) == EOF);
return (err ? -1:0);
}
@@ -5602,8 +5602,8 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
};
gint ret = 0;
- if ((fp = claws_fopen(compose->redirect_filename, "rb")) == NULL) {
- FILE_OP_ERROR(compose->redirect_filename, "claws_fopen");
+ if ((fp = g_fopen(compose->redirect_filename, "rb")) == NULL) {
+ FILE_OP_ERROR(compose->redirect_filename, "g_fopen");
return -1;
}
@@ -5621,7 +5621,7 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
buf = NULL;
continue;
}
- if (claws_fputs(buf, fdest) == -1) {
+ if (fputs(buf, fdest) == -1) {
g_free(buf);
buf = NULL;
goto error;
@@ -5630,7 +5630,7 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
if (!prefs_common.redirect_keep_from) {
if (g_ascii_strncasecmp(buf, "From:",
strlen("From:")) == 0) {
- err |= (claws_fputs(" (by way of ", fdest) == EOF);
+ err |= (fputs(" (by way of ", fdest) == EOF);
if (compose->account->name
&& *compose->account->name) {
gchar buffer[BUFFSIZE];
@@ -5646,13 +5646,13 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
} else
err |= (fprintf(fdest, "%s",
compose->account->address) < 0);
- err |= (claws_fputs(")", fdest) == EOF);
+ err |= (fputs(")", fdest) == EOF);
}
}
g_free(buf);
buf = NULL;
- if (claws_fputs("\n", fdest) == -1)
+ if (fputs("\n", fdest) == -1)
goto error;
}
@@ -5662,17 +5662,17 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
if (compose_redirect_write_headers(compose, fdest))
goto error;
- while ((len = claws_fread(rewrite_buf, sizeof(gchar), sizeof(rewrite_buf), fp)) > 0) {
- if (claws_fwrite(rewrite_buf, sizeof(gchar), len, fdest) != len)
+ while ((len = fread(rewrite_buf, sizeof(gchar), sizeof(rewrite_buf), fp)) > 0) {
+ if (fwrite(rewrite_buf, sizeof(gchar), len, fdest) != len)
goto error;
}
- claws_fclose(fp);
+ fclose(fp);
return 0;
error:
- claws_fclose(fp);
+ fclose(fp);
return -1;
}
@@ -5936,7 +5936,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
debug_print("saving sent message unencrypted...\n");
FILE *tmpfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmp_enc_file);
if (tmpfp) {
- claws_fclose(tmpfp);
+ fclose(tmpfp);
/* fp now points to a file with headers written,
* let's make a copy. */
@@ -5947,9 +5947,9 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
g_free(content);
/* Now write the unencrypted body. */
- if ((tmpfp = claws_fopen(tmp_enc_file, "a")) != NULL) {
+ if ((tmpfp = g_fopen(tmp_enc_file, "a")) != NULL) {
procmime_write_mimeinfo(mimemsg, tmpfp);
- claws_fclose(tmpfp);
+ fclose(tmpfp);
outbox = folder_find_item_from_identifier(compose_get_save_to(compose));
if (!outbox)
@@ -5991,8 +5991,8 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
size_t len;
gchar *chars, *tmp;
- if ((fp = claws_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "wb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return -1;
}
@@ -6012,24 +6012,24 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
g_free(tmp);
if (!chars) {
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
/* write body */
len = strlen(chars);
- if (claws_fwrite(chars, sizeof(gchar), len, fp) != len) {
- FILE_OP_ERROR(file, "claws_fwrite");
+ if (fwrite(chars, sizeof(gchar), len, fp) != len) {
+ FILE_OP_ERROR(file, "fwrite");
g_free(chars);
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
g_free(chars);
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(file, "fclose");
claws_unlink(file);
return -1;
}
@@ -6158,8 +6158,8 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
tmp = g_strdup_printf("%s%cqueue.%p%08x", get_tmp_dir(),
G_DIR_SEPARATOR, compose, (guint) rand());
debug_print("queuing to %s\n", tmp);
- if ((fp = claws_fopen(tmp, "w+b")) == NULL) {
- FILE_OP_ERROR(tmp, "claws_fopen");
+ if ((fp = g_fopen(tmp, "w+b")) == NULL) {
+ FILE_OP_ERROR(tmp, "g_fopen");
g_free(tmp);
return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
}
@@ -6221,7 +6221,7 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
err |= (fprintf(fp, "X-Claws-Sign:%d\n", compose->use_signing) < 0);
if (compose->use_encryption) {
if (!compose_warn_encryption(compose)) {
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
g_free(tmp);
return COMPOSE_QUEUE_ERROR_NO_MSG;
@@ -6246,7 +6246,7 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
* key selection */
if (err == TRUE)
g_warning("failed to write queue message");
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
g_free(tmp);
return COMPOSE_QUEUE_ERROR_NO_ENCRYPTION_KEY;
@@ -6299,7 +6299,7 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
if (compose->redirect_filename != NULL) {
if (compose_redirect_write_to_file(compose, fp) < 0) {
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
g_free(tmp);
return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
@@ -6307,7 +6307,7 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
} else {
gint result = 0;
if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
g_free(tmp);
return result;
@@ -6315,13 +6315,13 @@ static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, Fold
}
if (err == TRUE) {
g_warning("failed to write queue message");
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
g_free(tmp);
return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
}
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(tmp, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmp, "fclose");
claws_unlink(tmp);
g_free(tmp);
return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
@@ -7090,11 +7090,11 @@ void compose_add_extra_header_entries(GtkListStore *model)
if (extra_headers == NULL) {
exhrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "extraheaderrc", NULL);
- if ((exh = claws_fopen(exhrc, "rb")) == NULL) {
+ if ((exh = g_fopen(exhrc, "rb")) == NULL) {
debug_print("extra headers file not found\n");
goto extra_headers_done;
}
- while (claws_fgets(buf, BUFFSIZE, exh) != NULL) {
+ while (fgets(buf, BUFFSIZE, exh) != NULL) {
lastc = strlen(buf) - 1; /* remove trailing control chars */
while (lastc >= 0 && buf[lastc] != ':')
buf[lastc--] = '\0';
@@ -7112,7 +7112,7 @@ void compose_add_extra_header_entries(GtkListStore *model)
g_message("invalid extra header line: %s\n", buf);
}
}
- claws_fclose(exh);
+ fclose(exh);
extra_headers_done:
g_free(exhrc);
extra_headers = g_slist_prepend(extra_headers, g_strdup("")); /* end of list */
@@ -10166,13 +10166,13 @@ static void compose_register_draft(MsgInfo *info)
{
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
- FILE *fp = claws_fopen(filepath, "ab");
+ FILE *fp = g_fopen(filepath, "ab");
if (fp) {
gchar *name = folder_item_get_identifier(info->folder);
fprintf(fp, "%s\t%d\n", name, info->msgnum);
g_free(name);
- claws_fclose(fp);
+ fclose(fp);
}
g_free(filepath);
@@ -10215,8 +10215,8 @@ gboolean compose_draft (gpointer data, guint action)
tmp = g_strdup_printf("%s%cdraft.%p", get_tmp_dir(),
G_DIR_SEPARATOR, compose);
- if ((fp = claws_fopen(tmp, "wb")) == NULL) {
- FILE_OP_ERROR(tmp, "claws_fopen");
+ if ((fp = g_fopen(tmp, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp, "g_fopen");
goto warn_err;
}
@@ -10289,15 +10289,15 @@ gboolean compose_draft (gpointer data, guint action)
err |= (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0);
if (err) {
- claws_fclose(fp);
+ fclose(fp);
goto warn_err;
}
if (compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_STORE, action != COMPOSE_AUTO_SAVE) < 0) {
- claws_fclose(fp);
+ fclose(fp);
goto warn_err;
}
- if (claws_safe_fclose(fp) == EOF) {
+ if (safe_fclose(fp) == EOF) {
goto warn_err;
}
@@ -10467,11 +10467,11 @@ void compose_reopen_exit_drafts(void)
{
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
- FILE *fp = claws_fopen(filepath, "rb");
+ FILE *fp = g_fopen(filepath, "rb");
gchar buf[1024];
if (fp) {
- while (claws_fgets(buf, sizeof(buf), fp)) {
+ while (fgets(buf, sizeof(buf), fp)) {
gchar **parts = g_strsplit(buf, "\t", 2);
const gchar *folder = parts[0];
int msgnum = parts[1] ? atoi(parts[1]):-1;
@@ -10484,7 +10484,7 @@ void compose_reopen_exit_drafts(void)
}
g_strfreev(parts);
}
- claws_fclose(fp);
+ fclose(fp);
}
g_free(filepath);
compose_clear_exit_drafts();
@@ -10881,25 +10881,25 @@ int attach_image(Compose *compose, GtkSelectionData *data, const gchar *subtype)
debug_print("writing image to %s\n", file);
- if ((fp = claws_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "wb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
return -1;
}
- if (claws_fwrite(contents, 1, len, fp) != len) {
- FILE_OP_ERROR(file, "claws_fwrite");
- claws_fclose(fp);
+ if (fwrite(contents, 1, len, fp) != len) {
+ FILE_OP_ERROR(file, "fwrite");
+ fclose(fp);
if (claws_unlink(file) < 0)
FILE_OP_ERROR(file, "unlink");
g_free(file);
return -1;
}
- r = claws_safe_fclose(fp);
+ r = safe_fclose(fp);
if (r == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ FILE_OP_ERROR(file, "fclose");
if (claws_unlink(file) < 0)
FILE_OP_ERROR(file, "unlink");
g_free(file);
diff --git a/src/enriched.c b/src/enriched.c
@@ -124,7 +124,7 @@ static ERTFState ertf_read_line(ERTFParser *parser)
gchar buf2[ERTFBUFSIZE];
gint index;
- if (claws_fgets(buf, sizeof(buf), parser->fp) == NULL) {
+ if (fgets(buf, sizeof(buf), parser->fp) == NULL) {
parser->state = ERTF_EOF;
return ERTF_EOF;
}
diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c
@@ -2640,27 +2640,26 @@ static void fetch_content_run(struct etpan_thread_op * op)
goto free;
}
- f = claws_fdopen(fd, "wb");
+ f = fdopen(fd, "wb");
if (f == NULL) {
result->error = MAILIMAP_ERROR_FETCH;
goto close;
}
- r = claws_fwrite(content, 1, content_size, f);
+ r = fwrite(content, 1, content_size, f);
if (r < content_size) {
result->error = MAILIMAP_ERROR_FETCH;
goto do_fclose;
}
- r = claws_safe_fclose(f);
- if (r == EOF) {
+ if (safe_fclose(f) == EOF) {
result->error = MAILIMAP_ERROR_FETCH;
goto unlink;
}
goto free;
do_fclose:
- claws_fclose(f);
+ fclose(f);
goto unlink;
close:
close(fd);
diff --git a/src/exporthtml.c b/src/exporthtml.c
@@ -241,12 +241,12 @@ void exporthtml_set_attributes( ExportHtmlCtl *ctl, const gboolean value ) {
static gint exporthtml_create_css_dfl( const gchar *fileSpec ) {
FILE *cssFile;
- cssFile = claws_fopen( fileSpec, "rb" );
+ cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
- claws_fclose( cssFile );
+ fclose( cssFile );
return MGU_SUCCESS;
}
- cssFile = claws_fopen( fileSpec, "wb" );
+ cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
@@ -287,7 +287,7 @@ static gint exporthtml_create_css_dfl( const gchar *fileSpec ) {
fprintf( cssFile, ".tab-attr {\n" );
fprintf( cssFile, "}\n" );
- claws_safe_fclose( cssFile );
+ safe_fclose( cssFile );
return MGU_SUCCESS;
}
@@ -299,12 +299,12 @@ static gint exporthtml_create_css_dfl( const gchar *fileSpec ) {
static gint exporthtml_create_css_full( const gchar *fileSpec ) {
FILE *cssFile;
- cssFile = claws_fopen( fileSpec, "rb" );
+ cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
- claws_fclose( cssFile );
+ fclose( cssFile );
return MGU_SUCCESS;
}
- cssFile = claws_fopen( fileSpec, "wb" );
+ cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
@@ -351,7 +351,7 @@ static gint exporthtml_create_css_full( const gchar *fileSpec ) {
fprintf( cssFile, ".tab-attr {\n" );
fprintf( cssFile, "}\n" );
- claws_safe_fclose( cssFile );
+ safe_fclose( cssFile );
return MGU_SUCCESS;
}
@@ -949,7 +949,7 @@ void exporthtml_process(
static gchar *title;
gchar buf[512];
- htmlFile = claws_fopen( ctl->path, "wb" );
+ htmlFile = g_fopen( ctl->path, "wb" );
if( ! htmlFile ) {
/* Cannot open file */
g_print( "Cannot open file for write\n" );
@@ -980,7 +980,7 @@ void exporthtml_process(
fprintf( htmlFile, "</body>\n" );
fprintf( htmlFile, "</html>\n" );
- claws_safe_fclose( htmlFile );
+ safe_fclose( htmlFile );
ctl->retVal = MGU_SUCCESS;
/* Create stylesheet files */
diff --git a/src/folder.c b/src/folder.c
@@ -3001,12 +3001,12 @@ static gint folder_item_get_msg_num_by_file(FolderItem *dest, const gchar *file)
gint msgnum = 0;
gchar buf[BUFFSIZE];
- if ((fp = claws_fopen(file, "rb")) == NULL)
+ if ((fp = g_fopen(file, "rb")) == NULL)
return 0;
if ((folder_has_parent_of_type(dest, F_QUEUE)) ||
(folder_has_parent_of_type(dest, F_DRAFT)))
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
/* new way */
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
@@ -3040,7 +3040,7 @@ static gint folder_item_get_msg_num_by_file(FolderItem *dest, const gchar *file)
g_free(hentry[0].body);
hentry[0].body = NULL;
- claws_fclose(fp);
+ fclose(fp);
return msgnum;
}
diff --git a/src/gtk/about.c b/src/gtk/about.c
@@ -552,14 +552,14 @@ static GtkWidget *about_create_child_page_release_notes(void)
gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
path = g_strconcat(DOCDIR, G_DIR_SEPARATOR_S, RELEASE_NOTES_FILE, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
return scrolledwin;
}
g_free(path);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
const gchar *src_codeset = conv_get_locale_charset_str();
const gchar *dest_codeset = CS_UTF_8;
gchar *tmp;
@@ -573,7 +573,7 @@ static GtkWidget *about_create_child_page_release_notes(void)
gtk_text_buffer_insert(buffer, &iter, tmp, -1);
g_free(tmp);
}
- claws_fclose(fp);
+ fclose(fp);
return scrolledwin;
}
diff --git a/src/html.c b/src/html.c
@@ -142,7 +142,7 @@ static SC_HTMLState sc_html_read_line(SC_HTMLParser *parser)
if (parser->fp == NULL)
return SC_HTML_EOF;
- n = claws_fread(buf, 1, sizeof(buf) - 1, parser->fp);
+ n = fread(buf, 1, sizeof(buf) - 1, parser->fp);
if (n == 0) {
parser->state = SC_HTML_EOF;
return SC_HTML_EOF;
diff --git a/src/imap.c b/src/imap.c
@@ -1469,17 +1469,17 @@ static guint get_file_size_with_crs(const gchar *filename)
if (filename == NULL)
return -1;
- fp = claws_fopen(filename, "rb");
+ fp = g_fopen(filename, "rb");
if (!fp)
return -1;
- while (claws_fgets(buf, sizeof (buf), fp) != NULL) {
+ while (fgets(buf, sizeof (buf), fp) != NULL) {
cnt += strlen(buf);
if (!strstr(buf, "\r\n") && strstr(buf, "\n"))
cnt++;
}
- claws_fclose(fp);
+ fclose(fp);
return cnt;
}
diff --git a/src/main.c b/src/main.c
@@ -1231,12 +1231,12 @@ static void parse_cmd_compose_from_file(const gchar *fn, GString *body)
if (isstdin)
fp = stdin;
else {
- fp = claws_fopen(fn, "r");
+ fp = g_fopen(fn, "r");
if (!fp)
G_PRINT_EXIT(_("Cannot open filename for reading\n"));
}
- while (claws_fgets(fb, sizeof(fb), fp)) {
+ while (fgets(fb, sizeof(fb), fp)) {
gchar *tmp;
strretchomp(fb);
if (*fb == '\0')
@@ -1266,11 +1266,11 @@ static void parse_cmd_compose_from_file(const gchar *fn, GString *body)
g_string_append(body, to);
g_free(to);
g_string_append(body, "?body=");
- while (claws_fgets(fb, sizeof(fb), fp)) {
+ while (fgets(fb, sizeof(fb), fp)) {
g_string_append_uri_escaped(body, fb, NULL, TRUE);
}
if (!isstdin)
- claws_fclose(fp);
+ fclose(fp);
/* append the remaining headers */
g_string_append(body, headers->str);
g_string_free(headers, TRUE);
@@ -1908,7 +1908,7 @@ static gint prohibit_duplicate_launch(int *argc, char ***argv)
fd_gets(sock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
if (!STRNCMP(buf, ".\n")) break;
- if (claws_fputs(buf, stdout) == EOF) {
+ if (fputs(buf, stdout) == EOF) {
g_warning("writing to stdout failed");
break;
}
@@ -1935,7 +1935,7 @@ static gint prohibit_duplicate_launch(int *argc, char ***argv)
fd_gets(sock, buf, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
if (!STRNCMP(buf, ".\n")) break;
- if (claws_fputs(buf, stdout) == EOF) {
+ if (fputs(buf, stdout) == EOF) {
g_warning("writing to stdout failed");
break;
}
diff --git a/src/matcher.c b/src/matcher.c
@@ -1588,7 +1588,7 @@ static gboolean matcherlist_match_binary_content(MatcherList *matchers, MimeInfo
if (!outfp)
return FALSE;
- while (claws_fgets(buf, sizeof(buf), outfp) != NULL) {
+ while (fgets(buf, sizeof(buf), outfp) != NULL) {
strretchomp(buf);
for (l = matchers->matchers ; l != NULL ; l = g_slist_next(l)) {
@@ -1629,14 +1629,14 @@ static gboolean matcherlist_match_binary_content(MatcherList *matchers, MimeInfo
* no need to check the others. */
if (matcher->result && matcher->done) {
if (!matchers->bool_and) {
- claws_fclose(outfp);
+ fclose(outfp);
return TRUE;
}
}
}
}
- claws_fclose(outfp);
+ fclose(outfp);
return FALSE;
}
@@ -1788,8 +1788,8 @@ static gboolean matcherlist_match_file(MatcherList *matchers, MsgInfo *info,
if (file == NULL)
return FALSE;
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
return result;
}
@@ -1831,7 +1831,7 @@ static gboolean matcherlist_match_file(MatcherList *matchers, MsgInfo *info,
g_free(file);
- claws_fclose(fp);
+ fclose(fp);
return result;
}
@@ -2394,44 +2394,44 @@ static int prefs_filtering_write(FILE *fp, GSList *prefs_filtering)
continue;
if (prop->enabled) {
- if (claws_fputs("enabled ", fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs");
+ if (fputs("enabled ", fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs");
g_free(filtering_str);
return -1;
}
} else {
- if (claws_fputs("disabled ", fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs");
+ if (fputs("disabled ", fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs");
g_free(filtering_str);
return -1;
}
}
- if (claws_fputs("rulename \"", fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs");
+ if (fputs("rulename \"", fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs");
g_free(filtering_str);
return -1;
}
tmp_name = prop->name;
while (tmp_name && *tmp_name != '\0') {
if (*tmp_name != '"') {
- if (claws_fputc(*tmp_name, fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs || claws_fputc");
+ if (fputc(*tmp_name, fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs || fputc");
g_free(filtering_str);
return -1;
}
} else if (*tmp_name == '"') {
- if (claws_fputc('\\', fp) == EOF ||
- claws_fputc('"', fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs || claws_fputc");
+ if (fputc('\\', fp) == EOF ||
+ fputc('"', fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs || fputc");
g_free(filtering_str);
return -1;
}
}
tmp_name ++;
}
- if (claws_fputs("\" ", fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs");
+ if (fputs("\" ", fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs");
g_free(filtering_str);
return -1;
}
@@ -2440,8 +2440,8 @@ static int prefs_filtering_write(FILE *fp, GSList *prefs_filtering)
gchar *tmp = NULL;
tmp = g_strdup_printf("account %d ", prop->account_id);
- if (claws_fputs(tmp, fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs");
+ if (fputs(tmp, fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs");
g_free(filtering_str);
g_free(tmp);
return -1;
@@ -2449,9 +2449,9 @@ static int prefs_filtering_write(FILE *fp, GSList *prefs_filtering)
g_free(tmp);
}
- if(claws_fputs(filtering_str, fp) == EOF ||
- claws_fputc('\n', fp) == EOF) {
- FILE_OP_ERROR("filtering config", "claws_fputs || claws_fputc");
+ if(fputs(filtering_str, fp) == EOF ||
+ fputc('\n', fp) == EOF) {
+ FILE_OP_ERROR("filtering config", "fputs || fputc");
g_free(filtering_str);
return -1;
}
@@ -2499,7 +2499,7 @@ static gboolean prefs_matcher_write_func(GNode *node, gpointer d)
data->error = TRUE;
goto fail;
}
- if (claws_fputc('\n', data->fp) == EOF) {
+ if (fputc('\n', data->fp) == EOF) {
data->error = TRUE;
goto fail;
}
@@ -2537,19 +2537,19 @@ static int prefs_matcher_save(FILE *fp)
/* pre global rules */
if (fprintf(fp, "[preglobal]\n") < 0 ||
prefs_filtering_write(fp, pre_global_processing) < 0 ||
- claws_fputc('\n', fp) == EOF)
+ fputc('\n', fp) == EOF)
return -1;
/* post global rules */
if (fprintf(fp, "[postglobal]\n") < 0 ||
prefs_filtering_write(fp, post_global_processing) < 0 ||
- claws_fputc('\n', fp) == EOF)
+ fputc('\n', fp) == EOF)
return -1;
/* filtering rules */
if (fprintf(fp, "[filtering]\n") < 0 ||
prefs_filtering_write(fp, filtering_rules) < 0 ||
- claws_fputc('\n', fp) == EOF)
+ fputc('\n', fp) == EOF)
return -1;
return 0;
@@ -2597,11 +2597,11 @@ void prefs_matcher_read_config(void)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MATCHER_RC, NULL);
- f = claws_fopen(rcpath, "rb");
+ f = g_fopen(rcpath, "rb");
g_free(rcpath);
if (f != NULL) {
matcher_parser_start_parsing(f);
- claws_fclose(matcher_parserin);
+ fclose(matcher_parserin);
}
}
diff --git a/src/mbox.c b/src/mbox.c
@@ -52,10 +52,10 @@
#define FPUTS_TO_TMP_ABORT_IF_FAIL(s) \
{ \
lines++; \
- if (claws_fputs(s, tmp_fp) == EOF) { \
+ if (fputs(s, tmp_fp) == EOF) { \
g_warning("can't write to temporary file"); \
- claws_fclose(tmp_fp); \
- claws_fclose(mbox_fp); \
+ fclose(tmp_fp); \
+ fclose(mbox_fp); \
claws_unlink(tmp_file); \
g_free(tmp_file); \
return -1; \
@@ -89,24 +89,24 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
return -1;
}
- if ((mbox_fp = claws_fopen(mbox, "rb")) == NULL) {
- FILE_OP_ERROR(mbox, "claws_fopen");
+ if ((mbox_fp = g_fopen(mbox, "rb")) == NULL) {
+ FILE_OP_ERROR(mbox, "g_fopen");
alertpanel_error(_("Could not open mbox file:\n%s\n"), mbox);
return -1;
}
/* ignore empty lines on the head */
do {
- if (claws_fgets(buf, sizeof(buf), mbox_fp) == NULL) {
+ if (fgets(buf, sizeof(buf), mbox_fp) == NULL) {
g_warning("can't read mbox file");
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
return -1;
}
} while (buf[0] == '\n' || buf[0] == '\r');
if (strncmp(buf, "From ", 5) != 0) {
g_warning("invalid mbox format: %s", mbox);
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
return -1;
}
@@ -136,10 +136,10 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
GTK_EVENTS_FLUSH();
}
- if ((tmp_fp = claws_fopen(tmp_file, "wb")) == NULL) {
- FILE_OP_ERROR(tmp_file, "claws_fopen");
+ if ((tmp_fp = g_fopen(tmp_file, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp_file, "g_fopen");
g_warning("can't open temporary file");
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
g_free(tmp_file);
return -1;
}
@@ -151,7 +151,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
lines = 0;
/* process all lines from mboxrc file */
- while (claws_fgets(buf, sizeof(buf), mbox_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), mbox_fp) != NULL) {
int offset;
/* eat empty lines */
@@ -207,22 +207,22 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
}
/* more emails to expect? */
- more = !claws_feof(mbox_fp);
+ more = !feof(mbox_fp);
/* warn if email part is empty (it's the minimum check
we can do */
if (lines == 0) {
g_warning("malformed mbox: %s: message %d is empty", mbox, msgs);
- claws_fclose(tmp_fp);
- claws_fclose(mbox_fp);
+ fclose(tmp_fp);
+ fclose(mbox_fp);
claws_unlink(tmp_file);
return -1;
}
- if (claws_safe_fclose(tmp_fp) == EOF) {
- FILE_OP_ERROR(tmp_file, "claws_fclose");
+ if (safe_fclose(tmp_fp) == EOF) {
+ FILE_OP_ERROR(tmp_file, "fclose");
g_warning("can't write to temporary file");
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
claws_unlink(tmp_file);
g_free(tmp_file);
return -1;
@@ -230,7 +230,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
if (apply_filter) {
if ((msgnum = folder_item_add_msg(dropfolder, tmp_file, NULL, TRUE)) < 0) {
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
claws_unlink(tmp_file);
g_free(tmp_file);
return -1;
@@ -293,7 +293,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, gboolean apply_filter,
folder_item_update_thaw();
g_free(tmp_file);
- claws_fclose(mbox_fp);
+ fclose(mbox_fp);
debug_print("%d messages found.\n", msgs);
return msgs;
@@ -310,8 +310,8 @@ gint lock_mbox(const gchar *base, LockType type)
FILE *lockfp;
lockfile = g_strdup_printf("%s.%d", base, getpid());
- if ((lockfp = claws_fopen(lockfile, "wb")) == NULL) {
- FILE_OP_ERROR(lockfile, "claws_fopen");
+ if ((lockfp = g_fopen(lockfile, "wb")) == NULL) {
+ FILE_OP_ERROR(lockfile, "g_fopen");
g_warning("can't create lock file '%s', use 'flock' instead of 'file' if possible", lockfile);
g_free(lockfile);
return -1;
@@ -320,12 +320,12 @@ gint lock_mbox(const gchar *base, LockType type)
if (fprintf(lockfp, "%d\n", getpid()) < 0) {
FILE_OP_ERROR(lockfile, "fprintf");
g_free(lockfile);
- claws_fclose(lockfp);
+ fclose(lockfp);
return -1;
}
- if (claws_safe_fclose(lockfp) == EOF) {
- FILE_OP_ERROR(lockfile, "claws_fclose");
+ if (safe_fclose(lockfp) == EOF) {
+ FILE_OP_ERROR(lockfile, "fclose");
g_free(lockfile);
return -1;
}
@@ -476,8 +476,8 @@ gint copy_mbox(gint srcfd, const gchar *dest)
return -1;
}
- if ((dest_fp = claws_fopen(dest, "wb")) == NULL) {
- FILE_OP_ERROR(dest, "claws_fopen");
+ if ((dest_fp = g_fopen(dest, "wb")) == NULL) {
+ FILE_OP_ERROR(dest, "g_fopen");
return -1;
}
@@ -487,9 +487,9 @@ gint copy_mbox(gint srcfd, const gchar *dest)
}
while ((n_read = read(srcfd, buf, sizeof(buf))) > 0) {
- if (claws_fwrite(buf, 1, n_read, dest_fp) < n_read) {
+ if (fwrite(buf, 1, n_read, dest_fp) < n_read) {
g_warning("writing to %s failed", dest);
- claws_fclose(dest_fp);
+ fclose(dest_fp);
claws_unlink(dest);
return -1;
}
@@ -501,8 +501,8 @@ gint copy_mbox(gint srcfd, const gchar *dest)
err = TRUE;
}
- if (claws_safe_fclose(dest_fp) == EOF) {
- FILE_OP_ERROR(dest, "claws_fclose");
+ if (safe_fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
err = TRUE;
}
@@ -518,12 +518,12 @@ void empty_mbox(const gchar *mbox)
{
FILE *fp;
- if ((fp = claws_fopen(mbox, "wb")) == NULL) {
- FILE_OP_ERROR(mbox, "claws_fopen");
+ if ((fp = g_fopen(mbox, "wb")) == NULL) {
+ FILE_OP_ERROR(mbox, "g_fopen");
g_warning("can't truncate mailbox to zero");
return;
}
- claws_safe_fclose(fp);
+ safe_fclose(fp);
}
gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
@@ -547,8 +547,8 @@ gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
}
}
- if ((mbox_fp = claws_fopen(mbox, "wb")) == NULL) {
- FILE_OP_ERROR(mbox, "claws_fopen");
+ if ((mbox_fp = g_fopen(mbox, "wb")) == NULL) {
+ FILE_OP_ERROR(mbox, "g_fopen");
alertpanel_error(_("Could not create mbox file:\n%s\n"), mbox);
return -1;
}
@@ -574,14 +574,14 @@ gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
if (fprintf(mbox_fp, "From %s %s",
buf, ctime_r(&msginfo->date_t, buft)) < 0) {
err = -1;
- claws_fclose(msg_fp);
+ fclose(msg_fp);
goto out;
}
buf[0] = '\0';
/* write email to mboxrc */
- while (claws_fgets(buf, sizeof(buf), msg_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), msg_fp) != NULL) {
/* quote any From, >From, >>From, etc., according to mbox format specs */
int offset;
@@ -591,15 +591,15 @@ gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
offset++;
}
if (!strncmp(buf+offset, "From ", 5)) {
- if (claws_fputc('>', mbox_fp) == EOF) {
+ if (fputc('>', mbox_fp) == EOF) {
err = -1;
- claws_fclose(msg_fp);
+ fclose(msg_fp);
goto out;
}
}
- if (claws_fputs(buf, mbox_fp) == EOF) {
+ if (fputs(buf, mbox_fp) == EOF) {
err = -1;
- claws_fclose(msg_fp);
+ fclose(msg_fp);
goto out;
}
}
@@ -609,22 +609,22 @@ gint export_list_to_mbox(GSList *mlist, const gchar *mbox)
if (len > 0) {
len--;
if ((buf[len] != '\n') && (buf[len] != '\r')) {
- if (claws_fputc('\n', mbox_fp) == EOF) {
+ if (fputc('\n', mbox_fp) == EOF) {
err = -1;
- claws_fclose(msg_fp);
+ fclose(msg_fp);
goto out;
}
}
}
/* add a trailing empty line */
- if (claws_fputc('\n', mbox_fp) == EOF) {
+ if (fputc('\n', mbox_fp) == EOF) {
err = -1;
- claws_fclose(msg_fp);
+ fclose(msg_fp);
goto out;
}
- claws_safe_fclose(msg_fp);
+ safe_fclose(msg_fp);
statusbar_progress_all(msgs++,total, 500);
if (msgs%500 == 0)
GTK_EVENTS_FLUSH();
@@ -634,7 +634,7 @@ out:
statusbar_progress_all(0,0,0);
statusbar_pop_all();
- claws_safe_fclose(mbox_fp);
+ safe_fclose(mbox_fp);
return err;
}
diff --git a/src/messageview.c b/src/messageview.c
@@ -864,8 +864,8 @@ static gint disposition_notification_send(MsgInfo *msginfo)
g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg%p",
get_rc_dir(), G_DIR_SEPARATOR, msginfo);
- if ((fp = claws_fopen(tmp, "wb")) == NULL) {
- FILE_OP_ERROR(tmp, "claws_fopen");
+ if ((fp = g_fopen(tmp, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp, "g_fopen");
return -1;
}
@@ -1035,8 +1035,8 @@ static gint disposition_notification_send(MsgInfo *msginfo)
if (ok < 0)
goto FILE_ERROR;
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(tmp, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmp, "fclose");
claws_unlink(tmp);
return -1;
}
@@ -1073,7 +1073,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
return ok;
FILE_ERROR:
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(tmp);
return -1;
}
diff --git a/src/mh.c b/src/mh.c
@@ -1325,10 +1325,10 @@ static gchar *get_unseen_seq_name(void)
gchar *profile_path = g_strconcat(
get_home_dir(), G_DIR_SEPARATOR_S,
".mh_profile", NULL);
- FILE *fp = claws_fopen(profile_path, "r");
+ FILE *fp = g_fopen(profile_path, "r");
g_free(profile_path);
if (fp) {
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "Unseen-Sequence:", strlen("Unseen-Sequence:"))) {
gchar *seq_tmp = buf+strlen("Unseen-Sequence:");
while (*seq_tmp == ' ')
@@ -1338,7 +1338,7 @@ static gchar *get_unseen_seq_name(void)
break;
}
}
- claws_fclose(fp);
+ fclose(fp);
}
if (!seq_name)
seq_name = g_strdup("unseen");
diff --git a/src/mimeview.c b/src/mimeview.c
@@ -825,21 +825,21 @@ static void mimeview_show_message_part(MimeView *mimeview, MimeInfo *partinfo)
fname = mimeview->file;
if (!fname) return;
- if ((fp = claws_fopen(fname, "rb")) == NULL) {
- FILE_OP_ERROR(fname, "claws_fopen");
+ if ((fp = g_fopen(fname, "rb")) == NULL) {
+ FILE_OP_ERROR(fname, "g_fopen");
return;
}
if (fseek(fp, partinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeview->file, "fseek");
- claws_fclose(fp);
+ fclose(fp);
return;
}
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
textview_show_part(mimeview->textview, partinfo, fp);
- claws_fclose(fp);
+ fclose(fp);
}
static MimeViewer *get_viewer_for_content_type(MimeView *mimeview, const gchar *content_type)
@@ -1674,7 +1674,7 @@ static void mimeview_drag_data_get(GtkWidget *widget,
GPtrArray *headers = NULL;
FILE *fp;
- fp = claws_fopen(partinfo->data.filename, "rb");
+ fp = g_fopen(partinfo->data.filename, "rb");
if (fp != NULL && fseek(fp, partinfo->offset, SEEK_SET) == 0) {
headers = procheader_get_header_array(fp);
if (headers) {
@@ -1691,7 +1691,7 @@ static void mimeview_drag_data_get(GtkWidget *widget,
}
}
if (fp != NULL)
- claws_fclose(fp);
+ fclose(fp);
if (name)
filename = g_path_get_basename(name);
g_free(name);
diff --git a/src/msgcache.c b/src/msgcache.c
@@ -307,7 +307,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
guint32 idata; \
size_t ni; \
\
- if ((ni = claws_fread(&idata, sizeof(idata), 1, fp)) != 1) { \
+ if ((ni = fread(&idata, sizeof(idata), 1, fp)) != 1) { \
g_warning("read_int: cache data corrupted, read %"G_GSIZE_FORMAT" of %"G_GSIZE_FORMAT" at " \
"offset %ld", ni, sizeof(idata), ftell(fp)); \
procmsg_msginfo_free(&msginfo); \
@@ -354,7 +354,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
guint32 idata; \
\
idata = (guint32)bswap_32(n); \
- if (claws_fwrite(&idata, sizeof(idata), 1, fp) != 1) \
+ if (fwrite(&idata, sizeof(idata), 1, fp) != 1) \
w_err = 1; \
wrote += 4; \
}
@@ -378,7 +378,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
len = strlen(data); \
WRITE_CACHE_DATA_INT(len, fp); \
if (w_err == 0 && len > 0) { \
- if (claws_fwrite(data, 1, len, fp) != len) \
+ if (fwrite(data, 1, len, fp) != len) \
w_err = 1; \
wrote += len; \
} \
@@ -410,8 +410,8 @@ static FILE *msgcache_open_data_file(const gchar *file, guint version,
if (mode == DATA_WRITE) {
int w_err = 0, wrote = 0;
- if ((fp = claws_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "wb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return NULL;
}
if (change_file_mode_rw(fp, file) < 0)
@@ -420,23 +420,23 @@ static FILE *msgcache_open_data_file(const gchar *file, guint version,
WRITE_CACHE_DATA_INT(version, fp);
if (w_err != 0) {
g_warning("failed to write int");
- claws_fclose(fp);
+ fclose(fp);
return NULL;
}
return fp;
}
/* check version */
- if ((fp = claws_fopen(file, "rb")) == NULL)
+ if ((fp = g_fopen(file, "rb")) == NULL)
debug_print("Mark/Cache file '%s' not found\n", file);
else {
if (buf && buf_size > 0)
setvbuf(fp, buf, _IOFBF, buf_size);
- if (claws_fread(&data_ver, sizeof(data_ver), 1, fp) != 1 ||
+ if (fread(&data_ver, sizeof(data_ver), 1, fp) != 1 ||
version != bswap_32(data_ver)) {
g_message("%s: Mark/Cache version is different (%u != %u).\n",
file, bswap_32(data_ver), version);
- claws_fclose(fp);
+ fclose(fp);
fp = NULL;
}
data_ver = bswap_32(data_ver);
@@ -447,9 +447,9 @@ static FILE *msgcache_open_data_file(const gchar *file, guint version,
if (fp) {
/* reopen with append mode */
- claws_fclose(fp);
- if ((fp = claws_fopen(file, "ab")) == NULL)
- FILE_OP_ERROR(file, "claws_fopen");
+ fclose(fp);
+ if ((fp = g_fopen(file, "ab")) == NULL)
+ FILE_OP_ERROR(file, "g_fopen");
} else {
/* open with overwrite mode if mark file doesn't exist or
version is different */
@@ -469,7 +469,7 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
*str = NULL;
if (!swapping) {
- if ((ni = claws_fread(&len, sizeof(len), 1, fp) != 1) ||
+ if ((ni = fread(&len, sizeof(len), 1, fp) != 1) ||
len > G_MAXINT) {
g_warning("read_data_str: cache data (len) corrupted, read %"G_GSIZE_FORMAT
" of %"G_GSIZE_FORMAT" bytes at offset %ld", ni, sizeof(len),
@@ -477,7 +477,7 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
return -1;
}
} else {
- if ((ni = claws_fread(&len, sizeof(len), 1, fp) != 1) ||
+ if ((ni = fread(&len, sizeof(len), 1, fp) != 1) ||
bswap_32(len) > G_MAXINT) {
g_warning("read_data_str: cache data (len) corrupted, read %"G_GSIZE_FORMAT
" of %"G_GSIZE_FORMAT" bytes at offset %ld", ni, sizeof(len),
@@ -496,7 +496,7 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
return -1;
}
- if ((ni = claws_fread(tmpstr, 1, len, fp)) != len) {
+ if ((ni = fread(tmpstr, 1, len, fp)) != len) {
g_warning("read_data_str: cache data corrupted, read %"G_GSIZE_FORMAT" of %u "
"bytes at offset %ld",
ni, len, ftell(fp));
@@ -609,7 +609,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
}
if (msgcache_read_cache_data_str(fp, &srccharset, NULL) < 0) {
- claws_fclose(fp);
+ fclose(fp);
return NULL;
}
dstcharset = CS_UTF_8;
@@ -722,7 +722,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
g_hash_table_insert(cache->msgid_table, msginfo->msgid, msginfo);
}
} else {
- while (claws_fread(&num, sizeof(num), 1, fp) == 1) {
+ while (fread(&num, sizeof(num), 1, fp) == 1) {
if (swapping)
num = bswap_32(num);
@@ -786,7 +786,7 @@ bail_err:
munmap(cache_data, map_len);
#endif
}
- claws_fclose(fp);
+ fclose(fp);
if (conv != NULL) {
if (conv->free != NULL)
conv->free(conv);
@@ -873,10 +873,10 @@ void msgcache_read_mark(MsgCache *cache, const gchar *mark_file)
}
}
} else {
- while (claws_fread(&num, sizeof(num), 1, fp) == 1) {
+ while (fread(&num, sizeof(num), 1, fp) == 1) {
if (swapping)
num = bswap_32(num);
- if (claws_fread(&perm_flags, sizeof(perm_flags), 1, fp) != 1) {
+ if (fread(&perm_flags, sizeof(perm_flags), 1, fp) != 1) {
error = TRUE;
break;
}
@@ -896,7 +896,7 @@ bail_err:
munmap(cache_data, map_len);
#endif
}
- claws_fclose(fp);
+ fclose(fp);
if (error) {
debug_print("error reading cache mark from %s\n", mark_file);
}
@@ -977,7 +977,7 @@ void msgcache_read_tags(MsgCache *cache, const gchar *tags_file)
}
}
} else {
- while (claws_fread(&num, sizeof(num), 1, fp) == 1) {
+ while (fread(&num, sizeof(num), 1, fp) == 1) {
gint id = -1;
if (swapping)
num = bswap_32(num);
@@ -986,7 +986,7 @@ void msgcache_read_tags(MsgCache *cache, const gchar *tags_file)
g_slist_free(msginfo->tags);
msginfo->tags = NULL;
do {
- if (claws_fread(&id, sizeof(id), 1, fp) != 1)
+ if (fread(&id, sizeof(id), 1, fp) != 1)
id = -1;
if (swapping)
id = bswap_32(id);
@@ -1008,7 +1008,7 @@ bail_err:
munmap(cache_data, map_len);
#endif
}
- claws_fclose(fp);
+ fclose(fp);
if (error) {
debug_print("error reading cache tags from %s\n", tags_file);
}
@@ -1157,7 +1157,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
if (w_err != 0) {
g_warning("failed to write charset");
if (write_fps.cache_fp)
- claws_fclose(write_fps.cache_fp);
+ fclose(write_fps.cache_fp);
claws_unlink(new_cache);
g_free(new_cache);
g_free(new_mark);
@@ -1170,7 +1170,7 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
DATA_WRITE, NULL, 0);
if (write_fps.mark_fp == NULL) {
if (write_fps.cache_fp)
- claws_fclose(write_fps.cache_fp);
+ fclose(write_fps.cache_fp);
claws_unlink(new_cache);
g_free(new_cache);
g_free(new_mark);
@@ -1186,9 +1186,9 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
DATA_WRITE, NULL, 0);
if (write_fps.tags_fp == NULL) {
if (write_fps.cache_fp)
- claws_fclose(write_fps.cache_fp);
+ fclose(write_fps.cache_fp);
if (write_fps.mark_fp)
- claws_fclose(write_fps.mark_fp);
+ fclose(write_fps.mark_fp);
claws_unlink(new_cache);
claws_unlink(new_mark);
g_free(new_cache);
@@ -1219,11 +1219,11 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
/* close files */
if (write_fps.cache_fp)
- write_fps.error |= (claws_safe_fclose(write_fps.cache_fp) != 0);
+ write_fps.error |= (safe_fclose(write_fps.cache_fp) != 0);
if (write_fps.mark_fp)
- write_fps.error |= (claws_safe_fclose(write_fps.mark_fp) != 0);
+ write_fps.error |= (safe_fclose(write_fps.mark_fp) != 0);
if (write_fps.tags_fp)
- write_fps.error |= (claws_safe_fclose(write_fps.tags_fp) != 0);
+ write_fps.error |= (safe_fclose(write_fps.tags_fp) != 0);
if (write_fps.error != 0) {
diff --git a/src/news.c b/src/news.c
@@ -651,12 +651,12 @@ GSList *news_get_group_list(Folder *folder)
filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
g_free(path);
- if ((fp = claws_fopen(filename, "rb")) == NULL) {
+ if ((fp = g_fopen(filename, "rb")) == NULL) {
NewsSession *session;
gint ok;
clist *grouplist = NULL;
clistiter *cur;
- fp = claws_fopen(filename, "wb");
+ fp = g_fopen(filename, "wb");
if (!fp) {
g_free(filename);
@@ -664,7 +664,7 @@ GSList *news_get_group_list(Folder *folder)
}
session = news_session_get(folder);
if (!session) {
- claws_fclose(fp);
+ fclose(fp);
g_free(filename);
return NULL;
}
@@ -676,7 +676,7 @@ GSList *news_get_group_list(Folder *folder)
session_destroy(SESSION(session));
REMOTE_FOLDER(folder)->session = NULL;
}
- claws_fclose(fp);
+ fclose(fp);
g_free(filename);
return NULL;
}
@@ -693,7 +693,7 @@ GSList *news_get_group_list(Folder *folder)
log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n"));
session_destroy(SESSION(session));
REMOTE_FOLDER(folder)->session = NULL;
- claws_fclose(fp);
+ fclose(fp);
g_free(filename);
newsnntp_list_free(grouplist);
return NULL;
@@ -701,7 +701,7 @@ GSList *news_get_group_list(Folder *folder)
}
newsnntp_list_free(grouplist);
}
- if (claws_safe_fclose(fp) == EOF) {
+ if (safe_fclose(fp) == EOF) {
log_error(LOG_PROTOCOL, ("Can't write newsgroup list\n"));
session_destroy(SESSION(session));
REMOTE_FOLDER(folder)->session = NULL;
@@ -709,14 +709,14 @@ GSList *news_get_group_list(Folder *folder)
return NULL;
}
- if ((fp = claws_fopen(filename, "rb")) == NULL) {
- FILE_OP_ERROR(filename, "claws_fopen");
+ if ((fp = g_fopen(filename, "rb")) == NULL) {
+ FILE_OP_ERROR(filename, "g_fopen");
g_free(filename);
return NULL;
}
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar *p = buf;
gchar *name;
gint last_num;
@@ -743,7 +743,7 @@ GSList *news_get_group_list(Folder *folder)
}
}
- claws_fclose(fp);
+ fclose(fp);
g_free(filename);
list = g_slist_sort(list, (GCompareFunc)news_group_info_compare);
@@ -947,8 +947,8 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
if (tmp == NULL)
return -1;
- if ((tmpfp = claws_fopen(tmp, "wb")) == NULL) {
- FILE_OP_ERROR(tmp, "claws_fopen");
+ if ((tmpfp = g_fopen(tmp, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp, "g_fopen");
g_free(tmp);
return -1;
}
@@ -976,14 +976,14 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
msginfo->from,
date) < 0) {
FILE_OP_ERROR(tmp, "fprintf");
- claws_fclose(tmpfp);
+ fclose(tmpfp);
claws_unlink(tmp);
g_free(tmp);
return -1;
}
- if (claws_safe_fclose(tmpfp) == EOF) {
- FILE_OP_ERROR(tmp, "claws_fclose");
+ if (safe_fclose(tmpfp) == EOF) {
+ FILE_OP_ERROR(tmp, "fclose");
claws_unlink(tmp);
g_free(tmp);
return -1;
diff --git a/src/oauth2.c b/src/oauth2.c
@@ -233,22 +233,22 @@ void account_read_oauth2_all(void)
debug_print("Reading oauth2rc file\n");
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, OAUTH2_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
//No oauth2rc file exists
oauth2_text = g_strconcat("[Version: ", VERSION, "]\n", oauth2_tmpl, NULL);
str_write_to_file(oauth2_text, rcpath, TRUE);
g_free(oauth2_text);
debug_print("No oauth2rc file found, new one created\n");
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
return;
}
}else{
//oauth2rc file exists. Check version and whether protected from update
version_text = g_strconcat("[Version: ", VERSION, "]\n", NULL);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "protected=0", 11)) {
protected = 0;
debug_print("oauth2rc file is unprotected from updates\n");
@@ -265,14 +265,14 @@ void account_read_oauth2_all(void)
if(!protected && !matchedversion){
//oauth2rc not protected from updates and does not match this version of Claws
//Update it to the latest template version.
- claws_fclose(fp);
+ fclose(fp);
oauth2_text = g_strconcat("[Version: ", VERSION, "]\n", oauth2_tmpl, NULL);
str_write_to_file(oauth2_text, rcpath, TRUE);
g_free(oauth2_text);
debug_print("Replacement oauth2rc file created to match this Claws version\n");
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
return;
}
@@ -280,7 +280,7 @@ void account_read_oauth2_all(void)
}
g_free(rcpath);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "[Oauth2: ", 9)) {
strretchomp(buf);
memmove(buf, buf + 1, sizeof(buf) - 1);
@@ -290,7 +290,7 @@ void account_read_oauth2_all(void)
g_strdup(buf));
}
}
- claws_fclose(fp);
+ fclose(fp);
/* read config data from file */
for (cur = oauth2_label_list; cur != NULL; cur = cur->next) {
diff --git a/src/partial_download.c b/src/partial_download.c
@@ -90,14 +90,14 @@ int partial_msg_in_uidl_list(MsgInfo *msginfo)
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl", G_DIR_SEPARATOR_S, msginfo->extradata->account_server,
"-", msginfo->extradata->account_login, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl-", msginfo->extradata->account_server,
"-", sanitized_uid, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(sanitized_uid);
g_free(path);
return FALSE;
@@ -108,7 +108,7 @@ int partial_msg_in_uidl_list(MsgInfo *msginfo)
now = time(NULL);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar tmp[POPBUFSIZE];
strretchomp(buf);
recv_time = RECV_TIME_NONE;
@@ -122,12 +122,12 @@ int partial_msg_in_uidl_list(MsgInfo *msginfo)
}
}
if (!strcmp(uidl, msginfo->extradata->partial_recv)) {
- claws_fclose(fp);
+ fclose(fp);
return TRUE;
}
}
- claws_fclose(fp);
+ fclose(fp);
return FALSE;
}
@@ -171,14 +171,14 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
"uidl", G_DIR_SEPARATOR_S, tinfo->extradata->account_server,
"-", sanitized_uid, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl-", tinfo->extradata->account_server,
"-", tinfo->extradata->account_login, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
goto bail;
}
@@ -190,9 +190,9 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
g_free(sanitized_uid);
- if ((fpnew = claws_fopen(pathnew, "wb")) == NULL) {
- FILE_OP_ERROR(pathnew, "claws_fopen");
- claws_fclose(fp);
+ if ((fpnew = g_fopen(pathnew, "wb")) == NULL) {
+ FILE_OP_ERROR(pathnew, "g_fopen");
+ fclose(fp);
g_free(path);
g_free(pathnew);
goto bail;
@@ -200,7 +200,7 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
now = time(NULL);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
recv_time = RECV_TIME_NONE;
sprintf(partial_recv,"0");
@@ -217,8 +217,8 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
if (fprintf(fpnew, "%s\t%ld\t%s\n",
uidl, (long int) recv_time, partial_recv) < 0) {
FILE_OP_ERROR(pathnew, "fprintf");
- claws_fclose(fpnew);
- claws_fclose(fp);
+ fclose(fpnew);
+ fclose(fp);
g_free(path);
g_free(pathnew);
goto bail;
@@ -240,8 +240,8 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
if (fprintf(fpnew, "%s\t%ld\t%s\n",
uidl, (long int) recv_time, stat) < 0) {
FILE_OP_ERROR(pathnew, "fprintf");
- claws_fclose(fpnew);
- claws_fclose(fp);
+ fclose(fpnew);
+ fclose(fp);
g_free(path);
g_free(pathnew);
goto bail;
@@ -249,28 +249,28 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
g_free(stat);
}
}
- if (claws_safe_fclose(fpnew) == EOF) {
- FILE_OP_ERROR(pathnew, "claws_fclose");
- claws_fclose(fp);
+ if (safe_fclose(fpnew) == EOF) {
+ FILE_OP_ERROR(pathnew, "fclose");
+ fclose(fp);
g_free(path);
g_free(pathnew);
goto bail;
}
- claws_fclose(fp);
+ fclose(fp);
move_file(pathnew, path, TRUE);
g_free(path);
g_free(pathnew);
- if ((fp = claws_fopen(filename,"rb")) == NULL) {
- FILE_OP_ERROR(filename, "claws_fopen");
+ if ((fp = g_fopen(filename,"rb")) == NULL) {
+ FILE_OP_ERROR(filename, "g_fopen");
goto bail;
}
pathnew = g_strdup_printf("%s.new", filename);
- if ((fpnew = claws_fopen(pathnew, "wb")) == NULL) {
- FILE_OP_ERROR(pathnew, "claws_fopen");
- claws_fclose(fp);
+ if ((fpnew = g_fopen(pathnew, "wb")) == NULL) {
+ FILE_OP_ERROR(pathnew, "g_fopen");
+ fclose(fp);
g_free(pathnew);
goto bail;
}
@@ -278,20 +278,20 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
if (fprintf(fpnew, "SC-Marked-For-Download: %d\n",
download) < 0) {
FILE_OP_ERROR(pathnew, "fprintf");
- claws_fclose(fpnew);
- claws_fclose(fp);
+ fclose(fpnew);
+ fclose(fp);
g_free(pathnew);
goto bail;
}
- while (claws_fgets(buf, sizeof(buf)-1, fp) != NULL) {
+ while (fgets(buf, sizeof(buf)-1, fp) != NULL) {
if(strlen(buf) > strlen("SC-Marked-For-Download: x\n")
&& !strncmp(buf, "SC-Marked-For-Download:",
strlen("SC-Marked-For-Download:"))) {
if (fprintf(fpnew, "%s",
buf+strlen("SC-Marked-For-Download: x\n")) < 0) {
FILE_OP_ERROR(pathnew, "fprintf");
- claws_fclose(fpnew);
- claws_fclose(fp);
+ fclose(fpnew);
+ fclose(fp);
g_free(pathnew);
goto bail;
}
@@ -303,20 +303,20 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
}
if (fprintf(fpnew, "%s", buf) < 0) {
FILE_OP_ERROR(pathnew, "fprintf");
- claws_fclose(fpnew);
- claws_fclose(fp);
+ fclose(fpnew);
+ fclose(fp);
g_free(pathnew);
goto bail;
}
}
- if (claws_safe_fclose(fpnew) == EOF) {
- FILE_OP_ERROR(pathnew, "claws_fclose");
- claws_fclose(fp);
+ if (safe_fclose(fpnew) == EOF) {
+ FILE_OP_ERROR(pathnew, "fclose");
+ fclose(fp);
g_free(pathnew);
goto bail;
}
- claws_fclose(fp);
+ fclose(fp);
if (rename_force(pathnew, filename) != 0) {
g_free(pathnew);
goto bail;
@@ -395,14 +395,14 @@ gchar *partial_get_filename(const gchar *server, const gchar *login,
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl", G_DIR_SEPARATOR_S,
server, "-", sanitized_uid, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl-", server,
"-", sanitized_uid, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(sanitized_uid);
g_free(path);
return result;
@@ -413,7 +413,7 @@ gchar *partial_get_filename(const gchar *server, const gchar *login,
now = time(NULL);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar tmp[POPBUFSIZE];
strretchomp(buf);
recv_time = RECV_TIME_NONE;
@@ -432,7 +432,7 @@ gchar *partial_get_filename(const gchar *server, const gchar *login,
}
}
- claws_fclose(fp);
+ fclose(fp);
return result;
}
diff --git a/src/passwordstore.c b/src/passwordstore.c
@@ -370,16 +370,16 @@ static gint _write_to_file(FILE *fp)
/* Write out the config_version */
line = g_strdup_printf("[config_version:%d]\n", CLAWS_CONFIG_VERSION);
- if (claws_fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store, config_version", "claws_fputs");
+ if (fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store, config_version", "fputs");
g_free(line);
return -1;
}
g_free(line);
/* Add a newline if needed */
- if (_password_store != NULL && claws_fputs("\n", fp) == EOF) {
- FILE_OP_ERROR("password store", "claws_fputs");
+ if (_password_store != NULL && fputs("\n", fp) == EOF) {
+ FILE_OP_ERROR("password store", "fputs");
return -1;
}
@@ -404,8 +404,8 @@ static gint _write_to_file(FILE *fp)
}
line = g_strdup_printf("[%s:%s]\n", typestr, block->block_name);
- if (claws_fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store", "claws_fputs");
+ if (fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store", "fputs");
g_free(line);
return -1;
}
@@ -419,8 +419,8 @@ static gint _write_to_file(FILE *fp)
continue;
line = g_strdup_printf("%s %s\n", key, pwd);
- if (claws_fputs(line, fp) == EOF) {
- FILE_OP_ERROR("password store", "claws_fputs");
+ if (fputs(line, fp) == EOF) {
+ FILE_OP_ERROR("password store", "fputs");
g_free(line);
return -1;
}
@@ -429,8 +429,8 @@ static gint _write_to_file(FILE *fp)
g_list_free(keys);
/* Add a separating new line if there is another block remaining */
- if (item->next != NULL && claws_fputs("\n", fp) == EOF) {
- FILE_OP_ERROR("password store", "claws_fputs");
+ if (item->next != NULL && fputs("\n", fp) == EOF) {
+ FILE_OP_ERROR("password store", "fputs");
return -1;
}
diff --git a/src/pop.c b/src/pop.c
@@ -701,14 +701,14 @@ static void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
"-", sanitized_uid, NULL);
g_free(sanitized_uid);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
"uidl-", ac_prefs->recv_server,
"-", ac_prefs->userid, NULL);
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
session->uidl_table = table;
session->partial_recv_table = partial_recv_table;
@@ -719,7 +719,7 @@ static void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
now = time(NULL);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar tmp[POPBUFSIZE];
strretchomp(buf);
recv_time = RECV_TIME_NONE;
@@ -751,7 +751,7 @@ static void pop3_get_uidl_table(PrefsAccount *ac_prefs, Pop3Session *session)
GINT_TO_POINTER(partial_recv));
}
- claws_fclose(fp);
+ fclose(fp);
session->uidl_table = table;
session->partial_recv_table = partial_recv_table;
@@ -788,8 +788,8 @@ gint pop3_write_uidl_list(Pop3Session *session)
g_free(sanitized_uid);
- if ((fp = claws_fopen(tmp_path, "wb")) == NULL) {
- FILE_OP_ERROR(tmp_path, "claws_fopen");
+ if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp_path, "g_fopen");
goto err_write;
}
@@ -804,8 +804,8 @@ gint pop3_write_uidl_list(Pop3Session *session)
> 0);
}
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(tmp_path, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmp_path, "fclose");
fp = NULL;
goto err_write;
}
@@ -822,7 +822,7 @@ gint pop3_write_uidl_list(Pop3Session *session)
return 0;
err_write:
if (fp)
- claws_fclose(fp);
+ fclose(fp);
g_free(path);
g_free(tmp_path);
return -1;
@@ -838,8 +838,8 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
cm_return_val_if_fail(file != NULL, -1);
- if ((fp = claws_fopen(file, "wb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "wb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return -1;
}
@@ -849,7 +849,7 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
if (prefix != NULL) {
if (fprintf(fp, "%s\n", prefix) < 0) {
FILE_OP_ERROR(file, "fprintf");
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
@@ -861,11 +861,11 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
prev = data;
while ((cur = (gchar *)my_memmem(prev, len - (prev - data), "\r\n", 2))
!= NULL) {
- if ((cur > prev && claws_fwrite(prev, 1, cur - prev, fp) < 1) ||
- claws_fputc('\n', fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fwrite");
+ if ((cur > prev && fwrite(prev, 1, cur - prev, fp) < 1) ||
+ fputc('\n', fp) == EOF) {
+ FILE_OP_ERROR(file, "fwrite");
g_warning("can't write to file: %s", file);
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
@@ -888,25 +888,25 @@ static gint pop3_write_msg_to_file(const gchar *file, const gchar *data,
}
if (prev - data < len &&
- claws_fwrite(prev, 1, len - (prev - data), fp) < 1) {
- FILE_OP_ERROR(file, "claws_fwrite");
+ fwrite(prev, 1, len - (prev - data), fp) < 1) {
+ FILE_OP_ERROR(file, "fwrite");
g_warning("can't write to file: %s", file);
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
if (data[len - 1] != '\r' && data[len - 1] != '\n') {
- if (claws_fputc('\n', fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fputc");
+ if (fputc('\n', fp) == EOF) {
+ FILE_OP_ERROR(file, "fputc");
g_warning("can't write to file: %s", file);
- claws_fclose(fp);
+ fclose(fp);
claws_unlink(file);
return -1;
}
}
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(file, "fclose");
claws_unlink(file);
return -1;
}
diff --git a/src/prefs_account.c b/src/prefs_account.c
@@ -4573,8 +4573,8 @@ void prefs_account_write_config_all(GList *account_list)
privacy_prefs = NULL;
if (cur->next) {
- if (claws_fputc('\n', pfile->fp) == EOF) {
- FILE_OP_ERROR(rcpath, "claws_fputc");
+ if (fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputc");
prefs_file_close_revert(pfile);
g_free(rcpath);
return;
diff --git a/src/prefs_actions.c b/src/prefs_actions.c
@@ -458,8 +458,8 @@ void prefs_actions_read_config(void)
debug_print("Reading actions configurations...\n");
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
return;
}
@@ -472,7 +472,7 @@ void prefs_actions_read_config(void)
g_free(act);
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
const gchar *src_codeset = conv_get_locale_charset_str();
const gchar *dest_codeset = CS_UTF_8;
gchar *tmp;
@@ -493,7 +493,7 @@ void prefs_actions_read_config(void)
else
g_free(tmp);
}
- claws_fclose(fp);
+ fclose(fp);
}
void prefs_actions_write_config(void)
@@ -523,9 +523,9 @@ void prefs_actions_write_config(void)
act = g_strdup(act);
}
- if (claws_fputs(act, pfile->fp) == EOF ||
- claws_fputc('\n', pfile->fp) == EOF) {
- FILE_OP_ERROR(rcpath, "claws_fputs || claws_fputc");
+ if (fputs(act, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
prefs_file_close_revert(pfile);
g_free(act);
g_free(rcpath);
diff --git a/src/prefs_common.c b/src/prefs_common.c
@@ -1227,19 +1227,19 @@ GList *prefs_common_read_history_from_dir_with_defaults(const gchar *dirname, co
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
NULL);
}
- if ((fp = claws_fopen(path, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(path, "claws_fopen");
+ if ((fp = g_fopen(path, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(path, "g_fopen");
g_free(path);
/* returns default list if set, otherwise NULL */
return default_list;
}
g_free(path);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
g_strstrip(buf);
if (buf[0] == '\0') continue;
tmp = add_history(tmp, buf);
}
- claws_fclose(fp);
+ fclose(fp);
tmp = g_list_reverse(tmp);
@@ -1327,8 +1327,8 @@ static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar *
}
tmp_path = g_strconcat(path, ".tmp", NULL);
- if ((fp = claws_fopen(tmp_path, "wb")) == NULL) {
- FILE_OP_ERROR(tmp_path, "claws_fopen");
+ if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp_path, "g_fopen");
goto out;
}
@@ -1338,12 +1338,12 @@ static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar *
}
for (cur = list; cur != NULL; cur = cur->next) {
- TRY(claws_fputs((gchar *)cur->data, fp) != EOF &&
- claws_fputc('\n', fp) != EOF);
+ TRY(fputs((gchar *)cur->data, fp) != EOF &&
+ fputc('\n', fp) != EOF);
}
- if (claws_safe_fclose(fp) == EOF) {
- FILE_OP_ERROR(tmp_path, "claws_fclose");
+ if (safe_fclose(fp) == EOF) {
+ FILE_OP_ERROR(tmp_path, "fclose");
fp = NULL;
goto out;
}
@@ -1358,7 +1358,7 @@ static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar *
out:
if (fp)
- claws_safe_fclose(fp);
+ safe_fclose(fp);
g_free(tmp_path);
g_free(path);
}
diff --git a/src/prefs_customheader.c b/src/prefs_customheader.c
@@ -320,8 +320,8 @@ void prefs_custom_header_read_config(PrefsAccount *ac)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
CUSTOM_HEADER_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
ac->customhdr_list = NULL;
return;
@@ -335,7 +335,7 @@ void prefs_custom_header_read_config(PrefsAccount *ac)
custom_header_free(ch);
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
ch = custom_header_read_str(buf);
if (ch) {
if (ch->account_id == ac->account_id) {
@@ -346,7 +346,7 @@ void prefs_custom_header_read_config(PrefsAccount *ac)
}
}
- claws_fclose(fp);
+ fclose(fp);
}
static void prefs_custom_header_write_config(PrefsAccount *ac)
@@ -365,12 +365,12 @@ static void prefs_custom_header_write_config(PrefsAccount *ac)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
CUSTOM_HEADER_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
} else {
all_hdrs = NULL;
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
ch = custom_header_read_str(buf);
if (ch) {
if (ch->account_id != ac->account_id)
@@ -381,7 +381,7 @@ static void prefs_custom_header_write_config(PrefsAccount *ac)
}
}
- claws_fclose(fp);
+ fclose(fp);
}
if ((pfile = prefs_write_open(rcpath)) == NULL) {
@@ -395,9 +395,9 @@ static void prefs_custom_header_write_config(PrefsAccount *ac)
gchar *chstr;
chstr = custom_header_get_str(hdr);
- if (claws_fputs(chstr, pfile->fp) == EOF ||
- claws_fputc('\n', pfile->fp) == EOF) {
- FILE_OP_ERROR(rcpath, "claws_fputs || claws_fputc");
+ if (fputs(chstr, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
prefs_file_close_revert(pfile);
g_free(rcpath);
g_free(chstr);
@@ -411,9 +411,9 @@ static void prefs_custom_header_write_config(PrefsAccount *ac)
gchar *chstr;
chstr = custom_header_get_str(hdr);
- if (claws_fputs(chstr, pfile->fp) == EOF ||
- claws_fputc('\n', pfile->fp) == EOF) {
- FILE_OP_ERROR(rcpath, "claws_fputs || claws_fputc");
+ if (fputs(chstr, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
prefs_file_close_revert(pfile);
g_free(rcpath);
g_free(chstr);
@@ -629,13 +629,13 @@ static void prefs_custom_header_val_from_file_cb(void)
goto settext;
}
- fp = claws_fopen(filename, "rb");
+ fp = g_fopen(filename, "rb");
if (!fp) {
g_free(filename);
return;
}
- while ((len = claws_fread(inbuf, sizeof(gchar),
+ while ((len = fread(inbuf, sizeof(gchar),
B64_LINE_SIZE, fp))
== B64_LINE_SIZE) {
outbuf = g_base64_encode(inbuf, B64_LINE_SIZE);
@@ -645,14 +645,14 @@ static void prefs_custom_header_val_from_file_cb(void)
g_free(outbuf);
g_free(tmp);
}
- if (len > 0 && claws_feof(fp)) {
+ if (len > 0 && feof(fp)) {
tmp = contents;
outbuf = g_base64_encode(inbuf, len);
contents = g_strconcat(tmp?tmp:"",outbuf, NULL);
g_free(outbuf);
g_free(tmp);
}
- claws_fclose(fp);
+ fclose(fp);
}
} else {
if (!filename)
diff --git a/src/prefs_display_header.c b/src/prefs_display_header.c
@@ -391,8 +391,8 @@ void prefs_display_header_read_config(void)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DISPLAY_HEADER_RC, NULL);
- if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
g_free(rcpath);
prefs_common.disphdr_list = NULL;
prefs_display_header_set_default();
@@ -408,7 +408,7 @@ void prefs_display_header_read_config(void)
display_header_prop_free(dp);
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
g_strdelimit(buf, "\r\n", '\0');
dp = display_header_prop_read_str(buf);
if (dp)
@@ -416,7 +416,7 @@ void prefs_display_header_read_config(void)
g_slist_append(prefs_common.disphdr_list, dp);
}
- claws_fclose(fp);
+ fclose(fp);
}
static void prefs_display_header_write_config(void)
@@ -442,9 +442,9 @@ static void prefs_display_header_write_config(void)
gchar *dpstr;
dpstr = display_header_prop_get_str(dp);
- if (claws_fputs(dpstr, pfile->fp) == EOF ||
- claws_fputc('\n', pfile->fp) == EOF) {
- FILE_OP_ERROR(rcpath, "claws_fputs || claws_fputc");
+ if (fputs(dpstr, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
prefs_file_close_revert(pfile);
g_free(rcpath);
g_free(dpstr);
diff --git a/src/prefs_gtk.c b/src/prefs_gtk.c
@@ -93,15 +93,15 @@ void prefs_read_config(PrefParam *param, const gchar *label,
return;
}
- if ((fp = claws_fopen(rcfile, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcfile, "claws_fopen");
+ if ((fp = g_fopen(rcfile, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcfile, "g_fopen");
return;
}
block_label = g_strdup_printf("[%s]", label);
/* search aiming block */
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
gint val;
if (encoding) {
@@ -123,7 +123,7 @@ void prefs_read_config(PrefParam *param, const gchar *label,
}
g_free(block_label);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
/* reached next block */
if (buf[0] == '[') break;
@@ -143,7 +143,7 @@ void prefs_read_config(PrefParam *param, const gchar *label,
}
debug_print("Finished reading configuration.\n");
- claws_fclose(fp);
+ fclose(fp);
}
static void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
@@ -221,7 +221,7 @@ static void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
if (!(func)) \
{ \
g_warning("failed to write configuration to file"); \
- if (orig_fp) claws_fclose(orig_fp); \
+ if (orig_fp) fclose(orig_fp); \
prefs_file_close_revert(pfile); \
g_free(rcpath); \
g_free(block_label); \
@@ -243,13 +243,13 @@ void prefs_write_config(PrefParam *param, const gchar *label,
cm_return_if_fail(rcfile != NULL);
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, rcfile, NULL);
- if ((orig_fp = claws_fopen(rcpath, "rb")) == NULL) {
- if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
+ if ((orig_fp = g_fopen(rcpath, "rb")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "g_fopen");
}
if ((pfile = prefs_write_open(rcpath)) == NULL) {
g_warning("failed to write configuration to file");
- if (orig_fp) claws_fclose(orig_fp);
+ if (orig_fp) fclose(orig_fp);
g_free(rcpath);
return;
}
@@ -258,7 +258,7 @@ void prefs_write_config(PrefParam *param, const gchar *label,
/* search aiming block */
if (orig_fp) {
- while (claws_fgets(buf, sizeof(buf), orig_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
gint val;
val = strncmp(buf, block_label, strlen(block_label));
@@ -267,7 +267,7 @@ void prefs_write_config(PrefParam *param, const gchar *label,
block_matched = TRUE;
break;
} else
- TRY(claws_fputs(buf, pfile->fp) != EOF);
+ TRY(fputs(buf, pfile->fp) != EOF);
}
}
@@ -278,15 +278,15 @@ void prefs_write_config(PrefParam *param, const gchar *label,
if (block_matched) {
gboolean in_dup_block = FALSE;
- while (claws_fgets(buf, sizeof(buf), orig_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
/* next block */
if (buf[0] == '[') {
- TRY(claws_fputc('\n', pfile->fp) != EOF &&
- claws_fputs(buf, pfile->fp) != EOF);
+ TRY(fputc('\n', pfile->fp) != EOF &&
+ fputs(buf, pfile->fp) != EOF);
break;
}
}
- while (claws_fgets(buf, sizeof(buf), orig_fp) != NULL) {
+ while (fgets(buf, sizeof(buf), orig_fp) != NULL) {
if (buf[0] == '[') {
if (!strncmp(buf, block_label,
strlen(block_label)))
@@ -295,14 +295,14 @@ void prefs_write_config(PrefParam *param, const gchar *label,
in_dup_block = FALSE;
}
if (!in_dup_block)
- TRY(claws_fputs(buf, pfile->fp) != EOF);
+ TRY(fputs(buf, pfile->fp) != EOF);
}
}
g_free(block_label);
block_label = NULL;
- if (orig_fp) claws_fclose(orig_fp);
+ if (orig_fp) fclose(orig_fp);
if (prefs_file_close(pfile) < 0)
g_warning("failed to write configuration to file");
g_free(rcpath);
@@ -371,8 +371,8 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
}
if (buf[0] != '\0') {
- if (claws_fputs(buf, fp) == EOF) {
- perror("claws_fputs");
+ if (fputs(buf, fp) == EOF) {
+ perror("fputs");
return -1;
}
}
@@ -941,13 +941,13 @@ static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
GHashTable *section_cache = NULL;
if (rcfile)
- fp = claws_fopen(rcfile, "rb");
+ fp = g_fopen(rcfile, "rb");
if (!fp) {
debug_print("cache: %s: %s\n", rcfile?rcfile:"(null)", g_strerror(errno));
return -1;
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
if (buf[0] == '\0')
continue;
@@ -989,7 +989,7 @@ static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
}
}
}
- claws_fclose(fp);
+ fclose(fp);
return 0;
}
diff --git a/src/prefs_themes.c b/src/prefs_themes.c
@@ -889,7 +889,7 @@ static void prefs_themes_display_global_stats(const ThemesData *tdata)
#define FGETS_INFOFILE_LINE() \
line[0] = '\0'; \
- if (claws_fgets(line, INFOFILE_LINE_LEN, finfo) != NULL && (len = strlen(line)) > 0) { \
+ if (fgets(line, INFOFILE_LINE_LEN, finfo) != NULL && (len = strlen(line)) > 0) { \
if (line[len - 1] == '\n') line[len - 1] = '\0'; \
} \
else { \
@@ -922,7 +922,7 @@ static void prefs_themes_get_theme_info(ThemesData *tdata)
}
else {
sinfo = g_strconcat(path, G_DIR_SEPARATOR_S, THEMEINFO_FILE, NULL);
- finfo = claws_fopen(sinfo, "r");
+ finfo = g_fopen(sinfo, "r");
if (finfo == NULL) {
info->name = g_strdup(_("No info file available for this theme"));
info->author = g_strdup(_("Unknown"));
@@ -936,7 +936,7 @@ static void prefs_themes_get_theme_info(ThemesData *tdata)
FGETS_INFOFILE_LINE()
info->url = g_strdup(line);
- claws_fclose(finfo);
+ fclose(finfo);
}
g_free(sinfo);
diff --git a/src/procheader.c b/src/procheader.c
@@ -456,13 +456,13 @@ MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
return NULL;
#endif
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return NULL;
}
msginfo = procheader_parse_stream(fp, flags, full, decrypted);
- claws_fclose(fp);
+ fclose(fp);
if (msginfo) {
#ifdef G_OS_WIN32
@@ -1272,8 +1272,8 @@ gint procheader_get_header_from_msginfo(MsgInfo *msginfo, gchar **buf, gchar *he
hentry[0].name = header;
file = procmsg_get_message_file_path(msginfo);
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
g_free(*buf);
*buf = NULL;
@@ -1281,8 +1281,8 @@ gint procheader_get_header_from_msginfo(MsgInfo *msginfo, gchar **buf, gchar *he
}
val = procheader_get_one_field(buf, fp, hentry);
- if (claws_fclose(fp) == EOF) {
- FILE_OP_ERROR(file, "claws_fclose");
+ if (fclose(fp) == EOF) {
+ FILE_OP_ERROR(file, "fclose");
claws_unlink(file);
g_free(file);
g_free(*buf);
diff --git a/src/procmime.c b/src/procmime.c
@@ -277,12 +277,12 @@ const gchar *procmime_mimeinfo_get_parameter(MimeInfo *mimeinfo, const gchar *na
/* this is flowed */ \
if (delsp) \
lastline[llen-1] = '\0'; \
- if (claws_fputs(lastline, outfp) == EOF) \
+ if (fputs(lastline, outfp) == EOF) \
err = TRUE; \
} else { \
- if (claws_fputs(lastline, outfp) == EOF) \
+ if (fputs(lastline, outfp) == EOF) \
err = TRUE; \
- if (claws_fputs("\n", outfp) == EOF) \
+ if (fputs("\n", outfp) == EOF) \
err = TRUE; \
} \
} \
@@ -337,21 +337,21 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
if (mimeinfo->data.filename == NULL)
return FALSE;
- infp = claws_fopen(mimeinfo->data.filename, "rb");
+ infp = g_fopen(mimeinfo->data.filename, "rb");
if (!infp) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return FALSE;
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(infp);
+ fclose(infp);
return FALSE;
}
outfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
if (!outfp) {
perror("tmpfile");
- claws_fclose(infp);
+ fclose(infp);
g_free(tmpfilename);
return FALSE;
}
@@ -363,12 +363,12 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
*buf = '\0';
if (encoding == ENC_QUOTED_PRINTABLE) {
- while ((ftell(infp) < readend) && (claws_fgets(buf, sizeof(buf), infp) != NULL)) {
+ while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
size_t len;
len = qp_decode_line(buf);
buf[len] = '\0';
if (!flowed) {
- if (claws_fwrite(buf, 1, len, outfp) < len)
+ if (fwrite(buf, 1, len, outfp) < len)
err = TRUE;
} else {
FLUSH_LASTLINE();
@@ -393,8 +393,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
if (!tmpfp) {
perror("my_tmpfile");
if (tmp_file)
- claws_fclose(outfp);
- claws_fclose(infp);
+ fclose(outfp);
+ fclose(infp);
g_free(tmpfilename);
return FALSE;
}
@@ -402,7 +402,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
tmpfp = outfp;
while ((inlen = MIN(readend - ftell(infp), sizeof(buf))) > 0 && !err) {
- inread = claws_fread(buf, 1, inlen, infp);
+ inread = fread(buf, 1, inlen, infp);
memset(outbuf, 0, sizeof(buf));
len = (glong)g_base64_decode_step(buf, inlen, outbuf, &state, &save);
if (uncanonicalize == TRUE && strlen(outbuf) < (size_t)len && starting) {
@@ -412,7 +412,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
starting = FALSE;
if (((inread != inlen) || len < 0) && !got_error) {
g_warning("bad BASE64 content");
- if (claws_fwrite(_("[Error decoding BASE64]\n"),
+ if (fwrite(_("[Error decoding BASE64]\n"),
sizeof(gchar),
strlen(_("[Error decoding BASE64]\n")),
tmpfp) < strlen(_("[Error decoding BASE64]\n")))
@@ -424,10 +424,10 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
* per block */
if (null_bytes) {
/* we won't uncanonicalize, output to outfp directly */
- if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
+ if (fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
err = TRUE;
} else {
- if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, tmpfp) < (size_t)len)
+ if (fwrite(outbuf, sizeof(gchar), (size_t)len, tmpfp) < (size_t)len)
err = TRUE;
}
got_error = FALSE;
@@ -436,21 +436,21 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
if (uncanonicalize) {
rewind(tmpfp);
- while (claws_fgets(buf, sizeof(buf), tmpfp) != NULL) {
+ while (fgets(buf, sizeof(buf), tmpfp) != NULL) {
strcrchomp(buf);
- if (claws_fputs(buf, outfp) == EOF)
+ if (fputs(buf, outfp) == EOF)
err = TRUE;
}
}
if (tmpfp != outfp) {
- claws_fclose(tmpfp);
+ fclose(tmpfp);
}
} else if (encoding == ENC_X_UUENCODE) {
gchar outbuf[BUFFSIZE];
glong len;
gboolean flag = FALSE;
- while ((ftell(infp) < readend) && (claws_fgets(buf, sizeof(buf), infp) != NULL)) {
+ while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
if (!flag && strncmp(buf,"begin ", 6)) continue;
if (flag) {
@@ -460,15 +460,15 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
g_warning("bad UUENCODE content (%ld)", len);
break;
}
- if (claws_fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
+ if (fwrite(outbuf, sizeof(gchar), (size_t)len, outfp) < (size_t)len)
err = TRUE;
} else
flag = TRUE;
}
} else {
- while ((ftell(infp) < readend) && (claws_fgets(buf, sizeof(buf), infp) != NULL)) {
+ while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
if (!flowed) {
- if (claws_fputs(buf, outfp) == EOF)
+ if (fputs(buf, outfp) == EOF)
err = TRUE;
} else {
FLUSH_LASTLINE();
@@ -480,8 +480,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
g_warning("write error");
}
- claws_fclose(outfp);
- claws_fclose(infp);
+ fclose(outfp);
+ fclose(infp);
account_sigsep_matchlist_delete();
@@ -534,22 +534,22 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
}
if (mimeinfo->content == MIMECONTENT_FILE && mimeinfo->data.filename) {
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
g_warning("can't open file %s", mimeinfo->data.filename);
g_free(tmpfilename);
- claws_fclose(outfp);
+ fclose(outfp);
return FALSE;
}
} else if (mimeinfo->content == MIMECONTENT_MEM) {
infp = str_open_as_stream(mimeinfo->data.mem);
if (infp == NULL) {
g_free(tmpfilename);
- claws_fclose(outfp);
+ fclose(outfp);
return FALSE;
}
} else {
g_free(tmpfilename);
- claws_fclose(outfp);
+ fclose(outfp);
g_warning("unknown mimeinfo");
return FALSE;
}
@@ -566,61 +566,61 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
if (canonicalize_file(mimeinfo->data.filename, tmp_file) < 0) {
g_free(tmp_file);
g_free(tmpfilename);
- claws_fclose(infp);
- claws_fclose(outfp);
+ fclose(infp);
+ fclose(outfp);
return FALSE;
}
- if ((tmp_fp = claws_fopen(tmp_file, "rb")) == NULL) {
- FILE_OP_ERROR(tmp_file, "claws_fopen");
+ if ((tmp_fp = g_fopen(tmp_file, "rb")) == NULL) {
+ FILE_OP_ERROR(tmp_file, "g_fopen");
claws_unlink(tmp_file);
g_free(tmp_file);
g_free(tmpfilename);
- claws_fclose(infp);
- claws_fclose(outfp);
+ fclose(infp);
+ fclose(outfp);
return FALSE;
}
} else {
gchar *out = canonicalize_str(mimeinfo->data.mem);
- claws_fclose(infp);
+ fclose(infp);
infp = str_open_as_stream(out);
tmp_fp = infp;
g_free(out);
if (infp == NULL) {
g_free(tmpfilename);
- claws_fclose(outfp);
+ fclose(outfp);
return FALSE;
}
}
}
- while ((len = (glong)claws_fread(inbuf, sizeof(gchar),
+ while ((len = (glong)fread(inbuf, sizeof(gchar),
B64_LINE_SIZE, tmp_fp))
== B64_LINE_SIZE) {
out = g_base64_encode(inbuf, B64_LINE_SIZE);
- if (claws_fputs(out, outfp) == EOF)
+ if (fputs(out, outfp) == EOF)
err = TRUE;
g_free(out);
- if (claws_fputc('\n', outfp) == EOF)
+ if (fputc('\n', outfp) == EOF)
err = TRUE;
}
- if (len > 0 && claws_feof(tmp_fp)) {
+ if (len > 0 && feof(tmp_fp)) {
out = g_base64_encode(inbuf, (gsize)len);
- if (claws_fputs(out, outfp) == EOF)
+ if (fputs(out, outfp) == EOF)
err = TRUE;
g_free(out);
- if (claws_fputc('\n', outfp) == EOF)
+ if (fputc('\n', outfp) == EOF)
err = TRUE;
}
if (tmp_file) {
- claws_fclose(tmp_fp);
+ fclose(tmp_fp);
claws_unlink(tmp_file);
g_free(tmp_file);
}
} else if (encoding == ENC_QUOTED_PRINTABLE) {
gchar inbuf[BUFFSIZE], outbuf[BUFFSIZE * 4];
- while (claws_fgets(inbuf, sizeof(inbuf), infp) != NULL) {
+ while (fgets(inbuf, sizeof(inbuf), infp) != NULL) {
qp_encode_line(outbuf, inbuf);
if (!strncmp("From ", outbuf, sizeof("From ")-1)) {
@@ -628,27 +628,27 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
tmpbuf += sizeof("From ")-1;
- if (claws_fputs("=46rom ", outfp) == EOF)
+ if (fputs("=46rom ", outfp) == EOF)
err = TRUE;
- if (claws_fputs(tmpbuf, outfp) == EOF)
+ if (fputs(tmpbuf, outfp) == EOF)
err = TRUE;
} else {
- if (claws_fputs(outbuf, outfp) == EOF)
+ if (fputs(outbuf, outfp) == EOF)
err = TRUE;
}
}
} else {
gchar buf[BUFFSIZE];
- while (claws_fgets(buf, sizeof(buf), infp) != NULL) {
+ while (fgets(buf, sizeof(buf), infp) != NULL) {
strcrchomp(buf);
- if (claws_fputs(buf, outfp) == EOF)
+ if (fputs(buf, outfp) == EOF)
err = TRUE;
}
}
- claws_fclose(outfp);
- claws_fclose(infp);
+ fclose(outfp);
+ fclose(infp);
if (err == TRUE) {
g_free(tmpfilename);
@@ -692,30 +692,30 @@ static gint procmime_get_part_to_stream(FILE *outfp, MimeInfo *mimeinfo)
if (mimeinfo->encoding_type != ENC_BINARY && !procmime_decode_content(mimeinfo))
return -EINVAL;
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
saved_errno = errno;
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return -(saved_errno);
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
saved_errno = errno;
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(infp);
+ fclose(infp);
return -(saved_errno);
}
restlength = mimeinfo->length;
- while ((restlength > 0) && ((readlength = claws_fread(buf, 1, restlength > BUFFSIZE ? BUFFSIZE : restlength, infp)) > 0)) {
- if (claws_fwrite(buf, 1, (size_t)readlength, outfp) != (size_t)readlength) {
+ while ((restlength > 0) && ((readlength = fread(buf, 1, restlength > BUFFSIZE ? BUFFSIZE : restlength, infp)) > 0)) {
+ if (fwrite(buf, 1, (size_t)readlength, outfp) != (size_t)readlength) {
saved_errno = errno;
- claws_fclose(infp);
+ fclose(infp);
return -(saved_errno);
}
restlength -= readlength;
}
- claws_fclose(infp);
+ fclose(infp);
rewind(outfp);
return 0;
@@ -729,9 +729,9 @@ gint procmime_get_part(const gchar *outfile, MimeInfo *mimeinfo)
cm_return_val_if_fail(outfile != NULL, -1);
- if ((outfp = claws_fopen(outfile, "wb")) == NULL) {
+ if ((outfp = g_fopen(outfile, "wb")) == NULL) {
saved_errno = errno;
- FILE_OP_ERROR(outfile, "claws_fopen");
+ FILE_OP_ERROR(outfile, "g_fopen");
return -(saved_errno);
}
@@ -742,9 +742,9 @@ gint procmime_get_part(const gchar *outfile, MimeInfo *mimeinfo)
result = procmime_get_part_to_stream(outfp, mimeinfo);
- if (claws_fclose(outfp) == EOF) {
+ if (fclose(outfp) == EOF) {
saved_errno = errno;
- FILE_OP_ERROR(outfile, "claws_fclose");
+ FILE_OP_ERROR(outfile, "fclose");
if (claws_unlink(outfile) < 0)
FILE_OP_ERROR(outfile, "claws_unlink");
return -(saved_errno);
@@ -824,7 +824,7 @@ gboolean procmime_scan_text_content(MimeInfo *mimeinfo,
ertf_parser_destroy(parser);
conv_code_converter_destroy(conv);
} else if (mimeinfo->type == MIMETYPE_TEXT && mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT) {
- while (claws_fgets(buf, sizeof(buf), tmpfp) != NULL) {
+ while (fgets(buf, sizeof(buf), tmpfp) != NULL) {
str = conv_codeset_strdup(buf, src_codeset, CS_UTF_8);
if (str) {
if ((scan_ret = scan_callback(str, cb_data)) == TRUE) {
@@ -843,14 +843,14 @@ gboolean procmime_scan_text_content(MimeInfo *mimeinfo,
if (conv_fail)
g_warning("procmime_get_text_content(): code conversion failed");
- claws_fclose(tmpfp);
+ fclose(tmpfp);
return scan_ret;
}
static gboolean scan_fputs_cb(const gchar *str, gpointer fp)
{
- if (claws_fputs(str, (FILE *)fp) == EOF)
+ if (fputs(str, (FILE *)fp) == EOF)
return TRUE;
return FALSE;
@@ -870,7 +870,7 @@ FILE *procmime_get_text_content(MimeInfo *mimeinfo)
rewind(outfp);
if (err == TRUE) {
- claws_fclose(outfp);
+ fclose(outfp);
return NULL;
}
return outfp;
@@ -1186,23 +1186,23 @@ GList *procmime_get_mime_type_list(void)
return mime_type_list;
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
- if ((fp = claws_fopen(DATAROOTDIR "/mime/globs", "rb")) == NULL)
+ if ((fp = g_fopen(DATAROOTDIR "/mime/globs", "rb")) == NULL)
#else
- if ((fp = claws_fopen("/usr/share/mime/globs", "rb")) == NULL)
+ if ((fp = g_fopen("/usr/share/mime/globs", "rb")) == NULL)
#endif
{
fp_is_glob_file = FALSE;
- if ((fp = claws_fopen("/etc/mime.types", "rb")) == NULL) {
- if ((fp = claws_fopen(SYSCONFDIR "/mime.types", "rb"))
+ if ((fp = g_fopen("/etc/mime.types", "rb")) == NULL) {
+ if ((fp = g_fopen(SYSCONFDIR "/mime.types", "rb"))
== NULL) {
FILE_OP_ERROR(SYSCONFDIR "/mime.types",
- "claws_fopen");
+ "g_fopen");
return NULL;
}
}
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
p = strchr(buf, '#');
if (p) *p = '\0';
g_strstrip(buf);
@@ -1241,7 +1241,7 @@ GList *procmime_get_mime_type_list(void)
list = g_list_append(list, mime_type);
}
- claws_fclose(fp);
+ fclose(fp);
if (!list)
g_warning("can't read mime.types");
@@ -1280,12 +1280,12 @@ EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *ha
gfloat octet_percentage;
gboolean force_b64 = FALSE;
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return ENC_UNKNOWN;
}
- while ((len = claws_fread(buf, sizeof(guchar), sizeof(buf), fp)) > 0) {
+ while ((len = fread(buf, sizeof(guchar), sizeof(buf), fp)) > 0) {
guchar *p;
gulong i;
@@ -1300,7 +1300,7 @@ EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *ha
total_len += len;
}
- claws_fclose(fp);
+ fclose(fp);
if (total_len > 0)
octet_percentage = (gfloat)octet_chars / (gfloat)total_len;
@@ -1450,14 +1450,14 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
procmime_decode_content(mimeinfo);
- fp = claws_fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (fp == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return;
}
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(fp);
+ fclose(fp);
return;
}
procheader_get_header_fields(fp, hentry);
@@ -1493,7 +1493,7 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
}
content_start = ftell(fp);
- claws_fclose(fp);
+ fclose(fp);
len = mimeinfo->length - (content_start - mimeinfo->offset);
if (len < 0)
@@ -1527,14 +1527,14 @@ static void procmime_parse_disposition_notification(MimeInfo *mimeinfo,
procmime_decode_content(mimeinfo);
debug_print("parse disposition notification\n");
- fp = claws_fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (fp == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return;
}
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(fp);
+ fclose(fp);
return;
}
@@ -1545,7 +1545,7 @@ static void procmime_parse_disposition_notification(MimeInfo *mimeinfo,
procheader_get_header_fields(fp, hentry);
}
- claws_fclose(fp);
+ fclose(fp);
if (!hentry[0].body || !hentry[1].body) {
debug_print("MsgId %s, Disp %s\n",
@@ -1658,19 +1658,19 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
procmime_decode_content(mimeinfo);
- fp = claws_fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (fp == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return;
}
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(fp);
+ fclose(fp);
return;
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL && result == 0) {
+ while (fgets(buf, sizeof(buf), fp) != NULL && result == 0) {
if (ftell(fp) - 1 > (mimeinfo->offset + mimeinfo->length))
break;
@@ -1726,7 +1726,7 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
g_free(hentry[i].body);
hentry[i].body = NULL;
}
- claws_fclose(fp);
+ fclose(fp);
}
static void parse_parameters(const gchar *parameters, GHashTable *table)
@@ -2221,10 +2221,10 @@ static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean s
cm_return_val_if_fail(filename != NULL, NULL);
/* Open file */
- if ((fp = claws_fopen(filename, "rb")) == NULL)
+ if ((fp = g_fopen(filename, "rb")) == NULL)
return NULL;
/* Skip queue header */
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
/* new way */
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
@@ -2243,7 +2243,7 @@ static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean s
}
}
offset = ftell(fp);
- claws_fclose(fp);
+ fclose(fp);
mimeinfo = procmime_scan_file_with_offset(filename, offset, short_scan);
@@ -2494,16 +2494,16 @@ static gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp)
/* write header */
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return -1;
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(infp);
+ fclose(infp);
return -1;
}
- while (claws_fgets(buf, sizeof(buf), infp) == buf) {
+ while (fgets(buf, sizeof(buf), infp) == buf) {
strcrchomp(buf);
if (buf[0] == '\n' && buf[1] == '\0')
break;
@@ -2520,19 +2520,19 @@ static gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp)
continue;
}
len = strlen(buf);
- if (claws_fwrite(buf, sizeof(gchar), len, fp) < len) {
+ if (fwrite(buf, sizeof(gchar), len, fp) < len) {
g_warning("failed to dump %"G_GSIZE_FORMAT" bytes from file", len);
- claws_fclose(infp);
+ fclose(infp);
return -1;
}
skip = FALSE;
}
- claws_fclose(infp);
+ fclose(infp);
break;
case MIMECONTENT_MEM:
len = strlen(mimeinfo->data.mem);
- if (claws_fwrite(mimeinfo->data.mem, sizeof(gchar), len, fp) < len) {
+ if (fwrite(mimeinfo->data.mem, sizeof(gchar), len, fp) < len) {
g_warning("failed to dump %"G_GSIZE_FORMAT" bytes from mem", len);
return -1;
}
@@ -2571,26 +2571,26 @@ static gint procmime_write_multipart(MimeInfo *mimeinfo, FILE *fp)
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return -1;
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(infp);
+ fclose(infp);
return -1;
}
- while (claws_fgets(buf, sizeof(buf), infp) == buf) {
+ while (fgets(buf, sizeof(buf), infp) == buf) {
if (IS_BOUNDARY(buf, boundary, strlen(boundary)))
break;
len = strlen(buf);
- if (claws_fwrite(buf, sizeof(gchar), len, fp) < len) {
+ if (fwrite(buf, sizeof(gchar), len, fp) < len) {
g_warning("failed to write %"G_GSIZE_FORMAT, len);
- claws_fclose(infp);
+ fclose(infp);
return -1;
}
}
- claws_fclose(infp);
+ fclose(infp);
break;
case MIMECONTENT_MEM:
@@ -2599,7 +2599,7 @@ static gint procmime_write_multipart(MimeInfo *mimeinfo, FILE *fp)
(*(str2 - 1) == '-') && (*(str2 - 2) == '-'))
*(str2 - 2) = '\0';
len = strlen(str);
- if (claws_fwrite(str, sizeof(gchar), len, fp) < len) {
+ if (fwrite(str, sizeof(gchar), len, fp) < len) {
g_warning("failed to write %"G_GSIZE_FORMAT" from mem", len);
g_free(str);
return -1;
@@ -2644,17 +2644,17 @@ gint procmime_write_mimeinfo(MimeInfo *mimeinfo, FILE *fp)
if (G_NODE_IS_LEAF(mimeinfo->node)) {
switch (mimeinfo->content) {
case MIMECONTENT_FILE:
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return -1;
}
copy_file_part_to_fp(infp, mimeinfo->offset, mimeinfo->length, fp);
- claws_fclose(infp);
+ fclose(infp);
return 0;
case MIMECONTENT_MEM:
len = strlen(mimeinfo->data.mem);
- if (claws_fwrite(mimeinfo->data.mem, sizeof(gchar), len, fp) < len)
+ if (fwrite(mimeinfo->data.mem, sizeof(gchar), len, fp) < len)
return -1;
return 0;
@@ -2727,14 +2727,14 @@ void *procmime_get_part_as_string(MimeInfo *mimeinfo,
if (mimeinfo->content == MIMECONTENT_MEM)
return g_strdup(mimeinfo->data.mem);
- if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
return NULL;
}
if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(infp);
+ fclose(infp);
return NULL;
}
@@ -2744,19 +2744,19 @@ void *procmime_get_part_as_string(MimeInfo *mimeinfo,
if (data == NULL) {
g_warning("could not allocate %ld bytes for procmime_get_part_as_string",
(null_terminate ? length + 1 : length));
- claws_fclose(infp);
+ fclose(infp);
return NULL;
}
- readlength = claws_fread(data, length, 1, infp);
+ readlength = fread(data, length, 1, infp);
if (readlength <= 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fread");
g_free(data);
- claws_fclose(infp);
+ fclose(infp);
return NULL;
}
- claws_fclose(infp);
+ fclose(infp);
if (null_terminate)
data[length] = '\0';
diff --git a/src/procmsg.c b/src/procmsg.c
@@ -496,8 +496,8 @@ FILE *procmsg_open_message(MsgInfo *msginfo, gboolean skip_special_headers)
return NULL;
}
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
return NULL;
}
@@ -508,7 +508,7 @@ FILE *procmsg_open_message(MsgInfo *msginfo, gboolean skip_special_headers)
skip_special_headers == TRUE) {
gchar buf[BUFFSIZE];
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
/* new way */
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
@@ -582,7 +582,7 @@ void procmsg_get_filter_keyword(MsgInfo *msginfo, gchar **header, gchar **key,
if ((fp = procmsg_open_message(msginfo, FALSE)) == NULL)
return;
procheader_get_header_fields(fp, hentry);
- claws_fclose(fp);
+ fclose(fp);
#define SET_FILTER_KEY(hstr, idx) \
{ \
@@ -766,8 +766,8 @@ static PrefsAccount *procmsg_get_account_from_file(const gchar *file)
cm_return_val_if_fail(file != NULL, NULL);
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return NULL;
}
@@ -783,7 +783,7 @@ static PrefsAccount *procmsg_get_account_from_file(const gchar *file)
}
if (buf)
g_free(buf);
- claws_fclose(fp);
+ fclose(fp);
return mailac;
}
@@ -1111,16 +1111,16 @@ gint procmsg_remove_special_headers(const gchar *in, const gchar *out)
FILE *fp, *outfp;
gchar buf[BUFFSIZE];
- if ((fp = claws_fopen(in, "rb")) == NULL) {
- FILE_OP_ERROR(in, "claws_fopen");
+ if ((fp = g_fopen(in, "rb")) == NULL) {
+ FILE_OP_ERROR(in, "g_fopen");
return -1;
}
- if ((outfp = claws_fopen(out, "wb")) == NULL) {
- FILE_OP_ERROR(out, "claws_fopen");
- claws_fclose(fp);
+ if ((outfp = g_fopen(out, "wb")) == NULL) {
+ FILE_OP_ERROR(out, "g_fopen");
+ fclose(fp);
return -1;
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
/* new way */
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
@@ -1138,16 +1138,16 @@ gint procmsg_remove_special_headers(const gchar *in, const gchar *out)
break;
}
}
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
- if (claws_fputs(buf, outfp) == EOF) {
- FILE_OP_ERROR(out, "claws_fputs");
- claws_fclose(outfp);
- claws_fclose(fp);
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ if (fputs(buf, outfp) == EOF) {
+ FILE_OP_ERROR(out, "fputs");
+ fclose(outfp);
+ fclose(fp);
return -1;
}
}
- claws_safe_fclose(outfp);
- claws_fclose(fp);
+ safe_fclose(outfp);
+ fclose(fp);
return 0;
}
@@ -1581,8 +1581,8 @@ static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_ses
cm_return_val_if_fail(file != NULL, -1);
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
if (errstr) {
if (*errstr) g_free(*errstr);
*errstr = g_strdup_printf(_("Couldn't open file %s."), file);
@@ -1718,8 +1718,8 @@ send_mail:
/* write to temporary file */
tmp = g_strdup_printf("%s%cnntp%p", get_tmp_dir(),
G_DIR_SEPARATOR, file);
- if ((tmpfp = claws_fopen(tmp, "wb")) == NULL) {
- FILE_OP_ERROR(tmp, "claws_fopen");
+ if ((tmpfp = g_fopen(tmp, "wb")) == NULL) {
+ FILE_OP_ERROR(tmp, "g_fopen");
newsval = -1;
alertpanel_error(_("Couldn't create temporary file for news sending."));
} else {
@@ -1728,9 +1728,9 @@ send_mail:
g_warning("can't change file mode");
}
- while ((newsval == 0) && claws_fgets(buf, sizeof(buf), fp) != NULL) {
- if (claws_fputs(buf, tmpfp) == EOF) {
- FILE_OP_ERROR(tmp, "claws_fputs");
+ while ((newsval == 0) && fgets(buf, sizeof(buf), fp) != NULL) {
+ if (fputs(buf, tmpfp) == EOF) {
+ FILE_OP_ERROR(tmp, "fputs");
newsval = -1;
if (errstr) {
if (*errstr) g_free(*errstr);
@@ -1738,7 +1738,7 @@ send_mail:
}
}
}
- claws_safe_fclose(tmpfp);
+ safe_fclose(tmpfp);
if (newsval == 0) {
debug_print("Sending message by news\n");
@@ -1757,7 +1757,7 @@ send_mail:
g_free(tmp);
}
- claws_fclose(fp);
+ fclose(fp);
/* save message to outbox */
if (mailval == 0 && newsval == 0 && savecopyfolder) {
@@ -2357,26 +2357,26 @@ MsgInfo *procmsg_msginfo_new_from_mimeinfo(MsgInfo *src_msginfo, MimeInfo *mimei
MsgInfo *tmp_msginfo = NULL;
MsgFlags flags = {0, 0};
gchar *tmpfile = get_tmp_file();
- FILE *fp = claws_fopen(tmpfile, "wb");
+ FILE *fp = g_fopen(tmpfile, "wb");
if (!mimeinfo || mimeinfo->type != MIMETYPE_MESSAGE ||
g_ascii_strcasecmp(mimeinfo->subtype, "rfc822")) {
g_warning("procmsg_msginfo_new_from_mimeinfo(): unsuitable mimeinfo");
if (fp)
- claws_fclose(fp);
+ fclose(fp);
g_free(tmpfile);
return NULL;
}
if (fp && procmime_write_mimeinfo(mimeinfo, fp) >= 0) {
- claws_safe_fclose(fp);
+ safe_fclose(fp);
fp = NULL;
tmp_msginfo = procheader_parse_file(
tmpfile, flags,
TRUE, FALSE);
}
if (fp)
- claws_safe_fclose(fp);
+ safe_fclose(fp);
if (tmp_msginfo != NULL) {
if (src_msginfo)
diff --git a/src/send_message.c b/src/send_message.c
@@ -114,8 +114,8 @@ gint send_message(const gchar *file, PrefsAccount *ac_prefs, GSList *to_list)
cm_return_val_if_fail(ac_prefs != NULL, -1);
cm_return_val_if_fail(to_list != NULL, -1);
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
return -1;
}
@@ -123,13 +123,13 @@ gint send_message(const gchar *file, PrefsAccount *ac_prefs, GSList *to_list)
if (ac_prefs->use_mail_command && ac_prefs->mail_command &&
(*ac_prefs->mail_command)) {
val = send_message_local(ac_prefs->mail_command, fp);
- claws_fclose(fp);
+ fclose(fp);
inc_unlock();
return val;
} else {
val = send_message_smtp(ac_prefs, to_list, fp);
- claws_fclose(fp);
+ fclose(fp);
inc_unlock();
return val;
}
@@ -176,7 +176,7 @@ gint send_message_local(const gchar *command, FILE *fp)
}
g_strfreev(argv);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
strretchomp(buf);
if (buf[0] == '.' && buf[1] == '\0') {
if (fd_write_all(child_stdin, ".", 1) < 0) {
diff --git a/src/sourcewindow.c b/src/sourcewindow.c
@@ -151,8 +151,8 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo)
cm_return_if_fail(file != NULL);
- if ((fp = claws_fopen(file, "rb")) == NULL) {
- FILE_OP_ERROR(file, "claws_fopen");
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "g_fopen");
g_free(file);
return;
}
@@ -164,10 +164,10 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo)
g_free(title);
g_free(file);
- while (claws_fgets(buf, sizeof(buf), fp) != NULL)
+ while (fgets(buf, sizeof(buf), fp) != NULL)
source_window_append(sourcewin, buf);
- claws_fclose(fp);
+ fclose(fp);
}
static void source_window_append(SourceWindow *sourcewin, const gchar *str)
diff --git a/src/textview.c b/src/textview.c
@@ -666,15 +666,15 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
if (mimeinfo->content == MIMECONTENT_MEM)
fp = str_open_as_stream(mimeinfo->data.mem);
else
- fp = claws_fopen(mimeinfo->data.filename, "rb");
+ fp = g_fopen(mimeinfo->data.filename, "rb");
if (!fp) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
END_TIMING();
return;
}
if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(fp);
+ fclose(fp);
END_TIMING();
return;
}
@@ -689,7 +689,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
textview_show_header(textview, headers);
procheader_header_array_destroy(headers);
}
- claws_fclose(fp);
+ fclose(fp);
END_TIMING();
return;
}
@@ -1044,10 +1044,10 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
filename = procmime_get_tmp_file_name(mimeinfo);
if (procmime_get_part(filename, mimeinfo) == 0) {
- tmpfp = claws_fopen(filename, "rb");
+ tmpfp = g_fopen(filename, "rb");
if (tmpfp) {
textview_show_html(textview, tmpfp, conv);
- claws_fclose(tmpfp);
+ fclose(tmpfp);
}
claws_unlink(filename);
}
@@ -1057,10 +1057,10 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
filename = procmime_get_tmp_file_name(mimeinfo);
if (procmime_get_part(filename, mimeinfo) == 0) {
- tmpfp = claws_fopen(filename, "rb");
+ tmpfp = g_fopen(filename, "rb");
if (tmpfp) {
textview_show_ertf(textview, tmpfp, conv);
- claws_fclose(tmpfp);
+ fclose(tmpfp);
}
claws_unlink(filename);
}
@@ -1111,12 +1111,12 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
exit(255);
}
close(pfd[1]);
- tmpfp = claws_fdopen(pfd[0], "rb");
- while (claws_fgets(buf, sizeof(buf), tmpfp)) {
+ tmpfp = fdopen(pfd[0], "rb");
+ while (fgets(buf, sizeof(buf), tmpfp)) {
textview_write_line(textview, buf, conv, TRUE);
if (textview->stop_loading) {
- claws_fclose(tmpfp);
+ fclose(tmpfp);
waitpid(pid, pfd, 0);
g_unlink(fname);
account_sigsep_matchlist_delete();
@@ -1125,7 +1125,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
}
}
- claws_fclose(tmpfp);
+ fclose(tmpfp);
waitpid(pid, pfd, 0);
g_unlink(fname);
#endif
@@ -1147,27 +1147,27 @@ textview_default:
if (mimeinfo->content == MIMECONTENT_MEM)
tmpfp = str_open_as_stream(mimeinfo->data.mem);
else
- tmpfp = claws_fopen(mimeinfo->data.filename, "rb");
+ tmpfp = g_fopen(mimeinfo->data.filename, "rb");
if (!tmpfp) {
- FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
+ FILE_OP_ERROR(mimeinfo->data.filename, "g_fopen");
account_sigsep_matchlist_delete();
conv_code_converter_destroy(conv);
return;
}
if (fseek(tmpfp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
- claws_fclose(tmpfp);
+ fclose(tmpfp);
account_sigsep_matchlist_delete();
conv_code_converter_destroy(conv);
return;
}
debug_print("Viewing text content of type: %s (length: %ld)\n", mimeinfo->subtype, mimeinfo->length);
while (((i = ftell(tmpfp)) < mimeinfo->offset + mimeinfo->length) &&
- (claws_fgets(buf, sizeof(buf), tmpfp) != NULL)
+ (fgets(buf, sizeof(buf), tmpfp) != NULL)
&& continue_write) {
textview_write_line(textview, buf, conv, TRUE);
if (textview->stop_loading) {
- claws_fclose(tmpfp);
+ fclose(tmpfp);
account_sigsep_matchlist_delete();
conv_code_converter_destroy(conv);
return;
@@ -1179,7 +1179,7 @@ textview_default:
continue_write = FALSE;
}
}
- claws_fclose(tmpfp);
+ fclose(tmpfp);
}
account_sigsep_matchlist_delete();
@@ -1929,7 +1929,7 @@ static GPtrArray *textview_scan_header(TextView *textview, FILE *fp)
}
if (!prefs_common.display_header) {
- while (claws_fgets(buf, sizeof(buf), fp) != NULL)
+ while (fgets(buf, sizeof(buf), fp) != NULL)
if (buf[0] == '\r' || buf[0] == '\n') break;
return NULL;
}
diff --git a/src/vcard.c b/src/vcard.c
@@ -142,7 +142,7 @@ void vcard_free( VCardFile *cardFile ) {
cm_return_if_fail( cardFile != NULL );
/* Close file */
- if( cardFile->file ) claws_fclose( cardFile->file );
+ if( cardFile->file ) fclose( cardFile->file );
/* Clear cache */
addrcache_clear( cardFile->addressCache );
@@ -174,7 +174,7 @@ static gint vcard_open_file( VCardFile* cardFile ) {
/* g_print( "Opening file\n" ); */
cardFile->addressCache->dataRead = FALSE;
if( cardFile->path ) {
- cardFile->file = claws_fopen( cardFile->path, "rb" );
+ cardFile->file = g_fopen( cardFile->path, "rb" );
if( ! cardFile->file ) {
/* g_printerr( "can't open %s\n", cardFile->path ); */
cardFile->retVal = MGU_OPEN_FILE;
@@ -199,7 +199,7 @@ static gint vcard_open_file( VCardFile* cardFile ) {
*/
static void vcard_close_file( VCardFile *cardFile ) {
cm_return_if_fail( cardFile != NULL );
- if( cardFile->file ) claws_fclose( cardFile->file );
+ if( cardFile->file ) fclose( cardFile->file );
cardFile->file = NULL;
}
@@ -209,7 +209,7 @@ static void vcard_close_file( VCardFile *cardFile ) {
*/
static gchar *vcard_read_line( VCardFile *cardFile ) {
while( *cardFile->bufptr == '\n' || *cardFile->bufptr == '\0' ) {
- if( claws_fgets( cardFile->buffer, VCARDBUFSIZE, cardFile->file ) == NULL )
+ if( fgets( cardFile->buffer, VCARDBUFSIZE, cardFile->file ) == NULL )
return NULL;
g_strstrip( cardFile->buffer );
cardFile->bufptr = cardFile->buffer;
@@ -590,16 +590,16 @@ gchar *vcard_find_gnomecard( void ) {
strncat( str, GNOMECARD_FILE, WORK_BUFLEN - strlen(str) );
fileSpec = NULL;
- if( ( fp = claws_fopen( str, "rb" ) ) != NULL ) {
+ if( ( fp = g_fopen( str, "rb" ) ) != NULL ) {
/* Read configuration file */
lenlbl = strlen( GNOMECARD_SECTION );
- while( claws_fgets( buf, sizeof( buf ), fp ) != NULL ) {
+ while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
if( 0 == g_ascii_strncasecmp( buf, GNOMECARD_SECTION, lenlbl ) ) {
break;
}
}
- while( claws_fgets( buf, sizeof( buf ), fp ) != NULL ) {
+ while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
g_strchomp( buf );
if( buf[0] == '[' ) break;
for( i = 0; i < lenlbl; i++ ) {
@@ -611,7 +611,7 @@ gchar *vcard_find_gnomecard( void ) {
}
}
}
- claws_fclose( fp );
+ fclose( fp );
}
if( fileSpec == NULL ) {