/[imapfilter]/imapfilter/log.c
ViewVC logotype

Diff of /imapfilter/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.41 by lefcha, Mon Feb 9 19:56:42 2004 UTC revision 1.42 by lefcha, Tue Feb 10 22:21:09 2004 UTC
# Line 15  Line 15 
15    
16    
17  extern conn_t connpri, connaux;  extern conn_t connpri, connaux;
18  extern char logfile[PATH_MAX];  extern opts_t opts;
 extern unsigned int options;  
 extern int verbosity;  
19  extern unsigned int flags;  extern unsigned int flags;
20    
21  static FILE *debugfp = NULL;    /* Pointer to debug file. */  static FILE *debugfp = NULL;    /* Pointer to debug file. */
# Line 36  info(const char *info,...) Line 34  info(const char *info,...)
34  {  {
35          va_list args;          va_list args;
36    
37          if (verbosity == -2)          if (opts.verbosity == -2)
38                  return;                  return;
39    
40          va_start(args, info);          va_start(args, info);
# Line 53  verbose(const char *info,...) Line 51  verbose(const char *info,...)
51  {  {
52          va_list args;          va_list args;
53    
54          if (verbosity == 2) {          if (opts.verbosity == 2) {
55                  va_start(args, info);                  va_start(args, info);
56                  vprintf(info, args);                  vprintf(info, args);
57                  va_end(args);                  va_end(args);
# Line 69  debug(const char *debug,...) Line 67  debug(const char *debug,...)
67  {  {
68          va_list args;          va_list args;
69    
70          if ((options & OPTION_DEBUG) && debugfp) {          if (opts.debug && debugfp) {
71                  va_start(args, debug);                  va_start(args, debug);
72                  vfprintf(debugfp, debug, args);                  vfprintf(debugfp, debug, args);
73                  fflush(debugfp);                  fflush(debugfp);
# Line 91  error(const char *errmsg,...) Line 89  error(const char *errmsg,...)
89          fprintf(stderr, "imapfilter: ");          fprintf(stderr, "imapfilter: ");
90          vfprintf(stderr, errmsg, args);          vfprintf(stderr, errmsg, args);
91    
92          if ((options & OPTION_ERRORS) && logfp) {          if (opts.errors && logfp) {
93                  vfprintf(logfp, errmsg, args);                  vfprintf(logfp, errmsg, args);
94                  fflush(logfp);                  fflush(logfp);
95          }          }
# Line 162  debug_start(void) Line 160  debug_start(void)
160          static char dt[] = PATHNAME_DEBUG_FILE;          static char dt[] = PATHNAME_DEBUG_FILE;
161          int fd;          int fd;
162    
163          if (!(options & OPTION_DEBUG))          if (!opts.debug)
164                  return 0;                  return 0;
165    
166          fd = mkstemp(dt);          fd = mkstemp(dt);
# Line 170  debug_start(void) Line 168  debug_start(void)
168          if (fd != -1) {          if (fd != -1) {
169                  debugfp = fdopen(fd, "w");                  debugfp = fdopen(fd, "w");
170                  if (debugfp == NULL) {                  if (debugfp == NULL) {
171                          error("opening debug file %s: %s\n", logfile,                          error("opening debug file %s: %s\n", opts.logfile,
172                              strerror(errno));                              strerror(errno));
173                          return ERROR_TRIVIAL;                          return ERROR_TRIVIAL;
174                  }                  }
# Line 198  debug_stop(void) Line 196  debug_stop(void)
196  int  int
197  log_start(void)  log_start(void)
198  {  {
199          if (*logfile == '\0')          if (*opts.logfile == '\0')
200                  return 0;       /* Logging not enabled. */                  return 0;       /* Logging not enabled. */
201    
202          debug("log file: '%s'\n", logfile);          debug("log file: '%s'\n", opts.logfile);
203    
204          if (create_file(logfile, S_IRUSR | S_IWUSR))          if (create_file(opts.logfile, S_IRUSR | S_IWUSR))
205                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
206    
207          logfp = fopen(logfile, "a");          logfp = fopen(opts.logfile, "a");
208          if (logfp == NULL) {          if (logfp == NULL) {
209                  error("opening log file %s: %s\n", logfile, strerror(errno));                  error("opening log file %s: %s\n", opts.logfile,
210                        strerror(errno));
211                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
212          }          }
213          return 0;          return 0;

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26