xref: /openbsd/usr.sbin/syslogd/syslogd.h (revision d89ec533)
1 /*	$OpenBSD: syslogd.h,v 1.35 2021/09/10 15:18:36 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 /* Privilege separation */
27 void  priv_init(int, int, int, char **);
28 __dead void priv_exec(char *, int, int, int, char **);
29 int   priv_open_tty(const char *);
30 int   priv_open_log(const char *);
31 FILE *priv_open_utmp(void);
32 FILE *priv_open_config(void);
33 void  priv_config_parse_done(void);
34 int   priv_config_modified(void);
35 int   priv_getaddrinfo(char *, char *, char *, struct sockaddr *, size_t);
36 int   priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
37 
38 #define IOVCNT		7
39 
40 /* Terminal message */
41 #define TTYMSGTIME	1		/* timeout used by ttymsg */
42 #define TTYMAXDELAY	256		/* max events in ttymsg */
43 void ttymsg(char *, struct iovec *);
44 
45 /* File descriptor send/recv */
46 void send_fd(int, int);
47 int  receive_fd(int);
48 
49 #define ERRBUFSIZE	256
50 void vlogmsg(int pri, const char *, const char *, va_list);
51 __dead void die(int);
52 extern int Debug;
53 
54 struct ringbuf {
55 	char *buf;
56 	size_t len, start, end;
57 };
58 
59 struct ringbuf *ringbuf_init(size_t);
60 void		ringbuf_free(struct ringbuf *);
61 void		ringbuf_clear(struct ringbuf *);
62 size_t		ringbuf_used(struct ringbuf *);
63 int		ringbuf_append_line(struct ringbuf *, char *);
64 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
65