xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*
2  * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 
20 /* Privilege separation */
21 int   priv_init(char *, int, int, int, char **);
22 int   priv_open_tty(const char *);
23 int   priv_open_log(const char *);
24 FILE *priv_open_utmp(void);
25 FILE *priv_open_config(void);
26 void  priv_config_parse_done(void);
27 int   priv_config_modified(void);
28 int   priv_gethostserv(char *, char *, struct sockaddr *, size_t);
29 int   priv_gethostbyaddr(char *, int, int, char *, size_t);
30 
31 /* Terminal message */
32 char *ttymsg(struct iovec *, int, char *, int);
33 
34 /* File descriptor send/recv */
35 void send_fd(int, int);
36 int  receive_fd(int);
37 
38 /* The list of domain sockets */
39 #define MAXFUNIX	21
40 extern int nfunix;
41 extern char *funixn[MAXFUNIX];
42 extern char *ctlsock_path;
43 
44 #define dprintf		if (Debug) printf
45 extern int Debug;
46 extern int Startup;
47 
48 /* fds to poll */
49 #define PFD_KLOG	0		/* Offset of /dev/klog entry */
50 #define PFD_INET	1		/* Offset of inet socket entry */
51 #define PFD_CTLSOCK	2		/* Offset of control socket entry */
52 #define PFD_CTLCONN	3		/* Offset of control connection entry */
53 #define PFD_INET6	4		/* Offset of inet6 socket entry */
54 #define PFD_UNIX_0	5		/* Start of Unix socket entries */
55 #define N_PFD		(PFD_UNIX_0 + MAXFUNIX)	/* # of pollfd entries */
56 extern struct pollfd pfd[N_PFD];
57 
58 struct ringbuf {
59 	char *buf;
60 	size_t len, start, end;
61 };
62 
63 struct ringbuf *ringbuf_init(size_t);
64 void		ringbuf_free(struct ringbuf *);
65 void		ringbuf_clear(struct ringbuf *);
66 size_t		ringbuf_used(struct ringbuf *);
67 int		ringbuf_append_line(struct ringbuf *, char *);
68 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
69