11 |
|
|
12 |
|
|
13 |
extern int options; |
extern int options; |
14 |
extern account_data account; |
extern char logfile[PATH_MAX]; |
15 |
static FILE *logfp; /* Points to logfile. */ |
static FILE *logfp; /* Points to logfile. */ |
16 |
|
|
17 |
|
|
38 |
|
|
39 |
va_start(args, errmsg); |
va_start(args, errmsg); |
40 |
|
|
41 |
if (account.logfile[0]) { |
if (logfile[0]) { |
42 |
vfprintf(logfp, errmsg, args); |
vfprintf(logfp, errmsg, args); |
43 |
} |
} |
44 |
|
|
52 |
*/ |
*/ |
53 |
int open_logfile(void) |
int open_logfile(void) |
54 |
{ |
{ |
55 |
if (!(account.logfile[0])) |
if (!(logfile[0])) |
56 |
return SUCCESS; /* Logging not enabled. */ |
return SUCCESS; /* Logging not enabled. */ |
57 |
|
|
58 |
#ifdef DEBUG |
#ifdef DEBUG |
59 |
printf("debug: logfile: %s\n", account.logfile); |
printf("debug: logfile: %s\n", logfile); |
60 |
#endif |
#endif |
61 |
|
|
62 |
logfp = fopen(account.logfile, "a"); |
logfp = fopen(logfile, "a"); |
63 |
|
|
64 |
if (!logfp) { |
if (!logfp) { |
65 |
fprintf(stderr, "imapfilter: opening logfile %s: %s\n", |
fprintf(stderr, "imapfilter: opening logfile %s: %s\n", |
66 |
account.logfile, strerror(errno)); |
logfile, strerror(errno)); |
67 |
return FAILURE; |
return FAILURE; |
68 |
} |
} |
69 |
|
|
76 |
*/ |
*/ |
77 |
int close_logfile(void) |
int close_logfile(void) |
78 |
{ |
{ |
79 |
if (!(account.logfile[0])) |
if (!(logfile[0])) |
80 |
return SUCCESS; |
return SUCCESS; |
81 |
else |
else |
82 |
return fclose(logfp); |
return fclose(logfp); |
90 |
{ |
{ |
91 |
va_list args; |
va_list args; |
92 |
|
|
93 |
if (account.logfile[0]) { |
if (logfile[0]) { |
94 |
va_start(args, info); |
va_start(args, info); |
95 |
vfprintf(logfp, info, args); |
vfprintf(logfp, info, args); |
96 |
va_end(args); |
va_end(args); |