1243730Srwatson/*-
2243730Srwatson * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
3243730Srwatson * All rights reserved.
4243730Srwatson *
5243730Srwatson * Redistribution and use in source and binary forms, with or without
6243730Srwatson * modification, are permitted provided that the following conditions
7243730Srwatson * are met:
8243730Srwatson * 1. Redistributions of source code must retain the above copyright
9243730Srwatson *    notice, this list of conditions and the following disclaimer.
10243730Srwatson * 2. Redistributions in binary form must reproduce the above copyright
11243730Srwatson *    notice, this list of conditions and the following disclaimer in the
12243730Srwatson *    documentation and/or other materials provided with the distribution.
13243730Srwatson *
14243730Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15243730Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16243730Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17243730Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18243730Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19243730Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20243730Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21243730Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22243730Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23243730Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24243730Srwatson * SUCH DAMAGE.
25243730Srwatson *
26243730Srwatson * $P4: //depot/projects/trustedbsd/openbsm/bin/auditdistd/subr.h#1 $
27243730Srwatson */
28243730Srwatson
29243730Srwatson#ifndef	_AUDITDISTD_SUBR_H_
30243730Srwatson#define	_AUDITDISTD_SUBR_H_
31243730Srwatson
32243730Srwatson#include <sys/types.h>
33243730Srwatson
34243730Srwatson#include "auditdistd.h"
35243730Srwatson
36243730Srwatson#define	KEEP_ERRNO(work)	do {					\
37243730Srwatson	int _rerrno;							\
38243730Srwatson									\
39243730Srwatson	_rerrno = errno;						\
40243730Srwatson	work;								\
41243730Srwatson	errno = _rerrno;						\
42243730Srwatson} while (0)
43243730Srwatson
44243730Srwatsonint vsnprlcat(char *str, size_t size, const char *fmt, va_list ap);
45243730Srwatsonint snprlcat(char *str, size_t size, const char *fmt, ...);
46243730Srwatson
47243730Srwatsonconst char *role2str(int role);
48243730Srwatsonconst char *adist_errstr(int error);
49243730Srwatson
50243730Srwatsonvoid adreq_log(int loglevel, int debuglevel, int error, struct adreq *adreq,
51243730Srwatson    const char *fmt, ...);
52243730Srwatson
53243730Srwatsonint adist_random(unsigned char *buf, size_t size);
54243730Srwatson
55243730Srwatsonint wait_for_dir_init(int fd);
56243730Srwatsonint wait_for_file_init(int fd);
57243730Srwatsonvoid wait_for_dir(void);
58243730Srwatsonvoid wait_for_file(void);
59243730Srwatson
60243730Srwatson#endif	/* !_AUDITDISTD_SUBR_H_ */
61