xref: /openbsd-src/usr.sbin/syslogd/syslogd.h (revision 6a13ef69787db04ae501a22e92fa10865b44fd7c)
1 /*	$OpenBSD: syslogd.h,v 1.26 2016/10/17 11:19:55 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 void  priv_init(int, int, int, char **);
25 __dead void priv_exec(char *, int, int, int, char **);
26 int   priv_open_tty(const char *);
27 int   priv_open_log(const char *);
28 FILE *priv_open_utmp(void);
29 FILE *priv_open_config(void);
30 void  priv_config_parse_done(void);
31 int   priv_config_modified(void);
32 int   priv_getaddrinfo(char *, char *, char *, struct sockaddr *, size_t);
33 int   priv_getnameinfo(struct sockaddr *, socklen_t, char *, size_t);
34 
35 /* Terminal message */
36 #define TTYMSGTIME	1		/* timeout used by ttymsg */
37 #define TTYMAXDELAY	256		/* max events in ttymsg */
38 char *ttymsg(struct iovec *, int, char *);
39 
40 /* File descriptor send/recv */
41 void send_fd(int, int);
42 int  receive_fd(int);
43 
44 /* The list of domain sockets */
45 extern int nunix;
46 extern char **path_unix;
47 extern char *path_ctlsock;
48 
49 #define MAXLINE		8192		/* maximum line length */
50 #define ERRBUFSIZE	256
51 void logdebug(const char *, ...) __attribute__((__format__ (printf, 1, 2)));
52 extern int Debug;
53 extern int Startup;
54 
55 struct ringbuf {
56 	char *buf;
57 	size_t len, start, end;
58 };
59 
60 struct ringbuf *ringbuf_init(size_t);
61 void		ringbuf_free(struct ringbuf *);
62 void		ringbuf_clear(struct ringbuf *);
63 size_t		ringbuf_used(struct ringbuf *);
64 int		ringbuf_append_line(struct ringbuf *, char *);
65 ssize_t		ringbuf_to_string(char *, size_t, struct ringbuf *);
66