From 88de69e80f77a8ad79a1a03534b346f1a8d48ed6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 7 Jan 2005 21:17:18 +0000 Subject: * Solaris 2.8 compat * C++ compat git-svn-id: file:///home/lennart/svn/public/libasyncns/trunk@11 cc0fb855-19ed-0310-866e-8c1d96e4abae --- Makefile.am | 2 +- configure.ac | 3 +++ doc/README.html.in | 2 +- libasyncns/Makefile.am | 2 +- libasyncns/asyncns.c | 25 +++++++++++++++++++++++-- libasyncns/asyncns.h | 8 ++++++++ 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4a3c4ff..b6a0917 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,7 +35,7 @@ homepage: all dist doxygen test -d $$HOME/homepage/private mkdir -p $$HOME/homepage/private/projects/libasyncns $$HOME/homepage/private/projects/libasyncns/doxygen cp libasyncns-@PACKAGE_VERSION@.tar.gz $$HOME/homepage/private/projects/libasyncns - cp doc/README.html doc/FAQ.html doc/cli.html doc/daemon.html doc/modules.html doc/style.css $$HOME/homepage/private/projects/libasyncns + cp doc/README.html doc/style.css $$HOME/homepage/private/projects/libasyncns cp -a doxygen/html/* $$HOME/homepage/private/projects/libasyncns/doxygen cp $$HOME/homepage/private/projects/libasyncns/README.html $$HOME/homepage/private/projects/libasyncns/index.html diff --git a/configure.ac b/configure.ac index 4eb0200..581c086 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,9 @@ AC_FUNC_SELECT_ARGTYPES AC_TYPE_SIGNAL AC_CHECK_FUNCS([memset select strndup setresuid setreuid]) +AC_CHECK_LIB(nsl, gethostbyname) +AC_CHECK_LIB(socket, connect) + # If using GCC specify some additional parameters if test "x$GCC" = "xyes" ; then CFLAGS="$CFLAGS -pipe -W -Wall -pedantic" diff --git a/doc/README.html.in b/doc/README.html.in index 7514ec5..0376f72 100644 --- a/doc/README.html.in +++ b/doc/README.html.in @@ -86,7 +86,7 @@ documentation from the source tree)

Requirements

-

Currently, libasyncns is tested on Linux only.

+

Currently, libasyncns is tested on Linux and Solaris (sparc-sun-solaris2.8) only.

libasyncns was developed and tested on Debian GNU/Linux "testing" from January 2005, it should work on most other Linux diff --git a/libasyncns/Makefile.am b/libasyncns/Makefile.am index 8568caf..b89e3a9 100644 --- a/libasyncns/Makefile.am +++ b/libasyncns/Makefile.am @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -AM_CFLAGS=-D_GNU_SOURCE +AM_CFLAGS=-D_GNU_SOURCE -D__EXTENSIONS__ lib_LTLIBRARIES=libasyncns.la libasyncns_la_SOURCES=asyncns.c asyncns.h diff --git a/libasyncns/asyncns.c b/libasyncns/asyncns.c index fd74133..6976256 100644 --- a/libasyncns/asyncns.c +++ b/libasyncns/asyncns.c @@ -121,6 +121,27 @@ typedef struct nameinfo_response { int ret; } nameinfo_response_t; +#ifndef HAVE_STRNDUP + +static char *strndup(const char *s, size_t l) { + size_t a; + char *n; + + a = strlen(s); + if (a > l) + a = l; + + if (!(n = malloc(a+1))) + return NULL; + + strncpy(n, s, a); + n[a] = 0; + + return n; +} + +#endif + static int fd_nonblock(int fd) { int i; assert(fd >= 0); @@ -301,7 +322,7 @@ static int worker(int in_fd, int out_fd) { #ifdef HAVE_SETRESUID setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid); #elif HAVE_SETREUID - setuid(pw->pw_uid, pw->pw_uid); + setreuid(pw->pw_uid, pw->pw_uid); #else setuid(pw->pw_uid); seteuid(pw->pw_uid); @@ -487,7 +508,7 @@ static void *unserialize_addrinfo(void *p, struct addrinfo **ret_ai, size_t *len struct addrinfo *ai; assert(p); assert(ret_ai); - assert(index); + assert(length); if (*length < sizeof(addrinfo_serialization_t)) return NULL; diff --git a/libasyncns/asyncns.h b/libasyncns/asyncns.h index 6efcccc..ac5f789 100644 --- a/libasyncns/asyncns.h +++ b/libasyncns/asyncns.h @@ -44,6 +44,10 @@ /** \example asyncns-test.c * An example program */ +#ifdef __cplusplus +extern "C" { +#endif + /** An opaque libasyncns session structure */ typedef struct asyncns asyncns_t; @@ -124,4 +128,8 @@ void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata) * prior to this call it returns NULL. */ void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q); +#ifdef __cplusplus +} +#endif + #endif -- cgit