1d6d1624harti/*
29b4fc3dharti * Copyright (C) 2004-2005
3d6d1624harti *	Hartmut Brandt.
4d6d1624harti *	All rights reserved.
5d6d1624harti *
6d6d1624harti * Author: Harti Brandt <harti@freebsd.org>
76a228a1ngie *
8d6d1624harti * Redistribution and use in source and binary forms, with or without
9d6d1624harti * modification, are permitted provided that the following conditions
10d6d1624harti * are met:
11d6d1624harti * 1. Redistributions of source code must retain the above copyright
12d6d1624harti *    notice, this list of conditions and the following disclaimer.
13d6d1624harti * 2. Redistributions in binary form must reproduce the above copyright
14d6d1624harti *    notice, this list of conditions and the following disclaimer in the
15d6d1624harti *    documentation and/or other materials provided with the distribution.
166a228a1ngie *
17d6d1624harti * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18d6d1624harti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19d6d1624harti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20d6d1624harti * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21d6d1624harti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22d6d1624harti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23d6d1624harti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24d6d1624harti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25d6d1624harti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26d6d1624harti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27d6d1624harti * SUCH DAMAGE.
28d6d1624harti *
299b4fc3dharti * $Begemot: bsnmp/lib/support.h,v 1.2 2005/10/06 07:14:59 brandt_h Exp $
30d6d1624harti *
31d6d1624harti * Functions that are missing on certain systems. This header file is not
32d6d1624harti * to be installed.
33d6d1624harti */
34d6d1624harti#ifndef bsnmp_support_h_
35d6d1624harti#define bsnmp_support_h_
36d6d1624harti
37d6d1624harti#include <sys/cdefs.h>
38d6d1624harti
39d6d1624harti#ifndef HAVE_ERR_H
40d6d1624hartivoid err(int, const char *, ...) __printflike(2, 3) __dead2;
41d6d1624hartivoid errx(int, const char *, ...) __printflike(2, 3) __dead2;
42d6d1624harti
43d6d1624hartivoid warn(const char *, ...) __printflike(1, 2);
44d6d1624hartivoid warnx(const char *, ...) __printflike(1, 2);
45d6d1624harti#endif
46d6d1624harti
47d6d1624harti#ifndef HAVE_STRLCPY
48d6d1624hartisize_t strlcpy(char *, const char *, size_t);
49d6d1624harti#endif
50d6d1624harti
51d6d1624harti#ifndef HAVE_GETADDRINFO
52d6d1624harti
53d6d1624hartistruct addrinfo {
54d6d1624harti	u_int	ai_flags;
55d6d1624harti	int	ai_family;
56d6d1624harti	int	ai_socktype;
57d6d1624harti	int	ai_protocol;
58d6d1624harti	struct sockaddr *ai_addr;
59d6d1624harti	int	ai_addrlen;
60d6d1624harti	struct addrinfo *ai_next;
61d6d1624harti};
62d6d1624harti#define	AI_CANONNAME	0x0001
63d6d1624harti
64d6d1624hartiint getaddrinfo(const char *, const char *, const struct addrinfo *,
65d6d1624harti    struct addrinfo **);
66d6d1624harticonst char *gai_strerror(int);
67d6d1624hartivoid freeaddrinfo(struct addrinfo *);
68d6d1624harti
69d6d1624harti#endif
70d6d1624harti
719b4fc3dharti/*
729b4fc3dharti * For systems with missing stdint.h or inttypes.h
739b4fc3dharti */
749b4fc3dharti#if !defined(INT32_MIN)
759b4fc3dharti#define	INT32_MIN	(-0x7fffffff-1)
769b4fc3dharti#endif
779b4fc3dharti#if !defined(INT32_MAX)
789b4fc3dharti#define	INT32_MAX	(0x7fffffff)
799b4fc3dharti#endif
809b4fc3dharti#if !defined(UINT32_MAX)
819b4fc3dharti#define	UINT32_MAX	(0xffffffff)
829b4fc3dharti#endif
839b4fc3dharti
849b4fc3dharti/*
859b4fc3dharti * Systems missing SA_SIZE(). Taken from FreeBSD net/route.h:1.63
869b4fc3dharti */
879b4fc3dharti#ifndef SA_SIZE
889b4fc3dharti
899b4fc3dharti#define SA_SIZE(sa)						\
909b4fc3dharti    (  (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ?	\
919b4fc3dharti	sizeof(long)		:				\
929b4fc3dharti	1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
939b4fc3dharti
949b4fc3dharti#endif
959b4fc3dharti
96d6d1624harti#endif
97