initial import
[dosrtxon] / src / dos / logger.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <errno.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include "logger.h"
7
8 int init_logger(const char *fname)
9 {
10         int fd;
11         if((fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC, 0644)) == -1) {
12                 fprintf(stderr, "init_logger: failed to open %s: %s\n", fname, strerror(errno));
13                 return -1;
14         }
15
16         close(1);
17         close(2);
18         dup(fd);
19         dup(fd);
20         return 0;
21 }