From 4b40e94b03a9f4aa6c4a2a2c3b5dc186227ae588 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Tue, 25 Mar 2008 10:21:08 +0000 Subject: [PATCH] Merge of trunk into branch 1.6.x. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@339 119443c7-1b9e-41f8-b6fc-b9c35fce742c --- ChangeLog | 25 + THANKS | 3 +- build/msvc/stdint.h | 222 +++++++ build/vc8/libupnp.sln | 20 + build/vc8/libupnp.vcproj | 559 ++++++++++++++++++ build/vc9/ixml.vcproj | 222 +++++++ build/vc9/libupnp.sln | 69 +++ build/vc9/libupnp.vcproj | 558 +++++++++++++++++ build/vc9/threadutil.vcproj | 212 +++++++ build/vc9/tvcombo.vcproj | 212 +++++++ build/vc9/tvctrlpt.vcproj | 204 +++++++ build/vc9/tvdevice.vcproj | 204 +++++++ ixml/src/document.c | 2 +- ixml/src/ixmlparser.c | 4 +- threadutil/inc/ThreadPool.h | 15 +- threadutil/inc/ithread.h | 8 + threadutil/src/LinkedList.c | 9 +- threadutil/src/ThreadPool.c | 42 ++ upnp/inc/upnp.h | 4 +- upnp/sample/common/sample_util.c | 2 +- upnp/sample/common/sample_util.h | 66 ++- .../sample/tvcombo/linux/upnp_tv_combo_main.c | 20 +- upnp/sample/tvcombo/upnp_tv_ctrlpt.c | 44 +- upnp/sample/tvcombo/upnp_tv_ctrlpt.h | 2 + upnp/sample/tvcombo/upnp_tv_device.c | 55 +- upnp/sample/tvcombo/upnp_tv_device.h | 2 + .../tvctrlpt/linux/upnp_tv_ctrlpt_main.c | 138 ++--- upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c | 44 +- upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h | 2 + .../tvdevice/linux/upnp_tv_device_main.c | 44 +- upnp/sample/tvdevice/upnp_tv_device.c | 55 +- upnp/sample/tvdevice/upnp_tv_device.h | 2 + upnp/src/genlib/miniserver/miniserver.c | 12 +- upnp/src/genlib/net/http/httpparser.c | 10 + upnp/src/genlib/net/http/httpreadwrite.c | 8 + upnp/src/genlib/net/http/statcodes.c | 2 +- upnp/src/genlib/net/http/webserver.c | 6 +- upnp/src/inc/config.h | 1 + upnp/src/inc/upnpapi.h | 4 - upnp/src/inc/util.h | 132 +++-- upnp/src/soap/soap_device.c | 4 +- upnp/src/ssdp/ssdp_ctrlpt.c | 18 +- upnp/src/ssdp/ssdp_device.c | 9 +- upnp/src/ssdp/ssdp_server.c | 4 +- upnp/src/uuid/sysdep.c | 16 +- upnp/src/uuid/uuid.c | 2 +- 46 files changed, 2964 insertions(+), 334 deletions(-) create mode 100644 build/msvc/stdint.h create mode 100644 build/vc8/libupnp.sln create mode 100644 build/vc8/libupnp.vcproj create mode 100644 build/vc9/ixml.vcproj create mode 100644 build/vc9/libupnp.sln create mode 100644 build/vc9/libupnp.vcproj create mode 100644 build/vc9/threadutil.vcproj create mode 100644 build/vc9/tvcombo.vcproj create mode 100644 build/vc9/tvctrlpt.vcproj create mode 100644 build/vc9/tvdevice.vcproj diff --git a/ChangeLog b/ChangeLog index 1cdf8b3..c18d9c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,31 @@ Version 1.6.6 ******************************************************************************* +2008-03-20 Marcelo Jimenez + * Andre Sodermans (wienerschnitzel) patch for building libupnp under + windows systems with VC9. + +2008-03-20 Marcelo Jimenez + * Andre Sodermans (wienerschnitzel) patch for building libupnp under + windows systems with VC8. + +2008-03-08 Marcelo Jimenez + * Fixed a printf format problem on the upnp_tv_device.c from both + upnp/sample/tvdevie and upnp/sample/tvcombo directories. The variable + port was a short int instead of an unsigned short and it was beeing + print as a negative value. + +2008-03-08 Marcelo Jimenez + * SF Bug Tracker [ 1902668 ] Cannot compile on MSVC + Submitted By Luke Kim - nereusuj + Version 1.6.5 cannot be compiled because of some changes in 1.6.3. + MSVC does not support stdint.h, gettimeofday(), sys/param.h, const int + variables in array size and Windows does not define _WINDOWS_ but define + _WINDOWS. + * MSVC does not understand "const int"'s as declarators of array + dimensions, we must use #define'd constants. + * Use WIN32 instead of _WINDOWS_ or _WINDOWS. + 2008-02-22 Marcelo Jimenez * No longer ignore "upnp:rootdevice" advertisement. Thanks to Bob Ciora. diff --git a/THANKS b/THANKS index f226472..ebe0d89 100644 --- a/THANKS +++ b/THANKS @@ -7,6 +7,7 @@ Here is a list of these people. Help us keep it complete and exempt of errors. - Alex (afaucher) +- Andre Sodermans (wienerschnitzel) - Arno Willig - Bob Ciora - Chaos @@ -30,7 +31,7 @@ exempt of errors. - Keith Brindley - Leuk_He - Loigu -- Luke Kim +- Luke Kim (nereusuj) - Marcelo Roberto Jimenez (mroberto) - Markus Strobl - Nektarios K. Papadopoulos (npapadop) diff --git a/build/msvc/stdint.h b/build/msvc/stdint.h new file mode 100644 index 0000000..7e200dc --- /dev/null +++ b/build/msvc/stdint.h @@ -0,0 +1,222 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#if (_MSC_VER < 1300) && defined(__cplusplus) + extern "C++" { +#endif +# include +#if (_MSC_VER < 1300) && defined(__cplusplus) + } +#endif + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef int intptr_t; + typedef unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/build/vc8/libupnp.sln b/build/vc8/libupnp.sln new file mode 100644 index 0000000..299144e --- /dev/null +++ b/build/vc8/libupnp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libupnp", "libupnp.vcproj", "{6227F51A-1498-4C4A-B213-F6FDED605125}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.ActiveCfg = Debug|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.Build.0 = Debug|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.ActiveCfg = Release|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/vc8/libupnp.vcproj b/build/vc8/libupnp.vcproj new file mode 100644 index 0000000..fbb96b5 --- /dev/null +++ b/build/vc8/libupnp.vcproj @@ -0,0 +1,559 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/ixml.vcproj b/build/vc9/ixml.vcproj new file mode 100644 index 0000000..2c1205d --- /dev/null +++ b/build/vc9/ixml.vcproj @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/libupnp.sln b/build/vc9/libupnp.sln new file mode 100644 index 0000000..fd4ada7 --- /dev/null +++ b/build/vc9/libupnp.sln @@ -0,0 +1,69 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libupnp", "libupnp.vcproj", "{6227F51A-1498-4C4A-B213-F6FDED605125}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ixml", "ixml.vcproj", "{9C2C266D-35A3-465F-A297-0E21D54E5C89}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "threadutil", "threadutil.vcproj", "{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}" + ProjectSection(ProjectDependencies) = postProject + {6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125} + {9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvctrlpt", "tvctrlpt.vcproj", "{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}" + ProjectSection(ProjectDependencies) = postProject + {6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125} + {9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89} + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvdevice", "tvdevice.vcproj", "{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}" + ProjectSection(ProjectDependencies) = postProject + {6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125} + {9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89} + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvcombo", "tvcombo.vcproj", "{6365804B-22C6-4D5E-91F3-0C052EB55B4F}" + ProjectSection(ProjectDependencies) = postProject + {6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125} + {9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89} + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.ActiveCfg = Debug|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.Build.0 = Debug|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.ActiveCfg = Release|Win32 + {6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.Build.0 = Release|Win32 + {9C2C266D-35A3-465F-A297-0E21D54E5C89}.Debug|Win32.ActiveCfg = Debug|Win32 + {9C2C266D-35A3-465F-A297-0E21D54E5C89}.Debug|Win32.Build.0 = Debug|Win32 + {9C2C266D-35A3-465F-A297-0E21D54E5C89}.Release|Win32.ActiveCfg = Release|Win32 + {9C2C266D-35A3-465F-A297-0E21D54E5C89}.Release|Win32.Build.0 = Release|Win32 + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Debug|Win32.ActiveCfg = Debug|Win32 + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Debug|Win32.Build.0 = Debug|Win32 + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Release|Win32.ActiveCfg = Release|Win32 + {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Release|Win32.Build.0 = Release|Win32 + {8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Debug|Win32.Build.0 = Debug|Win32 + {8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Release|Win32.ActiveCfg = Release|Win32 + {8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Release|Win32.Build.0 = Release|Win32 + {7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Debug|Win32.Build.0 = Debug|Win32 + {7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Release|Win32.ActiveCfg = Release|Win32 + {7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Release|Win32.Build.0 = Release|Win32 + {6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Debug|Win32.ActiveCfg = Debug|Win32 + {6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Debug|Win32.Build.0 = Debug|Win32 + {6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Release|Win32.ActiveCfg = Release|Win32 + {6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/vc9/libupnp.vcproj b/build/vc9/libupnp.vcproj new file mode 100644 index 0000000..b3a7807 --- /dev/null +++ b/build/vc9/libupnp.vcproj @@ -0,0 +1,558 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/threadutil.vcproj b/build/vc9/threadutil.vcproj new file mode 100644 index 0000000..9f1e1a8 --- /dev/null +++ b/build/vc9/threadutil.vcproj @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/tvcombo.vcproj b/build/vc9/tvcombo.vcproj new file mode 100644 index 0000000..e5ccd58 --- /dev/null +++ b/build/vc9/tvcombo.vcproj @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/tvctrlpt.vcproj b/build/vc9/tvctrlpt.vcproj new file mode 100644 index 0000000..e2e3247 --- /dev/null +++ b/build/vc9/tvctrlpt.vcproj @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc9/tvdevice.vcproj b/build/vc9/tvdevice.vcproj new file mode 100644 index 0000000..c96e00c --- /dev/null +++ b/build/vc9/tvdevice.vcproj @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ixml/src/document.c b/ixml/src/document.c index 8b03ea2..1f7f530 100644 --- a/ixml/src/document.c +++ b/ixml/src/document.c @@ -268,7 +268,7 @@ ixmlDocument_createDocumentEx( OUT IXML_Document ** rtDoc ) * *=================================================================*/ IXML_Document * -ixmlDocument_createDocument( ) +ixmlDocument_createDocument() { IXML_Document *doc = NULL; diff --git a/ixml/src/ixmlparser.c b/ixml/src/ixmlparser.c index 585aef2..04c74bb 100644 --- a/ixml/src/ixmlparser.c +++ b/ixml/src/ixmlparser.c @@ -483,7 +483,7 @@ Parser_UTF8ToInt( IN const char *ss, * *===============================================================================*/ static Parser * -Parser_init( ) +Parser_init() { Parser *newParser = NULL; @@ -677,7 +677,7 @@ Parser_LoadDocument( OUT IXML_Document ** retDoc, int rc = IXML_SUCCESS; Parser *xmlParser = NULL; - xmlParser = Parser_init( ); + xmlParser = Parser_init(); if( xmlParser == NULL ) { return IXML_INSUFFICIENT_MEMORY; } diff --git a/threadutil/inc/ThreadPool.h b/threadutil/inc/ThreadPool.h index 6b20753..b7d8799 100644 --- a/threadutil/inc/ThreadPool.h +++ b/threadutil/inc/ThreadPool.h @@ -79,7 +79,20 @@ typedef enum priority {LOW_PRIORITY, #endif #include "LinkedList.h" -#include /* for gettimeofday() */ + +#ifdef WIN32 + #include + #include + struct timezone + { + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ + }; + int gettimeofday(struct timeval *tv, struct timezone *tz); +#else /* WIN32 */ + #include /* for gettimeofday() */ +#endif + #include "FreeList.h" #include "ithread.h" diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index 46947d3..c2ac37e 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -715,7 +715,11 @@ typedef pthread_rwlock_t ithread_rwlock_t; * 0 on success, Nonzero on failure. * See man page for sleep (man 3 sleep) *****************************************************************************/ +#ifndef WIN32 #define isleep sleep +#else +#define isleep(x) Sleep((x)*1000) +#endif /**************************************************************************** * Function: isleep @@ -730,7 +734,11 @@ typedef pthread_rwlock_t ithread_rwlock_t; * 0 on success, Nonzero on failure. * See man page for sleep (man 3 sleep) *****************************************************************************/ +#ifndef WIN32 #define imillisleep(x) usleep(1000*x) +#else +#define imillisleep Sleep +#endif #ifdef WIN32 #ifndef UPNP_STATIC_LIB diff --git a/threadutil/src/LinkedList.c b/threadutil/src/LinkedList.c index a67330f..c5060a9 100644 --- a/threadutil/src/LinkedList.c +++ b/threadutil/src/LinkedList.c @@ -30,11 +30,13 @@ /////////////////////////////////////////////////////////////////////////// #include "LinkedList.h" -#include +#ifndef WIN32 + #include +#endif #if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__) -#include + #include #else -#include + #include #endif #include @@ -532,3 +534,4 @@ ListSize( LinkedList * list ) return list->size; } + diff --git a/threadutil/src/ThreadPool.c b/threadutil/src/ThreadPool.c index 0085c89..0161546 100644 --- a/threadutil/src/ThreadPool.c +++ b/threadutil/src/ThreadPool.c @@ -1597,3 +1597,45 @@ int ThreadPoolGetStats( ThreadPool *tp, ThreadPoolStats *stats ) #endif /* STATS */ +#ifdef WIN32 +#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 +#else + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL +#endif + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + unsigned __int64 tmpres = 0; + static int tzflag; + + if (NULL != tv) + { + GetSystemTimeAsFileTime(&ft); + + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + /*converting file time to unix epoch*/ + tmpres /= 10; /*convert into microseconds*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + + if (NULL != tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} +#endif /* WIN32 */ diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 14d31a0..1b9b277 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -47,7 +47,9 @@ #include -#include +#ifndef WIN32 + #include +#endif #if (defined(BSD) && BSD >= 199306) #include #endif diff --git a/upnp/sample/common/sample_util.c b/upnp/sample/common/sample_util.c index bb58f35..b94a883 100644 --- a/upnp/sample/common/sample_util.c +++ b/upnp/sample/common/sample_util.c @@ -105,7 +105,7 @@ SampleUtil_RegisterUpdateFunction( state_update update_function ) * ********************************************************************************/ int -SampleUtil_Finish( ) +SampleUtil_Finish() { ithread_mutex_destroy( &display_mutex ); gPrintFun = NULL; diff --git a/upnp/sample/common/sample_util.h b/upnp/sample/common/sample_util.h index 9295850..55d9a89 100644 --- a/upnp/sample/common/sample_util.h +++ b/upnp/sample/common/sample_util.h @@ -34,24 +34,26 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ + #include - #include -#include "upnptools.h" #include "ithread.h" #include "ixml.h" +#include "upnptools.h" + + +// mutex to control displaying of events +extern ithread_mutex_t display_mutex; -//mutex to control displaying of events -extern ithread_mutex_t display_mutex ; typedef enum { STATE_UPDATE = 0, - DEVICE_ADDED =1, - DEVICE_REMOVED=2, - GET_VAR_COMPLETE=3 + DEVICE_ADDED = 1, + DEVICE_REMOVED = 2, + GET_VAR_COMPLETE = 3 } eventType; @@ -68,7 +70,7 @@ typedef enum { * node -- The DOM node from which to extract the value * ********************************************************************************/ -char * SampleUtil_GetElementValue(IN IXML_Element *element); +char *SampleUtil_GetElementValue(IN IXML_Element *element); /******************************************************************************** * SampleUtil_GetFirstServiceList @@ -85,7 +87,7 @@ char * SampleUtil_GetElementValue(IN IXML_Element *element); * ********************************************************************************/ -IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document * doc); +IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document *doc); /******************************************************************************** @@ -100,7 +102,7 @@ IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document * doc); * item -- The item to search for * ********************************************************************************/ -char * SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *item); +char *SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *item); @@ -116,7 +118,7 @@ char * SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *ite * item -- The item to search for * ********************************************************************************/ -char * SampleUtil_GetFirstElementItem(IN IXML_Element *element, IN const char *item); +char *SampleUtil_GetFirstElementItem(IN IXML_Element *element, IN const char *item); /******************************************************************************** * SampleUtil_PrintEventType @@ -162,9 +164,13 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType, * controlURL -- OUT -- The control URL for the service * ********************************************************************************/ -int SampleUtil_FindAndParseService (IN IXML_Document *DescDoc, IN char* location, - IN char *serviceType, OUT char **serviceId, - OUT char **eventURL, OUT char **controlURL); +int SampleUtil_FindAndParseService ( + IN IXML_Document *DescDoc, + IN char* location, + IN char *serviceType, + OUT char **serviceId, + OUT char **eventURL, + OUT char **controlURL); /******************************************************************************** @@ -196,8 +202,11 @@ extern print_string gPrintFun; * const char * UDN * int newDevice ********************************************************************************/ -typedef void (*state_update)( const char *varName, const char *varValue, const char *UDN, - eventType type); +typedef void (*state_update)( + const char *varName, + const char *varValue, + const char *UDN, + eventType type); //global state update function used by smaple util extern state_update gStateUpdateFun; @@ -224,7 +233,7 @@ int SampleUtil_Initialize(print_string print_function); * Parameters: * ********************************************************************************/ -int SampleUtil_Finish(void); +int SampleUtil_Finish(); /******************************************************************************** * SampleUtil_Print @@ -238,7 +247,7 @@ int SampleUtil_Finish(void); * . . . - variable number of args. (see printf) * ********************************************************************************/ -int SampleUtil_Print( char *fmt, ... ); +int SampleUtil_Print(char *fmt, ...); /******************************************************************************** * SampleUtil_RegisterUpdateFunction @@ -248,7 +257,7 @@ int SampleUtil_Print( char *fmt, ... ); * Parameters: * ********************************************************************************/ -int SampleUtil_RegisterUpdateFunction( state_update update_function ); +int SampleUtil_RegisterUpdateFunction(state_update update_function); /******************************************************************************** * SampleUtil_StateUpdate @@ -258,11 +267,22 @@ int SampleUtil_RegisterUpdateFunction( state_update update_function ); * Parameters: * ********************************************************************************/ -void SampleUtil_StateUpdate( const char *varName, const char *varValue, const char *UDN, - eventType type); +void SampleUtil_StateUpdate( + const char *varName, + const char *varValue, + const char *UDN, + eventType type); #ifdef __cplusplus }; +#endif /* __cplusplus */ + + +#ifdef WIN32 + #define snprintf _snprintf + #define strcasecmp stricmp #endif -#endif /* UPNPSDK_UTIL_H */ + +#endif /* SAMPLE_UTIL_H */ + diff --git a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c index 956a819..fc5fb44 100644 --- a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c +++ b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c @@ -449,17 +449,17 @@ device_main( int argc, char **argv ) port = ( unsigned short )portTemp; - return TvDeviceStart( - ip_address, port, desc_doc_name, web_dir_path, linux_print ); + return TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path, linux_print ); } -int -main( int argc, char **argv ) +int main( int argc, char **argv ) { int rc; ithread_t cmdloop_thread; +#ifndef WIN32 int sig; sigset_t sigs_to_catch; +#endif int code; device_main(argc, argv); @@ -468,11 +468,10 @@ main( int argc, char **argv ) SampleUtil_Print( "Error starting UPnP TV Control Point" ); return rc; } - // start a command loop thread - code = - ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, - NULL ); + /* start a command loop thread */ + code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL ); +#ifndef WIN32 /* Catch Ctrl-C and properly shutdown */ @@ -480,7 +479,10 @@ main( int argc, char **argv ) sigaddset( &sigs_to_catch, SIGINT ); sigwait( &sigs_to_catch, &sig ); - SampleUtil_Print( "Shutting down on signal %d...", sig ); + SampleUtil_Print( "Shutting down on signal %d...\n", sig ); +#else + ithread_join(cmdloop_thread, NULL); +#endif TvDeviceStop(); rc = TvCtrlPointStop(); diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c index 45ceee5..30ac22b 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c @@ -224,7 +224,7 @@ TvCtrlPointRefresh( void ) { int rc; - TvCtrlPointRemoveAll( ); + TvCtrlPointRemoveAll(); /* Search for all devices of type tvdevice version 1, @@ -539,7 +539,7 @@ TvCtrlPointGetDevice( int devnum, * ********************************************************************************/ int -TvCtrlPointPrintList( ) +TvCtrlPointPrintList() { struct TvDeviceNode *tmpdevnode; int i = 0; @@ -1096,7 +1096,7 @@ TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, if( DescDoc ) ixmlDocument_free( DescDoc ); - TvCtrlPointPrintList( ); + TvCtrlPointPrintList(); break; } @@ -1122,7 +1122,7 @@ TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, TvCtrlPointRemoveDevice( d_event->DeviceId ); SampleUtil_Print( "After byebye:" ); - TvCtrlPointPrintList( ); + TvCtrlPointPrintList(); break; } @@ -1354,7 +1354,7 @@ TvCtrlPointStart( print_string printFunctionPtr, { ithread_t timer_thread; int rc; - short int port = 0; + unsigned short port = 0; char *ip_address = NULL; SampleUtil_Initialize( printFunctionPtr ); @@ -1362,34 +1362,42 @@ TvCtrlPointStart( print_string printFunctionPtr, ithread_mutex_init( &DeviceListMutex, 0 ); - SampleUtil_Print( "Intializing UPnP with ipaddress=%s port=%d", - ip_address, port ); + SampleUtil_Print( + "Initializing UPnP Sdk with\n" + "\tipaddress = %s port = %u\n", + ip_address, port ); + rc = UpnpInit( ip_address, port ); if( UPNP_E_SUCCESS != rc ) { SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc ); - //UpnpFinish( ); + //UpnpFinish(); //return TV_ERROR; } - if( NULL == ip_address ) - ip_address = UpnpGetServerIpAddress( ); - if( 0 == port ) - port = UpnpGetServerPort( ); + if( NULL == ip_address ) { + ip_address = UpnpGetServerIpAddress(); + } + if( 0 == port ) { + port = UpnpGetServerPort(); + } - SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port ); + SampleUtil_Print( + "UPnP Initialized\n" + "\tipaddress= %s port = %u\n", + ip_address, port ); SampleUtil_Print( "Registering Control Point" ); rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler, &ctrlpt_handle, &ctrlpt_handle ); if( UPNP_E_SUCCESS != rc ) { SampleUtil_Print( "Error registering CP: %d", rc ); - UpnpFinish( ); + UpnpFinish(); return TV_ERROR; } SampleUtil_Print( "Control Point Registered" ); - TvCtrlPointRefresh( ); + TvCtrlPointRefresh(); // start a timer thread ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL ); @@ -1400,10 +1408,10 @@ TvCtrlPointStart( print_string printFunctionPtr, int TvCtrlPointStop( void ) { - TvCtrlPointRemoveAll( ); + TvCtrlPointRemoveAll(); UpnpUnRegisterClient( ctrlpt_handle ); - UpnpFinish( ); - SampleUtil_Finish( ); + UpnpFinish(); + SampleUtil_Finish(); return TV_SUCCESS; } diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h index b47f5c6..7c2d079 100644 --- a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h @@ -39,7 +39,9 @@ extern "C" { #include #include "ithread.h" +#ifndef WIN32 #include +#endif #include #include #include diff --git a/upnp/sample/tvcombo/upnp_tv_device.c b/upnp/sample/tvcombo/upnp_tv_device.c index ad459b6..d17d308 100644 --- a/upnp/sample/tvcombo/upnp_tv_device.c +++ b/upnp/sample/tvcombo/upnp_tv_device.c @@ -1913,11 +1913,11 @@ TvDeviceCallbackEventHandler( Upnp_EventType EventType, * *****************************************************************************/ int -TvDeviceStop( ) +TvDeviceStop() { UpnpUnRegisterRootDevice( device_handle ); - UpnpFinish( ); - SampleUtil_Finish( ); + UpnpFinish(); + SampleUtil_Finish(); ithread_mutex_destroy( &TVDevMutex ); return UPNP_E_SUCCESS; } @@ -1958,32 +1958,37 @@ TvDeviceStart( char *ip_address, SampleUtil_Initialize( pfun ); - SampleUtil_Print - ( "Initializing UPnP Sdk with \n \t ipaddress = %s port = %d\n", - ip_address, port ); + SampleUtil_Print( + "Initializing UPnP Sdk with\n" + "\tipaddress = %s port = %u\n", + ip_address, port ); if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error with UpnpInit -- %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } if( ip_address == NULL ) { - ip_address = UpnpGetServerIpAddress( ); + ip_address = UpnpGetServerIpAddress(); } if( port == 0 ) { - port = UpnpGetServerPort( ); + port = UpnpGetServerPort(); } - SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n", - ip_address, port ); + SampleUtil_Print( + "UPnP Initialized\n" + "\tipaddress= %s port = %u\n", + ip_address, port ); - if( desc_doc_name == NULL ) + if( desc_doc_name == NULL ) { desc_doc_name = "tvcombodesc.xml"; + } - if( web_dir_path == NULL ) + if( web_dir_path == NULL ) { web_dir_path = DEFAULT_WEB_DIR; + } snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, port, desc_doc_name ); @@ -1995,37 +2000,39 @@ TvDeviceStart( char *ip_address, SampleUtil_Print ( "Error specifying webserver root directory -- %s: %d\n", web_dir_path, ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } - SampleUtil_Print - ( "Registering the RootDevice\n\t with desc_doc_url: %s\n", - desc_doc_url ); + SampleUtil_Print( + "Registering the RootDevice\n" + "\t with desc_doc_url: %s\n", + desc_doc_url ); if( ( ret = UpnpRegisterRootDevice( desc_doc_url, TvDeviceCallbackEventHandler, &device_handle, &device_handle ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error registering the rootdevice : %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } else { - SampleUtil_Print( "RootDevice Registered\n" ); - - SampleUtil_Print( "Initializing State Table\n" ); + SampleUtil_Print( + "RootDevice Registered\n" + "Initializing State Table\n"); TvDeviceStateTableInit( desc_doc_url ); - SampleUtil_Print( "State Table Initialized\n" ); + SampleUtil_Print("State Table Initialized\n"); if( ( ret = UpnpSendAdvertisement( device_handle, default_advr_expire ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error sending advertisements : %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } - SampleUtil_Print( "Advertisements Sent\n" ); + SampleUtil_Print("Advertisements Sent\n"); } return UPNP_E_SUCCESS; } + diff --git a/upnp/sample/tvcombo/upnp_tv_device.h b/upnp/sample/tvcombo/upnp_tv_device.h index c797409..f16a4d5 100644 --- a/upnp/sample/tvcombo/upnp_tv_device.h +++ b/upnp/sample/tvcombo/upnp_tv_device.h @@ -41,7 +41,9 @@ extern "C" { #include "ithread.h" #include +#ifndef WIN32 #include +#endif #include #include "upnp.h" #include "sample_util.h" diff --git a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c index 8a26f72..7c386ef 100644 --- a/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c +++ b/upnp/sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c @@ -29,9 +29,12 @@ // /////////////////////////////////////////////////////////////////////////// -#include + #include "sample_util.h" #include "upnp_tv_ctrlpt.h" + + +#include #include /* @@ -124,108 +127,72 @@ TvCtrlPointPrintLongHelp( void ) SampleUtil_Print( "* TV Control Point Help Info *" ); SampleUtil_Print( "******************************" ); SampleUtil_Print( "" ); - SampleUtil_Print - ( "This sample control point application automatically searches" ); - SampleUtil_Print - ( "for and subscribes to the services of television device emulator" ); - SampleUtil_Print - ( "devices, described in the tvdevicedesc.xml description document." ); + SampleUtil_Print( "This sample control point application automatically searches" ); + SampleUtil_Print( "for and subscribes to the services of television device emulator" ); + SampleUtil_Print( "devices, described in the tvdevicedesc.xml description document." ); SampleUtil_Print( "" ); SampleUtil_Print( "Commands:" ); SampleUtil_Print( " Help" ); SampleUtil_Print( " Print this help info." ); SampleUtil_Print( " ListDev" ); - SampleUtil_Print - ( " Print the current list of TV Device Emulators that this" ); - SampleUtil_Print - ( " control point is aware of. Each device is preceded by a" ); - SampleUtil_Print - ( " device number which corresponds to the devnum argument of" ); + SampleUtil_Print( " Print the current list of TV Device Emulators that this" ); + SampleUtil_Print( " control point is aware of. Each device is preceded by a" ); + SampleUtil_Print( " device number which corresponds to the devnum argument of" ); SampleUtil_Print( " commands listed below." ); SampleUtil_Print( " Refresh" ); - SampleUtil_Print - ( " Delete all of the devices from the device list and issue new" ); - SampleUtil_Print - ( " search request to rebuild the list from scratch." ); + SampleUtil_Print( " Delete all of the devices from the device list and issue new" ); + SampleUtil_Print( " search request to rebuild the list from scratch." ); SampleUtil_Print( " PrintDev " ); - SampleUtil_Print - ( " Print the state table for the device ." ); - SampleUtil_Print - ( " e.g., 'PrintDev 1' prints the state table for the first" ); + SampleUtil_Print( " Print the state table for the device ." ); + SampleUtil_Print( " e.g., 'PrintDev 1' prints the state table for the first" ); SampleUtil_Print( " device in the device list." ); SampleUtil_Print( " PowerOn " ); - SampleUtil_Print - ( " Sends the PowerOn action to the Control Service of" ); + SampleUtil_Print( " Sends the PowerOn action to the Control Service of" ); SampleUtil_Print( " device ." ); SampleUtil_Print( " PowerOff " ); - SampleUtil_Print - ( " Sends the PowerOff action to the Control Service of" ); + SampleUtil_Print( " Sends the PowerOff action to the Control Service of" ); SampleUtil_Print( " device ." ); SampleUtil_Print( " SetChannel " ); - SampleUtil_Print - ( " Sends the SetChannel action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the channel to be changed" ); + SampleUtil_Print( " Sends the SetChannel action to the Control Service of" ); + SampleUtil_Print( " device , requesting the channel to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " SetVolume " ); - SampleUtil_Print - ( " Sends the SetVolume action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the volume to be changed" ); + SampleUtil_Print( " Sends the SetVolume action to the Control Service of" ); + SampleUtil_Print( " device , requesting the volume to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " SetColor " ); - SampleUtil_Print - ( " Sends the SetColor action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the color to be changed" ); + SampleUtil_Print( " Sends the SetColor action to the Control Service of" ); + SampleUtil_Print( " device , requesting the color to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " SetTint " ); - SampleUtil_Print - ( " Sends the SetTint action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the tint to be changed" ); + SampleUtil_Print( " Sends the SetTint action to the Control Service of" ); + SampleUtil_Print( " device , requesting the tint to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " SetContrast " ); - SampleUtil_Print - ( " Sends the SetContrast action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the contrast to be changed" ); + SampleUtil_Print( " Sends the SetContrast action to the Control Service of" ); + SampleUtil_Print( " device , requesting the contrast to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " SetBrightness " ); - SampleUtil_Print - ( " Sends the SetBrightness action to the Control Service of" ); - SampleUtil_Print - ( " device , requesting the brightness to be changed" ); + SampleUtil_Print( " Sends the SetBrightness action to the Control Service of" ); + SampleUtil_Print( " device , requesting the brightness to be changed" ); SampleUtil_Print( " to ." ); SampleUtil_Print( " CtrlAction " ); - SampleUtil_Print - ( " Sends an action request specified by the string " ); - SampleUtil_Print - ( " to the Control Service of device . This command" ); - SampleUtil_Print - ( " only works for actions that have no arguments." ); - SampleUtil_Print - ( " (e.g., \"CtrlAction 1 IncreaseChannel\")" ); + SampleUtil_Print( " Sends an action request specified by the string " ); + SampleUtil_Print( " to the Control Service of device . This command" ); + SampleUtil_Print( " only works for actions that have no arguments." ); + SampleUtil_Print( " (e.g., \"CtrlAction 1 IncreaseChannel\")" ); SampleUtil_Print( " PictAction " ); - SampleUtil_Print - ( " Sends an action request specified by the string " ); - SampleUtil_Print - ( " to the Picture Service of device . This command" ); - SampleUtil_Print - ( " only works for actions that have no arguments." ); - SampleUtil_Print - ( " (e.g., \"PictAction 1 DecreaseContrast\")" ); + SampleUtil_Print( " Sends an action request specified by the string " ); + SampleUtil_Print( " to the Picture Service of device . This command" ); + SampleUtil_Print( " only works for actions that have no arguments." ); + SampleUtil_Print( " (e.g., \"PictAction 1 DecreaseContrast\")" ); SampleUtil_Print( " CtrlGetVar " ); - SampleUtil_Print - ( " Requests the value of a variable specified by the string " ); - SampleUtil_Print - ( " from the Control Service of device ." ); + SampleUtil_Print( " Requests the value of a variable specified by the string " ); + SampleUtil_Print( " from the Control Service of device ." ); SampleUtil_Print( " (e.g., \"CtrlGetVar 1 Volume\")" ); SampleUtil_Print( " PictGetVar " ); - SampleUtil_Print - ( " Requests the value of a variable specified by the string " ); - SampleUtil_Print - ( " from the Picture Service of device ." ); + SampleUtil_Print( " Requests the value of a variable specified by the string " ); + SampleUtil_Print( " from the Picture Service of device ." ); SampleUtil_Print( " (e.g., \"PictGetVar 1 Tint\")" ); SampleUtil_Print( " Exit" ); SampleUtil_Print( " Exits the control point application." ); @@ -242,7 +209,7 @@ TvCtrlPointPrintLongHelp( void ) * ********************************************************************************/ void -TvCtrlPointPrintCommands( ) +TvCtrlPointPrintCommands() { int i; int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands ); @@ -321,11 +288,11 @@ TvCtrlPointProcessCommand( char *cmdline ) switch ( cmdnum ) { case PRTHELP: - TvCtrlPointPrintShortHelp( ); + TvCtrlPointPrintShortHelp(); break; case PRTFULLHELP: - TvCtrlPointPrintLongHelp( ); + TvCtrlPointPrintLongHelp(); break; case POWON: @@ -411,15 +378,15 @@ TvCtrlPointProcessCommand( char *cmdline ) break; case LSTDEV: - TvCtrlPointPrintList( ); + TvCtrlPointPrintList(); break; case REFRESH: - TvCtrlPointRefresh( ); + TvCtrlPointRefresh(); break; case EXITCMD: - rc = TvCtrlPointStop( ); + rc = TvCtrlPointStop(); exit( rc ); break; @@ -440,20 +407,23 @@ main( int argc, { int rc; ithread_t cmdloop_thread; +#ifndef WIN32 int sig; sigset_t sigs_to_catch; +#endif int code; rc = TvCtrlPointStart( linux_print, NULL ); if( rc != TV_SUCCESS ) { SampleUtil_Print( "Error starting UPnP TV Control Point" ); - exit( rc ); + return rc; } // start a command loop thread code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL ); +#ifndef WIN32 /* Catch Ctrl-C and properly shutdown */ @@ -462,6 +432,10 @@ main( int argc, sigwait( &sigs_to_catch, &sig ); SampleUtil_Print( "Shutting down on signal %d...", sig ); - rc = TvCtrlPointStop( ); - exit( rc ); +#else + ithread_join(cmdloop_thread, NULL); +#endif + + rc = TvCtrlPointStop(); + return rc; } diff --git a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c index 038cc4a..23c10d9 100644 --- a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c +++ b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.c @@ -224,7 +224,7 @@ TvCtrlPointRefresh( void ) { int rc; - TvCtrlPointRemoveAll( ); + TvCtrlPointRemoveAll(); /* Search for all devices of type tvdevice version 1, @@ -539,7 +539,7 @@ TvCtrlPointGetDevice( int devnum, * ********************************************************************************/ int -TvCtrlPointPrintList( ) +TvCtrlPointPrintList() { struct TvDeviceNode *tmpdevnode; int i = 0; @@ -1096,7 +1096,7 @@ TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, if( DescDoc ) ixmlDocument_free( DescDoc ); - TvCtrlPointPrintList( ); + TvCtrlPointPrintList(); break; } @@ -1122,7 +1122,7 @@ TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, TvCtrlPointRemoveDevice( d_event->DeviceId ); SampleUtil_Print( "After byebye:" ); - TvCtrlPointPrintList( ); + TvCtrlPointPrintList(); break; } @@ -1354,7 +1354,7 @@ TvCtrlPointStart( print_string printFunctionPtr, { ithread_t timer_thread; int rc; - short int port = 0; + unsigned short port = 0; char *ip_address = NULL; SampleUtil_Initialize( printFunctionPtr ); @@ -1362,34 +1362,42 @@ TvCtrlPointStart( print_string printFunctionPtr, ithread_mutex_init( &DeviceListMutex, 0 ); - SampleUtil_Print( "Initializing UPnP with ipaddress=%s port=%d", - ip_address, port ); + SampleUtil_Print( + "Initializing UPnP Sdk with\n" + "\tipaddress = %s port = %u\n", + ip_address, port ); + rc = UpnpInit( ip_address, port ); if( UPNP_E_SUCCESS != rc ) { SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc ); - UpnpFinish( ); + UpnpFinish(); return TV_ERROR; } - if( NULL == ip_address ) - ip_address = UpnpGetServerIpAddress( ); - if( 0 == port ) - port = UpnpGetServerPort( ); + if( NULL == ip_address ) { + ip_address = UpnpGetServerIpAddress(); + } + if( 0 == port ) { + port = UpnpGetServerPort(); + } - SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port ); + SampleUtil_Print( + "UPnP Initialized\n" + "\tipaddress= %s port = %u\n", + ip_address, port ); SampleUtil_Print( "Registering Control Point" ); rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler, &ctrlpt_handle, &ctrlpt_handle ); if( UPNP_E_SUCCESS != rc ) { SampleUtil_Print( "Error registering CP: %d", rc ); - UpnpFinish( ); + UpnpFinish(); return TV_ERROR; } SampleUtil_Print( "Control Point Registered" ); - TvCtrlPointRefresh( ); + TvCtrlPointRefresh(); // start a timer thread ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL ); @@ -1400,10 +1408,10 @@ TvCtrlPointStart( print_string printFunctionPtr, int TvCtrlPointStop( void ) { - TvCtrlPointRemoveAll( ); + TvCtrlPointRemoveAll(); UpnpUnRegisterClient( ctrlpt_handle ); - UpnpFinish( ); - SampleUtil_Finish( ); + UpnpFinish(); + SampleUtil_Finish(); return TV_SUCCESS; } diff --git a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h index b47f5c6..7c2d079 100644 --- a/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h +++ b/upnp/sample/tvctrlpt/upnp_tv_ctrlpt.h @@ -39,7 +39,9 @@ extern "C" { #include #include "ithread.h" +#ifndef WIN32 #include +#endif #include #include #include diff --git a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c index 665190b..8b58227 100644 --- a/upnp/sample/tvdevice/linux/upnp_tv_device_main.c +++ b/upnp/sample/tvdevice/linux/upnp_tv_device_main.c @@ -29,10 +29,14 @@ // /////////////////////////////////////////////////////////////////////////// -#include + #include "sample_util.h" #include "upnp_tv_device.h" + +#include + + /****************************************************************************** * linux_print * @@ -82,7 +86,7 @@ TvDeviceCommandLoop( void *args ) if( strcasecmp( cmd, "exit" ) == 0 ) { SampleUtil_Print( "Shutting down...\n" ); - TvDeviceStop( ); + TvDeviceStop(); exit( 0 ); } else { SampleUtil_Print( "\n Unknown command: %s\n\n", cmd ); @@ -117,26 +121,26 @@ TvDeviceCommandLoop( void *args ) * * *****************************************************************************/ -int -main( IN int argc, - IN char **argv ) +int main( IN int argc, IN char **argv ) { unsigned int portTemp = 0; char *ip_address = NULL, *desc_doc_name = NULL, *web_dir_path = NULL; + int rc; ithread_t cmdloop_thread; - int code; - unsigned int port = 0; +#ifndef WIN32 int sig; sigset_t sigs_to_catch; - +#endif + int code; + unsigned int port = 0; int i = 0; SampleUtil_Initialize( linux_print ); - //Parse options + // Parse options for( i = 1; i < argc; i++ ) { if( strcmp( argv[i], "-ip" ) == 0 ) { ip_address = argv[++i]; @@ -163,21 +167,18 @@ main( IN int argc, ( "\tweb_dir_path: Filesystem path where web files " "related to the device are stored\n" ); SampleUtil_Print( "\t\te.g.: /upnp/sample/tvdevice/web\n" ); - exit( 1 ); + return 1; } } port = ( unsigned short )portTemp; - TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path, - linux_print ); + TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path, linux_print ); - /* - start a command loop thread - */ - code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, - NULL ); + /* start a command loop thread */ + code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, NULL ); +#ifndef WIN32 /* Catch Ctrl-C and properly shutdown */ @@ -186,6 +187,11 @@ main( IN int argc, sigwait( &sigs_to_catch, &sig ); SampleUtil_Print( "Shutting down on signal %d...\n", sig ); - TvDeviceStop( ); - exit( 0 ); +#else + ithread_join(cmdloop_thread, NULL); +#endif + rc = TvDeviceStop(); + + return rc; } + diff --git a/upnp/sample/tvdevice/upnp_tv_device.c b/upnp/sample/tvdevice/upnp_tv_device.c index ba29f69..3298dd2 100644 --- a/upnp/sample/tvdevice/upnp_tv_device.c +++ b/upnp/sample/tvdevice/upnp_tv_device.c @@ -1915,11 +1915,11 @@ TvDeviceCallbackEventHandler( Upnp_EventType EventType, * *****************************************************************************/ int -TvDeviceStop( ) +TvDeviceStop() { UpnpUnRegisterRootDevice( device_handle ); - UpnpFinish( ); - SampleUtil_Finish( ); + UpnpFinish(); + SampleUtil_Finish(); ithread_mutex_destroy( &TVDevMutex ); return UPNP_E_SUCCESS; } @@ -1960,30 +1960,35 @@ TvDeviceStart( char *ip_address, SampleUtil_Initialize( pfun ); - SampleUtil_Print - ( "Initializing UPnP Sdk with \n \t ipaddress = %s port = %d\n", - ip_address, port ); + SampleUtil_Print( + "Initializing UPnP Sdk with\n" + "\tipaddress = %s port = %u\n", + ip_address, port ); if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error with UpnpInit -- %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } if( ip_address == NULL ) { - ip_address = UpnpGetServerIpAddress( ); + ip_address = UpnpGetServerIpAddress(); } - port = UpnpGetServerPort( ); + port = UpnpGetServerPort(); - SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n", - ip_address, port ); + SampleUtil_Print( + "UPnP Initialized\n" + "\tipaddress= %s port = %u\n", + ip_address, port ); - if( desc_doc_name == NULL ) + if( desc_doc_name == NULL ) { desc_doc_name = "tvdevicedesc.xml"; + } - if( web_dir_path == NULL ) + if( web_dir_path == NULL ) { web_dir_path = DEFAULT_WEB_DIR; + } snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, port, desc_doc_name ); @@ -1995,37 +2000,39 @@ TvDeviceStart( char *ip_address, SampleUtil_Print ( "Error specifying webserver root directory -- %s: %d\n", web_dir_path, ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } - SampleUtil_Print - ( "Registering the RootDevice\n\t with desc_doc_url: %s\n", - desc_doc_url ); + SampleUtil_Print( + "Registering the RootDevice\n" + "\t with desc_doc_url: %s\n", + desc_doc_url ); if( ( ret = UpnpRegisterRootDevice( desc_doc_url, TvDeviceCallbackEventHandler, &device_handle, &device_handle ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error registering the rootdevice : %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } else { - SampleUtil_Print( "RootDevice Registered\n" ); - - SampleUtil_Print( "Initializing State Table\n" ); + SampleUtil_Print( + "RootDevice Registered\n" + "Initializing State Table\n"); TvDeviceStateTableInit( desc_doc_url ); - SampleUtil_Print( "State Table Initialized\n" ); + SampleUtil_Print("State Table Initialized\n"); if( ( ret = UpnpSendAdvertisement( device_handle, default_advr_expire ) ) != UPNP_E_SUCCESS ) { SampleUtil_Print( "Error sending advertisements : %d\n", ret ); - UpnpFinish( ); + UpnpFinish(); return ret; } - SampleUtil_Print( "Advertisements Sent\n" ); + SampleUtil_Print("Advertisements Sent\n"); } return UPNP_E_SUCCESS; } + diff --git a/upnp/sample/tvdevice/upnp_tv_device.h b/upnp/sample/tvdevice/upnp_tv_device.h index c797409..f16a4d5 100644 --- a/upnp/sample/tvdevice/upnp_tv_device.h +++ b/upnp/sample/tvdevice/upnp_tv_device.h @@ -41,7 +41,9 @@ extern "C" { #include "ithread.h" #include +#ifndef WIN32 #include +#endif #include #include "upnp.h" #include "sample_util.h" diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 9892f93..80ec29c 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -35,6 +35,7 @@ ************************************************************************/ #include "config.h" + #ifndef WIN32 #include #include @@ -48,6 +49,7 @@ typedef int socklen_t; #define EAFNOSUPPORT 97 #endif /* WIN32 */ + #include "unixutil.h" #include "ithread.h" @@ -65,7 +67,6 @@ #include "ThreadPool.h" #include "httpreadwrite.h" #include "statcodes.h" -#include "upnp.h" #include "upnpapi.h" #define APPLICATION_LISTENING_PORT 49152 @@ -378,10 +379,7 @@ schedule_request_job( IN int connfd, static void RunMiniServer( MiniServerSockArray *miniSock ) { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - struct sockaddr_in clientAddr; socklen_t clientLen; SOCKET connectHnd; @@ -550,10 +548,7 @@ int get_miniserver_sockets( MiniServerSockArray * out, unsigned short listen_port ) { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - struct sockaddr_in serverAddr; int listenfd; int success; @@ -817,10 +812,7 @@ StartMiniServer( unsigned short listen_port ) int StopMiniServer() { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - int socklen = sizeof( struct sockaddr_in ); int sock; struct sockaddr_in ssdpAddr; diff --git a/upnp/src/genlib/net/http/httpparser.c b/upnp/src/genlib/net/http/httpparser.c index 70474dc..9a6cdb0 100644 --- a/upnp/src/genlib/net/http/httpparser.c +++ b/upnp/src/genlib/net/http/httpparser.c @@ -395,8 +395,13 @@ scanner_get_str( IN scanner_t * scanner ) * * Note : ************************************************************************/ +#ifndef WIN32 #warning The only use of the function 'scanner_pushback()' in the code is commented out. #warning 'scanner_pushback()' is a candidate for removal. +#else +#pragma message ("The only use of the function 'scanner_pushback()' in the code is commented out.") +#pragma message ("'scanner_pushback()' is a candidate for removal.") +#endif static UPNP_INLINE void scanner_pushback( INOUT scanner_t * scanner, IN size_t pushback_bytes ) @@ -965,8 +970,13 @@ read_until_crlf( INOUT scanner_t * scanner, * PARSE_FAILURE * PARSE_INCOMPLETE ************************************************************************/ +#ifndef WIN32 #warning There are currently no uses of the function 'skip_to_end_of_header()' in the code. #warning 'skip_to_end_of_header()' is a candidate for removal. +#else +#pragma message("There are currently no uses of the function 'skip_to_end_of_header()' in the code.") +#pragma message("'skip_to_end_of_header()' is a candidate for removal.") +#endif static UPNP_INLINE int skip_to_end_of_header( INOUT scanner_t * scanner ) { diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index ce74813..de5a979 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -71,8 +71,16 @@ #include "webserver.h" +/* + * Please, do not change these to const int while MSVC cannot understand + * const int in array dimensions. + */ +/* const int CHUNK_HEADER_SIZE = 10; const int CHUNK_TAIL_SIZE = 10; +*/ +#define CHUNK_HEADER_SIZE 10 +#define CHUNK_TAIL_SIZE 10 /************************************************************************ diff --git a/upnp/src/genlib/net/http/statcodes.c b/upnp/src/genlib/net/http/statcodes.c index ad690e1..92cd62b 100644 --- a/upnp/src/genlib/net/http/statcodes.c +++ b/upnp/src/genlib/net/http/statcodes.c @@ -176,7 +176,7 @@ http_get_code_text( int statusCode ) int table_num; if( !gInitialized ) { - init_tables( ); + init_tables(); } if( statusCode < 100 && statusCode >= 600 ) { diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index 5ac80dd..bda61a1 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -38,11 +38,9 @@ #include #include #ifndef UPNP_USE_BCBPP -#ifndef UPNP_USE_MSVCPP #include #include #endif -#endif #include "util.h" #include "strintmap.h" #include "membuffer.h" @@ -536,9 +534,9 @@ web_server_init( void ) int ret_code; if( bWebServerState == WEB_SERVER_DISABLED ) { - media_list_init( ); // decode media list + media_list_init(); // decode media list membuffer_init( &gDocumentRootDir ); - glob_alias_init( ); + glob_alias_init(); pVirtualDirList = NULL; diff --git a/upnp/src/inc/config.h b/upnp/src/inc/config.h index 4992c82..e79a6b3 100644 --- a/upnp/src/inc/config.h +++ b/upnp/src/inc/config.h @@ -32,6 +32,7 @@ #ifndef INTERNAL_CONFIG_H #define INTERNAL_CONFIG_H + #include "autoconfig.h" diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h index d2a23a6..6a481eb 100644 --- a/upnp/src/inc/upnpapi.h +++ b/upnp/src/inc/upnpapi.h @@ -36,12 +36,8 @@ #include "upnp.h" #include "client_table.h" - //#include "../ssdp/ssdplib.h" - - - #define MAX_INTERFACES 256 #define DEFAULT_INTERFACE 1 diff --git a/upnp/src/inc/util.h b/upnp/src/inc/util.h index 3982d5d..a5d308a 100644 --- a/upnp/src/inc/util.h +++ b/upnp/src/inc/util.h @@ -31,19 +31,22 @@ #ifndef UTIL_H #define UTIL_H + + #include "upnp.h" + // usually used to specify direction of parameters in functions #ifndef IN -#define IN + #define IN #endif #ifndef OUT -#define OUT + #define OUT #endif #ifndef INOUT -#define INOUT + #define INOUT #endif @@ -52,23 +55,18 @@ #define EVENT_TERMINATE -3 -#ifndef WIN32 - #define max(a, b) (((a)>(b))? (a):(b)) - #define min(a, b) (((a)<(b))? (a):(b)) -#endif - - // boolean type in C typedef char xboolean; #ifndef TRUE -#define TRUE 1 + #define TRUE 1 #endif #ifndef FALSE -#define FALSE 0 + #define FALSE 0 #endif + /////////////////////////// // funcs @@ -76,58 +74,62 @@ typedef char xboolean; extern "C" { #endif +/************************************************************************ + * Function: logerror + * + * Parameters: + * IN const char *fmt; format string + * + * Description: Log an error message. + * + * Return: void + ************************************************************************/ void log_error( IN const char *fmt, ... ); /************************************************************************ -* Function : linecopy -* -* Parameters : -* OUT char dest[LINE_SIZE] ; output buffer -* IN const char* src ; input buffer -* -* Description : Copy no of bytes spcified by the LINE_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ + * Function: linecopy + * + * Parameters: + * OUT char dest[LINE_SIZE]; output buffer + * IN const char *src; input buffer + * + * Description: Copy no of bytes spcified by the LINE_SIZE constant, + * from the source buffer. Null terminate the destination buffer. + * + * Return: void + ************************************************************************/ void linecopy( OUT char dest[LINE_SIZE], IN const char* src ); /************************************************************************ -* Function : namecopy -* -* Parameters : -* OUT char dest[NAME_SIZE] ; output buffer -* IN const char* src ; input buffer -* -* Description : Copy no of bytes spcified by the NAME_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ + * Function: namecopy + * + * Parameters: + * OUT char dest[NAME_SIZE]; output buffer + * IN const char *src; input buffer + * + * Description: Copy no of bytes spcified by the NAME_SIZE constant, + * from the source buffer. Null terminate the destination buffer + * + * Return: void + ************************************************************************/ void namecopy( OUT char dest[NAME_SIZE], IN const char* src ); /************************************************************************ -* Function : linecopylen -* -* Parameters : -* OUT char dest[LINE_SIZE] ; output buffer -* IN const char* src ; input buffer -* IN size_t srclen ; bytes to be copied. -* -* Description : Determine if the srclen passed in paramter is less than -* the permitted LINE_SIZE. If it is use the passed parameter, if not -* use the permitted LINE_SIZE as the length parameter -* Copy no of bytes spcified by the LINE_SIZE constant, -* from the source buffer. Null terminate the destination buffer -* -* Return : void ; -* -* Note : -************************************************************************/ + * Function: linecopylen + * + * Parameters: + * OUT char dest[LINE_SIZE]; output buffer + * IN const char *src; input buffer + * IN size_t srclen; bytes to be copied. + * + * Description : Determine if the srclen passed in paramter is less than + * the permitted LINE_SIZE. If it is use the passed parameter, if not + * use the permitted LINE_SIZE as the length parameter + * Copy no of bytes spcified by the LINE_SIZE constant, + * from the source buffer. Null terminate the destination buffer + * + * Return: void + ************************************************************************/ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen ); @@ -135,6 +137,9 @@ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen } // extern C #endif +/* Size of the errorBuffer variable, passed to the strerror_r() function */ +#define ERROR_BUFFER_LEN 256 + ////////////////////////////////// // C specific #ifndef __cplusplus @@ -148,16 +153,21 @@ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif - #define EADDRINUSE WSAEADDRINUSE + #define EADDRINUSE WSAEADDRINUSE - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define strcasecmp stricmp + #define strncasecmp strnicmp - #define sleep(a) Sleep((a)*1000) - #define usleep(a) Sleep((a)/1000) -#endif + #define sleep(a) Sleep((a)*1000) + #define usleep(a) Sleep((a)/1000) + + #define strerror_r(a,b,c) (strerror_s((b),(c),(a))) +#else + #define max(a, b) (((a)>(b))? (a):(b)) + #define min(a, b) (((a)<(b))? (a):(b)) +#endif /* WIN32 */ #endif // __cplusplus -#endif /* GENLIB_UTIL_UTIL_H */ +#endif /* UTIL_H */ diff --git a/upnp/src/soap/soap_device.c b/upnp/src/soap/soap_device.c index 98a02f7..2ecf733 100644 --- a/upnp/src/soap/soap_device.c +++ b/upnp/src/soap/soap_device.c @@ -607,7 +607,7 @@ get_device_info( IN http_message_t * request, save_char = control_url[request->uri.pathquery.size]; ((char *)control_url)[request->uri.pathquery.size] = '\0'; - HandleLock( ); + HandleLock(); if( GetDeviceHandleInfo( &device_hnd, &device_info ) != HND_DEVICE ) { goto error_handler; @@ -663,7 +663,7 @@ get_device_info( IN http_message_t * request, error_handler: ((char *)control_url)[request->uri.pathquery.size] = save_char; // restore - HandleUnlock( ); + HandleUnlock(); return ret_code; } diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c index 9be7fad..efe80f3 100644 --- a/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c @@ -46,12 +46,10 @@ #include "unixutil.h" #ifdef WIN32 - #include - #include - #ifndef imillisleep - #define imillisleep Sleep - #endif -#endif + #include + #include + #include +#endif /* WIN32 */ /************************************************************************ @@ -365,8 +363,13 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, * Returns: void * ***************************************************************************/ +#ifndef WIN32 #warning There are currently no uses of the function 'process_reply()' in the code. #warning 'process_reply()' is a candidate for removal. +#else +#pragma message("There are currently no uses of the function 'process_reply()' in the code.") +#pragma message("'process_reply()' is a candidate for removal.") +#endif static UPNP_INLINE void process_reply( IN char *request_buf, IN int buf_len, @@ -514,10 +517,7 @@ SearchByTarget( IN int Mx, IN char *St, IN void *Cookie ) { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - int socklen = sizeof( struct sockaddr_in ); int *id = NULL; int ret = 0; diff --git a/upnp/src/ssdp/ssdp_device.c b/upnp/src/ssdp/ssdp_device.c index f5f8d27..94af8aa 100644 --- a/upnp/src/ssdp/ssdp_device.c +++ b/upnp/src/ssdp/ssdp_device.c @@ -30,10 +30,14 @@ /////////////////////////////////////////////////////////////////////////// #include "config.h" + #ifdef INCLUDE_DEVICE_APIS #if EXCLUDE_SSDP == 0 + #include #include +#include + #include "ssdplib.h" #include "upnpapi.h" #include "ThreadPool.h" @@ -45,7 +49,7 @@ #ifdef WIN32 #include #include -#endif +#endif /* WIN32 */ #define MSGTYPE_SHUTDOWN 0 #define MSGTYPE_ADVERTISEMENT 1 @@ -213,10 +217,7 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr, IN int NumPacket, IN char **RqPacket ) { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - int ReplySock; int socklen = sizeof( struct sockaddr_in ); int NumCopy; diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c index 50f37e4..c40d465 100644 --- a/upnp/src/ssdp/ssdp_server.c +++ b/upnp/src/ssdp/ssdp_server.c @@ -43,6 +43,7 @@ #include "httpreadwrite.h" #ifdef WIN32 + #include #include #include #include "unixutil.h" @@ -861,10 +862,7 @@ readFromSSDPSocket( SOCKET socket ) int get_ssdp_sockets( MiniServerSockArray * out ) { - // strerror_r() buffer - const int ERROR_BUFFER_LEN = 256; char errorBuffer[ERROR_BUFFER_LEN]; - int onOff = 1; u_char ttl = 4; struct ip_mreq ssdpMcastAddr; diff --git a/upnp/src/uuid/sysdep.c b/upnp/src/uuid/sysdep.c index b776af5..c90467b 100644 --- a/upnp/src/uuid/sysdep.c +++ b/upnp/src/uuid/sysdep.c @@ -18,11 +18,11 @@ */ #include "config.h" -#ifndef WIN32 - #include -#else - #include -#endif +#ifdef WIN32 + #include +#else /* WIN32 */ + #include +#endif /* WIN32 */ #include #include #include "sysdep.h" @@ -56,7 +56,7 @@ get_ieee_node_identifier(uuid_node_t *node) less than 100ns. */ -#ifdef _WINDOWS_ +#ifdef WIN32 void get_system_time( uuid_time_t * uuid_time ) @@ -119,7 +119,7 @@ get_random_info(char seed[16]) MD5Final(seed, &c); }; -#else /* _WINDOWS_ */ +#else /* WIN32 */ /*-----------------------------------------------------------------------------*/ void @@ -163,5 +163,5 @@ get_random_info(char seed[16]) MD5Final(seed, &c); }; -#endif /* _WINDOWS_ */ +#endif /* WIN32 */ diff --git a/upnp/src/uuid/uuid.c b/upnp/src/uuid/uuid.c index 18d62c4..9aa6333 100644 --- a/upnp/src/uuid/uuid.c +++ b/upnp/src/uuid/uuid.c @@ -282,7 +282,7 @@ true_random( void ) inited = 1; }; - return ( rand( ) ); + return ( rand() ); } /*-----------------------------------------------------------------------------*/