xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision 99fd087599a8791921855f21bd7e36130f39aadc)
1 /*	$OpenBSD: syslogd.h,v 1.33 2019/07/05 13:23:27 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 /* Terminal message */
39 #define TTYMSGTIME	1		/* timeout used by ttymsg */
40 #define TTYMAXDELAY	256		/* max events in ttymsg */
41 void ttymsg(struct iovec *, int, char *);
42 
43 /* File descriptor send/recv */
44 void send_fd(int, int);
45 int  receive_fd(int);
46 
47 #define ERRBUFSIZE	256
48 void vlogmsg(int pri, const char *, const char *, va_list);
49 __dead void die(int);
50 extern int Debug;
51 
52 struct ringbuf {
53 	char *buf;
54 	size_t len, start, end;
55 };
56 
57 struct ringbuf *ringbuf_init(size_t);
58 void		ringbuf_free(struct ringbuf *);
59 void		ringbuf_clear(struct ringbuf *);
60 size_t		ringbuf_used(struct ringbuf *);
61 int		ringbuf_append_line(struct ringbuf *, char *);
62 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
63