Add IPv6 support.
[srvx.git] / src / gline.c
index 8effe88aa7931ff0deb6895f2c350587854f0c12..559541340ea58aa1da4bec3540023910494ba1b1 100644 (file)
@@ -1,11 +1,12 @@
 /* gline.c - Gline database
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #include "heap.h"
@@ -168,8 +170,6 @@ static char *
 gline_alternate_target(const char *target)
 {
     const char *hostname;
-    unsigned long ip;
-    char *res;
 
     /* If no host part, bail. */
     if (!(hostname = strchr(target, '@')))
@@ -177,23 +177,17 @@ gline_alternate_target(const char *target)
     /* If host part contains wildcards, bail. */
     if (hostname[strcspn(hostname, "*?/")])
         return NULL;
-    /* If host part looks like an IP, parse it that way. */
-    if (!hostname[strspn(hostname+1, "0123456789.")+1]) {
-        struct in_addr in;
-        struct hostent *he;
-        if (inet_aton(hostname+1, &in)
-            && (he = gethostbyaddr(&in, sizeof(in), AF_INET))) {
-            res = malloc((hostname - target) + 2 + strlen(he->h_name));
-            sprintf(res, "%.*s@%s", hostname - target, target, he->h_name);
-            return res;
-        } else
-            return NULL;
-    } else if (getipbyname(hostname+1, &ip)) {
-        res = malloc((hostname - target) + 18);
-        sprintf(res, "%.*s@%lu.%lu.%lu.%lu", hostname - target, target, ip & 255, (ip >> 8) & 255, (ip >> 16) & 255, (ip >> 24) & 255);
-        return res;
-    } else
-        return NULL;
+    /* Get parsed address and canonical name for host. */
+#if 0
+    irc_in_addr_t in; /* move this to the right place */
+    if (irc_pton(&in, NULL, hostname+1)) {
+        if (getnameinfo(/*TODO*/))
+              return NULL;
+    } else if (!getaddrinfo(/*TODO*/)) {
+    } else return NULL;
+#else
+    return NULL;
+#endif
 }
 
 struct gline *