]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/resolve.c
fix "beeing" typo
[ngircd-alex.git] / src / ngircd / resolve.c
index 041c15620b1585c56f84dd45c8fa7a17f55b0c1a..bccf5180f65ce0b839db30e28105986d40d49f85 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2003 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2009 by Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,8 +14,6 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: resolve.c,v 1.29 2008/02/26 22:04:17 fw Exp $";
-
 #include "imp.h"
 #include <assert.h>
 #include <errno.h>
@@ -92,7 +90,7 @@ Resolve_Addr(RES_STAT * s, const ng_ipaddr_t *Addr, int identsock,
 
        pid = Resolver_fork(pipefd);
        if (pid > 0) {
-               Log(LOG_DEBUG, "Resolver for %s created (PID %d).", ng_ipaddr_tostr(Addr), pid);
+               LogDebug("Resolver for %s created (PID %d).", ng_ipaddr_tostr(Addr), pid);
 
                s->pid = pid;
                s->resolver_fd = pipefd[0];
@@ -146,8 +144,8 @@ Resolve_Init(RES_STAT *s)
 }
 
 
-#ifndef WANT_IPV6
-#ifdef h_errno
+#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
+#if !defined(WANT_IPV6) && defined(h_errno)
 static char *
 Get_Error( int H_Error )
 {
@@ -164,8 +162,8 @@ Get_Error( int H_Error )
        }
        return "unknown error";
 }
-#endif /* h_errno */
-#endif /* WANT_IPV6 */
+#endif
+#endif
 
 
 /* Do "IDENT" (aka "AUTH") lookup and append result to resolved_addr array */
@@ -175,13 +173,12 @@ Do_IdentQuery(int identsock, array *resolved_addr)
 #ifdef IDENTAUTH
        char *res;
 
-       assert(identsock >= 0);
+       if (identsock < 0)
+               return;
 
 #ifdef DEBUG
        Log_Resolver(LOG_DEBUG, "Doing IDENT lookup on socket %d ...", identsock);
 #endif
-       if (identsock < 0)
-               return;
        res = ident_id( identsock, 10 );
 #ifdef DEBUG
        Log_Resolver(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"",
@@ -206,7 +203,7 @@ Do_IdentQuery(int identsock, array *resolved_addr)
  * the IP address in resbuf and returns false.
  * @param IpAddr ip address to resolve
  * @param resbuf result buffer to store DNS name/string representation of ip address
- * @reslen size of result buffer (must be >= NGT_INET_ADDRSTRLEN)
+ * @param reslen size of result buffer (must be >= NGT_INET_ADDRSTRLEN)
  * @return true if reverse lookup successful, false otherwise
  */
 static bool
@@ -221,7 +218,7 @@ ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen)
        *resbuf = 0;
 
        res = getnameinfo((struct sockaddr *) IpAddr, ng_ipaddr_salen(IpAddr),
-                               resbuf, reslen, NULL, 0, NI_NAMEREQD);
+                         resbuf, (socklen_t)reslen, NULL, 0, NI_NAMEREQD);
        if (res == 0)
                return true;
 
@@ -271,19 +268,21 @@ static bool
 ForwardLookup(const char *hostname, array *IpAddr)
 {
        ng_ipaddr_t addr;
+
 #ifdef HAVE_GETADDRINFO
        int res;
        struct addrinfo *a, *ai_results;
-       static struct addrinfo hints = {
+       static struct addrinfo hints;
+
 #ifndef WANT_IPV6
-               .ai_family = AF_INET,
+       hints.ai_family = AF_INET;
 #endif
 #ifdef AI_ADDRCONFIG   /* glibc has this, but not e.g. netbsd 4.0 */
-               .ai_flags = AI_ADDRCONFIG,
+       hints.ai_flags = AI_ADDRCONFIG;
 #endif
-               .ai_socktype = SOCK_STREAM,
-               .ai_protocol = IPPROTO_TCP
-       };
+       hints.ai_socktype = SOCK_STREAM;
+       hints.ai_protocol = IPPROTO_TCP;
+
 #ifdef WANT_IPV6
        assert(Conf_ConnectIPv6 || Conf_ConnectIPv4);
 
@@ -292,6 +291,8 @@ ForwardLookup(const char *hostname, array *IpAddr)
        if (!Conf_ConnectIPv4)
                hints.ai_family = AF_INET6;
 #endif
+       memset(&addr, 0, sizeof(addr));
+
        res = getaddrinfo(hostname, NULL, &hints, &ai_results);
        switch (res) {
        case 0: break;
@@ -541,5 +542,6 @@ Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
        Resolve_Shutdown(s);
        return (size_t)bytes_read;
 }
-/* -eof- */
 
+
+/* -eof- */