$OpenBSD: patch-source_commands_c,v 1.2 2002/06/30 18:23:31 brad Exp $
--- source/commands.c.orig	Mon Jan  8 01:24:22 2001
+++ source/commands.c	Thu Feb 28 17:29:03 2002
@@ -2604,13 +2604,13 @@ BUILT_IN_COMMAND(e_hostname)
 		int i;
 		char *newhost = NULL;
 #if !defined(__linux__) && !defined(__EMX__)
-#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701
+#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701 || defined(__OpenBSD__)
 		char device[80];
 #endif
 #endif
 
 		tmpnam(filename);
-#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701
+#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701 || defined(__OpenBSD__)
 		if (!(p = path_search("netstat", "/sbin:/usr/sbin:/bin:/usr/bin")))
 		{
 			yell("No Netstat to be found");
@@ -2637,10 +2637,16 @@ BUILT_IN_COMMAND(e_hostname)
 			unlink(filename);
 			return;
 		}
-#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701
+#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701 || defined(__OpenBSD__)
 		fgets(comm, 200, fptr);
 		fgets(comm, 200, fptr);
 		p = next_arg(comm, &q);
+#ifdef __OpenBSD__
+		while ((*p == 'l') && (*(p+1) == 'o')) {
+			fgets(comm, 200, fptr);
+			p = next_arg(comm, &q);
+		}
+#endif
 		strncpy(device, p, 79);
 		bitchsay("Looking for hostnames on device %s", device);
 #else
@@ -2655,7 +2661,7 @@ BUILT_IN_COMMAND(e_hostname)
 			if (strstr(comm, "inet6 addr") || strstr(comm, "inet addr"))
 #else
 			if (strstr(comm, "inet addr"))
-#endif
+#endif /* ifdef IPV6 */
 			{
 				/* inet addr:127.0.0.1  Mask:... */
 				/* inet6 addr: ::1/128 Scope:... */
@@ -2672,11 +2678,15 @@ BUILT_IN_COMMAND(e_hostname)
 				}
 				*q = 0;
 
-#elif defined(_BSDI_VERSION) && _BSDI_VERSION < 199701
+#elif defined(_BSDI_VERSION) && _BSDI_VERSION < 199701 || defined(__OpenBSD__)
 			if (!strncmp(comm, device, strlen(device)))
 			{
 				p = comm;
+#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199701
 				p += 24;
+#elif defined(__OpenBSD__)
+				p += strlen("Name    Mtu   Network     ")-1;
+#endif
 				while (*p && *p == ' ') p++;
 				q = strchr(p, ' ');
 				*q = 0;
