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