Subject: [have_fix] chat/irssi patches ac,ad and ae doesn't apply correctly under linux
To: None <tech-pkg@netbsd.org>
From: Sebastian P. <sebastian-p@gmx.net>
List: tech-pkg
Date: 07/05/2003 14:52:37
--Boundary-00=_VosB/TpNdkSVnza
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi
the mentioned patches for chat/irssi doesn't apply correctly on my linux box 
without user input (but they do on my NetBSD box). 
the problem is that there is only the name of the file to be patched listed 
and not the relative path:

[snip]
diff -c -r1.17 -r1.18
*** dcc-send.c	17 Nov 2002 15:51:04 -0000	1.17
--- dcc-send.c	19 Nov 2002 12:18:11 -0000	1.18
[snip]

if using src/irc/dcc/dcc-send.c instead of just dcc-send.c works fine.
i have fixed (and attached) the three patched. they are now in the unified 
output format. tested on linux and NetBSD.

bye
sp
--Boundary-00=_VosB/TpNdkSVnza
Content-Type: text/plain;
  charset="us-ascii";
  name="distinfo"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="distinfo"

$NetBSD$

SHA1 (irssi-0.8.6.tar.bz2) = 1f7a5b409f71d7b99a30f980d2e7eaa7373a406c
Size (irssi-0.8.6.tar.bz2) = 746551 bytes
SHA1 (patch-aa) = 45d8161733f58ab3733022c823933bb1cc93a8e2
SHA1 (patch-ab) = c395fbeeb2dd15490f04f2cb2c94daf6c5955e85
SHA1 (patch-ac) = 8ed79784bc60cb9c8bc506930eaff8e031b042e1
SHA1 (patch-ad) = 32e00ce62e538b8caa97ebf2ae524225e7e62b19
SHA1 (patch-ae) = 6c35eb7193426f1b519497d2d60344d5f4d35084

--Boundary-00=_VosB/TpNdkSVnza
Content-Type: text/x-diff;
  charset="us-ascii";
  name="patch-ac"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch-ac"

--- src/irc/dcc/dcc-send.c.orig	2002-11-17 17:00:02.000000000 +0100
+++ src/irc/dcc/dcc-send.c	2003-07-05 12:54:54.000000000 +0200
@@ -400,7 +400,7 @@
 	str = g_strdup_printf(dcc->file_quoted ?
 			      "DCC SEND \"%s\" %s %d %lu" :
 			      "DCC SEND %s %s %d %lu",
-			      fname, host, port, fsize);
+			      dcc->arg, host, port, fsize);
 	dcc_ctcp_message(server, target, chat, FALSE, str);
 	g_free(str);
 

--Boundary-00=_VosB/TpNdkSVnza
Content-Type: text/x-diff;
  charset="us-ascii";
  name="patch-ad"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch-ad"

--- src/core/network.c.orig	2002-08-26 21:10:02.000000000 +0200
+++ src/core/network.c	2003-07-05 12:54:54.000000000 +0200
@@ -201,10 +201,13 @@
 	/* set our own address */
 	if (my_ip != NULL) {
 		sin_set_ip(&so, my_ip);
-		if (bind(handle, &so.sa, SIZEOF_SOCKADDR(so)) == -1) {
+		if (bind(handle, &so.sa, SIZEOF_SOCKADDR(so)) < 0) {
 			/* failed, set it back to INADDR_ANY */
-			sin_set_ip(&so, NULL);
-			bind(handle, &so.sa, SIZEOF_SOCKADDR(so));
+			int old_errno = errno;
+
+			close(handle);
+			errno = old_errno;
+			return NULL;
 		}
 	}
 
@@ -466,33 +469,31 @@
 int net_gethostbyaddr(IPADDR *ip, char **name)
 {
 #ifdef HAVE_IPV6
-	struct addrinfo req, *ai;
+	union sockaddr_union so;
 	int host_error;
+	char hostname[NI_MAXHOST];
 #else
 	struct hostent *hp;
 #endif
-	char ipname[MAX_IP_LEN];
 
 	g_return_val_if_fail(ip != NULL, -1);
 	g_return_val_if_fail(name != NULL, -1);
 
-	net_ip2host(ip, ipname);
-
 	*name = NULL;
 #ifdef HAVE_IPV6
-	memset(&req, 0, sizeof(struct addrinfo));
-	req.ai_socktype = SOCK_STREAM;
-	req.ai_flags = AI_CANONNAME;
+	memset(&so, 0, sizeof(so));
+	sin_set_ip(&so, ip);
 
 	/* save error to host_error for later use */
-	host_error = getaddrinfo(ipname, NULL, &req, &ai);
-	if (host_error != 0)
-		return host_error;
-	*name = g_strdup(ai->ai_canonname);
+        host_error = getnameinfo((struct sockaddr *) &so, sizeof(so),
+                                 hostname, sizeof(hostname), NULL, 0, 0);
+        if (host_error != 0)
+                return host_error;
 
-	freeaddrinfo(ai);
+	*name = g_strdup(hostname);
 #else
-	hp = gethostbyaddr(ipname, strlen(ipname), AF_INET);
+	if (ip->family != AF_INET) return -1;
+	hp = gethostbyaddr(&ip->ip, 4, AF_INET);
 	if (hp == NULL) return -1;
 
 	*name = g_strdup(hp->h_name);

--Boundary-00=_VosB/TpNdkSVnza
Content-Type: text/x-diff;
  charset="us-ascii";
  name="patch-ae"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch-ae"

--- src/irc/core/modes.c.orig	2002-10-31 18:30:03.000000000 +0100
+++ src/irc/core/modes.c	2003-07-05 12:54:54.000000000 +0200
@@ -512,7 +512,6 @@
 			curmode = cmd_get_param(&modestr);
 			if (*curmode == '\0')
 				break;
-			continue;
 		}
 
 		if (*curmode == '+' || *curmode == '-') {

--Boundary-00=_VosB/TpNdkSVnza--