ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/log.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/log.c (file contents):
Revision 8506 by michael, Fri Apr 6 11:43:23 2018 UTC vs.
Revision 8508 by michael, Fri Apr 6 12:41:58 2018 UTC

# Line 26 | Line 26
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];
# Line 45 | Line 44 | log_set_file(enum log_type type, size_t
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)
# Line 55 | Line 57 | log_set_file(enum log_type type, size_t
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  
# Line 76 | Line 79 | log_reopen_all(void)
79        log->file = NULL;
80      }
81  
82 <    if (log->path[0])
82 >    if (log->path)
83        log->file = fopen(log->path, "a");
84    }
85   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)