1258945Sroberto#include <config.h>
2258945Sroberto
3258945Sroberto#include "log.h"
4258945Sroberto
5289764Sglebiusconst char *progname;		/* for msyslog use too */
6258945Sroberto
7289764Sglebiusstatic int counter = 0;
8289764Sglebius
9258945Srobertostatic void cleanup_log(void);
10258945Sroberto
11258945Srobertovoid
12280849Scysntp_init_logging(
13280849Scy	const char *prog
14280849Scy	)
15258945Sroberto{
16289764Sglebius
17258945Sroberto	msyslog_term = TRUE;
18280849Scy	init_logging(prog, 0, FALSE);
19280849Scy	msyslog_term_pid = FALSE;
20280849Scy	msyslog_include_timestamp = FALSE;
21258945Sroberto}
22258945Sroberto
23258945Sroberto
24258945Srobertovoid
25258945Srobertoopen_logfile(
26258945Sroberto	const char *logfile
27258945Sroberto	)
28258945Sroberto{
29280849Scy	change_logfile(logfile, FALSE);
30289764Sglebius	counter = 1; //counter++;
31258945Sroberto	atexit(cleanup_log);
32258945Sroberto}
33258945Sroberto
34289764Sglebius//not sure about this. Are the atexit() functions called by FIFO or LIFO order? The end result is PROBABLY the same
35258945Srobertostatic void
36258945Srobertocleanup_log(void)
37258945Sroberto{
38289764Sglebius	//counter--;
39289764Sglebius	//if(counter <= 0){
40289764Sglebius	if(counter == 1){
41289764Sglebius		syslogit = TRUE;
42289764Sglebius		fflush(syslog_file);
43289764Sglebius		fclose(syslog_file);
44289764Sglebius		syslog_file = NULL;
45289764Sglebius		counter = 0;
46289764Sglebius	}
47258945Sroberto}
48