132115b10SPawel Jakub Dawidek /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 432115b10SPawel Jakub Dawidek * Copyright (c) 2010 The FreeBSD Foundation 56d51b7d5SPawel Jakub Dawidek * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net> 632115b10SPawel Jakub Dawidek * All rights reserved. 732115b10SPawel Jakub Dawidek * 832115b10SPawel Jakub Dawidek * This software was developed by Pawel Jakub Dawidek under sponsorship from 932115b10SPawel Jakub Dawidek * the FreeBSD Foundation. 1032115b10SPawel Jakub Dawidek * 1132115b10SPawel Jakub Dawidek * Redistribution and use in source and binary forms, with or without 1232115b10SPawel Jakub Dawidek * modification, are permitted provided that the following conditions 1332115b10SPawel Jakub Dawidek * are met: 1432115b10SPawel Jakub Dawidek * 1. Redistributions of source code must retain the above copyright 1532115b10SPawel Jakub Dawidek * notice, this list of conditions and the following disclaimer. 1632115b10SPawel Jakub Dawidek * 2. Redistributions in binary form must reproduce the above copyright 1732115b10SPawel Jakub Dawidek * notice, this list of conditions and the following disclaimer in the 1832115b10SPawel Jakub Dawidek * documentation and/or other materials provided with the distribution. 1932115b10SPawel Jakub Dawidek * 2032115b10SPawel Jakub Dawidek * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 2132115b10SPawel Jakub Dawidek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2232115b10SPawel Jakub Dawidek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2332115b10SPawel Jakub Dawidek * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 2432115b10SPawel Jakub Dawidek * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2532115b10SPawel Jakub Dawidek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2632115b10SPawel Jakub Dawidek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2732115b10SPawel Jakub Dawidek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2832115b10SPawel Jakub Dawidek * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2932115b10SPawel Jakub Dawidek * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3032115b10SPawel Jakub Dawidek * SUCH DAMAGE. 3132115b10SPawel Jakub Dawidek */ 3232115b10SPawel Jakub Dawidek 3332115b10SPawel Jakub Dawidek #ifndef _SUBR_H_ 3432115b10SPawel Jakub Dawidek #define _SUBR_H_ 3532115b10SPawel Jakub Dawidek 3632115b10SPawel Jakub Dawidek #include <sys/types.h> 3732115b10SPawel Jakub Dawidek #include <stdbool.h> 3832115b10SPawel Jakub Dawidek 3932115b10SPawel Jakub Dawidek #include "hast.h" 4032115b10SPawel Jakub Dawidek 4132115b10SPawel Jakub Dawidek #define KEEP_ERRNO(work) do { \ 4232115b10SPawel Jakub Dawidek int _rerrno; \ 4332115b10SPawel Jakub Dawidek \ 4432115b10SPawel Jakub Dawidek _rerrno = errno; \ 4532115b10SPawel Jakub Dawidek work; \ 4632115b10SPawel Jakub Dawidek errno = _rerrno; \ 4732115b10SPawel Jakub Dawidek } while (0) 4832115b10SPawel Jakub Dawidek 499925a680SPawel Jakub Dawidek int vsnprlcat(char *str, size_t size, const char *fmt, va_list ap); 509925a680SPawel Jakub Dawidek int snprlcat(char *str, size_t size, const char *fmt, ...); 519925a680SPawel Jakub Dawidek 5232115b10SPawel Jakub Dawidek int provinfo(struct hast_resource *res, bool dowrite); 5332115b10SPawel Jakub Dawidek const char *role2str(int role); 54f78fe260SPawel Jakub Dawidek int drop_privs(const struct hast_resource *res); 5532115b10SPawel Jakub Dawidek 5632115b10SPawel Jakub Dawidek #endif /* !_SUBR_H_ */ 57