out_file.c
changeset 53 667cd5966695
parent 39 60858d13b22c
equal deleted inserted replaced
52:3af277b9f73b 53:667cd5966695
    50 
    50 
    51 
    51 
    52 /* Return -2 when the file is not enabled. Otherwise, the output of send().*/
    52 /* Return -2 when the file is not enabled. Otherwise, the output of send().*/
    53 int write_out_file(const char * restrict buf, const int len)
    53 int write_out_file(const char * restrict buf, const int len)
    54 {
    54 {
    55 	int res;
    55 	int res, res2;
    56 
    56 
    57 	if (!file_enabled)
    57 	if (!file_enabled)
    58 		return -2;
    58 		return -2;
    59 
    59 
    60 	res = write(out_file, buf, len);
    60 	res = write(out_file, buf, len);
    61 	if (res == -1)
    61 	res2 = write(out_file, "\n", 1);
       
    62 	if (res == -1 || res2 == -1)
    62 	{
    63 	{
    63 		fprintf(stderr, "Error writing to the log file: %s\n", 
    64 		fprintf(stderr, "Error writing to the log file: %s\n", 
    64 			strerror(errno));
    65 			strerror(errno));
    65 	} 
    66 	} 
    66 
    67