File: hl_getaddrinfo.m4

package info (click to toggle)
hamlib 3.3-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,952 kB
  • sloc: ansic: 136,360; sh: 12,250; cpp: 944; perl: 877; makefile: 607; python: 148; awk: 58
file content (139 lines) | stat: -rw-r--r-- 3,258 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Check for getaddrinfo replacement.             -*- Autoconf -*-

# Copyright (c) 2010 by Stephane Fillod
# 
# This file is part of Hamlib
# 
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


AC_DEFUN([HL_GETADDRINFO],
[

AC_CHECK_TYPES([struct addrinfo],[],[],[
     #if HAVE_NETDB_H
     # include <netdb.h>
     #endif
     #ifdef HAVE_SYS_SOCKET_H
     # include <sys/socket.h>
     #elif HAVE_WS2TCPIP_H
     # include <ws2tcpip.h>
     #endif
  ])

AC_LINK_IFELSE([AC_LANG_PROGRAM([[
    #include <sys/types.h>
    #if HAVE_NETDB_H
    # include <netdb.h>
    #endif
    #ifdef HAVE_SYS_SOCKET_H
    # include <sys/socket.h>
    #elif HAVE_WS2TCPIP_H
    # include <ws2tcpip.h>
    #endif
    #include <stddef.h>
    ]],
    [[getaddrinfo("", "", NULL, NULL);]])],
    [ac_cv_func_getaddrinfo=yes
     AC_DEFINE(HAVE_GETADDRINFO,[1],[Define if getaddrinfo is available])],
    [ac_cv_func_getaddrinfo=no])


AC_CHECK_DECLS([gai_strerror], [], [], [[
            #include <sys/types.h>
            #ifdef HAVE_SYS_SOCKET_H
            #include <sys/socket.h>
            #endif
            #ifdef HAVE_NETDB_H
            #include <netdb.h>
            #endif
            #ifdef HAVE_WS2TCPIP_H
            #include <ws2tcpip.h>
            #endif
            #include <stddef.h>
          ]])

dnl Checks for replacements
AC_REPLACE_FUNCS([getaddrinfo])

AH_BOTTOM(
[
/* Define missing prototypes, implemented in replacement lib */
#ifdef  __cplusplus
extern "C" {
#endif

#ifndef HAVE_STRUCT_ADDRINFO
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#elif HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
struct addrinfo {
    int ai_flags;
    int ai_family;
    int ai_socktype;
    int ai_protocol;
    socklen_t ai_addrlen;
    struct sockaddr *ai_addr;
};
#endif

#ifndef HAVE_GETADDRINFO

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#elif HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif

#ifndef AI_PASSIVE
#define AI_PASSIVE 0x0001
#endif

int getaddrinfo(const char *node, const char *service,
    const struct addrinfo *hints, struct addrinfo **res);
void freeaddrinfo(struct addrinfo *res);
#endif

#if !defined(HAVE_DECL_GAI_STRERROR) && !defined(gai_strerror)
const char *gai_strerror(int errcode);
#endif /* !HAVE_DECL_GAI_STRERROR */

#ifdef  __cplusplus
}
#endif
])


])