1204076Spjd/*-
2204076Spjd * Copyright (c) 2010 The FreeBSD Foundation
3219887Spjd * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
4204076Spjd * All rights reserved.
5204076Spjd *
6204076Spjd * This software was developed by Pawel Jakub Dawidek under sponsorship from
7204076Spjd * the FreeBSD Foundation.
8204076Spjd *
9204076Spjd * Redistribution and use in source and binary forms, with or without
10204076Spjd * modification, are permitted provided that the following conditions
11204076Spjd * are met:
12204076Spjd * 1. Redistributions of source code must retain the above copyright
13204076Spjd *    notice, this list of conditions and the following disclaimer.
14204076Spjd * 2. Redistributions in binary form must reproduce the above copyright
15204076Spjd *    notice, this list of conditions and the following disclaimer in the
16204076Spjd *    documentation and/or other materials provided with the distribution.
17204076Spjd *
18204076Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
19204076Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20204076Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21204076Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
22204076Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23204076Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24204076Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25204076Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26204076Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27204076Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28204076Spjd * SUCH DAMAGE.
29204076Spjd *
30204076Spjd * $FreeBSD$
31204076Spjd */
32204076Spjd
33204076Spjd#ifndef	_SUBR_H_
34204076Spjd#define	_SUBR_H_
35204076Spjd
36204076Spjd#include <sys/types.h>
37204076Spjd#include <stdbool.h>
38204076Spjd
39204076Spjd#include "hast.h"
40204076Spjd
41204076Spjd#define	KEEP_ERRNO(work)	do {					\
42204076Spjd	int _rerrno;							\
43204076Spjd									\
44204076Spjd	_rerrno = errno;						\
45204076Spjd	work;								\
46204076Spjd	errno = _rerrno;						\
47204076Spjd} while (0)
48204076Spjd
49219815Spjdint vsnprlcat(char *str, size_t size, const char *fmt, va_list ap);
50219815Spjdint snprlcat(char *str, size_t size, const char *fmt, ...);
51219815Spjd
52204076Spjdint provinfo(struct hast_resource *res, bool dowrite);
53204076Spjdconst char *role2str(int role);
54231017Strocinyint drop_privs(const struct hast_resource *res);
55204076Spjd
56204076Spjd#endif	/* !_SUBR_H_ */
57