/contrib/bsnmp/lib/support.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 96 lines · 44 code · 13 blank · 39 comment · 2 complexity · 315a5d51cc2893b6101f04cd5e3a46ab MD5 · raw file

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