1 #include "namespace.h"
2 #include <sys/types.h>
3 #include <sys/syslog.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <stdarg.h>
8 #include "extern.h"
9 
10 #ifdef __weak_alias
__weak_alias(closelog,_closelog)11 __weak_alias(closelog,_closelog)
12 __weak_alias(openlog,_openlog)
13 __weak_alias(setlogmask,_setlogmask)
14 __weak_alias(syslog,_syslog)
15 __weak_alias(vsyslog,_vsyslog)
16 __weak_alias(syslogp,_syslogp)
17 __weak_alias(vsyslogp,_vsyslogp)
18 #endif
19 
20 void
21 openlog(const char *path, int opt, int fac)
22 {
23 }
24 
25 void
closelog(void)26 closelog(void)
27 {
28 }
29 
30 int
setlogmask(int mask)31 setlogmask(int mask)
32 {
33           return 0xff;
34 }
35 
36 void
syslog(int fac,const char * fmt,...)37 syslog(int fac, const char *fmt, ...)
38 {
39           va_list ap;
40           va_start(ap, fmt);
41           vsyslog(fac, fmt, ap);
42           va_end(ap);
43 }
44 
45 void
vsyslog(int fac,const char * fmt,va_list ap)46 vsyslog(int fac, const char *fmt, va_list ap)
47 {
48           (void)vfprintf(stderr, fmt, ap);
49           /* Cheap hack to ensure %m causes error message string to be shown */
50           if (strstr(fmt, "%m"))
51                     (void)fprintf(stderr, " (%s)", strerror(errno));
52           (void)fprintf(stderr, "\n");
53           fflush(stderr);
54 }
55 
56 void
syslog_ss(int priority,struct syslog_data * data,const char * fmt,...)57 syslog_ss(int priority, struct syslog_data *data, const char *fmt, ...)
58 {
59           va_list ap;
60           va_start(ap, fmt);
61           vsyslog(priority, fmt, ap);
62           va_end(ap);
63 }
64 
65 void
vsyslog_ss(int priority,struct syslog_data * data,const char * fmt,va_list ap)66 vsyslog_ss(int priority, struct syslog_data *data, const char *fmt, va_list ap)
67 {
68           vsyslog(priority, fmt, ap);
69 }
70 
71 void
syslog_r(int priority,struct syslog_data * data,const char * fmt,...)72 syslog_r(int priority, struct syslog_data *data, const char *fmt, ...)
73 {
74           va_list ap;
75           va_start(ap, fmt);
76           vsyslog(priority, fmt, ap);
77           va_end(ap);
78 }
79 
80 void
vsyslog_r(int priority,struct syslog_data * data,const char * fmt,va_list ap)81 vsyslog_r(int priority, struct syslog_data *data, const char *fmt, va_list ap)
82 {
83           vsyslog(priority, fmt, ap);
84 }
85 
86 void
closelog_r(struct syslog_data * data)87 closelog_r(struct syslog_data *data)
88 {
89 }
90 
91 int
setlogmask_r(int maskpri,struct syslog_data * data)92 setlogmask_r(int maskpri, struct syslog_data *data)
93 {
94           return 0xff;
95 }
96 
97 void
openlog_r(const char * id,int logopt,int facility,struct syslog_data * data)98 openlog_r(const char *id, int logopt, int facility, struct syslog_data *data)
99 {
100 }
101 
102 void
syslogp_r(int priority,struct syslog_data * data,const char * msgid,const char * sdfmt,const char * fmt,...)103 syslogp_r(int priority, struct syslog_data *data, const char *msgid,
104     const char *sdfmt, const char *fmt, ...)
105 {
106           va_list ap;
107           va_start(ap, fmt);
108           vsyslog(priority, fmt, ap);
109           va_end(ap);
110 }
111 
112 void
vsyslogp_r(int priority,struct syslog_data * data,const char * msgid,const char * sdfmt,const char * fmt,va_list ap)113 vsyslogp_r(int priority, struct syslog_data *data, const char *msgid,
114     const char *sdfmt, const char *fmt, va_list ap)
115 {
116           vsyslog(priority, fmt, ap);
117 }
118 
119 void
syslogp_ss(int priority,struct syslog_data * data,const char * msgid,const char * sdfmt,const char * fmt,...)120 syslogp_ss(int priority, struct syslog_data *data, const char *msgid,
121     const char *sdfmt, const char *fmt, ...)
122 {
123           va_list ap;
124           va_start(ap, fmt);
125           vsyslog(priority, fmt, ap);
126           va_end(ap);
127 }
128 
129 void
vsyslogp_ss(int priority,struct syslog_data * data,const char * msgid,const char * sdfmt,const char * fmt,va_list ap)130 vsyslogp_ss(int priority, struct syslog_data *data, const char *msgid,
131     const char *sdfmt, const char *fmt, va_list ap)
132 {
133           vsyslog(priority, fmt, ap);
134 }
135 
136 void
syslogp(int priority,const char * msgid,const char * sdfmt,const char * fmt,...)137 syslogp(int priority, const char *msgid, const char *sdfmt, const char *fmt,
138     ...)
139 {
140           va_list ap;
141           va_start(ap, fmt);
142           vsyslog(priority, fmt, ap);
143           va_end(ap);
144 }
145 
146 void
vsyslogp(int priority,const char * msgid,const char * sdfmt,const char * fmt,va_list ap)147 vsyslogp(int priority, const char *msgid, const char *sdfmt, const char *fmt,
148     va_list ap)
149 {
150           vsyslog(priority, fmt, ap);
151 }
152