xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1 /*	$OpenBSD: syslogd.h,v 1.23 2015/10/23 16:28:52 bluhm Exp $ */
2 
3 /*
4  * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <sys/uio.h>
22 
23 /* Privilege separation */
24 int   priv_init(char *, int, int, int, char **);
25 int   priv_open_tty(const char *);
26 int   priv_open_log(const char *);
27 FILE *priv_open_utmp(void);
28 FILE *priv_open_config(void);
29 void  priv_config_parse_done(void);
30 int   priv_config_modified(void);
31 int   priv_getaddrinfo(char *, char *, char *, struct sockaddr *, size_t);
32 int   priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
33 
34 /* Terminal message */
35 #define TTYMSGTIME	1		/* timeout used by ttymsg */
36 #define TTYMAXDELAY	256		/* max events in ttymsg */
37 char *ttymsg(struct iovec *, int, char *);
38 
39 /* File descriptor send/recv */
40 void send_fd(int, int);
41 int  receive_fd(int);
42 
43 /* The list of domain sockets */
44 #define MAXUNIX	21
45 extern int nunix;
46 extern char *path_unix[MAXUNIX];
47 extern char *path_ctlsock;
48 extern int fd_ctlsock, fd_ctlconn, fd_klog, fd_sendsys;
49 extern int fd_udp, fd_udp6, fd_bind, fd_listen, fd_tls, fd_unix[MAXUNIX];
50 
51 #define MAXLINE		8192		/* maximum line length */
52 #define ERRBUFSIZE	256
53 void logdebug(const char *, ...) __attribute__((__format__ (printf, 1, 2)));
54 extern int Debug;
55 extern int Startup;
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