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 --- libasyncns/Makefile.am | 2 +- libasyncns/asyncns.c | 25 +++++++++++++++++++++++-- libasyncns/asyncns.h | 8 ++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'libasyncns') 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