16bea8766SBrooks Davis /* $FreeBSD$ */ 26bea8766SBrooks Davis 36bea8766SBrooks Davis /*- 4*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 5*8a16b7a1SPedro F. Giffuni * 66bea8766SBrooks Davis * Copyright (c) 2012 SRI International 76bea8766SBrooks Davis * Copyright (c) 1995 86bea8766SBrooks Davis * The Regents of the University of California. All rights reserved. 96bea8766SBrooks Davis * 106bea8766SBrooks Davis * Redistribution and use in source and binary forms, with or without 116bea8766SBrooks Davis * modification, are permitted provided that the following conditions 126bea8766SBrooks Davis * are met: 136bea8766SBrooks Davis * 1. Redistributions of source code must retain the above copyright 146bea8766SBrooks Davis * notice, this list of conditions and the following disclaimer. 156bea8766SBrooks Davis * 2. Redistributions in binary form must reproduce the above copyright 166bea8766SBrooks Davis * notice, this list of conditions and the following disclaimer in the 176bea8766SBrooks Davis * documentation and/or other materials provided with the distribution. 186bea8766SBrooks Davis * 3. Neither the name of the University nor the names of its contributors 196bea8766SBrooks Davis * may be used to endorse or promote products derived from this software 206bea8766SBrooks Davis * without specific prior written permission. 216bea8766SBrooks Davis * 226bea8766SBrooks Davis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 236bea8766SBrooks Davis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 246bea8766SBrooks Davis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 256bea8766SBrooks Davis * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 266bea8766SBrooks Davis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 276bea8766SBrooks Davis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 286bea8766SBrooks Davis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 296bea8766SBrooks Davis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 306bea8766SBrooks Davis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 316bea8766SBrooks Davis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 326bea8766SBrooks Davis * SUCH DAMAGE. 336bea8766SBrooks Davis */ 346bea8766SBrooks Davis 35acf26de3SEnji Cooper #ifndef _LIBNETBSD_UTIL_H_ 36acf26de3SEnji Cooper #define _LIBNETBSD_UTIL_H_ 376bea8766SBrooks Davis 38eec0029fSEnji Cooper #include <sys/types.h> 396bea8766SBrooks Davis #include <libutil.h> 406bea8766SBrooks Davis 41df948968SEd Maste void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...); 42df948968SEd Maste size_t estrlcpy(char *, const char *, size_t); 43df948968SEd Maste size_t estrlcat(char *, const char *, size_t); 44df948968SEd Maste char *estrdup(const char *); 45df948968SEd Maste char *estrndup(const char *, size_t); 46df948968SEd Maste void *emalloc(size_t); 47df948968SEd Maste void *ecalloc(size_t, size_t); 48df948968SEd Maste void *erealloc(void *, size_t); 49df948968SEd Maste struct __sFILE *efopen(const char *, const char *); 50df948968SEd Maste int easprintf(char ** __restrict, const char * __restrict, ...) 51df948968SEd Maste __printflike(2, 3); 52df948968SEd Maste int evasprintf(char ** __restrict, const char * __restrict, __va_list) 53df948968SEd Maste __printflike(2, 0); 546bea8766SBrooks Davis char *flags_to_string(u_long flags, const char *def); 55f5b9907cSEric van Gyzen int sockaddr_snprintf(char *, size_t, const char *, 56f5b9907cSEric van Gyzen const struct sockaddr *); 576bea8766SBrooks Davis int string_to_flags(char **stringp, u_long *setp, u_long *clrp); 586bea8766SBrooks Davis 59e0f389edSEnji Cooper #endif 60