1244557Sbrooks/* $FreeBSD: stable/11/lib/libnetbsd/util.h 332979 2018-04-25 01:30:29Z benno $ */ 2244557Sbrooks 3244557Sbrooks/*- 4244557Sbrooks * Copyright (c) 2012 SRI International 5244557Sbrooks * Copyright (c) 1995 6244557Sbrooks * The Regents of the University of California. All rights reserved. 7244557Sbrooks * 8244557Sbrooks * Redistribution and use in source and binary forms, with or without 9244557Sbrooks * modification, are permitted provided that the following conditions 10244557Sbrooks * are met: 11244557Sbrooks * 1. Redistributions of source code must retain the above copyright 12244557Sbrooks * notice, this list of conditions and the following disclaimer. 13244557Sbrooks * 2. Redistributions in binary form must reproduce the above copyright 14244557Sbrooks * notice, this list of conditions and the following disclaimer in the 15244557Sbrooks * documentation and/or other materials provided with the distribution. 16244557Sbrooks * 3. Neither the name of the University nor the names of its contributors 17244557Sbrooks * may be used to endorse or promote products derived from this software 18244557Sbrooks * without specific prior written permission. 19244557Sbrooks * 20244557Sbrooks * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21244557Sbrooks * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22244557Sbrooks * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23244557Sbrooks * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24244557Sbrooks * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25244557Sbrooks * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26244557Sbrooks * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27244557Sbrooks * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28244557Sbrooks * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29244557Sbrooks * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30244557Sbrooks * SUCH DAMAGE. 31244557Sbrooks */ 32244557Sbrooks 33314021Sngie#ifndef _LIBNETBSD_UTIL_H_ 34314021Sngie#define _LIBNETBSD_UTIL_H_ 35244557Sbrooks 36314021Sngie#include <sys/types.h> 37244557Sbrooks#include <libutil.h> 38244557Sbrooks 39332979Sbennovoid (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...); 40332979Sbennosize_t estrlcpy(char *, const char *, size_t); 41332979Sbennosize_t estrlcat(char *, const char *, size_t); 42332979Sbennochar *estrdup(const char *); 43332979Sbennochar *estrndup(const char *, size_t); 44332979Sbennovoid *emalloc(size_t); 45332979Sbennovoid *ecalloc(size_t, size_t); 46332979Sbennovoid *erealloc(void *, size_t); 47332979Sbennostruct __sFILE *efopen(const char *, const char *); 48332979Sbennoint easprintf(char ** __restrict, const char * __restrict, ...) 49332979Sbenno __printflike(2, 3); 50332979Sbennoint evasprintf(char ** __restrict, const char * __restrict, __va_list) 51332979Sbenno __printflike(2, 0); 52244557Sbrookschar *flags_to_string(u_long flags, const char *def); 53316098Svangyzenint sockaddr_snprintf(char *, size_t, const char *, 54316098Svangyzen const struct sockaddr *); 55244557Sbrooksint string_to_flags(char **stringp, u_long *setp, u_long *clrp); 56244557Sbrooks 57314021Sngie#endif 58