From 41f204029b77b059a76474a131a836ffe581ac5d Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 28 Oct 2009 07:44:45 +0000 Subject: [PATCH] * Fix some issues with uClibc. --- Makefile | 2 +- genconfig.sh | 9 +++++++++ getifaddr.c | 4 +++- getifaddr.h | 8 ++++++++ tagutils/tagutils-misc.c | 4 ++++ tagutils/tagutils.c | 6 ++++-- upnpsoap.c | 4 ++-- uuid.c | 1 - 8 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7761826..b47fddd 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ BASEOBJS = minidlna.o upnphttp.o upnpdescgen.o upnpsoap.o \ ALLOBJS = $(BASEOBJS) $(LNXOBJS) -LIBS = -lexif -ljpeg -lsqlite3 -lavformat -lid3tag -lFLAC -lvorbis +LIBS = -lpthread -lexif -ljpeg -lsqlite3 -lavformat -lid3tag -lFLAC -lvorbis #STATIC_LINKING: LIBS = -lvorbis -logg -lm -lsqlite3 -lpthread -lexif -ljpeg -lFLAC -lm -lid3tag -lz -lavformat -lavutil -lavcodec -lm TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o diff --git a/genconfig.sh b/genconfig.sh index 9be8cf0..f266ff2 100755 --- a/genconfig.sh +++ b/genconfig.sh @@ -159,6 +159,15 @@ echo "/*#define HAVE_INOTIFY_H*/" >> ${CONFIGFILE} fi echo "" >> ${CONFIGFILE} +echo "/* Enable if the system iconv.h exists. ID3 tag reading in various character sets will not work properly otherwise. */" >> ${CONFIGFILE} +if [ -f /usr/include/iconv.h ]; then +echo "#define HAVE_ICONV_H" >> ${CONFIGFILE} +else +echo -e "\nWARNING!! Iconv support not found. ID3 tag reading may not work." +echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE} +fi +echo "" >> ${CONFIGFILE} + echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE} echo "${NETGEAR}" >> ${CONFIGFILE} echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE} diff --git a/getifaddr.c b/getifaddr.c index c67ade7..b0f4919 100644 --- a/getifaddr.c +++ b/getifaddr.c @@ -109,7 +109,7 @@ getsyshwaddr(char * buf, int len) if(!ifaces) return(ret); - for(if_idx = ifaces+2; if_idx->if_index; if_idx++) + for(if_idx = ifaces; if_idx->if_index; if_idx++) { strncpy(ifr.ifr_name, if_idx->if_name, IFNAMSIZ); if(ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) @@ -118,6 +118,8 @@ getsyshwaddr(char * buf, int len) continue; if( ioctl(fd, SIOCGIFHWADDR, &ifr) < 0 ) continue; + if( MACADDR_IS_ZERO(&ifr.ifr_hwaddr.sa_data) ) + continue; ret = 0; break; } diff --git a/getifaddr.h b/getifaddr.h index b7ac3fc..0b08016 100644 --- a/getifaddr.h +++ b/getifaddr.h @@ -8,6 +8,14 @@ #define __GETIFADDR_H__ #include +#define MACADDR_IS_ZERO(x) \ + ((x[0] == 0x00) && \ + (x[1] == 0x00) && \ + (x[2] == 0x00) && \ + (x[3] == 0x00) && \ + (x[4] == 0x00) && \ + (x[5] == 0x00)) + /* getifaddr() * take a network interface name and write the * ip v4 address as text in the buffer diff --git a/tagutils/tagutils-misc.c b/tagutils/tagutils-misc.c index b772d63..eb75831 100644 --- a/tagutils/tagutils-misc.c +++ b/tagutils/tagutils-misc.c @@ -37,6 +37,7 @@ do_iconv(const char* to_ces, const char* from_ces, char *inbuf, size_t inbytesleft, char *outbuf_orig, size_t outbytesleft_orig) { +#ifdef HAVE_ICONV_H size_t rc; iconv_result ret = ICONV_OK; @@ -65,6 +66,9 @@ do_iconv(const char* to_ces, const char* from_ces, iconv_close(cd); return ret; +#else // HAVE_ICONV_H + return ICONV_FATAL; +#endif // HAVE_ICONV_H } #define N_LANG_ALT 8 diff --git a/tagutils/tagutils.c b/tagutils/tagutils.c index 2ef57a9..1669be1 100644 --- a/tagutils/tagutils.c +++ b/tagutils/tagutils.c @@ -31,13 +31,15 @@ #include #include #include -#include #include +#include #include #include #include -#include +#ifdef HAVE_ICONV_H +#include +#endif #include #include "tagutils.h" diff --git a/upnpsoap.c b/upnpsoap.c index 2875132..9384be0 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -301,6 +301,8 @@ set_filter_flags(char * filter) item = strtok_r(filter, ",", &saveptr); while( item != NULL ) { + if( saveptr ) + *(saveptr-1) = ','; if( strcmp(item, "@childCount") == 0 ) { flags |= FILTER_CHILDCOUNT; @@ -400,8 +402,6 @@ set_filter_flags(char * filter) flags |= FILTER_RES; flags |= FILTER_RES_SIZE; } - if( *saveptr ) - *(saveptr-1) = ','; item = strtok_r(NULL, ",", &saveptr); } diff --git a/uuid.c b/uuid.c index 3263241..4144308 100644 --- a/uuid.c +++ b/uuid.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include