pkgsrc/net/kphone/patches/patch-ac
joerg 6a1f571296 kphone uses lrelease from qt3-tools, so depend on it and change Makefile
to not expect it in PATH. Add DragonFly support and don't try to link
with libresolv on DragonFly.
2006-01-22 01:31:43 +00:00

122 lines
3.2 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$NetBSD: patch-ac,v 1.4 2006/01/22 01:31:43 joerg Exp $
--- dissipate2/siputil.cpp.orig 2005-06-21 12:14:49.000000000 +0100
+++ dissipate2/siputil.cpp 2005-11-24 16:47:03.000000000 +0000
@@ -5,6 +5,9 @@
#include <sys/time.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
+#if defined (__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+#include <ifaddrs.h>
+#endif
#include <net/if_arp.h>
#include <net/route.h>
#include <net/if.h>
@@ -13,6 +16,7 @@
#include <qobject.h>
#include <qmessagebox.h>
#include <netdb.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
@@ -26,6 +30,8 @@
/* max number of network interfaces*/
#define MAX_IF 5
+#ifdef __linux__
+
/* Path to the route entry in proc filesystem */
#define PROCROUTE "/proc/net/route"
@@ -41,6 +47,8 @@
#define SIOCGIFCOUNT 0x8935
#endif
+#endif /* not Linux */
+
char iface[16];
@@ -62,6 +70,7 @@
 */
char *getdefaultdev()
{
+#ifdef __linux__
FILE *fp = fopen( PROCROUTE, "r");
char buff[4096], gate_addr[128], net_addr[128];
char mask_addr[128];
@@ -85,19 +94,49 @@
return iface;
}
fclose(fp);
+
/* didn't find a default gateway */
return NULL;
+#else
+ return "";
+#endif /* Linux */
}
void findFqdn( void )
{
- int sock, err, if_count, i, j = 0;
+ int if_count, i, j = 0;
+#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__))
+ int sock, err;
struct ifconf netconf;
char buffer[32*MAX_IF];
- char if_name[10][21];
- char if_addr[10][21];
+#endif
+ char if_name[MAX_IF][21];
+ char if_addr[MAX_IF][21];
char *default_ifName;
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+ struct ifaddrs *ifp, *oifp;
+
+ if(getifaddrs(&ifp) < 0 )
+ printf( "Error with getifaddrs(): %i.\n", errno );
+ oifp=ifp; /* save ifp */
+ for (if_count = 0; ifp != NULL; ifp = ifp->ifa_next) {
+ if(ifp->ifa_addr->sa_family != AF_INET) continue;
+
+ if ( strncmp( ifp->ifa_name, "lo", 2 ) != 0 ) {
+ if(j == MAX_IF) printf( "Error: cannot handle more than %d interfaces.\n",MAX_IF);
+ else
+ {
+ strncpy( if_name[j], ifp->ifa_name, 20);
+ strncpy( if_addr[j], inet_ntoa(((struct sockaddr_in *)ifp->ifa_addr)->sin_addr ), 20);
+ j++;
+ }
+ }
+ if_count++;
+ }
+ if (oifp != NULL) freeifaddrs(oifp);
+
+#else /* not FreeBSD or NetBSD or DragonFly */
netconf.ifc_len = 32 * MAX_IF;
netconf.ifc_buf = buffer;
sock=socket( PF_INET, SOCK_DGRAM, 0 );
@@ -105,9 +144,11 @@
if ( err < 0 ) printf( "Error in ioctl: %i.\n", errno );
close( sock );
if_count = netconf.ifc_len / 32;
+#endif
printf( "Found %i interfaces.\n", if_count );
//#test
+#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__))
if ( if_count == 1 ) {
strncpy( if_name[j], netconf.ifc_req[0].ifr_name, 20 );
strncpy( if_addr[j], inet_ntoa(((struct sockaddr_in*)(&netconf.ifc_req[0].ifr_addr))->sin_addr), 20 );
@@ -122,6 +163,8 @@
}
}
}
+#endif /* not FreeBSD or NetBSD or DragonFly */
+
if( j == 1 ) {
dissipate_our_fqdn = strdup( if_addr[0] );
} else {