subr.h revision 256281
1300313Ssjg/*-
2236769Sobrien * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
3236769Sobrien * All rights reserved.
4236769Sobrien *
5236769Sobrien * Redistribution and use in source and binary forms, with or without
6236769Sobrien * modification, are permitted provided that the following conditions
7236769Sobrien * are met:
8236769Sobrien * 1. Redistributions of source code must retain the above copyright
9236769Sobrien *    notice, this list of conditions and the following disclaimer.
10236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright
11236769Sobrien *    notice, this list of conditions and the following disclaimer in the
12236769Sobrien *    documentation and/or other materials provided with the distribution.
13236769Sobrien *
14236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15236769Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16236769Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17236769Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18236769Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19236769Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20236769Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21236769Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22236769Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23236769Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24236769Sobrien * SUCH DAMAGE.
25236769Sobrien *
26236769Sobrien * $P4: //depot/projects/trustedbsd/openbsm/bin/auditdistd/subr.h#1 $
27236769Sobrien */
28236769Sobrien
29236769Sobrien#ifndef	_AUDITDISTD_SUBR_H_
30236769Sobrien#define	_AUDITDISTD_SUBR_H_
31236769Sobrien
32236769Sobrien#include <sys/types.h>
33236769Sobrien
34236769Sobrien#include "auditdistd.h"
35236769Sobrien
36236769Sobrien#define	KEEP_ERRNO(work)	do {					\
37236769Sobrien	int _rerrno;							\
38236769Sobrien									\
39236769Sobrien	_rerrno = errno;						\
40236769Sobrien	work;								\
41236769Sobrien	errno = _rerrno;						\
42236769Sobrien} while (0)
43236769Sobrien
44236769Sobrienint vsnprlcat(char *str, size_t size, const char *fmt, va_list ap);
45236769Sobrienint snprlcat(char *str, size_t size, const char *fmt, ...);
46236769Sobrien
47236769Sobrienconst char *role2str(int role);
48236769Sobrienconst char *adist_errstr(int error);
49236769Sobrien
50236769Sobrienvoid adreq_log(int loglevel, int debuglevel, int error, struct adreq *adreq,
51236769Sobrien    const char *fmt, ...);
52236769Sobrien
53236769Sobrienint adist_random(unsigned char *buf, size_t size);
54236769Sobrien
55236769Sobrienint wait_for_dir_init(int fd);
56236769Sobrienint wait_for_file_init(int fd);
57236769Sobrienvoid wait_for_dir(void);
58236769Sobrienvoid wait_for_file(void);
59236769Sobrien
60236769Sobrien#endif	/* !_AUDITDISTD_SUBR_H_ */
61236769Sobrien