subr.h revision 219887
11558Srgrimes/*- 21558Srgrimes * Copyright (c) 2010 The FreeBSD Foundation 31558Srgrimes * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net> 41558Srgrimes * All rights reserved. 51558Srgrimes * 61558Srgrimes * This software was developed by Pawel Jakub Dawidek under sponsorship from 71558Srgrimes * the FreeBSD Foundation. 81558Srgrimes * 91558Srgrimes * Redistribution and use in source and binary forms, with or without 101558Srgrimes * modification, are permitted provided that the following conditions 111558Srgrimes * are met: 121558Srgrimes * 1. Redistributions of source code must retain the above copyright 131558Srgrimes * notice, this list of conditions and the following disclaimer. 141558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151558Srgrimes * notice, this list of conditions and the following disclaimer in the 161558Srgrimes * documentation and/or other materials provided with the distribution. 171558Srgrimes * 181558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 191558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 221558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281558Srgrimes * SUCH DAMAGE. 291558Srgrimes * 30102411Scharnier * $FreeBSD: head/sbin/hastd/subr.h 219887 2011-03-22 21:19:51Z pjd $ 311558Srgrimes */ 3223675Speter 33102411Scharnier#ifndef _SUBR_H_ 3441477Sjulian#define _SUBR_H_ 35102411Scharnier 36102411Scharnier#include <sys/types.h> 37102411Scharnier#include <stdbool.h> 381558Srgrimes 3974556Smckusick#include "hast.h" 4023675Speter 411558Srgrimes#define KEEP_ERRNO(work) do { \ 421558Srgrimes int _rerrno; \ 4323799Sbde \ 4423675Speter _rerrno = errno; \ 45142123Sdelphij work; \ 46103949Smike errno = _rerrno; \ 471558Srgrimes} while (0) 4823675Speter 491558Srgrimesint vsnprlcat(char *str, size_t size, const char *fmt, va_list ap); 501558Srgrimesint snprlcat(char *str, size_t size, const char *fmt, ...); 51183820Skib 5274556Smckusickint provinfo(struct hast_resource *res, bool dowrite); 537585Sbdeconst char *role2str(int role); 5492839Simpint drop_privs(bool usecapsicum); 551558Srgrimes 5698542Smckusick#endif /* !_SUBR_H_ */ 5774556Smckusick