Commit 4433ddae authored by brendan's avatar brendan
Browse files

Karl's patch for freebsd, minus the sys/select.h test which breaks on OS X.

Also enables IPV6 in libshout!

svn path=/trunk/httpp/; revision=4884
parent 22ca9513
# Process this file with autoconf to produce a configure script.
# $Id: configure.in,v 1.41 2003/06/05 14:32:35 brendan Exp $
# $Id: configure.in,v 1.42 2003/06/05 17:09:12 brendan Exp $
m4_define(libshout_major, 2)
m4_define(libshout_minor, 0)
......@@ -36,7 +36,7 @@ dnl to be fine
case "$ac_cv_host" in
*openbsd*)
;;
*) AC_DEFINE(_XOPEN_SOURCE, 500, [Define if you have POSIX and XPG specifications])
*) AC_DEFINE(_XOPEN_SOURCE, 600, [Define if you have POSIX and XPG specifications])
;;
esac
if test -z "$GCC"; then
......@@ -68,7 +68,7 @@ dnl Checks for programs.
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h sys/socket.h sys/uio.h])
AC_CHECK_HEADERS([inttypes.h strings.h sys/socket.h sys/uio.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
......@@ -113,7 +113,9 @@ typedef int socklen_t;
dnl Checks for library functions.
AC_CHECK_FUNCS(nanosleep)
AC_CHECK_FUNCS(sethostent endhostent)
AC_CHECK_FUNCS(getnameinfo getaddrinfo inet_pton inet_aton)
AC_SEARCH_LIBS([inet_pton], [socket],
[AC_DEFINE([HAVE_INET_PTON], [1], [Define if you have the inet_pton function])])
AC_CHECK_FUNCS(getnameinfo getaddrinfo inet_aton)
dnl Extra dependencies
......
......@@ -12,6 +12,9 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <avl/avl.h>
#include "httpp.h"
......
......@@ -92,7 +92,7 @@ char *sock_get_localip(char *buff, int len)
{
char temp[1024];
if (gethostname(temp, 1024) != 0)
if (gethostname(temp, sizeof(temp)) != 0)
return NULL;
if (resolver_getip(temp, buff, len))
......@@ -588,7 +588,7 @@ sock_t sock_connect_wto(const char *hostname, const int port, const int timeout)
*/
sock_t sock_get_server_socket(const int port, char *sinterface)
{
#ifdef HAVE_IPV6
#ifdef HAVE_INET_PTON
struct sockaddr_storage sa;
#else
struct sockaddr_in sa;
......@@ -610,7 +610,7 @@ sock_t sock_get_server_socket(const int port, char *sinterface)
if (!resolver_getip(sinterface, ip, sizeof (ip)))
return SOCK_ERROR;
#ifdef HAVE_IPV6
#ifdef HAVE_INET_PTON
if (inet_pton(AF_INET, ip, &((struct sockaddr_in*)&sa)->sin_addr) > 0) {
((struct sockaddr_in*)&sa)->sin_family = AF_INET;
((struct sockaddr_in*)&sa)->sin_port = htons(port);
......@@ -667,7 +667,7 @@ int sock_listen(sock_t serversock, int backlog)
int sock_accept(sock_t serversock, char *ip, int len)
{
#ifdef HAVE_IPV6
#ifdef HAVE_INET_PTON
struct sockaddr_storage sa;
#else
struct sockaddr_in sa;
......@@ -682,7 +682,7 @@ int sock_accept(sock_t serversock, char *ip, int len)
ret = accept(serversock, (struct sockaddr *)&sa, &slen);
if (ret >= 0 && ip != NULL) {
#ifdef HAVE_IPV6
#ifdef HAVE_INET_PTON
if(((struct sockaddr_in *)&sa)->sin_family == AF_INET)
inet_ntop(AF_INET, &((struct sockaddr_in *)&sa)->sin_addr,
ip, len);
......
......@@ -107,8 +107,3 @@ int inet_aton(const char *s, struct in_addr *a);
#endif
#endif /* __SOCK_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment