From b1ae4db35a91ae523e57adf802a263f03be291a3 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Sat, 18 Dec 2010 17:08:36 -0200 Subject: [PATCH] Use the new include files UpnpIntTypes.h, UpnpStdInt.h and UpnpUniStd.h. Trying to keep platform dependency on the headers and clean the main code a little bit. --- threadutil/inc/ithread.h | 19 ++++--------------- upnp/Makefile.am | 5 ++++- upnp/inc/UpnpInet.h | 11 ++++------- upnp/inc/UpnpIntTypes.h | 11 +++++++++++ upnp/inc/UpnpStdInt.h | 11 +++++++++++ upnp/inc/UpnpUniStd.h | 10 ++++++++++ upnp/sample/common/tv_ctrlpt.h | 13 ++++--------- upnp/sample/common/tv_device.h | 13 ++++--------- upnp/src/api/upnpapi.c | 11 +---------- upnp/src/genlib/net/http/httpreadwrite.c | 10 ++-------- upnp/src/genlib/net/http/webserver.c | 16 ++-------------- upnp/src/inc/unixutil.h | 13 +++---------- 12 files changed, 60 insertions(+), 83 deletions(-) create mode 100644 upnp/inc/UpnpIntTypes.h create mode 100644 upnp/inc/UpnpStdInt.h create mode 100644 upnp/inc/UpnpUniStd.h diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index ac05c3b..d040067 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -1,3 +1,6 @@ +#ifndef ITHREAD_H +#define ITHREAD_H + /******************************************************************************* * * Copyright (c) 2000-2003 Intel Corporation @@ -29,36 +32,22 @@ * ******************************************************************************/ - -#ifndef ITHREAD_H -#define ITHREAD_H - - /*! * \file */ - #if !defined(WIN32) #include #endif - #include "UpnpGlobal.h" /* For UPNP_INLINE, EXPORT_SPEC */ - +#include "UpnpUniStd.h" /* for close() */ #ifdef __cplusplus extern "C" { #endif - #include -#ifdef WIN32 - /* Do not #include */ -#else - #include -#endif - #if defined(BSD) #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE diff --git a/upnp/Makefile.am b/upnp/Makefile.am index a6459b0..f949934 100644 --- a/upnp/Makefile.am +++ b/upnp/Makefile.am @@ -38,7 +38,10 @@ upnpinclude_HEADERS = \ inc/upnp.h \ inc/upnpdebug.h \ inc/UpnpGlobal.h \ - inc/UpnpInet.h + inc/UpnpInet.h \ + inc/UpnpIntTypes.h \ + inc/UpnpStdInt.h \ + inc/UpnpUniStd.h nodist_upnpinclude_HEADERS = inc/upnpconfig.h if ENABLE_TOOLS diff --git a/upnp/inc/UpnpInet.h b/upnp/inc/UpnpInet.h index 4d45825..704082b 100644 --- a/upnp/inc/UpnpInet.h +++ b/upnp/inc/UpnpInet.h @@ -1,4 +1,3 @@ - #ifndef UPNPINET_H #define UPNPINET_H @@ -8,13 +7,15 @@ * \brief Provides a platform independent way to include TCP/IP types and functions. */ +#include "UpnpUniStd.h" /* for close() */ + #ifdef WIN32 #include #include #include #define UpnpCloseSocket closesocket -#else +#else /* WIN32 */ #include #if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__) #include @@ -24,9 +25,6 @@ #endif #include - /* include for close(). - * Do not include this file in win32. */ - #include /* SOCKET is unsigned and is not a file descriptor on win32. */ #define SOCKET int /* INVALID_SOCKET is unsigned on win32. */ @@ -34,7 +32,6 @@ /* select() returns SOCKET_ERROR on win32. */ #define SOCKET_ERROR (-1) #define UpnpCloseSocket close -#endif +#endif /* WIN32 */ #endif /* UPNPINET_H */ - diff --git a/upnp/inc/UpnpIntTypes.h b/upnp/inc/UpnpIntTypes.h new file mode 100644 index 0000000..056ad97 --- /dev/null +++ b/upnp/inc/UpnpIntTypes.h @@ -0,0 +1,11 @@ +#ifndef UPNPINTTYPES_H +#define UPNPINTTYPES_H + +#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) + +/* Printf format for integers. */ +#include + +#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */ + +#endif /* UPNPINTTYPES_H */ diff --git a/upnp/inc/UpnpStdInt.h b/upnp/inc/UpnpStdInt.h new file mode 100644 index 0000000..1e3e31d --- /dev/null +++ b/upnp/inc/UpnpStdInt.h @@ -0,0 +1,11 @@ +#ifndef UPNPSTDINT_H +#define UPNPSTDINT_H + +#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) + +/* Sized integer types. */ +#include + +#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */ + +#endif /* UPNPSTDINT_H */ diff --git a/upnp/inc/UpnpUniStd.h b/upnp/inc/UpnpUniStd.h new file mode 100644 index 0000000..ee10e3a --- /dev/null +++ b/upnp/inc/UpnpUniStd.h @@ -0,0 +1,10 @@ +#ifndef UPNPUNISTD_H +#define UPNPUNISTD_H + +#ifdef WIN32 + /* Do not #include on WIN32. */ +#else /* WIN32 */ + #include /* for close() */ +#endif /* WIN32 */ + +#endif /* UPNPUNISTD_H */ diff --git a/upnp/sample/common/tv_ctrlpt.h b/upnp/sample/common/tv_ctrlpt.h index 70be1c6..00ed420 100644 --- a/upnp/sample/common/tv_ctrlpt.h +++ b/upnp/sample/common/tv_ctrlpt.h @@ -1,3 +1,6 @@ +#ifndef UPNP_TV_CTRLPT_H +#define UPNP_TV_CTRLPT_H + /************************************************************************** * * Copyright (c) 2000-2003 Intel Corporation @@ -29,9 +32,6 @@ * **************************************************************************/ -#ifndef UPNP_TV_CTRLPT_H -#define UPNP_TV_CTRLPT_H - /*! * \file */ @@ -46,6 +46,7 @@ extern "C" { #include "upnp.h" #include "UpnpString.h" #include "upnptools.h" +#include "UpnpUniStd.h" /* for close() */ #include #include @@ -53,12 +54,6 @@ extern "C" { #include #include -#ifdef WIN32 - /* Do not #include */ -#else - #include -#endif - #define TV_SERVICE_SERVCOUNT 2 #define TV_SERVICE_CONTROL 0 #define TV_SERVICE_PICTURE 1 diff --git a/upnp/sample/common/tv_device.h b/upnp/sample/common/tv_device.h index 17eb8b6..4bf9a28 100644 --- a/upnp/sample/common/tv_device.h +++ b/upnp/sample/common/tv_device.h @@ -1,3 +1,6 @@ +#ifndef UPNP_TV_DEVICE_H +#define UPNP_TV_DEVICE_H + /************************************************************************** * * Copyright (c) 2000-2003 Intel Corporation @@ -29,9 +32,6 @@ * **************************************************************************/ -#ifndef UPNP_TV_DEVICE_H -#define UPNP_TV_DEVICE_H - /*! * \file */ @@ -47,16 +47,11 @@ extern "C" { #include "ithread.h" #include "upnp.h" +#include "UpnpUniStd.h" /* for close() */ #include #include -#ifdef WIN32 - /* Do not #include */ -#else - #include -#endif - /*! Color constants */ #define MAX_COLOR 10 #define MIN_COLOR 1 diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index fa8c516..07a11d0 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -29,24 +29,19 @@ * ******************************************************************************/ - #include "config.h" - /*! * \file */ - #include - #include #include #include #include - #ifdef WIN32 /* Do not include these files */ #else @@ -69,10 +64,8 @@ #include #include #include - #include #endif - #include "upnpapi.h" #include "httpreadwrite.h" #include "membuffer.h" @@ -80,22 +73,20 @@ #include "soaplib.h" #include "ThreadPool.h" #include "sysdep.h" +#include "UpnpUniStd.h" /* for close() */ #include "uuid.h" - /* Needed for GENA */ #include "gena.h" #include "miniserver.h" #include "service_table.h" - #ifdef INTERNAL_WEB_SERVER #include "urlconfig.h" #include "VirtualDir.h" #include "webserver.h" #endif /* INTERNAL_WEB_SERVER */ - #ifndef IN6_IS_ADDR_GLOBAL #define IN6_IS_ADDR_GLOBAL(a) \ (((((__const uint8_t *) (a))[0] & htonl(0xff000000)) <= htonl(0x3f000000) \ diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index eeac907..17bd0b0 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -48,18 +48,13 @@ #include "statcodes.h" #include "sock.h" #include "UpnpInet.h" +#include "UpnpIntTypes.h" +#include "UpnpStdInt.h" #include "webserver.h" #include #include -#ifndef UPNP_USE_BCBPP - #ifndef UPNP_USE_MSVCPP - #include - #include - #endif -#endif - #ifdef WIN32 #include #define fseeko fseek @@ -70,7 +65,6 @@ #include #include #include - #include #include #endif diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index 3bdcd36..b7d9891 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -52,6 +52,8 @@ #include "unixutil.h" #include "upnp.h" #include "upnpapi.h" +#include "UpnpIntTypes.h" +#include "UpnpStdInt.h" #include "upnputil.h" #include "VirtualDir.h" @@ -59,20 +61,6 @@ #include #include -#ifdef UPNP_USE_BCBPP - /* Do not #include */ - /* Do not #include */ -#else - #include - #include -#endif /* !UPNP_USE_BCBPP */ - -#ifdef WIN32 - /* Do not #include */ -#else - #include -#endif - /*! * Response Types. */ diff --git a/upnp/src/inc/unixutil.h b/upnp/src/inc/unixutil.h index c5f6f25..d55c7fb 100644 --- a/upnp/src/inc/unixutil.h +++ b/upnp/src/inc/unixutil.h @@ -1,3 +1,6 @@ +#ifndef GENLIB_NET_UNIXUTIL_H +#define GENLIB_NET_UNIXUTIL_H + /******************************************************************************* * * Copyright (c) 2000-2003 Intel Corporation @@ -29,17 +32,10 @@ * ******************************************************************************/ - /* Unix-specific network utilities */ - -#ifndef GENLIB_NET_UNIXUTIL_H -#define GENLIB_NET_UNIXUTIL_H - - #include "UpnpInet.h" - #ifdef WIN32 typedef int socklen_t; #define EAFNOSUPPORT 97 @@ -48,9 +44,6 @@ #include #include #include - #include #endif - #endif /* GENLIB_NET_UNIXUTIL_H */ -