2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_RCSID("@(#)$Id: syslogio.c,v 1.29 2001/09/11 04:04:49 gshapiro Exp $")
18 # include <sm/rpool.h>
25 ** This is a output file type that copies its output to the syslog daemon.
26 ** Each line of output is written as a separate syslog message.
27 ** The client is responsible for calling openlog() before writing to
28 ** any syslog file, and calling closelog() after all syslog output is complete.
29 ** The only state associated with a syslog file is 'int priority',
30 ** which we store in fp->f_ival.
34 ** SM_SYSLOGOPEN -- open a file pointer to syslog
37 ** fp -- file pointer assigned for the open
38 ** info -- priority level of the syslog messages
43 ** 0 (zero) success always (see Overall)
47 sm_syslogopen(fp
, info
, flags
, rpool
)
53 int *priority
= (int *)info
;
55 fp
->f_ival
= *priority
;
60 ** SM_SYSLOGREAD -- read function for syslog
62 ** This is a "stub" function (placeholder) that always returns an error.
63 ** It is an error to read syslog.
66 ** fp -- the file pointer
67 ** buf -- buffer to place the data read
68 ** n -- number of bytes to read
71 ** -1 (error) always and sets errno
75 sm_syslogread(fp
, buf
, n
)
80 /* an error to read */
86 ** SM_SYSLOGWRITE -- write function for syslog
88 ** Send output to syslog.
91 ** fp -- the file pointer
92 ** buf -- buffer that the write data comes from
93 ** n -- number of bytes to write
96 ** 0 (zero) for success always
100 ** XXX TODO: more work needs to be done to ensure that each line of output
101 ** XXX written to a syslog file is mapped to exactly one syslog message.
104 sm_syslogwrite(fp
, buf
, n
)
109 syslog(fp
->f_ival
, "%s", buf
);
114 ** SM_SYSLOGSEEK -- position the syslog file offset
116 ** This is a "stub" function (placeholder) that always returns an error.
117 ** It is an error to seek syslog.
120 ** fp -- the file pointer
121 ** offset -- the new offset position relative to 'whence'
122 ** whence -- flag indicating start of 'offset'
125 ** -1 (error) always.
129 sm_syslogseek(fp
, offset
, whence
)
139 ** SM_SYSLOGCLOSE -- close the syslog file pointer
142 ** fp -- the file pointer
145 ** 0 (zero) success always (see Overall)
157 ** SM_SYSLOGSETINFO -- set information for the file pointer
160 ** fp -- the file pointer being set
161 ** what -- what information is being set
162 ** valp -- information content being set to
166 ** 0 (zero) on success
169 ** Sets internal file pointer data
173 sm_syslogsetinfo(fp
, what
, valp
)
181 fp
->f_ival
= *((int *)(valp
));
190 ** SM_SYSLOGGETINFO -- get information relating to the file pointer
193 ** fp -- the file pointer being queried
194 ** what -- the information type being queried
195 ** valp -- location to placed queried information
198 ** 0 (zero) on success
202 ** Fills in 'valp' with data.
206 sm_sysloggetinfo(fp
, what
, valp
)
214 *((int *)(valp
)) = fp
->f_ival
;