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.
This commit is contained in:
Marcelo Roberto Jimenez 2010-12-18 17:08:36 -02:00
parent dd75baab6b
commit b1ae4db35a
12 changed files with 60 additions and 83 deletions

View File

@ -1,3 +1,6 @@
#ifndef ITHREAD_H
#define ITHREAD_H
/******************************************************************************* /*******************************************************************************
* *
* Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
@ -29,36 +32,22 @@
* *
******************************************************************************/ ******************************************************************************/
#ifndef ITHREAD_H
#define ITHREAD_H
/*! /*!
* \file * \file
*/ */
#if !defined(WIN32) #if !defined(WIN32)
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include "UpnpGlobal.h" /* For UPNP_INLINE, EXPORT_SPEC */ #include "UpnpGlobal.h" /* For UPNP_INLINE, EXPORT_SPEC */
#include "UpnpUniStd.h" /* for close() */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <pthread.h> #include <pthread.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#if defined(BSD) #if defined(BSD)
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE

View File

@ -38,7 +38,10 @@ upnpinclude_HEADERS = \
inc/upnp.h \ inc/upnp.h \
inc/upnpdebug.h \ inc/upnpdebug.h \
inc/UpnpGlobal.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 nodist_upnpinclude_HEADERS = inc/upnpconfig.h
if ENABLE_TOOLS if ENABLE_TOOLS

View File

@ -1,4 +1,3 @@
#ifndef UPNPINET_H #ifndef UPNPINET_H
#define UPNPINET_H #define UPNPINET_H
@ -8,13 +7,15 @@
* \brief Provides a platform independent way to include TCP/IP types and functions. * \brief Provides a platform independent way to include TCP/IP types and functions.
*/ */
#include "UpnpUniStd.h" /* for close() */
#ifdef WIN32 #ifdef WIN32
#include <iphlpapi.h> #include <iphlpapi.h>
#include <winsock2.h> #include <winsock2.h>
#include <Ws2tcpip.h> #include <Ws2tcpip.h>
#define UpnpCloseSocket closesocket #define UpnpCloseSocket closesocket
#else #else /* WIN32 */
#include <sys/param.h> #include <sys/param.h>
#if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__) #if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__)
#include <ifaddrs.h> #include <ifaddrs.h>
@ -24,9 +25,6 @@
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
/* include <unistd.h> for close().
* Do not include this file in win32. */
#include <unistd.h>
/* SOCKET is unsigned and is not a file descriptor on win32. */ /* SOCKET is unsigned and is not a file descriptor on win32. */
#define SOCKET int #define SOCKET int
/* INVALID_SOCKET is unsigned on win32. */ /* INVALID_SOCKET is unsigned on win32. */
@ -34,7 +32,6 @@
/* select() returns SOCKET_ERROR on win32. */ /* select() returns SOCKET_ERROR on win32. */
#define SOCKET_ERROR (-1) #define SOCKET_ERROR (-1)
#define UpnpCloseSocket close #define UpnpCloseSocket close
#endif #endif /* WIN32 */
#endif /* UPNPINET_H */ #endif /* UPNPINET_H */

11
upnp/inc/UpnpIntTypes.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef UPNPINTTYPES_H
#define UPNPINTTYPES_H
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
/* Printf format for integers. */
#include <inttypes.h>
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
#endif /* UPNPINTTYPES_H */

11
upnp/inc/UpnpStdInt.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef UPNPSTDINT_H
#define UPNPSTDINT_H
#if !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP)
/* Sized integer types. */
#include <stdint.h>
#endif /* !defined(UPNP_USE_BCBPP) && !defined(UPNP_USE_MSVCPP) */
#endif /* UPNPSTDINT_H */

10
upnp/inc/UpnpUniStd.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef UPNPUNISTD_H
#define UPNPUNISTD_H
#ifdef WIN32
/* Do not #include <unistd.h> on WIN32. */
#else /* WIN32 */
#include <unistd.h> /* for close() */
#endif /* WIN32 */
#endif /* UPNPUNISTD_H */

View File

@ -1,3 +1,6 @@
#ifndef UPNP_TV_CTRLPT_H
#define UPNP_TV_CTRLPT_H
/************************************************************************** /**************************************************************************
* *
* Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
@ -29,9 +32,6 @@
* *
**************************************************************************/ **************************************************************************/
#ifndef UPNP_TV_CTRLPT_H
#define UPNP_TV_CTRLPT_H
/*! /*!
* \file * \file
*/ */
@ -46,6 +46,7 @@ extern "C" {
#include "upnp.h" #include "upnp.h"
#include "UpnpString.h" #include "UpnpString.h"
#include "upnptools.h" #include "upnptools.h"
#include "UpnpUniStd.h" /* for close() */
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
@ -53,12 +54,6 @@ extern "C" {
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#define TV_SERVICE_SERVCOUNT 2 #define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0 #define TV_SERVICE_CONTROL 0
#define TV_SERVICE_PICTURE 1 #define TV_SERVICE_PICTURE 1

View File

@ -1,3 +1,6 @@
#ifndef UPNP_TV_DEVICE_H
#define UPNP_TV_DEVICE_H
/************************************************************************** /**************************************************************************
* *
* Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
@ -29,9 +32,6 @@
* *
**************************************************************************/ **************************************************************************/
#ifndef UPNP_TV_DEVICE_H
#define UPNP_TV_DEVICE_H
/*! /*!
* \file * \file
*/ */
@ -47,16 +47,11 @@ extern "C" {
#include "ithread.h" #include "ithread.h"
#include "upnp.h" #include "upnp.h"
#include "UpnpUniStd.h" /* for close() */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
/*! Color constants */ /*! Color constants */
#define MAX_COLOR 10 #define MAX_COLOR 10
#define MIN_COLOR 1 #define MIN_COLOR 1

View File

@ -29,24 +29,19 @@
* *
******************************************************************************/ ******************************************************************************/
#include "config.h" #include "config.h"
/*! /*!
* \file * \file
*/ */
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WIN32 #ifdef WIN32
/* Do not include these files */ /* Do not include these files */
#else #else
@ -69,10 +64,8 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <unistd.h>
#endif #endif
#include "upnpapi.h" #include "upnpapi.h"
#include "httpreadwrite.h" #include "httpreadwrite.h"
#include "membuffer.h" #include "membuffer.h"
@ -80,22 +73,20 @@
#include "soaplib.h" #include "soaplib.h"
#include "ThreadPool.h" #include "ThreadPool.h"
#include "sysdep.h" #include "sysdep.h"
#include "UpnpUniStd.h" /* for close() */
#include "uuid.h" #include "uuid.h"
/* Needed for GENA */ /* Needed for GENA */
#include "gena.h" #include "gena.h"
#include "miniserver.h" #include "miniserver.h"
#include "service_table.h" #include "service_table.h"
#ifdef INTERNAL_WEB_SERVER #ifdef INTERNAL_WEB_SERVER
#include "urlconfig.h" #include "urlconfig.h"
#include "VirtualDir.h" #include "VirtualDir.h"
#include "webserver.h" #include "webserver.h"
#endif /* INTERNAL_WEB_SERVER */ #endif /* INTERNAL_WEB_SERVER */
#ifndef IN6_IS_ADDR_GLOBAL #ifndef IN6_IS_ADDR_GLOBAL
#define IN6_IS_ADDR_GLOBAL(a) \ #define IN6_IS_ADDR_GLOBAL(a) \
(((((__const uint8_t *) (a))[0] & htonl(0xff000000)) <= htonl(0x3f000000) \ (((((__const uint8_t *) (a))[0] & htonl(0xff000000)) <= htonl(0x3f000000) \

View File

@ -48,18 +48,13 @@
#include "statcodes.h" #include "statcodes.h"
#include "sock.h" #include "sock.h"
#include "UpnpInet.h" #include "UpnpInet.h"
#include "UpnpIntTypes.h"
#include "UpnpStdInt.h"
#include "webserver.h" #include "webserver.h"
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#ifndef UPNP_USE_BCBPP
#ifndef UPNP_USE_MSVCPP
#include <inttypes.h>
#include <stdint.h>
#endif
#endif
#ifdef WIN32 #ifdef WIN32
#include <malloc.h> #include <malloc.h>
#define fseeko fseek #define fseeko fseek
@ -70,7 +65,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif

View File

@ -52,6 +52,8 @@
#include "unixutil.h" #include "unixutil.h"
#include "upnp.h" #include "upnp.h"
#include "upnpapi.h" #include "upnpapi.h"
#include "UpnpIntTypes.h"
#include "UpnpStdInt.h"
#include "upnputil.h" #include "upnputil.h"
#include "VirtualDir.h" #include "VirtualDir.h"
@ -59,20 +61,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef UPNP_USE_BCBPP
/* Do not #include <inttypes.h> */
/* Do not #include <stdint.h> */
#else
#include <inttypes.h>
#include <stdint.h>
#endif /* !UPNP_USE_BCBPP */
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
/*! /*!
* Response Types. * Response Types.
*/ */

View File

@ -1,3 +1,6 @@
#ifndef GENLIB_NET_UNIXUTIL_H
#define GENLIB_NET_UNIXUTIL_H
/******************************************************************************* /*******************************************************************************
* *
* Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
@ -29,17 +32,10 @@
* *
******************************************************************************/ ******************************************************************************/
/* Unix-specific network utilities */ /* Unix-specific network utilities */
#ifndef GENLIB_NET_UNIXUTIL_H
#define GENLIB_NET_UNIXUTIL_H
#include "UpnpInet.h" #include "UpnpInet.h"
#ifdef WIN32 #ifdef WIN32
typedef int socklen_t; typedef int socklen_t;
#define EAFNOSUPPORT 97 #define EAFNOSUPPORT 97
@ -48,9 +44,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h>
#endif #endif
#endif /* GENLIB_NET_UNIXUTIL_H */ #endif /* GENLIB_NET_UNIXUTIL_H */