26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "log.h" |
29 |
– |
#include "irc_string.h" |
30 |
– |
#include "ircd.h" |
29 |
|
#include "conf.h" |
30 |
|
#include "misc.h" |
31 |
+ |
#include "memory.h" |
32 |
|
|
33 |
|
|
34 |
|
static struct LogFile |
35 |
|
{ |
36 |
< |
char path[HYB_PATH_MAX + 1]; |
36 |
> |
char *path; |
37 |
|
size_t size; |
38 |
|
FILE *file; |
39 |
|
} log_type_table[LOG_TYPE_LAST]; |
44 |
|
{ |
45 |
|
struct LogFile *log = &log_type_table[type]; |
46 |
|
|
47 |
< |
strlcpy(log->path, path, sizeof(log->path)); |
47 |
> |
if (log->path) |
48 |
> |
xfree(log->path); |
49 |
> |
|
50 |
> |
log->path = xstrdup(path); |
51 |
|
log->size = size; |
52 |
|
|
53 |
|
if (type == LOG_TYPE_IRCD) |
57 |
|
void |
58 |
|
log_del_all(void) |
59 |
|
{ |
60 |
< |
unsigned int type = 0; |
60 |
> |
for (unsigned int type = 1; type < LOG_TYPE_LAST; ++type) |
61 |
> |
{ |
62 |
> |
struct LogFile *log = &log_type_table[type]; |
63 |
|
|
64 |
< |
while (++type < LOG_TYPE_LAST) |
65 |
< |
log_type_table[type].path[0] = '\0'; |
64 |
> |
xfree(log->path); |
65 |
> |
log->path = NULL; |
66 |
> |
} |
67 |
|
} |
68 |
|
|
69 |
|
void |
70 |
|
log_reopen_all(void) |
71 |
|
{ |
72 |
< |
unsigned int type = 0; |
68 |
< |
|
69 |
< |
while (++type < LOG_TYPE_LAST) |
72 |
> |
for (unsigned int type = 1; type < LOG_TYPE_LAST; ++type) |
73 |
|
{ |
74 |
|
struct LogFile *log = &log_type_table[type]; |
75 |
|
|
79 |
|
log->file = NULL; |
80 |
|
} |
81 |
|
|
82 |
< |
if (log->path[0]) |
82 |
> |
if (log->path) |
83 |
|
log->file = fopen(log->path, "a"); |
84 |
|
} |
85 |
|
} |