⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apr_network.m4

📁 Apache官方在今天放出产品系列2.2的最新版本2.2.11的源码包 最流行的HTTP服务器软件之一
💻 M4
📖 第 1 页 / 共 2 页
字号:
dnl -------------------------------------------------------- -*- autoconf -*-dnl Licensed to the Apache Software Foundation (ASF) under one or morednl contributor license agreements.  See the NOTICE file distributed withdnl this work for additional information regarding copyright ownership.dnl The ASF licenses this file to You under the Apache License, Version 2.0dnl (the "License"); you may not use this file except in compliance withdnl the License.  You may obtain a copy of the License atdnldnl     http://www.apache.org/licenses/LICENSE-2.0dnldnl Unless required by applicable law or agreed to in writing, softwarednl distributed under the License is distributed on an "AS IS" BASIS,dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.dnl See the License for the specific language governing permissions anddnl limitations under the License.dnl -----------------------------------------------------------------dnl apr_network.m4: APR's autoconf macros for testing network supportdnldnldnl check for type in_addrdnlAC_DEFUN(APR_TYPE_IN_ADDR,[  AC_CACHE_CHECK(for type in_addr, ac_cv_type_in_addr,[  AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef HAVE_WINSOCK2_H#include <winsock2.h>#endif],[ struct in_addr arg; arg.s_addr = htonl(INADDR_ANY);], [ ac_cv_type_in_addr="yes"] , [ac_cv_type_in_addr="no"])])])dnldnl check for working getaddrinfo()dnldnl Note that if the system doesn't have gai_strerror(), wednl can't use getaddrinfo() because we can't get stringsdnl describing the error codes.dnlAC_DEFUN([APR_CHECK_WORKING_GETADDRINFO], [  AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[  AC_TRY_RUN( [#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STRING_H#include <string.h>#endif#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_SYS_SOCKET_H#include <sys/socket.h>#endifvoid main(void) {    struct addrinfo hints, *ai;    int error;    memset(&hints, 0, sizeof(hints));    hints.ai_family = AF_UNSPEC;    hints.ai_socktype = SOCK_STREAM;    error = getaddrinfo("127.0.0.1", NULL, &hints, &ai);    if (error) {        exit(1);    }    if (ai->ai_addr->sa_family != AF_INET) {        exit(1);    }    exit(0);}],[  ac_cv_working_getaddrinfo="yes"],[  ac_cv_working_getaddrinfo="no"],[  ac_cv_working_getaddrinfo="yes"])])if test "$ac_cv_working_getaddrinfo" = "yes"; then  if test "$ac_cv_func_gai_strerror" != "yes"; then    ac_cv_working_getaddrinfo="no"  else    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works well enough for APR])  fifi])dnl Check whether the AI_ADDRCONFIG flag can be used with getaddrinfoAC_DEFUN([APR_CHECK_GETADDRINFO_ADDRCONFIG], [  AC_CACHE_CHECK(for working AI_ADDRCONFIG, apr_cv_gai_addrconfig, [  AC_TRY_RUN([#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STRING_H#include <string.h>#endif#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_SYS_SOCKET_H#include <sys/socket.h>#endifint main(int argc, char **argv) {    struct addrinfo hints, *ai;    memset(&hints, 0, sizeof(hints));    hints.ai_family = AF_UNSPEC;    hints.ai_socktype = SOCK_STREAM;    hints.ai_flags = AI_ADDRCONFIG;    return getaddrinfo("localhost", NULL, &hints, &ai) != 0;}], [apr_cv_gai_addrconfig=yes],     [apr_cv_gai_addrconfig=no],    [apr_cv_gai_addrconfig=no])])if test $apr_cv_gai_addrconfig = yes; then   AC_DEFINE(HAVE_GAI_ADDRCONFIG, 1, [Define if getaddrinfo accepts the AI_ADDRCONFIG flag])fi])dnldnl check for working getnameinfo()dnlAC_DEFUN([APR_CHECK_WORKING_GETNAMEINFO], [  AC_CACHE_CHECK(for working getnameinfo, ac_cv_working_getnameinfo,[  AC_TRY_RUN( [#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STRING_H#include <string.h>#endif#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_SYS_SOCKET_H#include <sys/socket.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endifvoid main(void) {    struct sockaddr_in sa;    char hbuf[256];    int error;    sa.sin_family = AF_INET;    sa.sin_port = 0;    sa.sin_addr.s_addr = inet_addr("127.0.0.1");#ifdef SIN6_LEN    sa.sin_len = sizeof(sa);#endif    error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa),                        hbuf, 256, NULL, 0,                        NI_NUMERICHOST);    if (error) {        exit(1);    } else {        exit(0);    }}],[  ac_cv_working_getnameinfo="yes"],[  ac_cv_working_getnameinfo="no"],[  ac_cv_working_getnameinfo="yes"])])if test "$ac_cv_working_getnameinfo" = "yes"; then  AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define if getnameinfo exists])fi])dnldnl check for negative error codes for getaddrinfo()dnlAC_DEFUN([APR_CHECK_NEGATIVE_EAI], [  AC_CACHE_CHECK(for negative error codes for getaddrinfo, ac_cv_negative_eai,[  AC_TRY_RUN( [#ifdef HAVE_NETDB_H#include <netdb.h>#endifvoid main(void) {    if (EAI_ADDRFAMILY < 0) {        exit(0);    }    exit(1);}],[  ac_cv_negative_eai="yes"],[  ac_cv_negative_eai="no"],[  ac_cv_negative_eai="no"])])if test "$ac_cv_negative_eai" = "yes"; then  AC_DEFINE(NEGATIVE_EAI, 1, [Define if EAI_ error codes from getaddrinfo are negative])fi])dnldnl Checks the definition of gethostbyname_r and gethostbyaddr_rdnl which are different for glibc, solaris and assorted other operatingdnl systemsdnldnl Note that this test is executed too early to see if we have all ofdnl the headers.AC_DEFUN([APR_CHECK_GETHOSTBYNAME_R_STYLE], [dnl Try and compile a glibc2 gethostbyname_r piece of code, and set thednl style of the routines to glibc2 on successAC_CACHE_CHECK([style of gethostbyname_r routine], ac_cv_gethostbyname_r_style,APR_TRY_COMPILE_NO_WARNING([#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef HAVE_ARPA_INET_H#include <arpa/inet.h>#endif#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif],[int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0,                           (char *) 0, 0, (struct hostent **) 0, &tmp);/* use tmp to suppress the warning */tmp=0;], ac_cv_gethostbyname_r_style=glibc2, ac_cv_gethostbyname_r_style=none))if test "$ac_cv_gethostbyname_r_style" = "glibc2"; then    AC_DEFINE(GETHOSTBYNAME_R_GLIBC2, 1, [Define if gethostbyname_r has the glibc style])fiAC_CACHE_CHECK([3rd argument to the gethostbyname_r routines], ac_cv_gethostbyname_r_arg,APR_TRY_COMPILE_NO_WARNING([#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef HAVE_ARPA_INET_H#include <arpa/inet.h>#endif#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif],[int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0,                           (struct hostent_data *) 0);/* use tmp to suppress the warning */tmp=0;], ac_cv_gethostbyname_r_arg=hostent_data, ac_cv_gethostbyname_r_arg=char))if test "$ac_cv_gethostbyname_r_arg" = "hostent_data"; then    AC_DEFINE(GETHOSTBYNAME_R_HOSTENT_DATA, 1, [Define if gethostbyname_r has the hostent_data for the third argument])fi])dnldnl Checks the definition of getservbyname_rdnl which are different for glibc, solaris and assorted other operatingdnl systemsdnldnl Note that this test is executed too early to see if we have all ofdnl the headers.AC_DEFUN([APR_CHECK_GETSERVBYNAME_R_STYLE], [dnl Try and compile a glibc2 getservbyname_r piece of code, and set thednl style of the routines to glibc2 on successAC_CACHE_CHECK([style of getservbyname_r routine], ac_cv_getservbyname_r_style, [APR_TRY_COMPILE_NO_WARNING([#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef HAVE_ARPA_INET_H#include <arpa/inet.h>#endif#ifdef HAVE_NETDB_H#include <netdb.h>#endif#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif],[int tmp = getservbyname_r((const char *) 0, (const char *) 0,                          (struct servent *) 0, (char *) 0, 0,                          (struct servent **) 0);/* use tmp to suppress the warning */tmp=0;], ac_cv_getservbyname_r_style=glibc2, ac_cv_getservbyname_r_style=none)if test "$ac_cv_getservbyname_r_style" = "none"; then    dnl Try and compile a Solaris getservbyname_r piece of code, and set the    dnl style of the routines to solaris on success    APR_TRY_COMPILE_NO_WARNING([    #ifdef HAVE_SYS_TYPES_H    #include <sys/types.h>    #endif    #ifdef HAVE_NETINET_IN_H    #include <netinet/in.h>    #endif    #ifdef HAVE_ARPA_INET_H    #include <arpa/inet.h>    #endif    #ifdef HAVE_NETDB_H    #include <netdb.h>    #endif    #ifdef HAVE_STDLIB_H    #include <stdlib.h>    #endif    ],[    struct servent *tmp = getservbyname_r((const char *) 0, (const char *) 0,                                          (struct servent *) 0, (char *) 0, 0);    /* use tmp to suppress the warning */    tmp=NULL;    ], ac_cv_getservbyname_r_style=solaris, ac_cv_getservbyname_r_style=none)fiif test "$ac_cv_getservbyname_r_style" = "none"; then    dnl Try and compile a OSF/1 getservbyname_r piece of code, and set the    dnl style of the routines to osf1 on success    APR_TRY_COMPILE_NO_WARNING([    #ifdef HAVE_SYS_TYPES_H    #include <sys/types.h>    #endif    #ifdef HAVE_NETINET_IN_H    #include <netinet/in.h>    #endif    #ifdef HAVE_ARPA_INET_H    #include <arpa/inet.h>    #endif    #ifdef HAVE_NETDB_H    #include <netdb.h>    #endif    #ifdef HAVE_STDLIB_H    #include <stdlib.h>    #endif    ],[    int tmp = getservbyname_r((const char *) 0, (const char *) 0,                              (struct servent *) 0, (struct servent_data *) 0);    /* use tmp to suppress the warning */    tmp=0;    ], ac_cv_getservbyname_r_style=osf1, ac_cv_getservbyname_r_style=none)fi])if test "$ac_cv_getservbyname_r_style" = "glibc2"; then    AC_DEFINE(GETSERVBYNAME_R_GLIBC2, 1, [Define if getservbyname_r has the glibc style])elif test "$ac_cv_getservbyname_r_style" = "solaris"; then    AC_DEFINE(GETSERVBYNAME_R_SOLARIS, 1, [Define if getservbyname_r has the Solaris style])elif test "$ac_cv_getservbyname_r_style" = "osf1"; then    AC_DEFINE(GETSERVBYNAME_R_OSF1, 1, [Define if getservbyname_r has the OSF/1 style])fi])dnldnl see if TCP_NODELAY setting is inherited from listening socketsdnlAC_DEFUN([APR_CHECK_TCP_NODELAY_INHERITED], [  AC_CACHE_CHECK(if TCP_NODELAY setting is inherited from listening sockets, ac_cv_tcp_nodelay_inherited,[  AC_TRY_RUN( [#include <stdio.h>#ifdef HAVE_SYS_TYPES_H#include <sys/types.h>#endif#ifdef HAVE_SYS_SOCKET_H#include <sys/socket.h>#endif#ifdef HAVE_NETINET_IN_H#include <netinet/in.h>#endif#ifdef HAVE_NETINET_TCP_H#include <netinet/tcp.h>#endif#ifndef HAVE_SOCKLEN_Ttypedef int socklen_t;#endifint main(void) {    int listen_s, connected_s, client_s;    int listen_port, rc;    struct sockaddr_in sa;    socklen_t sa_len;    socklen_t option_len;    int option;    listen_s = socket(AF_INET, SOCK_STREAM, 0);    if (listen_s < 0) {        perror("socket");        exit(1);    }    option = 1;    rc = setsockopt(listen_s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof option);    if (rc < 0) {        perror("setsockopt TCP_NODELAY");        exit(1);    }    memset(&sa, 0, sizeof sa);    sa.sin_family = AF_INET;#ifdef BEOS    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);#endif    /* leave port 0 to get ephemeral */    rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa);    if (rc < 0) {        perror("bind for ephemeral port");        exit(1);    }    /* find ephemeral port */    sa_len = sizeof(sa);    rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len);    if (rc < 0) {        perror("getsockname");        exit(1);    }    listen_port = sa.sin_port;    rc = listen(listen_s, 5);    if (rc < 0) {        perror("listen");        exit(1);    }    client_s = socket(AF_INET, SOCK_STREAM, 0);    if (client_s < 0) {        perror("socket");        exit(1);    }    memset(&sa, 0, sizeof sa);    sa.sin_family = AF_INET;    sa.sin_port   = listen_port;#ifdef BEOS    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);#endif    /* leave sin_addr all zeros to use loopback */    rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa);    if (rc < 0) {        perror("connect");        exit(1);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -