Commit bd198acb authored by Per Cederqvist's avatar Per Cederqvist

(copy_file, copy_db_file): Use i_fopen and i_fclose instead of fopen

	and fclose.
parent 2c069236
......@@ -45,6 +45,7 @@
#include "server-config.h"
#include "param.h"
#include "linkansi.h"
#include "eintr.h"
/* The current version of splitkomdb uses three files to store all state.
You can restore the database with commands similar to these:
......@@ -122,7 +123,7 @@ copy_file(const char *from,
FILE *tofp;
size_t sz;
if ((tofp = fopen(to, "w")) == NULL)
if ((tofp = i_fopen(to, "w")) == NULL)
{
fprintf(stderr, "%s: opening ", argv0);
perror(to);
......@@ -163,7 +164,7 @@ copy_file(const char *from,
exit(1);
}
if (fclose(tofp) != 0)
if (i_fclose(tofp) != 0)
{
fprintf(stderr, "%s: closing ", argv0);
perror(to);
......@@ -178,12 +179,12 @@ copy_db_file(void)
FILE *fp;
const char *from;
fp = fopen((from = param.datafile_name), "r");
fp = i_fopen((from = param.datafile_name), "r");
if (fp == NULL || !is_clean(fp))
{
if (fp != NULL)
fclose(fp);
fp = fopen((from = param.backupfile_name), "r");
i_fclose(fp);
fp = i_fopen((from = param.backupfile_name), "r");
assert(is_clean(fp));
}
if (fseek(fp, 0, SEEK_SET) != 0)
......@@ -192,7 +193,7 @@ copy_db_file(void)
exit(1);
}
copy_file(from, fp, data_copy);
fclose(fp);
i_fclose(fp);
}
......@@ -205,7 +206,7 @@ file_equal(const char *from,
int c1;
int c2;
if ((copyfp = fopen(assumed_copy, "r")) == NULL)
if ((copyfp = i_fopen(assumed_copy, "r")) == NULL)
{
if (errno == ENOENT)
return 0;
......@@ -221,12 +222,12 @@ file_equal(const char *from,
{
if (ferror(copyfp))
{
fclose(copyfp);
i_fclose(copyfp);
return 0;
}
else
{
fclose(copyfp);
i_fclose(copyfp);
return 1;
}
}
......@@ -240,7 +241,7 @@ file_equal(const char *from,
exit(1);
}
fclose(copyfp);
i_fclose(copyfp);
return 0;
}
}
......@@ -252,7 +253,7 @@ copy_text_file(void)
{
FILE *fromfp;
if ((fromfp = fopen(param.textfile_name, "r")) == NULL)
if ((fromfp = i_fopen(param.textfile_name, "r")) == NULL)
{
fprintf(stderr, "%s: opening ", argv0);
perror(param.textfile_name);
......@@ -262,7 +263,7 @@ copy_text_file(void)
if (file_equal(param.textfile_name, fromfp, text_base))
{
copy_file(param.textfile_name, fromfp, text_tail);
fclose(fromfp);
i_fclose(fromfp);
}
else
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment