xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision c1a45aed656e7d5627c30c92421893a76f370ccb)
1 /*	$OpenBSD: syslogd.h,v 1.36 2022/01/13 10:34:07 martijn Exp $ */
2 
3 /*
4  * Copyright (c) 2014-2017 Alexander Bluhm <bluhm@genua.de>
5  * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <sys/uio.h>
23 
24 #include <stdarg.h>
25 
26 extern int	ZuluTime;
27 
28 /* Privilege separation */
29 void  priv_init(int, int, int, char **);
30 __dead void priv_exec(char *, int, int, int, char **);
31 int   priv_open_tty(const char *);
32 int   priv_open_log(const char *);
33 FILE *priv_open_utmp(void);
34 FILE *priv_open_config(void);
35 void  priv_config_parse_done(void);
36 int   priv_config_modified(void);
37 int   priv_getaddrinfo(char *, char *, char *, struct sockaddr *, size_t);
38 int   priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
39 
40 #define IOVCNT		7
41 
42 /* Terminal message */
43 #define TTYMSGTIME	1		/* timeout used by ttymsg */
44 #define TTYMAXDELAY	256		/* max events in ttymsg */
45 void ttymsg(char *, struct iovec *);
46 
47 /* File descriptor send/recv */
48 void send_fd(int, int);
49 int  receive_fd(int);
50 
51 #define ERRBUFSIZE	256
52 void vlogmsg(int pri, const char *, const char *, va_list);
53 __dead void die(int);
54 extern int Debug;
55 
56 struct ringbuf {
57 	char *buf;
58 	size_t len, start, end;
59 };
60 
61 struct ringbuf *ringbuf_init(size_t);
62 void		ringbuf_free(struct ringbuf *);
63 void		ringbuf_clear(struct ringbuf *);
64 size_t		ringbuf_used(struct ringbuf *);
65 int		ringbuf_append_line(struct ringbuf *, char *);
66 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
67