xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision c1f8818c70b0a2dda195c4121f78004f13ef6c05)
1 /*	$OpenBSD: syslogd.h,v 1.37 2023/10/12 22:36:54 bluhm 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(const char *, const char *, const char *,
38     struct sockaddr *, size_t);
39 int   priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
40 
41 #define IOVCNT		7
42 
43 /* Terminal message */
44 #define TTYMSGTIME	1		/* timeout used by ttymsg */
45 #define TTYMAXDELAY	256		/* max events in ttymsg */
46 void ttymsg(char *, struct iovec *);
47 
48 /* File descriptor send/recv */
49 void send_fd(int, int);
50 int  receive_fd(int);
51 
52 #define ERRBUFSIZE	256
53 void vlogmsg(int pri, const char *, const char *, va_list);
54 __dead void die(int);
55 extern int Debug;
56 
57 struct ringbuf {
58 	char *buf;
59 	size_t len, start, end;
60 };
61 
62 struct ringbuf *ringbuf_init(size_t);
63 void		ringbuf_free(struct ringbuf *);
64 void		ringbuf_clear(struct ringbuf *);
65 size_t		ringbuf_used(struct ringbuf *);
66 int		ringbuf_append_line(struct ringbuf *, char *);
67 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
68