subr.h revision 219887
1230479Snetchild/*- 2230479Snetchild * Copyright (c) 2010 The FreeBSD Foundation 3230479Snetchild * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net> 4230479Snetchild * All rights reserved. 5230479Snetchild * 6230479Snetchild * This software was developed by Pawel Jakub Dawidek under sponsorship from 7230479Snetchild * the FreeBSD Foundation. 8230479Snetchild * 9230479Snetchild * Redistribution and use in source and binary forms, with or without 10230479Snetchild * modification, are permitted provided that the following conditions 11230479Snetchild * are met: 12230479Snetchild * 1. Redistributions of source code must retain the above copyright 13230479Snetchild * notice, this list of conditions and the following disclaimer. 14230479Snetchild * 2. Redistributions in binary form must reproduce the above copyright 15230479Snetchild * notice, this list of conditions and the following disclaimer in the 16230479Snetchild * documentation and/or other materials provided with the distribution. 17230479Snetchild * 18230479Snetchild * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 19230479Snetchild * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20230479Snetchild * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21230479Snetchild * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * $FreeBSD: head/sbin/hastd/subr.h 219887 2011-03-22 21:19:51Z pjd $ 31 */ 32 33#ifndef _SUBR_H_ 34#define _SUBR_H_ 35 36#include <sys/types.h> 37#include <stdbool.h> 38 39#include "hast.h" 40 41#define KEEP_ERRNO(work) do { \ 42 int _rerrno; \ 43 \ 44 _rerrno = errno; \ 45 work; \ 46 errno = _rerrno; \ 47} while (0) 48 49int vsnprlcat(char *str, size_t size, const char *fmt, va_list ap); 50int snprlcat(char *str, size_t size, const char *fmt, ...); 51 52int provinfo(struct hast_resource *res, bool dowrite); 53const char *role2str(int role); 54int drop_privs(bool usecapsicum); 55 56#endif /* !_SUBR_H_ */ 57