1 /***************************************************************************
2     syslog.c  -  handles syslog messages
3                              -------------------
4     begin                : Thu Jan 13 2000
5     copyright            : (C) 1998-2000 by pnm2ppa project
6     email                :
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifdef HAVE_CONFIG_H
19 # include "config.h"
20 #endif
21 
22 /*Michael Mancini <gwaihir@email.com>
23   16 Jan 2000
24   BeOS syslog() wrapper
25   syslog.c
26   modified Duncan Haldane <duncan_haldane@users.sourceforge.net>
27   Oct 2000. all syslog messages arrive here wrapped.
28 */
29 
30 #include  <stdio.h>
31 #include "ppa_syslog.h"
32 #include "global.h"
33 
34 BOOLEAN verbose = false ;
35 
36 /*
37   For some reason, BeOS doesn't seem to implement syslog(), even though it is
38   included with the system.  Wierd.  This wraps the syslog functions used
39   and writes the info to the stderr stream, if __NO_SYSLOG__ is defined.
40 */
41 
42 
43 void
wrap_syslog(int log_pri,char * fmt,char * message)44 wrap_syslog(int log_pri, char *fmt, char *message )
45 {
46   if  (!(gSilent)) {
47 #ifdef __NO_SYSLOG__
48       gVerbose = true;
49 #else
50       if (gLogInfo || log_pri != LOG_INFO)
51 	syslog ( log_pri , "%s", message );
52       else if(verbose)
53 	fprintf(stderr,"pnm2ppa: %s",message);
54 #endif
55   }
56 
57   if (gVerbose)
58     {
59       /* Send the syslog data to the stderr stream */
60       fprintf(stderr,"pnm2ppa: %s",message);
61     }
62   return ;
63 }
64 
wrap_openlog(char * ident,int level)65 void wrap_openlog( char *ident, int level )
66 {
67 #ifndef __NO_SYSLOG__
68   if ( level ) {
69       /* level 1  also sends messages  to stderr */
70 #ifdef __NO_LOG_PERROR__
71     /* for systems (e.g. Solaris) where LOG_PERROR is not valid */
72       openlog ( ident, LOG_CONS | LOG_PID, LOG_LPR);
73       gVerbose = true;
74 #else
75       openlog ( ident, LOG_PERROR | LOG_CONS | LOG_PID, LOG_LPR);
76       verbose = gVerbose;
77       gVerbose = false;
78 #endif
79   }
80   else {
81       /*  standard level 0, messages sent to syslog only */
82       openlog ( ident, LOG_CONS | LOG_PID, LOG_LPR);
83       verbose = gVerbose;
84       gVerbose = false;
85     }
86 #endif
87   return;
88 }
89 
90 void
wrap_closelog(void)91 wrap_closelog( void)
92 {
93 #ifndef __NO_SYSLOG__
94   closelog();
95 #endif
96   return;
97 }
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110