More fixes to Mac OS X and NetBSD from Rene Hexel:
[pupnp-devel] NetBSD & Mac OS X packages and patches Okay, I found a couple more things. I have attached a patch file against the trunk (version 206) that make the repository code compile and run on both Mac OS X and NetBSD. This fixes the following issues: upnp/src/api/upnpapi.c: SIOCGIFCONF didn't work properly, use getifaddrs() instead (on BSD systems). threadutil/src/ThreadPool.c: priorities only work if _POSIX_PRIORITY_SCHEDULING is defined (and greater than 0). threadutil/src/LinkedList.c and threadutil/src/iasnprintf.c: use stdlib.h instead of malloc.h on all BSD systems (not just FreeBSD). This is important, because malloc.h does not exist on Darwin/Mac OS X. Cheers , Rene git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@207 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
837f31bacd
commit
6acffb7ede
@ -30,7 +30,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LinkedList.h"
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/param.h>
|
||||
#if (defined(BSD) && BSD >= 199306)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
|
@ -96,12 +96,14 @@ SetPolicyType( PolicyType in )
|
||||
#else
|
||||
#ifdef WIN32
|
||||
return sched_setscheduler( 0, in);
|
||||
#else
|
||||
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||
struct sched_param current;
|
||||
|
||||
sched_getparam( 0, ¤t );
|
||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||
return sched_setscheduler( 0, in, ¤t );
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -123,7 +125,7 @@ SetPolicyType( PolicyType in )
|
||||
static int
|
||||
SetPriority( ThreadPriority priority )
|
||||
{
|
||||
|
||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||
int currentPolicy;
|
||||
int minPriority = 0;
|
||||
int maxPriority = 0;
|
||||
@ -155,7 +157,9 @@ SetPriority( ThreadPriority priority )
|
||||
|
||||
return pthread_setschedparam( ithread_self(), currentPolicy,
|
||||
&newPriority );
|
||||
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/param.h>
|
||||
#if (defined(BSD) && BSD >= 199306)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -53,6 +54,11 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#if (defined(BSD) && BSD >= 199306)
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "upnpapi.h"
|
||||
#include "httpreadwrite.h"
|
||||
@ -3717,8 +3723,44 @@ void printNodes( IXML_Node * tmpRoot, int depth )
|
||||
strcpy( out, inet_ntoa(LocalAddr.sin_addr));
|
||||
}
|
||||
return UPNP_E_SUCCESS;
|
||||
#else
|
||||
#elif (defined(BSD) && BSD >= 199306)
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
|
||||
if (getifaddrs(&ifap) != 0) {
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"DiscoverInterfaces: getifaddrs() returned error\n" );
|
||||
return UPNP_E_INIT;
|
||||
}
|
||||
|
||||
// cycle through available interfaces
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
// Skip loopback, point-to-point and down interfaces,
|
||||
// except don't skip down interfaces
|
||||
// if we're trying to get a list of configurable interfaces.
|
||||
if( ( ifa->ifa_flags & IFF_LOOPBACK )
|
||||
|| ( !( ifa->ifa_flags & IFF_UP ) ) ) {
|
||||
continue;
|
||||
}
|
||||
if( ifa->ifa_addr->sa_family == AF_INET ) {
|
||||
// We don't want the loopback interface.
|
||||
if( ((struct sockaddr_in *)(ifa->ifa_addr))->sin_addr.s_addr ==
|
||||
htonl( INADDR_LOOPBACK ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
strncpy( out, inet_ntoa( ((struct sockaddr_in *)(ifa->ifa_addr))->
|
||||
sin_addr ), LINE_SIZE );
|
||||
out[LINE_SIZE-1] = '\0';
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Inside getlocalhostname : after strncpy %s\n",
|
||||
out );
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifap);
|
||||
|
||||
return ifa ? UPNP_E_SUCCESS : UPNP_E_INIT;
|
||||
#else
|
||||
char szBuffer[MAX_INTERFACES * sizeof( struct ifreq )];
|
||||
struct ifconf ifConf;
|
||||
struct ifreq ifReq;
|
||||
|
Loading…
x
Reference in New Issue
Block a user