1133211Sharti/* 2156066Sharti * Copyright (C) 2004-2005 3133211Sharti * Hartmut Brandt. 4133211Sharti * All rights reserved. 5133211Sharti * 6133211Sharti * Author: Harti Brandt <harti@freebsd.org> 7133211Sharti * 8133211Sharti * Redistribution and use in source and binary forms, with or without 9133211Sharti * modification, are permitted provided that the following conditions 10133211Sharti * are met: 11133211Sharti * 1. Redistributions of source code must retain the above copyright 12133211Sharti * notice, this list of conditions and the following disclaimer. 13133211Sharti * 2. Redistributions in binary form must reproduce the above copyright 14133211Sharti * notice, this list of conditions and the following disclaimer in the 15133211Sharti * documentation and/or other materials provided with the distribution. 16133211Sharti * 17133211Sharti * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18133211Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19133211Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20133211Sharti * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 21133211Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22133211Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23133211Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24133211Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25133211Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26133211Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27133211Sharti * SUCH DAMAGE. 28133211Sharti * 29156066Sharti * $Begemot: bsnmp/lib/support.h,v 1.2 2005/10/06 07:14:59 brandt_h Exp $ 30133211Sharti * 31133211Sharti * Functions that are missing on certain systems. This header file is not 32133211Sharti * to be installed. 33133211Sharti */ 34133211Sharti#ifndef bsnmp_support_h_ 35133211Sharti#define bsnmp_support_h_ 36133211Sharti 37133211Sharti#include <sys/cdefs.h> 38133211Sharti 39133211Sharti#ifndef HAVE_ERR_H 40133211Shartivoid err(int, const char *, ...) __printflike(2, 3) __dead2; 41133211Shartivoid errx(int, const char *, ...) __printflike(2, 3) __dead2; 42133211Sharti 43133211Shartivoid warn(const char *, ...) __printflike(1, 2); 44133211Shartivoid warnx(const char *, ...) __printflike(1, 2); 45133211Sharti#endif 46133211Sharti 47133211Sharti#ifndef HAVE_STRLCPY 48133211Shartisize_t strlcpy(char *, const char *, size_t); 49133211Sharti#endif 50133211Sharti 51133211Sharti#ifndef HAVE_GETADDRINFO 52133211Sharti 53133211Shartistruct addrinfo { 54133211Sharti u_int ai_flags; 55133211Sharti int ai_family; 56133211Sharti int ai_socktype; 57133211Sharti int ai_protocol; 58133211Sharti struct sockaddr *ai_addr; 59133211Sharti int ai_addrlen; 60133211Sharti struct addrinfo *ai_next; 61133211Sharti}; 62133211Sharti#define AI_CANONNAME 0x0001 63133211Sharti 64133211Shartiint getaddrinfo(const char *, const char *, const struct addrinfo *, 65133211Sharti struct addrinfo **); 66133211Sharticonst char *gai_strerror(int); 67133211Shartivoid freeaddrinfo(struct addrinfo *); 68133211Sharti 69133211Sharti#endif 70133211Sharti 71156066Sharti/* 72156066Sharti * For systems with missing stdint.h or inttypes.h 73156066Sharti */ 74156066Sharti#if !defined(INT32_MIN) 75156066Sharti#define INT32_MIN (-0x7fffffff-1) 76133211Sharti#endif 77156066Sharti#if !defined(INT32_MAX) 78156066Sharti#define INT32_MAX (0x7fffffff) 79156066Sharti#endif 80156066Sharti#if !defined(UINT32_MAX) 81156066Sharti#define UINT32_MAX (0xffffffff) 82156066Sharti#endif 83156066Sharti 84156066Sharti/* 85156066Sharti * Systems missing SA_SIZE(). Taken from FreeBSD net/route.h:1.63 86156066Sharti */ 87156066Sharti#ifndef SA_SIZE 88156066Sharti 89156066Sharti#define SA_SIZE(sa) \ 90156066Sharti ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \ 91156066Sharti sizeof(long) : \ 92156066Sharti 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) 93156066Sharti 94156066Sharti#endif 95156066Sharti 96156066Sharti#endif 97