Compare commits
24 Commits
release-1.
...
release-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaaa721a15 | ||
|
|
b09faaaec4 | ||
|
|
881952bd0d | ||
|
|
ec93478a4f | ||
|
|
a7ab0acfe8 | ||
|
|
85a8da77f2 | ||
|
|
25620c1967 | ||
|
|
8bc61b1a5c | ||
|
|
aec58e6c9e | ||
|
|
4bcb9dd5e1 | ||
|
|
8cfa0e488c | ||
|
|
9e775e662e | ||
|
|
03400550cd | ||
|
|
62a5d7c5ef | ||
|
|
df80fbae36 | ||
|
|
9c6ea48583 | ||
|
|
8da593fae3 | ||
|
|
b4816a33a9 | ||
|
|
1b029e80af | ||
|
|
907b103439 | ||
|
|
ecd755d3f8 | ||
|
|
b8cac59dd9 | ||
|
|
591e0d3e25 | ||
|
|
bd3bf7ad0a |
382
ChangeLog
382
ChangeLog
@@ -1,8 +1,313 @@
|
||||
*******************************************************************************
|
||||
Version 1.4.7
|
||||
*******************************************************************************
|
||||
|
||||
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Added support for the Basic Device
|
||||
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by
|
||||
Titus Winters.
|
||||
|
||||
2007-05-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Fixed the file libupnp.pc.in to generate a correct path for the
|
||||
include files.
|
||||
|
||||
2007-05-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Removing the Dbg_Level, InitLog, SetLogFileNames and CloseLog
|
||||
defines. These were just aliases, no reason to keep them.
|
||||
|
||||
2007-05-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Changed the comments of the include files that expose the UPnP API
|
||||
to use only C89 comments and no C99 comments.
|
||||
|
||||
2007-05-24 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
* Added tvcombo sample that demonstrates coexistence of a device and a
|
||||
control point in the same application.
|
||||
|
||||
2007-05-24 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
* SF Tracker FR [ 1570020 ].
|
||||
* Enable both device and control point in the same application. Resolve
|
||||
deadlock in the SSDP processing threads.
|
||||
* Fix Threadpool expansion condition.
|
||||
Thanks to Siva Chandran P. for the original patch.
|
||||
|
||||
2007-05-24 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
* Modified tvdevice (control and picture) service descriptions to make
|
||||
compatible with WinXP/IE control point. 'in' arguments must appear before
|
||||
'out' arguments in argument list.
|
||||
Thanks to Martin Tremblay for pointing out the solution originally provided
|
||||
by MORIOKA Yasuhiro.
|
||||
|
||||
2007-05-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* More MSVC fixes, using XINLINE instead of inline, MSVC has troubles
|
||||
with inline. Thanks to David Maass for reporting.
|
||||
* Changed XINLINE to UPNP_INLINE.
|
||||
|
||||
2007-05-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Added the file build/inc/msvc/inttypes.h. This file is for use with
|
||||
MSVC only, because it does not provide C99 compatibility.
|
||||
|
||||
2007-05-18 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Removed all uses of the DEVICEONLY(x) macro.
|
||||
|
||||
2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Removed all uses of the DBGONLY(x) macro. A static inline empty
|
||||
function now is used and the compiler takes care of optimizing it out.
|
||||
|
||||
2007-05-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Fixed a bug in UpnpPrintf, function could call va_start() and return
|
||||
befor calling va_end().
|
||||
|
||||
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h.
|
||||
Thanks to David Maass.
|
||||
|
||||
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* sizeof is unsigned, so %zu is more adequate than %zd.
|
||||
|
||||
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Using an invented printf directive PRIzu that on MSVC
|
||||
expands to "lu", and on normal C99 compilers expands to "zu".
|
||||
|
||||
2007-05-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Rewrote raw_find_str. Now it no longer uses strcasestr(), but it
|
||||
transforms the first input buffer into lowercase.
|
||||
|
||||
2007-05-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Fix for debug printf format strings. size_t are not expected
|
||||
in a string format like "%.*s".
|
||||
|
||||
2007-05-08 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Added inttypes.h as a header requirement in configure.ac.
|
||||
|
||||
2007-05-11 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Moved upnp_tv_ctrlpt and upnp_tv_device executables from folder
|
||||
upnp to folder upnp/sample. Moved folder upnp/sample/tvdevice/web
|
||||
to folder upnp/sample/web. This way, if someone compiles the
|
||||
tarball and executes upnp_tv_device from its creation directory,
|
||||
there will be no error -108 for not finding directory web.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.6
|
||||
*******************************************************************************
|
||||
|
||||
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Fix for freebsd host_os in configure.ac.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.5
|
||||
*******************************************************************************
|
||||
|
||||
2007-04-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* Case insensitive comparison in raw_find_str() (httpparser.c) as
|
||||
suggested by Craig Nelson in SF Tracker [ 1689382 ] DLINK DIR-625
|
||||
patch.
|
||||
|
||||
2007-04-07 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
* Fix for a bug in makeAction where va_arg was beeing called one
|
||||
extra time.
|
||||
|
||||
2007-04-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* SF Tracker [ 1703533 ] Patch to make it compile under FreeBSD
|
||||
Submitted By: Timothy Redaelli - drittz
|
||||
I made some patches to make it compile under FreeBSD using
|
||||
gethostbyaddr_r when supported.
|
||||
|
||||
2007-04-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* [pupnp-devel] Type mixup on x86_64 causes UPNP_E_OUTOF_MEMORY
|
||||
Submitted By: Glen Masgai
|
||||
after an UpnpSendActionAsync() for example, i get UPNP_E_OUTOF_MEMORY
|
||||
in the callback using 1.4.4 on a x86_64 system. This happens in
|
||||
http_MakeMessage(), which in some cases get called with wrong types
|
||||
(int instead of size_t) in combination with format "b" and "Q".
|
||||
The attached patch should fix this.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.4
|
||||
*******************************************************************************
|
||||
|
||||
2007-04-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* SF Tracker [ 1695399 ] Typo in util.h
|
||||
Submitted By: Luke Kim - nereusuj
|
||||
Unix sleep is in seconds but WIN32 Sleep is in milliseconds.
|
||||
|
||||
2007-04-17 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* SF Tracker [ 1652827 ] UpnpRegisterRootDevice returned -104
|
||||
Submitted By: Michael Andersen - miwer
|
||||
|
||||
Issue was found to be related to sizeof (size_t) != sizeof (int)
|
||||
on AMD64 systems. Emil Ljungdahl's AMD64 patch has been applied along
|
||||
with some other fixes. Original user report follows:
|
||||
|
||||
When I run upnpd I get the above mentioned error (UPNP_E_OUTOF_MEMORY).
|
||||
I've tried with 1.4.1 and 1.4.2-RC3, it's the same. I don't understand why,
|
||||
because I have plenty of RAM, and I even tried closing some applications,
|
||||
but it didn't help.
|
||||
|
||||
$ upnpd eth1 br0
|
||||
|
||||
The following is logged in the /var/log/messages:
|
||||
Feb 6 01:33:47 server upnpd[6933]: Error registering the root device with
|
||||
descDocUrl: http://192.168.0.1:49152/gatedesc.xml
|
||||
Feb 6 01:33:47 server upnpd[6933]: UpnpRegisterRootDevice returned -104
|
||||
|
||||
|
||||
I tried enabling debugging and it looks like it cannot allocate memory
|
||||
through the membuffer_append function. It's wierd because it's only a few
|
||||
bytes.
|
||||
|
||||
Please note, that I enabled some extra debugging lines that were commented,
|
||||
in order to get more information. See attached files.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.3
|
||||
*******************************************************************************
|
||||
|
||||
2007-03-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
* SF Tracker [ 1663004 ] Compile on Cygwin
|
||||
Submitted By: Jon Foster - jongfoster
|
||||
This patch gives basic support for building under Cygwin - it compiles,
|
||||
links, and a simple UPnP device application can initialise. I'm not sure
|
||||
if it actually works yet, but this is definitely a step in the right
|
||||
direction.
|
||||
|
||||
Patch is against the 1.4.1 release. Changes are:
|
||||
|
||||
* threadutil/inc/ithread.h: Fix the ithread mutex support to use
|
||||
documented, portable APIs (if present) rather than the Non-Portable (_NP)
|
||||
ones it uses now. This is required because Cygwin implements only the
|
||||
portable API.
|
||||
|
||||
* threadutil/src/ThreadPool.c: Fake SetPolicyType() to do nothing on Cygwin
|
||||
because otherwise it fails. Should probably investigate why it fails and
|
||||
add a proper implementation later.
|
||||
|
||||
* upnp/src/api/upnpapi.c: On Cygwin, zero out the GlobalHndMutex structure
|
||||
before initialising it. Without this, the initialisation fails. This
|
||||
appears to be a bug in Cygwin.
|
||||
|
||||
* upnp/src/genlib/net/uri/uri.c: Use gethostbyname() on Cygwin.
|
||||
|
||||
2007-03-05 Oxy <oxygenic(at)users.sourceforge.net>
|
||||
* Code adapted and typedefs added to compile cleanly under Windows
|
||||
with Borland C++ Builder and MS Visual C++
|
||||
|
||||
2007-03-03 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* Fixed nasty segmentation fault bug on membuffer.c.
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.2
|
||||
*******************************************************************************
|
||||
|
||||
2007-02-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* 32/64 bits portability issues on *printf.
|
||||
Use %zd for size_t, and cast to (long long) for off_t.
|
||||
|
||||
2007-02-02 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* Bumped the program version to 1.4.2 in config.ac.
|
||||
|
||||
* Now requires autoconf 2.60.
|
||||
|
||||
* Fixed docdir use.
|
||||
|
||||
* Does not install the documentation by default.
|
||||
|
||||
* Use dist-bzip2 to create a .bz2 distribution file.
|
||||
|
||||
2007-01-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* SF Tracker [ 1634922 ] Support for large files (>= 2 GiB), part 2
|
||||
Submitted By: Jonathan - no_dice
|
||||
Summary: This patch hopefully fixes the remaining types and related
|
||||
code to enable files >= 2 GiB to be streamed. Jonathan claims to have
|
||||
tested this with a patched version of ushare-0.9.8 and a D-Link DSM-520.
|
||||
|
||||
2007-01-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* SF Tracker [ 1628629 ] Multicast interface patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
This patch fixes two problems:
|
||||
1) Specify the IP address for the interface when we do
|
||||
setsockopt IP_ADD_MEMBERSHIP. This makes it possible to run
|
||||
when no default router has been configured.
|
||||
2) Explicitly set the multicast interface through setsockopt
|
||||
IP_MULTICAST_IF. Avoids socket error -207 in some cases.
|
||||
|
||||
* SF Tracker [ 1628590 ] XML parsing segfault patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
This patch fixes a segmentation fault problem that occurrs
|
||||
when parsing XML code than some routers produce.
|
||||
|
||||
2007-01-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* SF Tracker [ 1628552 ] XML white space patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
|
||||
* SF Tracker [ 1628562 ] Maximum total jobs patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
Also, I incremented the libray versions and included some
|
||||
comments in the file configure.ac so that we do not bump
|
||||
the library version excessively, only the necessary numbers
|
||||
on the next release.
|
||||
|
||||
* SF Tracker [ 1628575 ] Linksys WRT54G patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
|
||||
* SF Tracker [ 1628636 ] SSDP packet copy patch
|
||||
Submitted By: Fredrik Svensson - svefredrik
|
||||
Changed NUM_COPY to 1 since, according to section 9.2 of the
|
||||
HTTPU/MU spec, we should never send more than one copy of a
|
||||
reply to an SSDP request. Ref. section 9.2 of
|
||||
http://www.upnp.org/download/draft-goland-http-udp-04.txt
|
||||
|
||||
2006-12-23 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||
|
||||
* Thorough revision of every call of http_MakeMessage() due to a
|
||||
bug introduced in rev.79 "largefile patch added".
|
||||
http_MakeMessage() has a worst than brain damaged "printf" like
|
||||
interface. In rev.79, the "N" format parameter must be an off_t.
|
||||
Every call of this function with an "N" format parameter and an
|
||||
int passed on the stack would fail terribly.
|
||||
|
||||
* SF Bug tracker [ 1590469 ]
|
||||
Typo in ixmlparser.c
|
||||
Submitted By: Erik Johansson - erijo
|
||||
|
||||
* SF Bug Tracker [ 1590466 ] Invalid xml output
|
||||
Submitted By: Erik Johansson - erijo
|
||||
|
||||
* SF Patch tracker [ 1581161 ] VStudio2005 patch
|
||||
Submitted By: David Maass - darkservant
|
||||
|
||||
* SF Patch tracker [ 1587272 ] const-ified ixml
|
||||
Submitted By: Erik Johansson
|
||||
|
||||
* Finished const-ifications as suggested by Erik Johansson in
|
||||
SF Patch tracker [ 1587272 ].
|
||||
|
||||
2006-07-05 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
* [bug-id] 1580440
|
||||
[submitted-by] Erik Johansson - erijo
|
||||
[patched-by] Erik Johansson - erijo
|
||||
The SOAP HTTP message that's generated on upnp errors
|
||||
is missing a \r\n\ between header and body.
|
||||
|
||||
2006-07-07 Oxy <virtual_worlds(at)gmx.de>
|
||||
|
||||
* support for large files (>2 GBytes) added
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
Version 1.4.1
|
||||
*******************************************************************************
|
||||
|
||||
2006-07-07 Oxy <virtual_worlds(at)gmx.de>
|
||||
|
||||
* full support for Windows added, static library and DLL are fully
|
||||
working, code compiles with Borland Builder C++ and MS Visual
|
||||
C/C++
|
||||
working, code compiles with Borland Builder C++ and MS Visual
|
||||
C/C++
|
||||
|
||||
2006-07-05 Nektarios K. Papadopoulos <npapadop(at)inaccessnetworks.com>
|
||||
|
||||
@@ -27,9 +332,9 @@
|
||||
* Patch to fix memory leaks and reasons for crashes added (thanks
|
||||
to loigu)
|
||||
|
||||
*************************************************************************
|
||||
Release of version 1.4.0
|
||||
*************************************************************************
|
||||
*******************************************************************************
|
||||
Version 1.4.0
|
||||
*******************************************************************************
|
||||
|
||||
2006-05-26 Oxy <virtual_worlds(at)gmx.de>
|
||||
|
||||
@@ -46,24 +351,27 @@ Release of version 1.4.0
|
||||
2006-05-18 Oxy <virtual_worlds(at)gmx.de>
|
||||
|
||||
* DSM-320 patch added (fetched from project MediaTomb)
|
||||
|
||||
* httpGet additons atch added, Added proxy support by introducing
|
||||
UpnpOpenHttpGetProxy. UpnpOpenHttpGet now just calls
|
||||
UpnpOpenHttpGetProxy with the proxy url set to NULL.
|
||||
|
||||
* Bugfix for typo ("\0" / "0") in ixmlparser.c
|
||||
|
||||
* Bugfix for M-Search packet
|
||||
|
||||
*************************************************************************
|
||||
*******************************************************************************
|
||||
FORK FROM DEAD libupnp
|
||||
*************************************************************************
|
||||
*******************************************************************************
|
||||
|
||||
2006-04-29 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-04-29 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* THANKS: new file with list of contributors
|
||||
|
||||
* upnp/src/gena/gena_device.c (respond_ok): add 'Content-Length: 0'
|
||||
in subscription response. Patch by Chaos (Bug # 1455367).
|
||||
|
||||
2006-04-08 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-04-08 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/doc/UPnP_Programming_Guide.pdf: replace this document with
|
||||
the one in libupnp-doc-1.2.1 because current CVS version
|
||||
@@ -74,20 +382,20 @@ FORK FROM DEAD libupnp
|
||||
* changes applied to several files to work under Sparc Solaris, temporarily
|
||||
requiring a define SPARC_SOLARIS
|
||||
|
||||
2006-04-03 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-04-03 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/Makefile.am: install upnp samples in $(docdir)/examples
|
||||
|
||||
2006-03-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* configure.ac: add --with-docdir option to choose where documentation
|
||||
is installed (or -without-docdir to not install the documentation)
|
||||
|
||||
2006-03-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* ixml/test: add simple test suite for xml parser
|
||||
|
||||
2006-03-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* ixml/src/ixmlparser.c (Parser_processCDSect): fix bug which prevents
|
||||
CDATA sections which contain a 0 (zero) to be parsed (instead the
|
||||
@@ -98,18 +406,18 @@ FORK FROM DEAD libupnp
|
||||
option, and move samples compilation from check_PROGRAMS to
|
||||
noinst_PROGRAMS
|
||||
|
||||
2006-03-25 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-25 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/genlib/miniserver/miniserver.c (get_miniserver_sockets):
|
||||
fix bug if new socket created has fd 0 (can only occur when stdin
|
||||
has been closed). Patch by Oskar Liljeblad 2004-07-02 :
|
||||
http://sourceforge.net/mailarchive/message.php?msg_id=8870528
|
||||
|
||||
2006-03-21 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-21 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/test/test_init.c: add some version checks and exit if failure
|
||||
|
||||
2006-03-05 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-05 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* libupnp version 1.3.1
|
||||
|
||||
@@ -124,11 +432,11 @@ FORK FROM DEAD libupnp
|
||||
dependencies between upnp and ixml / threadutil, so that programs
|
||||
linking against upnp only still work.
|
||||
|
||||
2006-03-04 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-04 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* libupnp version 1.3.0
|
||||
|
||||
2006-03-03 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-03-03 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/genlib/net/http/httpreadwrite.c (get_sdk_info): use
|
||||
package version string from configure to set sdk info
|
||||
@@ -136,7 +444,7 @@ FORK FROM DEAD libupnp
|
||||
* upnp/Makefile.am: add sample/tvdevice/web/ files in EXTRA_DIST
|
||||
+ do not distribute generated upnpconfig.h file.
|
||||
|
||||
2006-02-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-02-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/inc/config.h, configure.ac: use only new defines
|
||||
UPNP_HAVE_xx instead of INCLUDE_yyy_APIS and INTERNAL_WEB_SERVER
|
||||
@@ -145,7 +453,7 @@ FORK FROM DEAD libupnp
|
||||
the librarie LDFLAGS in order to export only the symbols defined
|
||||
in the API
|
||||
|
||||
2006-02-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-02-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* configure.ac: add libtool versions for the 3 libraries
|
||||
|
||||
@@ -153,7 +461,7 @@ FORK FROM DEAD libupnp
|
||||
|
||||
* threadutil/src/ThreadPool.c (SetSeed): add missing 'static'
|
||||
|
||||
2006-02-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-02-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* threadutil/inc/iasnprintf.h: add gcc __printf__ format attribute
|
||||
to "iasnprintf"
|
||||
@@ -174,11 +482,11 @@ FORK FROM DEAD libupnp
|
||||
the configuration of the installed libraries (generates installed
|
||||
file <upnp/upnpconfig.h>)
|
||||
|
||||
2006-02-22 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-02-22 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/ : add missing include of config.h in some .c files
|
||||
|
||||
2006-02-21 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-02-21 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/inc/upnp.h: move some definitions which should not be
|
||||
exported into "upnp/src/inc/util.h"
|
||||
@@ -186,12 +494,12 @@ FORK FROM DEAD libupnp
|
||||
* import all modifications below from libupnp in djmount 0.51
|
||||
into official libupnp
|
||||
|
||||
2006-01-17 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-01-17 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* threadutil/Makefile.am (libthreadutil_la_SOURCES): remove extraneous
|
||||
file
|
||||
|
||||
2006-01-15 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-01-15 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* configure.ac: add checks for large-file support
|
||||
|
||||
@@ -211,53 +519,53 @@ FORK FROM DEAD libupnp
|
||||
* ixml/src/node.c (ixmlNode_getNodeType): fix compilation warning
|
||||
on const return type
|
||||
|
||||
2006-01-12 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-01-12 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/inc/readwrite.h : suppress unused C++ header file
|
||||
|
||||
2006-01-11 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2006-01-11 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/inc/config.h, upnp/src/inc/upnpapi.h,
|
||||
upnp/src/inc/httpreadwrite.h: remove internal configuration variable
|
||||
MINIMUM_DELAY (no clear purpose)
|
||||
|
||||
2005-12-05 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-12-05 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/inc/upnp.h: re-declare obsolete method UpnpSetContentLength,
|
||||
for binary compatibility with previous libupnp version.
|
||||
|
||||
* upnp/src/api/upnpapi.c: correct type of g_maxContentLength to size_t
|
||||
|
||||
2005-11-01 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-11-01 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* autoconfiscate library : replace all makefiles by Makefile.am
|
||||
for automake support, + preliminary autoconf support
|
||||
(generated config.h not yet used in source files)
|
||||
|
||||
2005-10-18 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-10-18 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/makefile: fix location of DEBUG STATIC libupnp library
|
||||
|
||||
* upnp/sample/tvctrlpt/linux/Makefile,
|
||||
upnp/sample/tvdevice/linux/Makefile: fix STATIC library support
|
||||
|
||||
2005-10-16 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-10-16 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* threadutil/src/Makefile (clean): remove built library
|
||||
|
||||
2005-08-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-08-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* ixml/src/ixml.h, ixml/src/ixml.c (ixmlRelaxParser) : new function
|
||||
|
||||
* ixml/src/ixmlparser.h, ixml/src/ixmlparser.c (Parser_setErrorChar) :
|
||||
new function
|
||||
|
||||
2005-08-02 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-08-02 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* ixml/src/Makefile: correct bug for static library being incorrectly
|
||||
stripped when building non-debug
|
||||
|
||||
2005-06-09 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-06-09 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* ixml/src/element.c (ixmlElement_removeAttributeNode):
|
||||
remove some compilation warning
|
||||
@@ -268,7 +576,7 @@ FORK FROM DEAD libupnp
|
||||
* upnp/inc/upnptools.h, upnp/src/api/upnptools.c :
|
||||
add missing const's in public API
|
||||
|
||||
2005-05-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-05-28 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/inc/config.h: suppress HTTP_READ_BYTES (unused)
|
||||
and replace by DEFAULT_SOAP_CONTENT_LENGTH (previously in upnpapi.h)
|
||||
@@ -289,7 +597,7 @@ FORK FROM DEAD libupnp
|
||||
* upnp/src/genlib/net/http/httpreadwrite.c : corrected an incorrect
|
||||
sprintf format
|
||||
|
||||
2005-05-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-05-27 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/makefile, upnp/src/makefile,
|
||||
ixml/Makefile, ixml/src/Makefile,
|
||||
@@ -297,7 +605,7 @@ FORK FROM DEAD libupnp
|
||||
implement STATIC library support (from patch at
|
||||
http://sourceforge.net/tracker/?group_id=7189&atid=307189 )
|
||||
|
||||
2005-05-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
2005-05-26 R<>mi Turboult <r3mi(at)users.sourceforge.net>
|
||||
|
||||
* upnp/src/api/upnpapi.c, upnp/src/soap/soap_device.c,
|
||||
upnp/src/soap/makefile :
|
||||
|
||||
49
Makefile.am
49
Makefile.am
@@ -1,44 +1,49 @@
|
||||
# $Id: Makefile.am,v 1.5 2006/04/29 20:12:50 r3mi Exp $
|
||||
|
||||
#
|
||||
# Top-level "Makefile.am" for libupnp
|
||||
#
|
||||
# Copyright (C) 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
# Copyright (C) 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
#
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-debug --enable-samples
|
||||
|
||||
SUBDIRS = ixml threadutil upnp docs/dist
|
||||
SUBDIRS = \
|
||||
ixml \
|
||||
threadutil \
|
||||
upnp \
|
||||
docs/dist
|
||||
|
||||
|
||||
EXTRA_DIST = libupnp.pc.in LICENSE THANKS libupnp.spec \
|
||||
build/libupnp.bpf \
|
||||
build/libupnp.bpr \
|
||||
build/libupnp.dsp \
|
||||
build/libupnp.dsw \
|
||||
build/inc/autoconfig.h \
|
||||
build/inc/config.h \
|
||||
build/inc/upnpconfig.h
|
||||
EXTRA_DIST = \
|
||||
libupnp.pc.in \
|
||||
LICENSE \
|
||||
THANKS \
|
||||
libupnp.spec \
|
||||
build/libupnp.bpf \
|
||||
build/libupnp.bpr \
|
||||
build/libupnp.dsp \
|
||||
build/libupnp.dsw \
|
||||
build/inc/autoconfig.h \
|
||||
build/inc/config.h \
|
||||
build/inc/upnpconfig.h \
|
||||
build/msvc/inttypes.h
|
||||
|
||||
|
||||
# This variable must have 'exec' in its name, in order to be installed
|
||||
# by 'install-exec' target (instead of default 'install-data')
|
||||
pkgconfigexecdir = $(libdir)/pkgconfig
|
||||
pkgconfigexec_DATA = libupnp.pc
|
||||
pkgconfigexecdir = $(libdir)/pkgconfig
|
||||
pkgconfigexec_DATA = libupnp.pc
|
||||
|
||||
|
||||
$(pkgconfigexec_DATA): config.status
|
||||
|
||||
|
||||
if WITH_DOCDIR
|
||||
docdir = @DOCDIR@
|
||||
doc_DATA = LICENSE README NEWS TODO THANKS
|
||||
if WITH_DOCUMENTATION
|
||||
doc_DATA = LICENSE README NEWS TODO THANKS
|
||||
endif
|
||||
|
||||
|
||||
CLEANFILES = IUpnpErrFile.txt IUpnpInfoFile.txt
|
||||
|
||||
|
||||
|
||||
|
||||
CLEANFILES = IUpnpErrFile.txt IUpnpInfoFile.txt
|
||||
|
||||
|
||||
2
README
2
README
@@ -1,7 +1,7 @@
|
||||
Portable SDK for UPnP* Devices (libupnp)
|
||||
|
||||
Copyright (c) 2000-2003 Intel Corporation - All Rights Reserved.
|
||||
Copyright (c) 2005-2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
Copyright (c) 2005-2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
Copyright (c) 2006 Michel Pfeiffer and others <virtual_worlds@gmx.de>
|
||||
|
||||
See LICENSE for details.
|
||||
|
||||
25
THANKS
25
THANKS
@@ -6,18 +6,29 @@ suggesting various improvements or submitting actual code.
|
||||
Here is a list of these people. Help us keep it complete and
|
||||
exempt of errors.
|
||||
|
||||
- Erwan Velu
|
||||
- Paul Vixie
|
||||
- Arno Willig
|
||||
- Eric Tanguy
|
||||
- Oskar Liljeblad
|
||||
- Chaos
|
||||
- John Dennis
|
||||
- Craig Nelson
|
||||
- David Maass
|
||||
- Emil Ljungdahl
|
||||
- Erik Johansson
|
||||
- Eric Tanguy
|
||||
- Erwan Velu
|
||||
- Fredrik Svensson
|
||||
- Glen Masgai
|
||||
- Jiri Zouhar
|
||||
- John Dennis
|
||||
- Jonathan (no_dice)
|
||||
- Leuk_He
|
||||
- Loigu
|
||||
- Marcelo Jimenez
|
||||
- Luke Kim
|
||||
- Marcelo Roberto Jimenez
|
||||
- Markus Strobl
|
||||
- Nektarios K. Papadopoulos
|
||||
- Oxy
|
||||
- Oskar Liljeblad
|
||||
- Michael (Oxy)
|
||||
- Paul Vixie
|
||||
- Siva Chandran
|
||||
- Timothy Redaelli
|
||||
- Titus Winters
|
||||
|
||||
|
||||
@@ -13,7 +13,3 @@ autoreconf --force --install -Wall -Wno-obsolete $* || exit 1
|
||||
echo "Now run ./configure and then make."
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* autoconfig.h. Generated by configure. */
|
||||
/* autoconfig.h. Generated from autoconfig.h.in by configure. */
|
||||
/* autoconfig.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 to compile debug code */
|
||||
@@ -19,15 +19,18 @@
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#define HAVE_FSEEKO 1
|
||||
|
||||
/* Define to 1 if you have the `ftime' function. */
|
||||
#define HAVE_FTIME 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `compat' library (-lcompat). */
|
||||
/* #undef HAVE_LIBCOMPAT */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
@@ -92,19 +95,19 @@
|
||||
#define PACKAGE "libupnp"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "virtual_worlds@gmx.de"
|
||||
#define PACKAGE_BUGREPORT "mroberto@users.sourceforge.net"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libupnp"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libupnp 1.4.0"
|
||||
#define PACKAGE_STRING "libupnp 1.4.7"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libupnp"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.4.0"
|
||||
#define PACKAGE_VERSION "1.4.7"
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
@@ -135,27 +138,30 @@
|
||||
#define UPNP_VERSION_MINOR 4
|
||||
|
||||
/* see upnpconfig.h */
|
||||
#define UPNP_VERSION_PATCH 0
|
||||
#define UPNP_VERSION_PATCH 7
|
||||
|
||||
/* see upnpconfig.h */
|
||||
#define UPNP_VERSION_STRING "1.4.0"
|
||||
#define UPNP_VERSION_STRING "1.4.7"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.4.0"
|
||||
#define VERSION "1.4.7"
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* File Offset size */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
/* #undef _LARGEFILE_SOURCE */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
/* Large files support */
|
||||
#define _LARGE_FILE_SOURCE
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Substitute for socklen_t */
|
||||
|
||||
@@ -95,6 +95,17 @@
|
||||
#define MAX_THREADS 12
|
||||
//@}
|
||||
|
||||
/** @name MAX_JOBS_TOTAL
|
||||
* The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
|
||||
* that can be queued. If this limit is reached further jobs will be thrown
|
||||
* to avoid memory exhaustion. The default value 100.
|
||||
* (Added by Axis.)
|
||||
*/
|
||||
|
||||
//@{
|
||||
#define MAX_JOBS_TOTAL 100
|
||||
//@}
|
||||
|
||||
/** @name DEFAULT_SOAP_CONTENT_LENGTH
|
||||
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
||||
* This prevents devices that have a misbehaving web server to send
|
||||
@@ -293,68 +304,40 @@
|
||||
|
||||
|
||||
|
||||
/** @name DBGONLY
|
||||
The {\bf DBGONLY} macro allows code to be marked so that it
|
||||
is only included in the DEBUG build and not the release. To
|
||||
use this macro, put the code inside of the parentheses:
|
||||
|
||||
{\tt DBGONLY(int i;)}
|
||||
|
||||
This will cause a declaration of the integer {\tt i} only
|
||||
in the debug build.
|
||||
*/
|
||||
|
||||
//@{
|
||||
#ifdef DEBUG
|
||||
#define DBGONLY(x) x
|
||||
#else
|
||||
#define DBGONLY(x)
|
||||
#endif
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
#undef EXCLUDE_WEB_SERVER
|
||||
#undef EXCLUDE_MINISERVER
|
||||
#ifdef INTERNAL_WEB_SERVER
|
||||
#define EXCLUDE_WEB_SERVER 0
|
||||
#define EXCLUDE_MINISERVER 0
|
||||
# define EXCLUDE_WEB_SERVER 0
|
||||
# define EXCLUDE_MINISERVER 0
|
||||
#else
|
||||
#define EXCLUDE_WEB_SERVER 1
|
||||
#define EXCLUDE_MINISERVER 1
|
||||
# define EXCLUDE_WEB_SERVER 1
|
||||
# define EXCLUDE_MINISERVER 1
|
||||
#endif
|
||||
|
||||
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
|
||||
#undef EXCLUDE_MINISERVER
|
||||
#define EXCLUDE_MINISERVER 1
|
||||
#if INTERNAL_WEB_SERVER
|
||||
# error "conflicting settings: use configure --disable-webserver"
|
||||
#endif
|
||||
# undef EXCLUDE_MINISERVER
|
||||
# define EXCLUDE_MINISERVER 1
|
||||
# if INTERNAL_WEB_SERVER
|
||||
# error "conflicting settings: use configure --disable-webserver"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
|
||||
#undef EXCLUDE_MINISERVER
|
||||
#define EXCLUDE_MINISERVER 0
|
||||
#if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
||||
#error "conflicting settings : use configure --enable-webserver"
|
||||
#endif
|
||||
# undef EXCLUDE_MINISERVER
|
||||
# define EXCLUDE_MINISERVER 0
|
||||
# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
||||
# error "conflicting settings : use configure --enable-webserver"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
#define CLIENTONLY(x) x
|
||||
# define CLIENTONLY(x) x
|
||||
#else
|
||||
#define CLIENTONLY(x)
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
#define DEVICEONLY(x) x
|
||||
#else
|
||||
#define DEVICEONLY(x)
|
||||
# define CLIENTONLY(x)
|
||||
#endif
|
||||
|
||||
//@}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* upnp/inc/upnpconfig.h. Generated by configure. */
|
||||
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
|
||||
// -*- C -*-
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
// Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@@ -40,7 +40,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
/** The library version (string) e.g. "1.3.0" */
|
||||
#define UPNP_VERSION_STRING "1.4.0"
|
||||
#define UPNP_VERSION_STRING "1.4.7"
|
||||
|
||||
/** Major version of the library */
|
||||
#define UPNP_VERSION_MAJOR 1
|
||||
@@ -49,7 +49,7 @@
|
||||
#define UPNP_VERSION_MINOR 4
|
||||
|
||||
/** Patch version of the library */
|
||||
#define UPNP_VERSION_PATCH 0
|
||||
#define UPNP_VERSION_PATCH 7
|
||||
|
||||
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
||||
#define UPNP_VERSION \
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
/** Defined to 1 if the library has been compiled with DEBUG enabled
|
||||
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
|
||||
#undef UPNP_HAVE_DEBUG
|
||||
/* #undef UPNP_HAVE_DEBUG */
|
||||
|
||||
|
||||
/** Defined to 1 if the library has been compiled with client API enabled
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<RESFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value="..\..\..\pthreads-w32-1-10-0-release\pthreadBC1.lib"/>
|
||||
<LIBFILES value="D:\pthreads-w32-1-10-0-release\pthreadBC1.lib"/>
|
||||
<LIBRARIES value=""/>
|
||||
<SPARELIBS value=""/>
|
||||
<PACKAGES value=""/>
|
||||
@@ -45,11 +45,11 @@
|
||||
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
|
||||
<RELEASELIBPATH value="$(BCB)\lib\release"/>
|
||||
<LINKER value="tlink32"/>
|
||||
<USERDEFINES value="WIN32;LIBUPNP_EXPORTS"/>
|
||||
<USERDEFINES value="WIN32;LIBUPNP_EXPORTS;UPNP_USE_BCBPP"/>
|
||||
<SYSDEFINES value="NO_STRICT;_NO_VCL"/>
|
||||
<MAINSOURCE value="libupnp.bpf"/>
|
||||
<INCLUDEPATH value="..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc"/>
|
||||
<LIBPATH value="..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<INCLUDEPATH value="..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc;..\..\pthreads-w32-1-10-0-release"/>
|
||||
<LIBPATH value="..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib;..\..\pthreads-w32-1-10-0-release"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
@@ -94,22 +94,27 @@ ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=1
|
||||
Item0=..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc
|
||||
Count=3
|
||||
Item0=..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc;..\..\pthreads-w32-1-10-0-release
|
||||
Item1=..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc;D:\DEVELOP\pthreads-w32-1-10-0-release
|
||||
Item2=..\upnp\src\genlib\util;..\upnp\src;..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\threadutil\src;..\ixml\src;$(BCB)\include;$(BCB)\include\vcl;..\ixml\inc;..\threadutil\inc;..\upnp\inc;inc;..\ixml\src\inc;..\upnp\src\inc
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=1
|
||||
Item0=..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Count=3
|
||||
Item0=..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib;..\..\pthreads-w32-1-10-0-release
|
||||
Item1=..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib;D:\DEVELOP\pthreads-w32-1-10-0-release
|
||||
Item2=..\upnp\src\uuid;..\upnp\src\urlconfig;..\upnp\src\ssdp;..\upnp\src\soap;..\upnp\src\genlib\util;..\upnp\src\genlib\service_table;..\upnp\src\genlib\net\uri;..\upnp\src\genlib\net\http;..\upnp\src\genlib\net;..\upnp\src\genlib\miniserver;..\upnp\src\genlib\client_table;..\upnp\src\gena;..\upnp\src\api;..\upnp\src;..\threadutil\src;..\ixml\src;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=1
|
||||
Item0=$(BCB)\source\vcl
|
||||
|
||||
[HistoryLists\hlConditionals]
|
||||
Count=3
|
||||
Item0=WIN32;LIBUPNP_EXPORTS
|
||||
Item1=WIN32;EXPORT_SPEC
|
||||
Item2=WIN32
|
||||
Count=4
|
||||
Item0=WIN32;LIBUPNP_EXPORTS;UPNP_USE_BCBPP
|
||||
Item1=WIN32;LIBUPNP_EXPORTS
|
||||
Item2=WIN32;EXPORT_SPEC
|
||||
Item3=WIN32
|
||||
|
||||
[Debugging]
|
||||
DebugSourceDirs=$(BCB)\source\vcl
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=libupnp - Win32 Debug
|
||||
!MESSAGE Dies ist kein g<>ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>hren Sie den Befehl
|
||||
!MESSAGE Dies ist kein g<>ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>hren Sie den Befehl
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libupnp.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE Sie k<>nnen beim Ausf<73>hren von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE Sie k<>nnen beim Ausf<73>hren von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libupnp.mak" CFG="libupnp - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE F<>r die Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE F<>r die Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE
|
||||
!MESSAGE "libupnp - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libupnp - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library")
|
||||
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\pthreads\include" /I "..\ixml\src\inc" /I "..\ixml\inc" /I "..\threadutil\inc" /I "..\upnp\inc" /I "..\upnp\src\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /FR /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\pthreads\include" /I "..\ixml\src\inc" /I "..\ixml\inc" /I "..\threadutil\inc" /I "..\upnp\inc" /I "..\upnp\src\inc" /I ".\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /D "PTW32_STATIC_LIB" /D "UPNP_STATIC_LIB" /D "UPNP_USE_MSVCPP" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
@@ -53,7 +53,8 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\pthreads\lib\pthreadvc2.lib ws2_32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib /nologo /dll /machine:I386
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "libupnp - Win32 Debug"
|
||||
|
||||
@@ -69,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\pthreads\include" /I "..\ixml\src\inc" /I "..\ixml\inc" /I "..\threadutil\inc" /I "..\upnp\inc" /I "..\upnp\src\inc" /I "..\build\inc" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\pthreads\include" /I "..\ixml\src\inc" /I "..\ixml\inc" /I "..\threadutil\inc" /I "..\upnp\inc" /I "..\upnp\src\inc" /I "..\build\inc" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBUPNP_EXPORTS" /D "UPNP_USE_MSVCPP" /FR /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
@@ -79,7 +80,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\pthreads\lib\pthreadvc2.lib ws2_32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -274,6 +275,146 @@ SOURCE=..\upnp\src\win_dll.c
|
||||
# Begin Group "Header-Dateien"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\client_table.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\config.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\gena.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\gena_ctrlpt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\gena_device.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\global.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\gmtdate.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\http_client.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\httpparser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\httpreadwrite.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\inet_pton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\md5.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\membuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\miniserver.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\netall.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\parsetools.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\server.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\service_table.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\soaplib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\sock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\ssdplib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\statcodes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\statuscodes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\strintmap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\sysdep.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\unixutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\upnp_timeout.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\upnpapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\upnpclosesocket.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\uri.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\urlconfig.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\util.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\utilall.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\uuid.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\upnp\src\inc\webserver.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Ressourcendateien"
|
||||
|
||||
|
||||
301
build/msvc/inttypes.h
Normal file
301
build/msvc/inttypes.h
Normal file
@@ -0,0 +1,301 @@
|
||||
// ISO C9x compliant inttypes.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_INTTYPES_H_ // [
|
||||
#define _MSC_INTTYPES_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// 7.8 Format conversion of integer types
|
||||
|
||||
typedef struct {
|
||||
intmax_t quot;
|
||||
intmax_t rem;
|
||||
} imaxdiv_t;
|
||||
|
||||
// 7.8.1 Macros for format specifiers
|
||||
|
||||
// The fprintf macros for signed integers are:
|
||||
#define PRId8 "d"
|
||||
#define PRIi8 "i"
|
||||
#define PRIdLEAST8 "d"
|
||||
#define PRIiLEAST8 "i"
|
||||
#define PRIdFAST8 "d"
|
||||
#define PRIiFAST8 "i"
|
||||
|
||||
#define PRId16 "hd"
|
||||
#define PRIi16 "hi"
|
||||
#define PRIdLEAST16 "hd"
|
||||
#define PRIiLEAST16 "hi"
|
||||
#define PRIdFAST16 "hd"
|
||||
#define PRIiFAST16 "hi"
|
||||
|
||||
#define PRId32 "I32d"
|
||||
#define PRIi32 "I32i"
|
||||
#define PRIdLEAST32 "I32d"
|
||||
#define PRIiLEAST32 "I32i"
|
||||
#define PRIdFAST32 "I32d"
|
||||
#define PRIiFAST32 "I32i"
|
||||
|
||||
#define PRId64 "I64d"
|
||||
#define PRIi64 "I64i"
|
||||
#define PRIdLEAST64 "I64d"
|
||||
#define PRIiLEAST64 "I64i"
|
||||
#define PRIdFAST64 "I64d"
|
||||
#define PRIiFAST64 "I64i"
|
||||
|
||||
#define PRIdMAX "I64d"
|
||||
#define PRIiMAX "I64i"
|
||||
|
||||
#define PRIdPTR "Id"
|
||||
#define PRIiPTR "Ii"
|
||||
|
||||
// The fprintf macros for unsigned integers are:
|
||||
#define PRIo8 "o"
|
||||
#define PRIu8 "u"
|
||||
#define PRIx8 "x"
|
||||
#define PRIX8 "X"
|
||||
#define PRIoLEAST8 "o"
|
||||
#define PRIuLEAST8 "u"
|
||||
#define PRIxLEAST8 "x"
|
||||
#define PRIXLEAST8 "X"
|
||||
#define PRIoFAST8 "o"
|
||||
#define PRIuFAST8 "u"
|
||||
#define PRIxFAST8 "x"
|
||||
#define PRIXFAST8 "X"
|
||||
|
||||
#define PRIo16 "ho"
|
||||
#define PRIu16 "hu"
|
||||
#define PRIx16 "hx"
|
||||
#define PRIX16 "hX"
|
||||
#define PRIoLEAST16 "ho"
|
||||
#define PRIuLEAST16 "hu"
|
||||
#define PRIxLEAST16 "hx"
|
||||
#define PRIXLEAST16 "hX"
|
||||
#define PRIoFAST16 "ho"
|
||||
#define PRIuFAST16 "hu"
|
||||
#define PRIxFAST16 "hx"
|
||||
#define PRIXFAST16 "hX"
|
||||
|
||||
#define PRIo32 "I32o"
|
||||
#define PRIu32 "I32u"
|
||||
#define PRIx32 "I32x"
|
||||
#define PRIX32 "I32X"
|
||||
#define PRIoLEAST32 "I32o"
|
||||
#define PRIuLEAST32 "I32u"
|
||||
#define PRIxLEAST32 "I32x"
|
||||
#define PRIXLEAST32 "I32X"
|
||||
#define PRIoFAST32 "I32o"
|
||||
#define PRIuFAST32 "I32u"
|
||||
#define PRIxFAST32 "I32x"
|
||||
#define PRIXFAST32 "I32X"
|
||||
|
||||
#define PRIo64 "I64o"
|
||||
#define PRIu64 "I64u"
|
||||
#define PRIx64 "I64x"
|
||||
#define PRIX64 "I64X"
|
||||
#define PRIoLEAST64 "I64o"
|
||||
#define PRIuLEAST64 "I64u"
|
||||
#define PRIxLEAST64 "I64x"
|
||||
#define PRIXLEAST64 "I64X"
|
||||
#define PRIoFAST64 "I64o"
|
||||
#define PRIuFAST64 "I64u"
|
||||
#define PRIxFAST64 "I64x"
|
||||
#define PRIXFAST64 "I64X"
|
||||
|
||||
#define PRIoMAX "I64o"
|
||||
#define PRIuMAX "I64u"
|
||||
#define PRIxMAX "I64x"
|
||||
#define PRIXMAX "I64X"
|
||||
|
||||
#define PRIoPTR "Io"
|
||||
#define PRIuPTR "Iu"
|
||||
#define PRIxPTR "Ix"
|
||||
#define PRIXPTR "IX"
|
||||
|
||||
// The fscanf macros for signed integers are:
|
||||
#define SCNd8 "d"
|
||||
#define SCNi8 "i"
|
||||
#define SCNdLEAST8 "d"
|
||||
#define SCNiLEAST8 "i"
|
||||
#define SCNdFAST8 "d"
|
||||
#define SCNiFAST8 "i"
|
||||
|
||||
#define SCNd16 "hd"
|
||||
#define SCNi16 "hi"
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNdFAST16 "hd"
|
||||
#define SCNiFAST16 "hi"
|
||||
|
||||
#define SCNd32 "ld"
|
||||
#define SCNi32 "li"
|
||||
#define SCNdLEAST32 "ld"
|
||||
#define SCNiLEAST32 "li"
|
||||
#define SCNdFAST32 "ld"
|
||||
#define SCNiFAST32 "li"
|
||||
|
||||
#define SCNd64 "I64d"
|
||||
#define SCNi64 "I64i"
|
||||
#define SCNdLEAST64 "I64d"
|
||||
#define SCNiLEAST64 "I64i"
|
||||
#define SCNdFAST64 "I64d"
|
||||
#define SCNiFAST64 "I64i"
|
||||
|
||||
#define SCNdMAX "I64d"
|
||||
#define SCNiMAX "I64i"
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define SCNdPTR "I64d"
|
||||
# define SCNiPTR "I64i"
|
||||
#else // _WIN64 ][
|
||||
# define SCNdPTR "ld"
|
||||
# define SCNiPTR "li"
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// The fscanf macros for unsigned integers are:
|
||||
#define SCNo8 "o"
|
||||
#define SCNu8 "u"
|
||||
#define SCNx8 "x"
|
||||
#define SCNX8 "X"
|
||||
#define SCNoLEAST8 "o"
|
||||
#define SCNuLEAST8 "u"
|
||||
#define SCNxLEAST8 "x"
|
||||
#define SCNXLEAST8 "X"
|
||||
#define SCNoFAST8 "o"
|
||||
#define SCNuFAST8 "u"
|
||||
#define SCNxFAST8 "x"
|
||||
#define SCNXFAST8 "X"
|
||||
|
||||
#define SCNo16 "ho"
|
||||
#define SCNu16 "hu"
|
||||
#define SCNx16 "hx"
|
||||
#define SCNX16 "hX"
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNXLEAST16 "hX"
|
||||
#define SCNoFAST16 "ho"
|
||||
#define SCNuFAST16 "hu"
|
||||
#define SCNxFAST16 "hx"
|
||||
#define SCNXFAST16 "hX"
|
||||
|
||||
#define SCNo32 "lo"
|
||||
#define SCNu32 "lu"
|
||||
#define SCNx32 "lx"
|
||||
#define SCNX32 "lX"
|
||||
#define SCNoLEAST32 "lo"
|
||||
#define SCNuLEAST32 "lu"
|
||||
#define SCNxLEAST32 "lx"
|
||||
#define SCNXLEAST32 "lX"
|
||||
#define SCNoFAST32 "lo"
|
||||
#define SCNuFAST32 "lu"
|
||||
#define SCNxFAST32 "lx"
|
||||
#define SCNXFAST32 "lX"
|
||||
|
||||
#define SCNo64 "I64o"
|
||||
#define SCNu64 "I64u"
|
||||
#define SCNx64 "I64x"
|
||||
#define SCNX64 "I64X"
|
||||
#define SCNoLEAST64 "I64o"
|
||||
#define SCNuLEAST64 "I64u"
|
||||
#define SCNxLEAST64 "I64x"
|
||||
#define SCNXLEAST64 "I64X"
|
||||
#define SCNoFAST64 "I64o"
|
||||
#define SCNuFAST64 "I64u"
|
||||
#define SCNxFAST64 "I64x"
|
||||
#define SCNXFAST64 "I64X"
|
||||
|
||||
#define SCNoMAX "I64o"
|
||||
#define SCNuMAX "I64u"
|
||||
#define SCNxMAX "I64x"
|
||||
#define SCNXMAX "I64X"
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define SCNoPTR "I64o"
|
||||
# define SCNuPTR "I64u"
|
||||
# define SCNxPTR "I64x"
|
||||
# define SCNXPTR "I64X"
|
||||
#else // _WIN64 ][
|
||||
# define SCNoPTR "lo"
|
||||
# define SCNuPTR "lu"
|
||||
# define SCNxPTR "lx"
|
||||
# define SCNXPTR "lX"
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.8.2 Functions for greatest-width integer types
|
||||
|
||||
// 7.8.2.1 The imaxabs function
|
||||
#define imaxabs _abs64
|
||||
|
||||
// 7.8.2.2 The imaxdiv function
|
||||
|
||||
// This is modified version of div() function from Microsoft's div.c found
|
||||
// in %MSVC.NET%\crt\src\div.c
|
||||
#ifdef STATIC_IMAXDIV // [
|
||||
static
|
||||
#else // STATIC_IMAXDIV ][
|
||||
_inline
|
||||
#endif // STATIC_IMAXDIV ]
|
||||
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
|
||||
{
|
||||
imaxdiv_t result;
|
||||
|
||||
result.quot = numer / denom;
|
||||
result.rem = numer % denom;
|
||||
|
||||
if (numer < 0 && result.rem > 0) {
|
||||
// did division wrong; must fix up
|
||||
++result.quot;
|
||||
result.rem -= denom;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 7.8.2.3 The strtoimax and strtoumax functions
|
||||
#define strtoimax _strtoi64
|
||||
#define strtoumax _strtoui64
|
||||
|
||||
// 7.8.2.4 The wcstoimax and wcstoumax functions
|
||||
#define wcstoimax _wcstoi64
|
||||
#define wcstoumax _wcstoui64
|
||||
|
||||
|
||||
#endif // _MSC_INTTYPES_H_ ]
|
||||
163
configure.ac
163
configure.ac
@@ -1,16 +1,15 @@
|
||||
# -*- Autoconf -*-
|
||||
# $Id: configure.ac,v 1.11 2006/04/09 13:59:44 r3mi Exp $
|
||||
#
|
||||
# Top-level configure.ac file for libupnp
|
||||
#
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
#
|
||||
# (C) Copyright 2005-2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
# (C) Copyright 2005-2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
#
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT([libupnp], [1.4.1], [virtual_worlds@gmx.de])
|
||||
AC_INIT([libupnp], [1.4.7], [mroberto@users.sourceforge.net])
|
||||
# *Independently* of the above libupnp package version, the libtool version
|
||||
# of the 3 libraries need to be updated whenever there is a change released :
|
||||
# "current:revision:age" (this is NOT the same as the package version), where:
|
||||
@@ -19,16 +18,39 @@ AC_INIT([libupnp], [1.4.1], [virtual_worlds@gmx.de])
|
||||
# - interfaces added: age++
|
||||
# - interfaces removed: age=0
|
||||
# *please update only once, before a formal release, not for each change*
|
||||
AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
||||
AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
||||
#
|
||||
# For release 1.4.1, we had:
|
||||
#AC_SUBST([LT_VERSION_IXML], [2:2:0])
|
||||
#AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
|
||||
#AC_SUBST([LT_VERSION_UPNP], [2:2:0])
|
||||
#
|
||||
# "current:revision:age"
|
||||
#
|
||||
# - Code has changed in ixml
|
||||
# revision: 2 -> 3
|
||||
# - Code has changed in threadutil
|
||||
# revision: 2 -> 3
|
||||
# - Interface added in threadutil
|
||||
# current: 2 -> 3
|
||||
# revisiion: 3 -> 0
|
||||
# age: 0 -> 1
|
||||
# - Code has changed in upnp (revision 2 -> 3)
|
||||
# revision: 2 -> 3
|
||||
AC_SUBST([LT_VERSION_IXML], [2:3:0])
|
||||
AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
|
||||
AC_SUBST([LT_VERSION_UPNP], [2:3:0])
|
||||
|
||||
|
||||
AC_CONFIG_AUX_DIR(config.aux)
|
||||
AC_CONFIG_MACRO_DIR(m4)
|
||||
AC_CONFIG_SRCDIR(upnp/inc/upnp.h)
|
||||
|
||||
AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects])
|
||||
AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects dist-bzip2])
|
||||
|
||||
#
|
||||
# Get canonical host names in host and host_os
|
||||
#
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
#
|
||||
# There are 3 configuration files :
|
||||
@@ -42,6 +64,7 @@ AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects])
|
||||
# installed libraries.
|
||||
#
|
||||
AC_CONFIG_HEADERS([autoconfig.h upnp/inc/upnpconfig.h])
|
||||
#AC_SYS_LARGEFILE_SENSITIVE
|
||||
|
||||
AC_REVISION([$Revision: 1.11 $])
|
||||
|
||||
@@ -106,19 +129,31 @@ RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])
|
||||
|
||||
|
||||
# doc installation
|
||||
AC_MSG_CHECKING([documentation installation])
|
||||
AC_ARG_WITH([docdir],
|
||||
AC_HELP_STRING([--with-docdir=DIR],
|
||||
[where documentation is installed
|
||||
@<:@[DATADIR/doc/]AC_PACKAGE_NAME[-]AC_PACKAGE_VERSION@:>@])
|
||||
AC_HELP_STRING([--without-docdir],
|
||||
[do not install the documentation]),
|
||||
[DOCDIR="$with_docdir"],
|
||||
[DOCDIR="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"])
|
||||
# autoconf >= 2.60 already defines ${docdir}, but we will not use its
|
||||
# default value, which is ${datarootdir}/doc/${PACKAGE_TARNAME}.
|
||||
# That would give us ${datarootdir}/doc/libupnp, and we want the package
|
||||
# version on that.
|
||||
docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}"
|
||||
AC_MSG_CHECKING([for documentation directory])
|
||||
AC_ARG_WITH(
|
||||
[documentation],
|
||||
AS_HELP_STRING(
|
||||
[--with-documentation=directory_name],
|
||||
[where documentation is installed
|
||||
@<:@[DATADIR/doc/]AC_PACKAGE_NAME[-]AC_PACKAGE_VERSION@:>@])
|
||||
AS_HELP_STRING(
|
||||
[--without-documentation],
|
||||
[do not install the documentation]),
|
||||
[],
|
||||
[with_documentation=no])
|
||||
|
||||
AM_CONDITIONAL(WITH_DOCDIR, test x"$with_docdir" != xno)
|
||||
AC_SUBST(DOCDIR)
|
||||
AC_MSG_RESULT($DOCDIR)
|
||||
# If something has been entered after an equal sign, assume it is the directory
|
||||
if test x"$with_documentation" != xyes -a x"$with_documentation" != xno; then
|
||||
docdir="$with_documentation"
|
||||
fi
|
||||
AM_CONDITIONAL(WITH_DOCUMENTATION, test x"$with_documentation" != xno)
|
||||
AC_SUBST(docdir)
|
||||
AC_MSG_RESULT($docdir)
|
||||
|
||||
|
||||
#
|
||||
@@ -131,22 +166,40 @@ AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_EGREP
|
||||
|
||||
|
||||
#
|
||||
# Default compilation flags
|
||||
#
|
||||
if test x"$enable_debug" = xyes; then
|
||||
# AC_PROG_CC already sets CFLAGS to "-g -O2" by default
|
||||
:
|
||||
else
|
||||
# add optimise for size
|
||||
AX_CFLAGS_GCC_OPTION([-Os])
|
||||
fi
|
||||
AX_CFLAGS_WARN_ALL
|
||||
echo "--------------------- Default compilation flags -------------------------------"
|
||||
echo host is $host
|
||||
echo host_os is $host_os
|
||||
case $host_os in
|
||||
freebsd*)
|
||||
echo "Using FreeBSD specific compiler settings"
|
||||
# Put FreeBSD specific compiler flags here
|
||||
;;
|
||||
*)
|
||||
echo "Using non-specific system compiler settings"
|
||||
if test x"$enable_debug" = xyes; then
|
||||
# AC_PROG_CC already sets CFLAGS to "-g -O2" by default
|
||||
:
|
||||
else
|
||||
# add optimise for size
|
||||
AX_CFLAGS_GCC_OPTION([-Os])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Arrange for large-file support (can be disabled with --disable-largefile).
|
||||
# Define _FILE_OFFSET_BITS and _LARGE_FILES if necessary
|
||||
AC_SYS_LARGEFILE
|
||||
AX_CFLAGS_WARN_ALL
|
||||
echo "-------------------------------------------------------------------------------"
|
||||
|
||||
|
||||
#
|
||||
# Lot's of stuff to ensure large file support
|
||||
#
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_DEFINE([_LARGE_FILE_SOURCE], [], [Large files support])
|
||||
AC_DEFINE([_FILE_OFFSET_BITS], [64], [File Offset size])
|
||||
|
||||
|
||||
#
|
||||
@@ -155,7 +208,25 @@ AC_SYS_LARGEFILE
|
||||
AC_HEADER_STDC
|
||||
# libupnp code doesn't use autoconf variables yet,
|
||||
# so just abort if a header file is not found.
|
||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h],[],[AC_MSG_ERROR([required header file missing])])
|
||||
AC_CHECK_HEADERS(
|
||||
[ \
|
||||
arpa/inet.h \
|
||||
fcntl.h \
|
||||
inttypes.h \
|
||||
limits.h \
|
||||
netdb.h \
|
||||
netinet/in.h \
|
||||
stdlib.h \
|
||||
string.h \
|
||||
sys/ioctl.h \
|
||||
sys/socket.h \
|
||||
sys/time.h \
|
||||
sys/timeb.h \
|
||||
syslog.h \
|
||||
unistd.h \
|
||||
],
|
||||
[],
|
||||
[AC_MSG_ERROR([required header file missing])])
|
||||
|
||||
|
||||
#
|
||||
@@ -171,25 +242,29 @@ TYPE_SOCKLEN_T
|
||||
#
|
||||
AC_FUNC_VPRINTF
|
||||
AC_FUNC_FSEEKO
|
||||
AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
|
||||
|
||||
|
||||
#
|
||||
# Checks for POSIX Threads
|
||||
#
|
||||
ACX_PTHREAD([],[AC_MSG_ERROR([POSIX threads are required to build this program])])
|
||||
ACX_PTHREAD(
|
||||
[],
|
||||
[AC_MSG_ERROR([POSIX threads are required to build this program])])
|
||||
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
ixml/Makefile
|
||||
ixml/doc/Makefile
|
||||
threadutil/Makefile
|
||||
upnp/Makefile
|
||||
upnp/doc/Makefile
|
||||
upnp/sample/Makefile
|
||||
docs/dist/Makefile
|
||||
libupnp.pc
|
||||
])
|
||||
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
ixml/Makefile
|
||||
ixml/doc/Makefile
|
||||
threadutil/Makefile
|
||||
upnp/Makefile
|
||||
upnp/doc/Makefile
|
||||
docs/dist/Makefile
|
||||
libupnp.pc
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
13
docs/dist/Makefile.am
vendored
13
docs/dist/Makefile.am
vendored
@@ -1,4 +1,7 @@
|
||||
EXTRA_DIST = ./UPnP_Programming_Guide.pdf \
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
./UPnP_Programming_Guide.pdf \
|
||||
./IXML_Programming_Guide.pdf \
|
||||
./html/upnp/icon1.gif \
|
||||
./html/upnp/icon2.gif \
|
||||
@@ -251,9 +254,10 @@ EXTRA_DIST = ./UPnP_Programming_Guide.pdf \
|
||||
./html/ixml/ixmlCloneDOMString.html \
|
||||
./html/ixml/ixmlFreeDOMString.html
|
||||
|
||||
if WITH_DOCDIR
|
||||
docsdir = @DOCDIR@
|
||||
nobase_docs_DATA = ./UPnP_Programming_Guide.pdf \
|
||||
if WITH_DOCUMENTATION
|
||||
docsdir = @docdir@
|
||||
nobase_docs_DATA = \
|
||||
./UPnP_Programming_Guide.pdf \
|
||||
./IXML_Programming_Guide.pdf \
|
||||
./html/upnp/icon1.gif \
|
||||
./html/upnp/icon2.gif \
|
||||
@@ -506,3 +510,4 @@ if WITH_DOCDIR
|
||||
./html/ixml/ixmlCloneDOMString.html \
|
||||
./html/ixml/ixmlFreeDOMString.html
|
||||
endif
|
||||
|
||||
|
||||
247
ixml/inc/ixml.h
247
ixml/inc/ixml.h
@@ -1,59 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 _IXML_H_
|
||||
#define _IXML_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include <malloc.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
// set up declspec for dll export to make functions visible to library users
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
/* set up declspec for dll export to make functions visible to library users */
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
|
||||
#define DOMString char *
|
||||
|
||||
|
||||
@@ -88,7 +90,7 @@ typedef int BOOL;
|
||||
* etc., refer to section 1.1 of the DOM2-Core recommendation.
|
||||
*/
|
||||
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -121,7 +123,7 @@ typedef enum
|
||||
*
|
||||
*=================================================================*/
|
||||
typedef enum
|
||||
{ // see DOM spec
|
||||
{ /* see DOM spec */
|
||||
IXML_INDEX_SIZE_ERR = 1,
|
||||
IXML_DOMSTRING_SIZE_ERR = 2,
|
||||
IXML_HIERARCHY_REQUEST_ERR = 3,
|
||||
@@ -240,7 +242,7 @@ extern "C" {
|
||||
* its functionality. For more information, refer to DOM2-Core page 34.
|
||||
*/
|
||||
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** Returns the name of the {\bf Node}, depending on what type of
|
||||
* {\bf Node} it is, in a read-only string. Refer to the table in the
|
||||
@@ -260,7 +262,7 @@ ixmlNode_getNodeName(IXML_Node *nodeptr
|
||||
* @return [DOMString] A {\bf DOMString} of the {\bf Node} value.
|
||||
*/
|
||||
|
||||
EXPORT_SPEC DOMString
|
||||
EXPORT_SPEC const DOMString
|
||||
ixmlNode_getNodeValue(IXML_Node *nodeptr
|
||||
/** Pointer to the {\bf Node} to retrieve the value. */
|
||||
);
|
||||
@@ -282,7 +284,7 @@ ixmlNode_getNodeValue(IXML_Node *nodeptr
|
||||
EXPORT_SPEC int
|
||||
ixmlNode_setNodeValue(IXML_Node *nodeptr,
|
||||
/** The {\bf Node} to which to assign a new value. */
|
||||
char *newNodeValue
|
||||
const char *newNodeValue
|
||||
/** The new value of the {\bf Node}. */
|
||||
);
|
||||
|
||||
@@ -439,7 +441,7 @@ ixmlNode_getNamespaceURI(IXML_Node *nodeptr
|
||||
* or {\tt NULL}.
|
||||
*/
|
||||
|
||||
EXPORT_SPEC DOMString
|
||||
EXPORT_SPEC const DOMString
|
||||
ixmlNode_getPrefix(IXML_Node *nodeptr
|
||||
/** The {\bf Node} from which to retrieve the prefix. */
|
||||
);
|
||||
@@ -620,7 +622,7 @@ ixmlNode_cloneNode(IXML_Node *nodeptr,
|
||||
*/
|
||||
|
||||
EXPORT_SPEC BOOL
|
||||
ixmlNode_hasAttributes(IXML_Node *node
|
||||
ixmlNode_hasAttributes(IXML_Node *nodeptr
|
||||
/** The {\bf Node} to query for attributes. */
|
||||
);
|
||||
|
||||
@@ -630,11 +632,11 @@ ixmlNode_hasAttributes(IXML_Node *node
|
||||
*/
|
||||
|
||||
EXPORT_SPEC void
|
||||
ixmlNode_free(IXML_Node *IXML_Node
|
||||
ixmlNode_free(IXML_Node *nodeptr
|
||||
/** The {\bf Node} to free. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -649,7 +651,7 @@ ixmlNode_free(IXML_Node *IXML_Node
|
||||
* allowable attributes and values for a particular element. For more
|
||||
* information, refer to the {\it Interface Attr} section in the DOM2-Core.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
|
||||
/** Frees an {\bf Attr} node.
|
||||
@@ -662,7 +664,7 @@ ixmlAttr_free(IXML_Attr *attrNode
|
||||
/** The {\bf Attr} node to free. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
|
||||
/*================================================================
|
||||
@@ -680,7 +682,7 @@ ixmlAttr_free(IXML_Attr *attrNode
|
||||
* information, refer to the {\it Interface CDATASection} section in the
|
||||
* DOM2-Core.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
|
||||
/** Initializes a {\bf CDATASection} node.
|
||||
@@ -704,7 +706,7 @@ ixmlCDATASection_free(IXML_CDATASection *nodeptr
|
||||
/** The {\bf CDATASection} node to free. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -719,7 +721,7 @@ ixmlCDATASection_free(IXML_CDATASection *nodeptr
|
||||
* primary interface to the elements of the document. For more information,
|
||||
* refer to the {\it Interface Document} section in the DOM2Core.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** Initializes a {\bf Document} node.
|
||||
*
|
||||
@@ -867,7 +869,7 @@ EXPORT_SPEC int
|
||||
ixmlDocument_createCDATASectionEx(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
node. */
|
||||
DOMString data,
|
||||
const DOMString data,
|
||||
/** The data to associate with the new
|
||||
{\bf CDATASection} node. */
|
||||
IXML_CDATASection** cdNode
|
||||
@@ -886,7 +888,7 @@ EXPORT_SPEC IXML_CDATASection*
|
||||
ixmlDocument_createCDATASection(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
node. */
|
||||
DOMString data
|
||||
const DOMString data
|
||||
/** The data to associate with the new {\bf
|
||||
CDATASection} node. */
|
||||
);
|
||||
@@ -899,7 +901,7 @@ ixmlDocument_createCDATASection(IXML_Document *doc,
|
||||
EXPORT_SPEC IXML_Attr*
|
||||
ixmlDocument_createAttribute(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new node. */
|
||||
char *name
|
||||
const char *name
|
||||
/** The name of the new attribute. */
|
||||
);
|
||||
|
||||
@@ -924,7 +926,7 @@ EXPORT_SPEC int
|
||||
ixmlDocument_createAttributeEx(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
node. */
|
||||
char *name,
|
||||
const char *name,
|
||||
/** The name of the new attribute. */
|
||||
IXML_Attr** attrNode
|
||||
/** A pointer to a {\bf Attr} where the new
|
||||
@@ -943,11 +945,11 @@ ixmlDocument_createAttributeEx(IXML_Document *doc,
|
||||
EXPORT_SPEC IXML_NodeList*
|
||||
ixmlDocument_getElementsByTagName(IXML_Document *doc,
|
||||
/** The {\bf Document} to search. */
|
||||
DOMString tagName
|
||||
const DOMString tagName
|
||||
/** The tag name to find. */
|
||||
);
|
||||
|
||||
// introduced in DOM level 2
|
||||
/* introduced in DOM level 2 */
|
||||
|
||||
/** Creates a new {\bf Element} node in the given qualified name and
|
||||
* namespace URI.
|
||||
@@ -970,10 +972,10 @@ EXPORT_SPEC int
|
||||
ixmlDocument_createElementNSEx(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
node. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI for the new {\bf
|
||||
Element}. */
|
||||
DOMString qualifiedName,
|
||||
const DOMString qualifiedName,
|
||||
/** The qualified name of the new {\bf
|
||||
Element}. */
|
||||
IXML_Element** rtElement
|
||||
@@ -992,10 +994,10 @@ ixmlDocument_createElementNSEx(IXML_Document *doc,
|
||||
EXPORT_SPEC IXML_Element*
|
||||
ixmlDocument_createElementNS(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new node. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI for the new {\bf
|
||||
Element}. */
|
||||
DOMString qualifiedName
|
||||
const DOMString qualifiedName
|
||||
/** The qualified name of the new {\bf
|
||||
Element}. */
|
||||
);
|
||||
@@ -1021,9 +1023,9 @@ EXPORT_SPEC int
|
||||
ixmlDocument_createAttributeNSEx(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
{\bf Attr}. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI for the attribute. */
|
||||
DOMString qualifiedName,
|
||||
const DOMString qualifiedName,
|
||||
/** The qualified name of the attribute. */
|
||||
IXML_Attr** attrNode
|
||||
/** A pointer to an {\bf Attr} where the
|
||||
@@ -1040,9 +1042,9 @@ EXPORT_SPEC IXML_Attr*
|
||||
ixmlDocument_createAttributeNS(IXML_Document *doc,
|
||||
/** The owner {\bf Document} of the new
|
||||
{\bf Attr}. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI for the attribute. */
|
||||
DOMString qualifiedName
|
||||
const DOMString qualifiedName
|
||||
/** The qualified name of the attribute. */
|
||||
);
|
||||
|
||||
@@ -1059,11 +1061,11 @@ ixmlDocument_createAttributeNS(IXML_Document *doc,
|
||||
EXPORT_SPEC IXML_NodeList*
|
||||
ixmlDocument_getElementsByTagNameNS(IXML_Document* doc,
|
||||
/** The {\bf Document} to search. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace of the elements to
|
||||
find or {\tt "*"} to match any
|
||||
namespace. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the elements to
|
||||
find or {\tt "*"} to match any local
|
||||
name. */
|
||||
@@ -1079,7 +1081,7 @@ EXPORT_SPEC IXML_Element*
|
||||
ixmlDocument_getElementById(IXML_Document* doc,
|
||||
/** The owner {\bf Document} of the {\bf
|
||||
Element}. */
|
||||
DOMString tagName
|
||||
const DOMString tagName
|
||||
/** The name of the {\bf Element}.*/
|
||||
);
|
||||
|
||||
@@ -1128,7 +1130,7 @@ ixmlDocument_importNode(IXML_Document* doc,
|
||||
/** A pointer to a new {\bf Node} owned by {\bf
|
||||
doc}. */
|
||||
);
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -1144,7 +1146,7 @@ ixmlDocument_importNode(IXML_Document* doc,
|
||||
* extends the {\bf Node} interface and adds more operations to manipulate
|
||||
* attributes.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** Initializes a {\bf IXML_Element} node.
|
||||
*
|
||||
@@ -1174,11 +1176,11 @@ ixmlElement_getTagName(IXML_Element* element
|
||||
* attribute.
|
||||
*/
|
||||
|
||||
EXPORT_SPEC DOMString
|
||||
EXPORT_SPEC const DOMString
|
||||
ixmlElement_getAttribute(IXML_Element* element,
|
||||
/** The {\bf Element} from which to retrieve the
|
||||
attribute. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the attribute to retrieve. */
|
||||
);
|
||||
|
||||
@@ -1202,9 +1204,9 @@ EXPORT_SPEC int
|
||||
ixmlElement_setAttribute(IXML_Element* element,
|
||||
/** The {\bf Element} on which to set the
|
||||
attribute. */
|
||||
DOMString name,
|
||||
const DOMString name,
|
||||
/** The name of the attribute. */
|
||||
DOMString value
|
||||
const DOMString value
|
||||
/** The value of the attribute. Note that this is
|
||||
a non-parsed string and any markup must be
|
||||
escaped. */
|
||||
@@ -1224,7 +1226,7 @@ EXPORT_SPEC int
|
||||
ixmlElement_removeAttribute(IXML_Element* element,
|
||||
/** The {\bf Element} from which to remove the
|
||||
attribute. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the attribute to remove. */
|
||||
);
|
||||
|
||||
@@ -1240,7 +1242,7 @@ EXPORT_SPEC IXML_Attr*
|
||||
ixmlElement_getAttributeNode(IXML_Element* element,
|
||||
/** The {\bf Element} from which to get the
|
||||
attribute node. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the attribute node to find. */
|
||||
);
|
||||
|
||||
@@ -1309,12 +1311,12 @@ EXPORT_SPEC IXML_NodeList*
|
||||
ixmlElement_getElementsByTagName(IXML_Element* element,
|
||||
/** The {\bf Element} from which to start
|
||||
the search. */
|
||||
DOMString tagName
|
||||
const DOMString tagName
|
||||
/** The name of the tag for which to
|
||||
search. */
|
||||
);
|
||||
|
||||
// introduced in DOM 2
|
||||
/* introduced in DOM 2 */
|
||||
|
||||
/** Retrieves an attribute value using the local name and namespace URI.
|
||||
*
|
||||
@@ -1322,13 +1324,13 @@ ixmlElement_getElementsByTagName(IXML_Element* element,
|
||||
* matching attribute.
|
||||
*/
|
||||
|
||||
EXPORT_SPEC DOMString
|
||||
EXPORT_SPEC const DOMString
|
||||
ixmlElement_getAttributeNS(IXML_Element* element,
|
||||
/** The {\bf Element} from which to get the
|
||||
attribute value. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the attribute. */
|
||||
DOMString localname
|
||||
const DOMString localname
|
||||
/** The local name of the attribute. */
|
||||
);
|
||||
|
||||
@@ -1358,11 +1360,11 @@ EXPORT_SPEC int
|
||||
ixmlElement_setAttributeNS(IXML_Element* element,
|
||||
/** The {\bf Element} on which to set the
|
||||
attribute. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the new attribute. */
|
||||
DOMString qualifiedName,
|
||||
const DOMString qualifiedName,
|
||||
/** The qualified name of the attribute. */
|
||||
DOMString value
|
||||
const DOMString value
|
||||
/** The new value for the attribute. */
|
||||
);
|
||||
|
||||
@@ -1380,9 +1382,9 @@ EXPORT_SPEC int
|
||||
ixmlElement_removeAttributeNS(IXML_Element* element,
|
||||
/** The {\bf Element} from which to remove the
|
||||
the attribute. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the attribute. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the attribute.*/
|
||||
);
|
||||
|
||||
@@ -1395,9 +1397,9 @@ EXPORT_SPEC IXML_Attr*
|
||||
ixmlElement_getAttributeNodeNS(IXML_Element* element,
|
||||
/** The {\bf Element} from which to get the
|
||||
attribute. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the attribute. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the attribute. */
|
||||
);
|
||||
|
||||
@@ -1441,10 +1443,10 @@ EXPORT_SPEC IXML_NodeList*
|
||||
ixmlElement_getElementsByTagNameNS(IXML_Element* element,
|
||||
/** The {\bf Element} from which to start
|
||||
the search. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the {\bf
|
||||
Element}s to find. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the {\bf Element}s
|
||||
to find. */
|
||||
);
|
||||
@@ -1461,7 +1463,7 @@ EXPORT_SPEC BOOL
|
||||
ixmlElement_hasAttribute(IXML_Element* element,
|
||||
/** The {\bf Element} on which to check for an
|
||||
attribute. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the attribute for which to check. */
|
||||
);
|
||||
|
||||
@@ -1477,9 +1479,9 @@ EXPORT_SPEC BOOL
|
||||
ixmlElement_hasAttributeNS(IXML_Element* element,
|
||||
/** The {\bf Element} on which to check for the
|
||||
attribute. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the attribute. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the attribute. */
|
||||
);
|
||||
|
||||
@@ -1493,7 +1495,7 @@ ixmlElement_free(IXML_Element* element
|
||||
/** The {\bf Element} to free. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -1508,7 +1510,7 @@ ixmlElement_free(IXML_Element* element
|
||||
* no particular order. The {\bf Node} interface uses a {\bf NamedNodeMap}
|
||||
* to maintain the attributes of a node.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** Returns the number of items contained in this {\bf NamedNodeMap}.
|
||||
*
|
||||
@@ -1529,7 +1531,7 @@ ixmlNamedNodeMap_getLength(IXML_NamedNodeMap *nnMap
|
||||
EXPORT_SPEC IXML_Node*
|
||||
ixmlNamedNodeMap_getNamedItem(IXML_NamedNodeMap *nnMap,
|
||||
/** The {\bf NamedNodeMap} to search. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the {\bf Node} to find. */
|
||||
);
|
||||
|
||||
@@ -1560,7 +1562,7 @@ EXPORT_SPEC IXML_Node*
|
||||
ixmlNamedNodeMap_removeNamedItem(IXML_NamedNodeMap *nnMap,
|
||||
/** The {\bf NamedNodeMap} from which to
|
||||
remove the item. */
|
||||
DOMString name
|
||||
const DOMString name
|
||||
/** The name of the item to remove. */
|
||||
);
|
||||
|
||||
@@ -1579,7 +1581,7 @@ ixmlNamedNodeMap_item(IXML_NamedNodeMap *nnMap,
|
||||
/** The index into the map to remove. */
|
||||
);
|
||||
|
||||
// introduced in DOM level 2
|
||||
/* introduced in DOM level 2 */
|
||||
|
||||
/** Retrieves a {\bf Node} from a {\bf NamedNodeMap} specified by
|
||||
* namespace URI and local name.
|
||||
@@ -1592,10 +1594,10 @@ EXPORT_SPEC IXML_Node*
|
||||
ixmlNamedNodeMap_getNamedItemNS(IXML_NamedNodeMap *nnMap,
|
||||
/** The {\bf NamedNodeMap} from which to
|
||||
remove the {\bf Node}. */
|
||||
DOMString *namespaceURI,
|
||||
const DOMString *namespaceURI,
|
||||
/** The namespace URI of the {\bf Node} to
|
||||
remove. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the {\bf Node} to
|
||||
remove. */
|
||||
);
|
||||
@@ -1627,10 +1629,10 @@ EXPORT_SPEC IXML_Node*
|
||||
ixmlNamedNodeMap_removeNamedItemNS(IXML_NamedNodeMap *nnMap,
|
||||
/** The {\bf NamedNodeMap} from which to
|
||||
remove the {\bf Node}. */
|
||||
DOMString namespaceURI,
|
||||
const DOMString namespaceURI,
|
||||
/** The namespace URI of the {\bf Node}
|
||||
to remove. */
|
||||
DOMString localName
|
||||
const DOMString localName
|
||||
/** The local name of the {\bf Node} to
|
||||
remove. */
|
||||
);
|
||||
@@ -1646,7 +1648,7 @@ ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap
|
||||
/** The {\bf NamedNodeMap to free}. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -1661,7 +1663,7 @@ ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap
|
||||
* the nodes contained in a {\bf NodeList}. The DOM2-Core refers to
|
||||
* this as being {\it live}.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** Retrieves a {\bf Node} from a {\bf NodeList} specified by a
|
||||
* numerical index.
|
||||
@@ -1701,8 +1703,8 @@ ixmlNodeList_free(IXML_NodeList *nList
|
||||
/** The {\bf NodeList} to free. */
|
||||
);
|
||||
|
||||
//@} Interface NodeList
|
||||
//@} DOM Interfaces
|
||||
/*! @} */ /* Interface NodeList */
|
||||
/*! @} */ /* DOM Interfaces */
|
||||
|
||||
/**@name IXML API
|
||||
* The IXML API contains utility functions that are not part of the standard
|
||||
@@ -1710,7 +1712,7 @@ ixmlNodeList_free(IXML_NodeList *nList
|
||||
* file or buffer, create an XML file from a DOM structure, and manipulate
|
||||
* DOMString objects.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/*================================================================
|
||||
*
|
||||
@@ -1738,7 +1740,7 @@ ixmlNodeList_free(IXML_NodeList *nList
|
||||
* of the DOM tree or {\tt NULL} on an error.
|
||||
*/
|
||||
|
||||
DOMString
|
||||
EXPORT_SPEC DOMString
|
||||
ixmlPrintDocument(IXML_Document *doc);
|
||||
|
||||
/** Renders a {\bf Node} and all sub-elements into an XML text
|
||||
@@ -1756,7 +1758,7 @@ ixmlPrintDocument(IXML_Document *doc);
|
||||
* of the DOM tree or {\tt NULL} on an error.
|
||||
*/
|
||||
|
||||
DOMString
|
||||
EXPORT_SPEC DOMString
|
||||
ixmlPrintNode(IXML_Node *doc
|
||||
/** The root of the {\bf Node} tree to render to XML text. */
|
||||
);
|
||||
@@ -1777,7 +1779,7 @@ ixmlPrintNode(IXML_Node *doc
|
||||
* of the DOM tree or {\tt NULL} on an error.
|
||||
*/
|
||||
|
||||
DOMString
|
||||
EXPORT_SPEC DOMString
|
||||
ixmlDocumenttoString(IXML_Document *doc);
|
||||
|
||||
/** Renders a {\bf Node} and all sub-elements into an XML text
|
||||
@@ -1809,7 +1811,7 @@ ixmlNodetoString(IXML_Node *doc
|
||||
* characters are replaced by the {\bf errorChar}, and invalid "&" entities
|
||||
* are left untranslated. The parsing is then allowed to continue.
|
||||
*/
|
||||
void
|
||||
EXPORT_SPEC void
|
||||
ixmlRelaxParser(char errorChar);
|
||||
|
||||
|
||||
@@ -1819,7 +1821,7 @@ ixmlRelaxParser(char errorChar);
|
||||
* {\tt NULL} on an error.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Document*
|
||||
ixmlParseBuffer(char *buffer
|
||||
ixmlParseBuffer(const char *buffer
|
||||
/** The buffer that contains the XML text to convert to a
|
||||
{\bf Document}. */
|
||||
);
|
||||
@@ -1842,7 +1844,7 @@ ixmlParseBuffer(char *buffer
|
||||
*/
|
||||
|
||||
EXPORT_SPEC int
|
||||
ixmlParseBufferEx(char *buffer,
|
||||
ixmlParseBufferEx(const char *buffer,
|
||||
/** The buffer that contains the XML text to convert to a
|
||||
{\bf Document}. */
|
||||
IXML_Document** doc
|
||||
@@ -1857,7 +1859,7 @@ ixmlParseBufferEx(char *buffer,
|
||||
*/
|
||||
|
||||
EXPORT_SPEC IXML_Document*
|
||||
ixmlLoadDocument(char* xmlFile
|
||||
ixmlLoadDocument(const char* xmlFile
|
||||
/** The filename of the XML text to convert to a {\bf
|
||||
Document}. */
|
||||
);
|
||||
@@ -1879,7 +1881,7 @@ ixmlLoadDocument(char* xmlFile
|
||||
*/
|
||||
|
||||
EXPORT_SPEC int
|
||||
ixmlLoadDocumentEx(char* xmlFile,
|
||||
ixmlLoadDocumentEx(const char* xmlFile,
|
||||
/** The filename of the XML text to convert to a {\bf
|
||||
Document}. */
|
||||
IXML_Document** doc
|
||||
@@ -1913,6 +1915,7 @@ ixmlFreeDOMString(DOMString buf
|
||||
}
|
||||
#endif
|
||||
|
||||
//@} IXML API
|
||||
/*! @} */ /* IXML API */
|
||||
|
||||
#endif /* _IXML_H_ */
|
||||
|
||||
#endif // _IXML_H_
|
||||
|
||||
@@ -373,7 +373,7 @@ ixmlDocument_createTextNode( IN IXML_Document * doc,
|
||||
================================================================*/
|
||||
int
|
||||
ixmlDocument_createAttributeEx( IN IXML_Document * doc,
|
||||
IN char *name,
|
||||
IN const char *name,
|
||||
OUT IXML_Attr ** rtAttr )
|
||||
{
|
||||
IXML_Attr *attrNode = NULL;
|
||||
@@ -427,7 +427,7 @@ ixmlDocument_createAttributeEx( IN IXML_Document * doc,
|
||||
================================================================*/
|
||||
IXML_Attr *
|
||||
ixmlDocument_createAttribute( IN IXML_Document * doc,
|
||||
IN char *name )
|
||||
IN const char *name )
|
||||
{
|
||||
IXML_Attr *attrNode = NULL;
|
||||
|
||||
@@ -451,8 +451,8 @@ ixmlDocument_createAttribute( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlDocument_createAttributeNSEx( IN IXML_Document * doc,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString qualifiedName,
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString qualifiedName,
|
||||
OUT IXML_Attr ** rtAttr )
|
||||
{
|
||||
IXML_Attr *attrNode = NULL;
|
||||
@@ -507,8 +507,8 @@ ixmlDocument_createAttributeNSEx( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_Attr *
|
||||
ixmlDocument_createAttributeNS( IN IXML_Document * doc,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString qualifiedName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString qualifiedName )
|
||||
{
|
||||
IXML_Attr *attrNode = NULL;
|
||||
|
||||
@@ -531,7 +531,7 @@ ixmlDocument_createAttributeNS( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlDocument_createCDATASectionEx( IN IXML_Document * doc,
|
||||
IN DOMString data,
|
||||
IN const DOMString data,
|
||||
OUT IXML_CDATASection ** rtCD )
|
||||
{
|
||||
int errCode = IXML_SUCCESS;
|
||||
@@ -588,7 +588,7 @@ ixmlDocument_createCDATASectionEx( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_CDATASection *
|
||||
ixmlDocument_createCDATASection( IN IXML_Document * doc,
|
||||
IN DOMString data )
|
||||
IN const DOMString data )
|
||||
{
|
||||
|
||||
IXML_CDATASection *cDSectionNode = NULL;
|
||||
@@ -613,8 +613,8 @@ ixmlDocument_createCDATASection( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlDocument_createElementNSEx( IN IXML_Document * doc,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString qualifiedName,
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString qualifiedName,
|
||||
OUT IXML_Element ** rtElement )
|
||||
{
|
||||
|
||||
@@ -673,8 +673,8 @@ ixmlDocument_createElementNSEx( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_Element *
|
||||
ixmlDocument_createElementNS( IN IXML_Document * doc,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString qualifiedName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString qualifiedName )
|
||||
{
|
||||
IXML_Element *newElement = NULL;
|
||||
|
||||
@@ -698,7 +698,7 @@ ixmlDocument_createElementNS( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_NodeList *
|
||||
ixmlDocument_getElementsByTagName( IN IXML_Document * doc,
|
||||
IN char *tagName )
|
||||
IN const char *tagName )
|
||||
{
|
||||
IXML_NodeList *returnNodeList = NULL;
|
||||
|
||||
@@ -728,8 +728,8 @@ ixmlDocument_getElementsByTagName( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_NodeList *
|
||||
ixmlDocument_getElementsByTagNameNS( IN IXML_Document * doc,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
IXML_NodeList *returnNodeList = NULL;
|
||||
|
||||
@@ -756,7 +756,7 @@ ixmlDocument_getElementsByTagNameNS( IN IXML_Document * doc,
|
||||
*=================================================================*/
|
||||
IXML_Element *
|
||||
ixmlDocument_getElementById( IN IXML_Document * doc,
|
||||
IN DOMString tagName )
|
||||
IN const DOMString tagName )
|
||||
{
|
||||
IXML_Element *rtElement = NULL;
|
||||
IXML_Node *nodeptr = ( IXML_Node * ) doc;
|
||||
|
||||
@@ -71,7 +71,7 @@ ixmlElement_getTagName( IN IXML_Element * element )
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlElement_setTagName( IN IXML_Element * element,
|
||||
IN char *tagName )
|
||||
IN const char *tagName )
|
||||
{
|
||||
int rc = IXML_SUCCESS;
|
||||
|
||||
@@ -104,9 +104,9 @@ ixmlElement_setTagName( IN IXML_Element * element,
|
||||
* does not have a specified value.
|
||||
*
|
||||
*=================================================================*/
|
||||
DOMString
|
||||
const DOMString
|
||||
ixmlElement_getAttribute( IN IXML_Element * element,
|
||||
IN DOMString name )
|
||||
IN const DOMString name )
|
||||
{
|
||||
IXML_Node *attrNode;
|
||||
|
||||
@@ -142,8 +142,8 @@ ixmlElement_getAttribute( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlElement_setAttribute( IN IXML_Element * element,
|
||||
IN char *name,
|
||||
IN char *value )
|
||||
IN const char *name,
|
||||
IN const char *value )
|
||||
{
|
||||
IXML_Node *attrNode;
|
||||
IXML_Attr *newAttrNode;
|
||||
@@ -221,7 +221,7 @@ ixmlElement_setAttribute( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlElement_removeAttribute( IN IXML_Element * element,
|
||||
IN char *name )
|
||||
IN const char *name )
|
||||
{
|
||||
|
||||
IXML_Node *attrNode;
|
||||
@@ -262,7 +262,7 @@ ixmlElement_removeAttribute( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
IXML_Attr *
|
||||
ixmlElement_getAttributeNode( IN IXML_Element * element,
|
||||
IN char *name )
|
||||
IN const char *name )
|
||||
{
|
||||
|
||||
IXML_Node *attrNode;
|
||||
@@ -483,7 +483,7 @@ ixmlElement_removeAttributeNode( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
IXML_NodeList *
|
||||
ixmlElement_getElementsByTagName( IN IXML_Element * element,
|
||||
IN char *tagName )
|
||||
IN const char *tagName )
|
||||
{
|
||||
IXML_NodeList *returnNodeList = NULL;
|
||||
|
||||
@@ -508,10 +508,10 @@ ixmlElement_getElementsByTagName( IN IXML_Element * element,
|
||||
* not have the specified value.
|
||||
*
|
||||
*=================================================================*/
|
||||
DOMString
|
||||
const DOMString
|
||||
ixmlElement_getAttributeNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
IXML_Node *attrNode;
|
||||
|
||||
@@ -553,9 +553,9 @@ ixmlElement_getAttributeNS( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlElement_setAttributeNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString qualifiedName,
|
||||
IN DOMString value )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString qualifiedName,
|
||||
IN const DOMString value )
|
||||
{
|
||||
IXML_Node *attrNode = NULL;
|
||||
IXML_Node newAttrNode;
|
||||
@@ -672,8 +672,8 @@ ixmlElement_setAttributeNS( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlElement_removeAttributeNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
IXML_Node *attrNode;
|
||||
|
||||
@@ -719,8 +719,8 @@ ixmlElement_removeAttributeNS( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
IXML_Attr *
|
||||
ixmlElement_getAttributeNodeNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
|
||||
IXML_Node *attrNode;
|
||||
@@ -861,8 +861,8 @@ ixmlElement_setAttributeNodeNS( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
IXML_NodeList *
|
||||
ixmlElement_getElementsByTagNameNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
IXML_Node *node = ( IXML_Node * ) element;
|
||||
IXML_NodeList *nodeList = NULL;
|
||||
@@ -892,7 +892,7 @@ ixmlElement_getElementsByTagNameNS( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
BOOL
|
||||
ixmlElement_hasAttribute( IN IXML_Element * element,
|
||||
IN DOMString name )
|
||||
IN const DOMString name )
|
||||
{
|
||||
|
||||
IXML_Node *attrNode;
|
||||
@@ -930,8 +930,8 @@ ixmlElement_hasAttribute( IN IXML_Element * element,
|
||||
*=================================================================*/
|
||||
BOOL
|
||||
ixmlElement_hasAttributeNS( IN IXML_Element * element,
|
||||
IN DOMString namespaceURI,
|
||||
IN DOMString localName )
|
||||
IN const DOMString namespaceURI,
|
||||
IN const DOMString localName )
|
||||
{
|
||||
|
||||
IXML_Node *attrNode;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
||||
|
||||
#ifndef WIN32
|
||||
#define XINLINE inline
|
||||
#define UPNP_INLINE inline
|
||||
#endif
|
||||
|
||||
#define MEMBUF_DEF_SIZE_INC 20
|
||||
|
||||
@@ -88,8 +88,8 @@ typedef struct _Parser
|
||||
|
||||
|
||||
|
||||
int Parser_LoadDocument( IXML_Document **retDoc, char * xmlFile, BOOL file);
|
||||
BOOL Parser_isValidXmlName( DOMString name);
|
||||
int Parser_LoadDocument( IXML_Document **retDoc, const char * xmlFile, BOOL file);
|
||||
BOOL Parser_isValidXmlName( const DOMString name);
|
||||
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
|
||||
void Parser_freeNodeContent( IXML_Node *IXML_Nodeptr);
|
||||
|
||||
@@ -98,7 +98,7 @@ void Parser_setErrorChar( char c );
|
||||
void ixmlAttr_free(IXML_Attr *attrNode);
|
||||
void ixmlAttr_init(IXML_Attr *attrNode);
|
||||
|
||||
int ixmlElement_setTagName(IXML_Element *element, char *tagName);
|
||||
int ixmlElement_setTagName(IXML_Element *element, const char *tagName);
|
||||
|
||||
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap);
|
||||
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add);
|
||||
@@ -106,12 +106,12 @@ int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node
|
||||
void ixmlNode_init(IXML_Node *IXML_Nodeptr);
|
||||
BOOL ixmlNode_compare(IXML_Node *srcIXML_Node, IXML_Node *destIXML_Node);
|
||||
|
||||
void ixmlNode_getElementsByTagName( IXML_Node *n, char *tagname, IXML_NodeList **list);
|
||||
void ixmlNode_getElementsByTagNameNS( IXML_Node *IXML_Node, char *namespaceURI,
|
||||
char *localName, IXML_NodeList **list);
|
||||
void ixmlNode_getElementsByTagName( IXML_Node *n, const char *tagname, IXML_NodeList **list);
|
||||
void ixmlNode_getElementsByTagNameNS( IXML_Node *IXML_Node, const char *namespaceURI,
|
||||
const char *localName, IXML_NodeList **list);
|
||||
|
||||
int ixmlNode_setNodeProperties(IXML_Node* node, IXML_Node *src);
|
||||
int ixmlNode_setNodeName( IXML_Node* node, DOMString qualifiedName);
|
||||
int ixmlNode_setNodeName( IXML_Node* node, const DOMString qualifiedName);
|
||||
|
||||
void ixmlNodeList_init(IXML_NodeList *nList);
|
||||
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
*=================================================================*/
|
||||
static void
|
||||
copy_with_escape( INOUT ixml_membuf * buf,
|
||||
IN char *p )
|
||||
IN const char *p )
|
||||
{
|
||||
int i;
|
||||
int plen;
|
||||
@@ -87,13 +87,13 @@ void
|
||||
ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
|
||||
IN ixml_membuf * buf )
|
||||
{
|
||||
char *nodeName = NULL;
|
||||
char *nodeValue = NULL;
|
||||
const char *nodeName = NULL;
|
||||
const char *nodeValue = NULL;
|
||||
IXML_Node *child = NULL,
|
||||
*sibling = NULL;
|
||||
|
||||
if( nodeptr != NULL ) {
|
||||
nodeName = ( char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeValue = ixmlNode_getNodeValue( nodeptr );
|
||||
|
||||
switch ( ixmlNode_getNodeType( nodeptr ) ) {
|
||||
@@ -103,14 +103,16 @@ ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
|
||||
break;
|
||||
|
||||
case eCDATA_SECTION_NODE:
|
||||
ixml_membuf_append_str( buf, "<![CDATA[" );
|
||||
ixml_membuf_append_str( buf, nodeValue );
|
||||
ixml_membuf_append_str( buf, "]]>" );
|
||||
break;
|
||||
|
||||
case ePROCESSING_INSTRUCTION_NODE:
|
||||
ixml_membuf_append_str( buf, "<?" );
|
||||
ixml_membuf_append_str( buf, nodeName );
|
||||
ixml_membuf_append_str( buf, " " );
|
||||
ixml_membuf_append_str( buf, nodeValue );
|
||||
copy_with_escape( buf, nodeValue );
|
||||
ixml_membuf_append_str( buf, "?>\n" );
|
||||
break;
|
||||
|
||||
@@ -122,10 +124,9 @@ ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
|
||||
case eATTRIBUTE_NODE:
|
||||
ixml_membuf_append_str( buf, nodeName );
|
||||
ixml_membuf_append_str( buf, "=\"" );
|
||||
if( nodeValue != NULL ) {
|
||||
ixml_membuf_append_str( buf, nodeValue );
|
||||
}
|
||||
copy_with_escape( buf, nodeValue );
|
||||
ixml_membuf_append_str( buf, "\"" );
|
||||
|
||||
if( nodeptr->nextSibling != NULL ) {
|
||||
ixml_membuf_append_str( buf, " " );
|
||||
ixmlPrintDomTreeRecursive( nodeptr->nextSibling, buf );
|
||||
@@ -145,7 +146,7 @@ ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
|
||||
if( ( child != NULL )
|
||||
&& ( ixmlNode_getNodeType( child ) ==
|
||||
eELEMENT_NODE ) ) {
|
||||
ixml_membuf_append_str( buf, ">\n" );
|
||||
ixml_membuf_append_str( buf, ">\r\n" );
|
||||
} else {
|
||||
ixml_membuf_append_str( buf, ">" );
|
||||
}
|
||||
@@ -163,7 +164,7 @@ ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
|
||||
&& ixmlNode_getNodeType( sibling ) == eTEXT_NODE ) {
|
||||
ixml_membuf_append_str( buf, ">" );
|
||||
} else {
|
||||
ixml_membuf_append_str( buf, ">\n" );
|
||||
ixml_membuf_append_str( buf, ">\r\n" );
|
||||
}
|
||||
ixmlPrintDomTreeRecursive( ixmlNode_getNextSibling
|
||||
( nodeptr ), buf );
|
||||
@@ -187,15 +188,15 @@ void
|
||||
ixmlPrintDomTree( IN IXML_Node * nodeptr,
|
||||
IN ixml_membuf * buf )
|
||||
{
|
||||
char *nodeName = NULL;
|
||||
char *nodeValue = NULL;
|
||||
const char *nodeName = NULL;
|
||||
const char *nodeValue = NULL;
|
||||
IXML_Node *child = NULL;
|
||||
|
||||
if( ( nodeptr == NULL ) || ( buf == NULL ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
nodeName = ( char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeValue = ixmlNode_getNodeValue( nodeptr );
|
||||
|
||||
switch ( ixmlNode_getNodeType( nodeptr ) ) {
|
||||
@@ -210,7 +211,7 @@ ixmlPrintDomTree( IN IXML_Node * nodeptr,
|
||||
case eATTRIBUTE_NODE:
|
||||
ixml_membuf_append_str( buf, nodeName );
|
||||
ixml_membuf_append_str( buf, "=\"" );
|
||||
ixml_membuf_append_str( buf, nodeValue );
|
||||
copy_with_escape( buf, nodeValue );
|
||||
ixml_membuf_append_str( buf, "\"" );
|
||||
break;
|
||||
|
||||
@@ -226,7 +227,7 @@ ixmlPrintDomTree( IN IXML_Node * nodeptr,
|
||||
child = ixmlNode_getFirstChild( nodeptr );
|
||||
if( ( child != NULL )
|
||||
&& ( ixmlNode_getNodeType( child ) == eELEMENT_NODE ) ) {
|
||||
ixml_membuf_append_str( buf, ">\n" );
|
||||
ixml_membuf_append_str( buf, ">\r\n" );
|
||||
} else {
|
||||
ixml_membuf_append_str( buf, ">" );
|
||||
}
|
||||
@@ -238,7 +239,7 @@ ixmlPrintDomTree( IN IXML_Node * nodeptr,
|
||||
// Done with children. Output the end tag.
|
||||
ixml_membuf_append_str( buf, "</" );
|
||||
ixml_membuf_append_str( buf, nodeName );
|
||||
ixml_membuf_append_str( buf, ">\n" );
|
||||
ixml_membuf_append_str( buf, ">\r\n" );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -258,15 +259,15 @@ void
|
||||
ixmlDomTreetoString( IN IXML_Node * nodeptr,
|
||||
IN ixml_membuf * buf )
|
||||
{
|
||||
char *nodeName = NULL;
|
||||
char *nodeValue = NULL;
|
||||
const char *nodeName = NULL;
|
||||
const char *nodeValue = NULL;
|
||||
IXML_Node *child = NULL;
|
||||
|
||||
if( ( nodeptr == NULL ) || ( buf == NULL ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
nodeName = ( char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
|
||||
nodeValue = ixmlNode_getNodeValue( nodeptr );
|
||||
|
||||
switch ( ixmlNode_getNodeType( nodeptr ) ) {
|
||||
@@ -281,7 +282,7 @@ ixmlDomTreetoString( IN IXML_Node * nodeptr,
|
||||
case eATTRIBUTE_NODE:
|
||||
ixml_membuf_append_str( buf, nodeName );
|
||||
ixml_membuf_append_str( buf, "=\"" );
|
||||
ixml_membuf_append_str( buf, nodeValue );
|
||||
copy_with_escape( buf, nodeValue );
|
||||
ixml_membuf_append_str( buf, "\"" );
|
||||
break;
|
||||
|
||||
@@ -324,7 +325,7 @@ ixmlDomTreetoString( IN IXML_Node * nodeptr,
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlLoadDocumentEx( IN char *xmlFile,
|
||||
ixmlLoadDocumentEx( IN const char *xmlFile,
|
||||
IXML_Document ** doc )
|
||||
{
|
||||
|
||||
@@ -342,7 +343,7 @@ ixmlLoadDocumentEx( IN char *xmlFile,
|
||||
*
|
||||
*=================================================================*/
|
||||
IXML_Document *
|
||||
ixmlLoadDocument( IN char *xmlFile )
|
||||
ixmlLoadDocument( IN const char *xmlFile )
|
||||
{
|
||||
|
||||
IXML_Document *doc = NULL;
|
||||
@@ -371,7 +372,7 @@ ixmlPrintDocument(IXML_Document *doc)
|
||||
}
|
||||
|
||||
ixml_membuf_init( buf );
|
||||
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\n" );
|
||||
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );
|
||||
ixmlPrintDomTree( rootNode, buf );
|
||||
return buf->buf;
|
||||
|
||||
@@ -420,7 +421,7 @@ ixmlDocumenttoString(IXML_Document *doc)
|
||||
}
|
||||
|
||||
ixml_membuf_init( buf );
|
||||
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\n" );
|
||||
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );
|
||||
ixmlDomTreetoString( rootNode, buf );
|
||||
return buf->buf;
|
||||
|
||||
@@ -469,7 +470,7 @@ ixmlRelaxParser(char errorChar)
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlParseBufferEx( IN char *buffer,
|
||||
ixmlParseBufferEx( IN const char *buffer,
|
||||
IXML_Document ** retDoc )
|
||||
{
|
||||
|
||||
@@ -477,7 +478,7 @@ ixmlParseBufferEx( IN char *buffer,
|
||||
return IXML_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if( strlen( buffer ) == 0 ) {
|
||||
if( buffer[0] == '\0' ) {
|
||||
return IXML_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -491,7 +492,7 @@ ixmlParseBufferEx( IN char *buffer,
|
||||
*
|
||||
*=================================================================*/
|
||||
IXML_Document *
|
||||
ixmlParseBuffer( IN char *buffer )
|
||||
ixmlParseBuffer( IN const char *buffer )
|
||||
{
|
||||
IXML_Document *doc = NULL;
|
||||
|
||||
|
||||
@@ -232,15 +232,30 @@ static BOOL Parser_ElementPrefixDefined( Parser * myParser,
|
||||
IXML_Node * newNode,
|
||||
char **nsURI );
|
||||
static int Parser_setElementNamespace( IXML_Element * newElement,
|
||||
char *nsURI );
|
||||
const char *nsURI );
|
||||
static int Parser_parseDocument( IXML_Document ** retDoc,
|
||||
Parser * domParser );
|
||||
static BOOL Parser_hasDefaultNamespace( Parser * xmlParser,
|
||||
IXML_Node * newNode,
|
||||
char **nsURI );
|
||||
static int Parser_getChar( IN char *src,
|
||||
static int Parser_getChar( IN const char *src,
|
||||
INOUT int *cLen );
|
||||
|
||||
/*==============================================================================*
|
||||
* safe_strdup
|
||||
* strdup that handles NULL input.
|
||||
*
|
||||
*===============================================================================*/
|
||||
static char *
|
||||
safe_strdup(const char *s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
if (s == NULL) {
|
||||
return strdup("");
|
||||
}
|
||||
return strdup(s);
|
||||
}
|
||||
|
||||
/*==============================================================================*
|
||||
* Parser_isCharInTable
|
||||
* will determine whether character c is in the table of tbl
|
||||
@@ -312,9 +327,9 @@ Parser_isNameChar( IN int c,
|
||||
*
|
||||
*===============================================================================*/
|
||||
BOOL
|
||||
Parser_isValidXmlName( IN DOMString name )
|
||||
Parser_isValidXmlName( IN const DOMString name )
|
||||
{
|
||||
char *pstr = NULL;
|
||||
const char *pstr = NULL;
|
||||
int i = 0,
|
||||
nameLen = 0;
|
||||
|
||||
@@ -325,7 +340,7 @@ Parser_isValidXmlName( IN DOMString name )
|
||||
pstr = name;
|
||||
if( Parser_isNameChar( *pstr, FALSE ) == TRUE ) {
|
||||
for( i = 1; i < nameLen; i++ ) {
|
||||
if( Parser_isNameChar( *( pstr + 1 ), TRUE ) == FALSE ) { //illegal char
|
||||
if( Parser_isNameChar( *( pstr + i ), TRUE ) == FALSE ) { //illegal char
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -419,11 +434,11 @@ Parser_intToUTF8( IN int c,
|
||||
*
|
||||
*===============================================================================*/
|
||||
static int
|
||||
Parser_UTF8ToInt( IN char *ss,
|
||||
Parser_UTF8ToInt( IN const char *ss,
|
||||
OUT int *len )
|
||||
{
|
||||
|
||||
unsigned char *s = ( unsigned char * )ss;
|
||||
const unsigned char *s = ( const unsigned char * )ss;
|
||||
int c = *s;
|
||||
|
||||
if( c <= 127 ) { // if c<=127, c is just the character.
|
||||
@@ -525,14 +540,14 @@ Parser_pushElement( IN Parser * xmlParser,
|
||||
memset( pNewStackElement, 0, sizeof( IXML_ElementStack ) );
|
||||
// the element member includes both prefix and name
|
||||
|
||||
pNewStackElement->element = strdup( newElement->nodeName );
|
||||
pNewStackElement->element = safe_strdup( newElement->nodeName );
|
||||
if( pNewStackElement->element == NULL ) {
|
||||
free( pNewStackElement );
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
if( newElement->prefix != 0 ) {
|
||||
pNewStackElement->prefix = strdup( newElement->prefix );
|
||||
pNewStackElement->prefix = safe_strdup( newElement->prefix );
|
||||
if( pNewStackElement->prefix == NULL ) {
|
||||
Parser_freeElementStackItem( pNewStackElement );
|
||||
free( pNewStackElement );
|
||||
@@ -542,7 +557,7 @@ Parser_pushElement( IN Parser * xmlParser,
|
||||
|
||||
if( newElement->namespaceURI != 0 ) {
|
||||
pNewStackElement->namespaceUri =
|
||||
strdup( newElement->namespaceURI );
|
||||
safe_strdup( newElement->namespaceURI );
|
||||
if( pNewStackElement->namespaceUri == NULL ) {
|
||||
Parser_freeElementStackItem( pNewStackElement );
|
||||
free( pNewStackElement );
|
||||
@@ -602,7 +617,7 @@ Parser_popElement( IN Parser * xmlParser )
|
||||
*=================================================================*/
|
||||
static int
|
||||
Parser_readFileOrBuffer( IN Parser * xmlParser,
|
||||
IN char *xmlFileName,
|
||||
IN const char *xmlFileName,
|
||||
IN BOOL file )
|
||||
{
|
||||
int fileSize = 0;
|
||||
@@ -634,7 +649,7 @@ Parser_readFileOrBuffer( IN Parser * xmlParser,
|
||||
fclose( xmlFilePtr );
|
||||
}
|
||||
} else {
|
||||
xmlParser->dataBuffer = strdup( xmlFileName );
|
||||
xmlParser->dataBuffer = safe_strdup( xmlFileName );
|
||||
if( xmlParser->dataBuffer == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -651,7 +666,7 @@ Parser_readFileOrBuffer( IN Parser * xmlParser,
|
||||
*=================================================================*/
|
||||
int
|
||||
Parser_LoadDocument( OUT IXML_Document ** retDoc,
|
||||
IN char *xmlFileName,
|
||||
IN const char *xmlFileName,
|
||||
IN BOOL file )
|
||||
{
|
||||
int rc = IXML_SUCCESS;
|
||||
@@ -1117,10 +1132,10 @@ Parser_skipWhiteSpaces( IN Parser * xmlParser )
|
||||
*
|
||||
*===============================================================================*/
|
||||
static int
|
||||
Parser_getChar( IN char *src,
|
||||
Parser_getChar( IN const char *src,
|
||||
INOUT int *cLen )
|
||||
{
|
||||
char *pnum;
|
||||
const char *pnum;
|
||||
int sum;
|
||||
char c;
|
||||
int i;
|
||||
@@ -1213,13 +1228,13 @@ fail_entity:
|
||||
*===============================================================================*/
|
||||
static int
|
||||
Parser_copyToken( IN Parser * xmlParser,
|
||||
IN char *src,
|
||||
IN const char *src,
|
||||
IN int len )
|
||||
{
|
||||
int i,
|
||||
c,
|
||||
cl;
|
||||
char *psrc,
|
||||
const char *psrc,
|
||||
*pend;
|
||||
utf8char uch;
|
||||
|
||||
@@ -1563,7 +1578,7 @@ Parser_getNextToken( IN Parser * xmlParser )
|
||||
*===============================================================================*/
|
||||
static char *
|
||||
Parser_getNameSpace( IN Parser * xmlParser,
|
||||
IN char *prefix )
|
||||
IN const char *prefix )
|
||||
{
|
||||
IXML_ElementStack *pCur;
|
||||
IXML_NamespaceURI *pNsUri;
|
||||
@@ -1597,7 +1612,7 @@ Parser_addNamespace( IN Parser * xmlParser )
|
||||
{
|
||||
IXML_Node *pNode;
|
||||
IXML_ElementStack *pCur;
|
||||
char *namespaceUri;
|
||||
const char *namespaceUri;
|
||||
|
||||
pNode = xmlParser->pNeedPrefixNode;
|
||||
pCur = xmlParser->pCurElement;
|
||||
@@ -1610,7 +1625,7 @@ Parser_addNamespace( IN Parser * xmlParser )
|
||||
// it would be wrong that pNode->namespace != NULL.
|
||||
assert( pNode->namespaceURI == NULL );
|
||||
|
||||
pNode->namespaceURI = strdup( pCur->namespaceUri );
|
||||
pNode->namespaceURI = safe_strdup( pCur->namespaceUri );
|
||||
if( pNode->namespaceURI == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1626,7 +1641,7 @@ Parser_addNamespace( IN Parser * xmlParser )
|
||||
|
||||
namespaceUri = Parser_getNameSpace( xmlParser, pCur->prefix );
|
||||
if( namespaceUri != NULL ) {
|
||||
pNode->namespaceURI = strdup( namespaceUri );
|
||||
pNode->namespaceURI = safe_strdup( namespaceUri );
|
||||
if( pNode->namespaceURI == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1661,7 +1676,7 @@ Parser_setNodePrefixAndLocalName( IN IXML_Node * node )
|
||||
pStrPrefix = strchr( node->nodeName, ':' );
|
||||
if( pStrPrefix == NULL ) {
|
||||
node->prefix = NULL;
|
||||
node->localName = strdup( node->nodeName );
|
||||
node->localName = safe_strdup( node->nodeName );
|
||||
if( node->localName == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1678,7 +1693,7 @@ Parser_setNodePrefixAndLocalName( IN IXML_Node * node )
|
||||
memset( node->prefix, 0, nPrefix + 1 );
|
||||
strncpy( node->prefix, node->nodeName, nPrefix );
|
||||
|
||||
node->localName = strdup( pLocalName );
|
||||
node->localName = safe_strdup( pLocalName );
|
||||
if( node->localName == NULL ) {
|
||||
free( node->prefix );
|
||||
node->prefix = NULL; //no need to free really, main loop will frees it
|
||||
@@ -1718,7 +1733,7 @@ Parser_xmlNamespace( IN Parser * xmlParser,
|
||||
}
|
||||
///here it goes to segfault on "" when not copying
|
||||
if(newNode->nodeValue){
|
||||
pCur->namespaceUri = strdup( newNode->nodeValue );
|
||||
pCur->namespaceUri = safe_strdup( newNode->nodeValue );
|
||||
if( pCur->namespaceUri == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1738,7 +1753,7 @@ Parser_xmlNamespace( IN Parser * xmlParser,
|
||||
|
||||
if( ( pCur->prefix != NULL )
|
||||
&& ( strcmp( pCur->prefix, newNode->localName ) == 0 ) ) {
|
||||
pCur->namespaceUri = strdup( newNode->nodeValue );
|
||||
pCur->namespaceUri = safe_strdup( newNode->nodeValue );
|
||||
if( pCur->namespaceUri == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1765,13 +1780,13 @@ Parser_xmlNamespace( IN Parser * xmlParser,
|
||||
}
|
||||
memset( pNewNs, 0, sizeof( IXML_NamespaceURI ) );
|
||||
|
||||
pNewNs->prefix = strdup( newNode->localName );
|
||||
pNewNs->prefix = safe_strdup( newNode->localName );
|
||||
if( pNewNs->prefix == NULL ) {
|
||||
free( pNewNs );
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
pNewNs->nsURI = strdup( newNode->nodeValue );
|
||||
pNewNs->nsURI = safe_strdup( newNode->nodeValue );
|
||||
if( pNewNs->nsURI == NULL ) {
|
||||
Parser_freeNsURI( pNewNs );
|
||||
free( pNewNs );
|
||||
@@ -1789,7 +1804,7 @@ Parser_xmlNamespace( IN Parser * xmlParser,
|
||||
free( pNs->nsURI );
|
||||
}
|
||||
|
||||
pNs->nsURI = strdup( newNode->nodeValue );
|
||||
pNs->nsURI = safe_strdup( newNode->nodeValue );
|
||||
if( pNs->nsURI == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1826,7 +1841,7 @@ Parser_processSTag( IN Parser * xmlParser,
|
||||
|
||||
pCurToken = ( xmlParser->tokenBuf ).buf;
|
||||
if( pCurToken != NULL ) {
|
||||
node->nodeName = strdup( pCurToken );
|
||||
node->nodeName = safe_strdup( pCurToken );
|
||||
if( node->nodeName == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -1977,7 +1992,7 @@ Parser_processCDSect( IN char **pSrc,
|
||||
strncpy( node->nodeValue, pCDataStart, tokenLength );
|
||||
node->nodeValue[tokenLength] = '\0';
|
||||
|
||||
node->nodeName = strdup( CDATANODENAME );
|
||||
node->nodeName = safe_strdup( CDATANODENAME );
|
||||
if( node->nodeName == NULL ) {
|
||||
// no need to free node->nodeValue at all, bacause node contents
|
||||
// will be freed by the main loop.
|
||||
@@ -2002,13 +2017,13 @@ Parser_processCDSect( IN char **pSrc,
|
||||
*===============================================================================*/
|
||||
static int
|
||||
Parser_setElementNamespace( IN IXML_Element * newElement,
|
||||
IN char *nsURI )
|
||||
IN const char *nsURI )
|
||||
{
|
||||
if( newElement != NULL ) {
|
||||
if( newElement->n.namespaceURI != NULL ) {
|
||||
return IXML_SYNTAX_ERR;
|
||||
} else {
|
||||
( newElement->n ).namespaceURI = strdup( nsURI );
|
||||
( newElement->n ).namespaceURI = safe_strdup( nsURI );
|
||||
if( ( newElement->n ).namespaceURI == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -2107,7 +2122,7 @@ Parser_processContent( IN Parser * xmlParser,
|
||||
|
||||
pCurToken = ( xmlParser->tokenBuf ).buf;
|
||||
if( pCurToken != NULL ) {
|
||||
node->nodeValue = strdup( pCurToken );
|
||||
node->nodeValue = safe_strdup( pCurToken );
|
||||
if( node->nodeValue == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -2115,7 +2130,7 @@ Parser_processContent( IN Parser * xmlParser,
|
||||
return IXML_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
node->nodeName = strdup( TEXTNODENAME );
|
||||
node->nodeName = safe_strdup( TEXTNODENAME );
|
||||
if( node->nodeName == NULL ) {
|
||||
return IXML_SYNTAX_ERR;
|
||||
}
|
||||
@@ -2152,7 +2167,7 @@ Parser_processETag( IN Parser * xmlParser,
|
||||
if( pCurToken == NULL ) {
|
||||
return IXML_SYNTAX_ERR;
|
||||
}
|
||||
node->nodeName = strdup( pCurToken );
|
||||
node->nodeName = safe_strdup( pCurToken );
|
||||
if( node->nodeName == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -2320,7 +2335,7 @@ Parser_processAttribute( IN Parser * xmlParser,
|
||||
return IXML_SYNTAX_ERR;
|
||||
}
|
||||
// copy in the attribute name
|
||||
node->nodeName = strdup( pCurToken );
|
||||
node->nodeName = safe_strdup( pCurToken );
|
||||
if( node->nodeName == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -2373,7 +2388,7 @@ Parser_processAttribute( IN Parser * xmlParser,
|
||||
|
||||
pCurToken = ( xmlParser->tokenBuf ).buf;
|
||||
if( pCurToken != NULL ) { // attribute has value, like a="c"
|
||||
node->nodeValue = strdup( pCurToken );
|
||||
node->nodeValue = safe_strdup( pCurToken );
|
||||
if( node->nodeValue == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
@@ -2456,7 +2471,7 @@ Parser_getNextNode( IN Parser * xmlParser,
|
||||
goto ErrorHandler;
|
||||
}
|
||||
|
||||
node->nodeName = strdup( lastElement );
|
||||
node->nodeName = safe_strdup( lastElement );
|
||||
if( node->nodeName == NULL ) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
*=================================================================*/
|
||||
unsigned long
|
||||
ixmlNamedNodeMap_getItemNumber( IN IXML_NamedNodeMap * nnMap,
|
||||
IN char *name )
|
||||
IN const char *name )
|
||||
{
|
||||
IXML_Node *tempNode;
|
||||
unsigned long returnItemNo = 0;
|
||||
@@ -92,7 +92,7 @@ ixmlNamedNodeMap_init( IN IXML_NamedNodeMap * nnMap )
|
||||
*=================================================================*/
|
||||
IXML_Node *
|
||||
ixmlNamedNodeMap_getNamedItem( IN IXML_NamedNodeMap * nnMap,
|
||||
IN char *name )
|
||||
IN const char *name )
|
||||
{
|
||||
long index;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ ixmlNode_getLocalName( IN IXML_Node * nodeptr )
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setNamespaceURI( IN IXML_Node * nodeptr,
|
||||
IN char *namespaceURI )
|
||||
IN const char *namespaceURI )
|
||||
{
|
||||
|
||||
if( nodeptr == NULL ) {
|
||||
@@ -207,7 +207,7 @@ ixmlNode_setNamespaceURI( IN IXML_Node * nodeptr,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setPrefix( IN IXML_Node * nodeptr,
|
||||
IN char *prefix )
|
||||
IN const char *prefix )
|
||||
{
|
||||
|
||||
if( nodeptr == NULL ) {
|
||||
@@ -240,7 +240,7 @@ ixmlNode_setPrefix( IN IXML_Node * nodeptr,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setLocalName( IN IXML_Node * nodeptr,
|
||||
IN char *localName )
|
||||
IN const char *localName )
|
||||
{
|
||||
|
||||
assert( nodeptr != NULL );
|
||||
@@ -288,10 +288,10 @@ ixmlNode_getNamespaceURI( IN IXML_Node * nodeptr )
|
||||
* the prefix of the node.
|
||||
*
|
||||
*=================================================================*/
|
||||
DOMString
|
||||
const DOMString
|
||||
ixmlNode_getPrefix( IN IXML_Node * nodeptr )
|
||||
{
|
||||
DOMString prefix = NULL;
|
||||
const DOMString prefix = NULL;
|
||||
|
||||
if( nodeptr != NULL ) {
|
||||
prefix = nodeptr->prefix;
|
||||
@@ -309,7 +309,7 @@ ixmlNode_getPrefix( IN IXML_Node * nodeptr )
|
||||
* the nodeValue of the node.
|
||||
*
|
||||
*=================================================================*/
|
||||
DOMString
|
||||
const DOMString
|
||||
ixmlNode_getNodeValue( IN IXML_Node * nodeptr )
|
||||
{
|
||||
|
||||
@@ -330,7 +330,7 @@ ixmlNode_getNodeValue( IN IXML_Node * nodeptr )
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setNodeValue( IN IXML_Node * nodeptr,
|
||||
IN char *newNodeValue )
|
||||
IN const char *newNodeValue )
|
||||
{
|
||||
int rc = IXML_SUCCESS;
|
||||
|
||||
@@ -1425,7 +1425,7 @@ ixmlNode_hasAttributes( IXML_Node * nodeptr )
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_getElementsByTagNameRecursive( IN IXML_Node * n,
|
||||
IN char *tagname,
|
||||
IN const char *tagname,
|
||||
OUT IXML_NodeList ** list )
|
||||
{
|
||||
const char *name;
|
||||
@@ -1457,7 +1457,7 @@ ixmlNode_getElementsByTagNameRecursive( IN IXML_Node * n,
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_getElementsByTagName( IN IXML_Node * n,
|
||||
IN char *tagname,
|
||||
IN const char *tagname,
|
||||
OUT IXML_NodeList ** list )
|
||||
{
|
||||
const char *name;
|
||||
@@ -1484,8 +1484,8 @@ ixmlNode_getElementsByTagName( IN IXML_Node * n,
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_getElementsByTagNameNSRecursive( IN IXML_Node * n,
|
||||
IN char *namespaceURI,
|
||||
IN char *localName,
|
||||
IN const char *namespaceURI,
|
||||
IN const char *localName,
|
||||
OUT IXML_NodeList ** list )
|
||||
{
|
||||
const DOMString nsURI;
|
||||
@@ -1525,8 +1525,8 @@ ixmlNode_getElementsByTagNameNSRecursive( IN IXML_Node * n,
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_getElementsByTagNameNS( IN IXML_Node * n,
|
||||
IN char *namespaceURI,
|
||||
IN char *localName,
|
||||
IN const char *namespaceURI,
|
||||
IN const char *localName,
|
||||
OUT IXML_NodeList ** list )
|
||||
{
|
||||
const DOMString nsURI;
|
||||
@@ -1560,7 +1560,7 @@ ixmlNode_getElementsByTagNameNS( IN IXML_Node * n,
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setNodeName( IN IXML_Node * node,
|
||||
IN DOMString qualifiedName )
|
||||
IN const DOMString qualifiedName )
|
||||
{
|
||||
int rc = IXML_SUCCESS;
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ Name: libupnp
|
||||
Description: Linux SDK for UPnP Devices
|
||||
Version: @VERSION@
|
||||
Libs: @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml
|
||||
Cflags: @PTHREAD_CFLAGS@ -I${includedir}
|
||||
Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp
|
||||
|
||||
|
||||
|
||||
16
libupnp.spec
16
libupnp.spec
@@ -1,15 +1,14 @@
|
||||
Version: 1.4.1
|
||||
Version: 1.4.7
|
||||
Summary: Universal Plug and Play (UPnP) SDK
|
||||
Name: libupnp
|
||||
Release: 1%{?dist}
|
||||
License: BSD
|
||||
Group: System Environment/Libraries
|
||||
URL: http://www.libupnp.org/
|
||||
Source: http://puzzle.dl.sourceforge.net/sourceforge/pupnp/%{name}-%{version}.tar.gz
|
||||
Source: http://puzzle.dl.sourceforge.net/sourceforge/pupnp/%{name}-%{version}.tar.bz2
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
%define docdir %{_docdir}/%{name}-%{version}-%{release}
|
||||
%define docdeveldir %{_docdir}/%{name}-devel-%{version}-%{release}
|
||||
%define docdeveldir %{_docdir}/%{name}-devel-%{version}
|
||||
|
||||
%description
|
||||
The Universal Plug and Play (UPnP) SDK for Linux provides
|
||||
@@ -29,7 +28,7 @@ the UPnP SDK libraries.
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
%configure --with-docdir=%{docdir}/
|
||||
%configure --with-documentation
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
@@ -78,6 +77,12 @@ make install DESTDIR=$RPM_BUILD_ROOT
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%changelog
|
||||
* Mon Nov 19 2007 Marcelo Jimenez <mroberto@users.sourceforge.net> - 1.4.7-1
|
||||
- Update to version 1.4.7
|
||||
|
||||
* Fri Feb 02 2007 Eric Tanguy <eric.tanguy@univ-nantes.fr> - 1.4.2-1
|
||||
- Update to version 1.4.2
|
||||
|
||||
* Wed Jul 05 2006 Eric Tanguy <eric.tanguy@univ-nantes.fr> - 1.4.1-1
|
||||
- Update to version 1.4.1
|
||||
|
||||
@@ -117,3 +122,4 @@ rm -rf %{buildroot}
|
||||
* Thu Dec 22 2005 Eric Tanguy 1.2.1a-1
|
||||
- Modify spec file from
|
||||
http://rpm.pbone.net/index.php3/stat/4/idpl/2378737/com/libupnp-1.2.1a_DSM320-3.i386.rpm.html
|
||||
|
||||
|
||||
14
svnignore
Normal file
14
svnignore
Normal file
@@ -0,0 +1,14 @@
|
||||
.deps
|
||||
.dirstamp
|
||||
.libs
|
||||
.*.swp
|
||||
*~
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autoconfig.h*
|
||||
autom4te.cache
|
||||
config*
|
||||
libtool
|
||||
libupnp.pc
|
||||
stamp-h*
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 FREE_LIST_H
|
||||
#define FREE_LIST_H
|
||||
@@ -36,9 +36,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#include <malloc.h>
|
||||
|
||||
|
||||
#include "ithread.h"
|
||||
#include <errno.h>
|
||||
|
||||
@@ -52,7 +49,7 @@ extern "C" {
|
||||
*****************************************************************************/
|
||||
typedef struct FREELISTNODE
|
||||
{
|
||||
struct FREELISTNODE*next; //pointer to next free node
|
||||
struct FREELISTNODE *next;
|
||||
} FreeListNode;
|
||||
|
||||
|
||||
@@ -65,12 +62,10 @@ typedef struct FREELISTNODE
|
||||
*****************************************************************************/
|
||||
typedef struct FREELIST
|
||||
{
|
||||
FreeListNode *head; //head of free list
|
||||
size_t element_size; //size of elements in free
|
||||
//list
|
||||
int maxFreeListLength; //max size of free structures
|
||||
//to keep
|
||||
int freeListLength; //current size of free list
|
||||
FreeListNode *head;
|
||||
size_t element_size;
|
||||
int maxFreeListLength;
|
||||
int freeListLength;
|
||||
|
||||
}FreeList;
|
||||
|
||||
@@ -141,4 +136,5 @@ int FreeListDestroy (FreeList *free_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FREE_LIST_H
|
||||
#endif /* FREE_LIST_H */
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 LINKED_LIST_H
|
||||
#define LINKED_LIST_H
|
||||
@@ -70,9 +70,9 @@ typedef int (*cmp_routine)(void *itemA,void *itemB);
|
||||
*****************************************************************************/
|
||||
typedef struct LISTNODE
|
||||
{
|
||||
struct LISTNODE *prev; //previous node
|
||||
struct LISTNODE *next; //next node
|
||||
void *item; //item
|
||||
struct LISTNODE *prev;
|
||||
struct LISTNODE *next;
|
||||
void *item;
|
||||
} ListNode;
|
||||
|
||||
/****************************************************************************
|
||||
@@ -96,12 +96,12 @@ typedef struct LISTNODE
|
||||
*****************************************************************************/
|
||||
typedef struct LINKEDLIST
|
||||
{
|
||||
ListNode head; //head, first item is stored at: head->next
|
||||
ListNode tail; //tail, last item is stored at: tail->prev
|
||||
long size; //size of list
|
||||
FreeList freeNodeList; //free list to use
|
||||
free_function free_func; //free function to use
|
||||
cmp_routine cmp_func; //compare function to use
|
||||
ListNode head; /* head, first item is stored at: head->next */
|
||||
ListNode tail; /* tail, last item is stored at: tail->prev */
|
||||
long size; /* size of list */
|
||||
FreeList freeNodeList; /* free list to use */
|
||||
free_function free_func; /* free function to use */
|
||||
cmp_routine cmp_func; /* compare function to use */
|
||||
} LinkedList;
|
||||
|
||||
/****************************************************************************
|
||||
@@ -327,4 +327,5 @@ int ListSize(LinkedList* list);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //LINKED_LIST_H
|
||||
#endif /* LINKED_LIST_H */
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 THREADPOOL_H
|
||||
#define THREADPOOL_H
|
||||
@@ -36,17 +36,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Size of job free list
|
||||
/* Size of job free list */
|
||||
#define JOBFREELISTSIZE 100
|
||||
|
||||
#define INFINITE_THREADS -1
|
||||
|
||||
#define EMAXTHREADS (-8 & 1<<29)
|
||||
|
||||
//Invalid Policy
|
||||
/* Invalid Policy */
|
||||
#define INVALID_POLICY (-9 & 1<<29)
|
||||
|
||||
//Invalid JOB Id
|
||||
/* Invalid JOB Id */
|
||||
#define INVALID_JOB_ID (-2 & 1<<29)
|
||||
|
||||
typedef enum duration {SHORT_TERM,PERSISTENT} Duration;
|
||||
@@ -55,39 +55,31 @@ typedef enum priority {LOW_PRIORITY,
|
||||
MED_PRIORITY,
|
||||
HIGH_PRIORITY} ThreadPriority;
|
||||
|
||||
#define DEFAULT_PRIORITY MED_PRIORITY //default priority used by TPJobInit
|
||||
#define DEFAULT_MIN_THREADS 1 //default minimum used by TPAttrInit
|
||||
#define DEFAULT_MAX_THREADS 10 //default max used by TPAttrInit
|
||||
#define DEFAULT_JOBS_PER_THREAD 10 //default jobs per thread used by TPAttrInit
|
||||
#define DEFAULT_STARVATION_TIME 500 //default starvation time used by TPAttrInit
|
||||
#define DEFAULT_IDLE_TIME 10 * 1000 //default idle time used by TPAttrInit
|
||||
#define DEFAULT_FREE_ROUTINE NULL //default free routine used TPJobInit
|
||||
#define DEFAULT_PRIORITY MED_PRIORITY /* default priority used by TPJobInit */
|
||||
#define DEFAULT_MIN_THREADS 1 /* default minimum used by TPAttrInit */
|
||||
#define DEFAULT_MAX_THREADS 10 /* default max used by TPAttrInit */
|
||||
#define DEFAULT_JOBS_PER_THREAD 10 /* default jobs per thread used by TPAttrInit */
|
||||
#define DEFAULT_STARVATION_TIME 500 /* default starvation time used by TPAttrInit */
|
||||
#define DEFAULT_IDLE_TIME 10 * 1000 /* default idle time used by TPAttrInit */
|
||||
#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */
|
||||
#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
|
||||
|
||||
#define STATS 1 //always include stats because code change is minimal
|
||||
#define STATS 1 /* always include stats because code change is minimal */
|
||||
|
||||
|
||||
//Statistics
|
||||
#ifdef WIN32 // todo: check why STATSONLY fails during compilation
|
||||
#undef STATS
|
||||
/* Statistics */
|
||||
#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */
|
||||
#undef STATS
|
||||
#endif
|
||||
|
||||
#ifdef STATS
|
||||
#define STATSONLY(x) x
|
||||
#define STATSONLY(x) x
|
||||
#else
|
||||
#define STATSONLY(x)
|
||||
#define STATSONLY(x)
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
//DEBUGGING
|
||||
#ifndef WIN32
|
||||
#ifdef DEBUG
|
||||
#define DBGONLY(x) x
|
||||
#else
|
||||
#define DBGONLY(x)
|
||||
#endif
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#include "LinkedList.h"
|
||||
@@ -100,7 +92,7 @@ typedef enum priority {LOW_PRIORITY,
|
||||
#define EXPORT
|
||||
typedef int PolicyType;
|
||||
#define DEFAULT_POLICY SCHED_OTHER
|
||||
#define DEFAULT_SCHED_PARAM 0 //default priority
|
||||
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: free_routine
|
||||
@@ -119,23 +111,25 @@ typedef void (*free_routine)(void *arg);
|
||||
*****************************************************************************/
|
||||
typedef struct THREADPOOLATTR
|
||||
{
|
||||
int minThreads; //minThreads, ThreadPool will always maintain at least
|
||||
//this many threads
|
||||
int minThreads; /* minThreads, ThreadPool will always maintain at least
|
||||
this many threads */
|
||||
|
||||
int maxThreads; //maxThreads, ThreadPool will never have more than this
|
||||
//number of threads
|
||||
int maxThreads; /* maxThreads, ThreadPool will never have more than this
|
||||
number of threads */
|
||||
|
||||
int maxIdleTime; //maxIdleTime (in milliseconds)
|
||||
// this is the maximum time a thread will remain idle
|
||||
// before dying
|
||||
int maxIdleTime; /* maxIdleTime (in milliseconds)
|
||||
this is the maximum time a thread will remain idle
|
||||
before dying */
|
||||
|
||||
int jobsPerThread; //jobs per thread to maintain
|
||||
int jobsPerThread; /* jobs per thread to maintain */
|
||||
|
||||
int starvationTime; //the time a low priority or med priority
|
||||
//job waits before getting bumped
|
||||
//up a priority (in milliseconds)
|
||||
int maxJobsTotal; /* maximum number of jobs that can be queued totally. */
|
||||
|
||||
PolicyType schedPolicy; //scheduling policy to use
|
||||
int starvationTime; /* the time a low priority or med priority
|
||||
job waits before getting bumped
|
||||
up a priority (in milliseconds) */
|
||||
|
||||
PolicyType schedPolicy; /* scheduling policy to use */
|
||||
|
||||
} ThreadPoolAttr;
|
||||
|
||||
@@ -147,12 +141,12 @@ typedef struct THREADPOOLATTR
|
||||
*****************************************************************************/
|
||||
typedef struct THREADPOOLJOB
|
||||
{
|
||||
start_routine func; //function
|
||||
void *arg; //arg
|
||||
free_routine free_func; //free function
|
||||
struct timeb requestTime; //time of request
|
||||
int priority; //priority of request
|
||||
int jobId; //id
|
||||
start_routine func;
|
||||
void *arg;
|
||||
free_routine free_func;
|
||||
struct timeb requestTime;
|
||||
int priority;
|
||||
int jobId;
|
||||
} ThreadPoolJob;
|
||||
|
||||
/****************************************************************************
|
||||
@@ -162,32 +156,32 @@ typedef struct THREADPOOLJOB
|
||||
* Structure to hold statistics
|
||||
*****************************************************************************/
|
||||
|
||||
STATSONLY(
|
||||
#ifdef STATS
|
||||
|
||||
typedef struct TPOOLSTATS
|
||||
{
|
||||
double totalTimeHQ; //total time spent by all jobs in high priority Q
|
||||
int totalJobsHQ; //total jobs in HQ run so far
|
||||
double avgWaitHQ; //average wait in HQ
|
||||
double totalTimeMQ; //total time spent by all jobs in med priority Q
|
||||
int totalJobsMQ; //total jobs in MQ run so far
|
||||
double avgWaitMQ; //average wait in MQ
|
||||
double totalTimeLQ; //total time spent by all jobs in low priority Q
|
||||
int totalJobsLQ; //total jobs in LQ run so far
|
||||
double avgWaitLQ; //average wait in LQ
|
||||
double totalWorkTime; //total time spent working for all threads
|
||||
double totalIdleTime; //total time spent idle for all threads
|
||||
int workerThreads; //number of current workerThreads
|
||||
int idleThreads; //number of current idle threads
|
||||
int persistentThreads; //number of persistent threads
|
||||
int totalThreads; //total number of current threads
|
||||
int maxThreads; //max threads so far
|
||||
int currentJobsHQ; // current jobs in Q
|
||||
int currentJobsLQ; //current jobs in Q
|
||||
int currentJobsMQ; //current jobs in Q
|
||||
double totalTimeHQ;
|
||||
int totalJobsHQ;
|
||||
double avgWaitHQ;
|
||||
double totalTimeMQ;
|
||||
int totalJobsMQ;
|
||||
double avgWaitMQ;
|
||||
double totalTimeLQ;
|
||||
int totalJobsLQ;
|
||||
double avgWaitLQ;
|
||||
double totalWorkTime;
|
||||
double totalIdleTime;
|
||||
int workerThreads;
|
||||
int idleThreads;
|
||||
int persistentThreads;
|
||||
int totalThreads;
|
||||
int maxThreads;
|
||||
int currentJobsHQ;
|
||||
int currentJobsLQ;
|
||||
int currentJobsMQ;
|
||||
}ThreadPoolStats;
|
||||
|
||||
)
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@@ -212,24 +206,26 @@ typedef struct TPOOLSTATS
|
||||
|
||||
typedef struct THREADPOOL
|
||||
{
|
||||
ithread_mutex_t mutex; //mutex to protect job qs
|
||||
ithread_cond_t condition; //condition variable to signal Q
|
||||
ithread_cond_t start_and_shutdown; //condition variable for start
|
||||
//and stop
|
||||
int lastJobId; //ids for jobs
|
||||
int shutdown; //whether or not we are shutting down
|
||||
int totalThreads; //total number of threads
|
||||
int persistentThreads; //number of persistent threads
|
||||
FreeList jobFreeList; //free list of jobs
|
||||
LinkedList lowJobQ; //low priority job Q
|
||||
LinkedList medJobQ; //med priority job Q
|
||||
LinkedList highJobQ; //high priority job Q
|
||||
ThreadPoolJob *persistentJob; //persistent job
|
||||
ithread_mutex_t mutex; /* mutex to protect job qs */
|
||||
ithread_cond_t condition; /* condition variable to signal Q */
|
||||
ithread_cond_t start_and_shutdown; /* condition variable for start
|
||||
and stop */
|
||||
int lastJobId; /* ids for jobs */
|
||||
int shutdown; /* whether or not we are shutting down */
|
||||
int totalThreads; /* total number of threads */
|
||||
int persistentThreads; /* number of persistent threads */
|
||||
FreeList jobFreeList; /* free list of jobs */
|
||||
LinkedList lowJobQ; /* low priority job Q */
|
||||
LinkedList medJobQ; /* med priority job Q */
|
||||
LinkedList highJobQ; /* high priority job Q */
|
||||
ThreadPoolJob *persistentJob; /* persistent job */
|
||||
|
||||
ThreadPoolAttr attr; //thread pool attributes
|
||||
ThreadPoolAttr attr; /* thread pool attributes */
|
||||
|
||||
//statistics
|
||||
STATSONLY(ThreadPoolStats stats;)
|
||||
#ifdef STATS
|
||||
/* statistics */
|
||||
ThreadPoolStats stats;
|
||||
#endif
|
||||
|
||||
} ThreadPool;
|
||||
|
||||
@@ -521,6 +517,19 @@ int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
|
||||
int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetMaxJobsTotal
|
||||
*
|
||||
* Description:
|
||||
* Sets the maximum number jobs that can be qeued totally.
|
||||
* Parameters:
|
||||
* attr - must be valid thread pool attributes.
|
||||
* maxJobsTotal - maximum number of jobs
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetStats
|
||||
*
|
||||
@@ -534,12 +543,15 @@ int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
STATSONLY( EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats););
|
||||
#ifdef STATS
|
||||
EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);
|
||||
|
||||
STATSONLY(EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats););
|
||||
EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ThreadPool
|
||||
#endif /* ThreadPool */
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 TIMERTHREAD_H
|
||||
#define TIMERTHREAD_H
|
||||
@@ -43,9 +43,9 @@ extern "C" {
|
||||
|
||||
#define INVALID_EVENT_ID (-10 & 1<<29)
|
||||
|
||||
//Timeout Types
|
||||
//absolute means in seconds from Jan 1, 1970
|
||||
//relative means in seconds from current time
|
||||
/* Timeout Types */
|
||||
/* absolute means in seconds from Jan 1, 1970 */
|
||||
/* relative means in seconds from current time */
|
||||
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
|
||||
*****************************************************************************/
|
||||
typedef struct TIMERTHREAD
|
||||
{
|
||||
ithread_mutex_t mutex; //mutex to protect eventQ
|
||||
ithread_cond_t condition; //condition variable
|
||||
int lastEventId; //last event id
|
||||
LinkedList eventQ; //event q
|
||||
int shutdown; //whether or not we are shutdown
|
||||
FreeList freeEvents; //FreeList for events
|
||||
ThreadPool *tp; //ThreadPool to use
|
||||
ithread_mutex_t mutex;
|
||||
ithread_cond_t condition;
|
||||
int lastEventId;
|
||||
LinkedList eventQ;
|
||||
int shutdown;
|
||||
FreeList freeEvents;
|
||||
ThreadPool *tp;
|
||||
} TimerThread;
|
||||
|
||||
|
||||
@@ -85,9 +85,9 @@ typedef struct TIMERTHREAD
|
||||
typedef struct TIMEREVENT
|
||||
{
|
||||
ThreadPoolJob job;
|
||||
time_t eventTime; //absolute time for event in seconds since Jan 1, 1970
|
||||
Duration persistent; //long term or short term job
|
||||
int id; //id of job
|
||||
time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */
|
||||
Duration persistent; /* long term or short term job */
|
||||
int id;
|
||||
} TimerEvent;
|
||||
|
||||
|
||||
@@ -188,4 +188,5 @@ int TimerThreadShutdown(TimerThread *timer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //TIMER_THREAD_H
|
||||
#endif /* TIMER_THREAD_H */
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 ITHREADH
|
||||
#define ITHREADH
|
||||
@@ -36,20 +36,28 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_ONLY(x) x
|
||||
#else
|
||||
#define DEBUG_ONLY(x)
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#endif
|
||||
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
/* This system has SuS2-compliant mutex attributes.
|
||||
* E.g. on Cygwin, where we don't have the old nonportable (NP) symbols
|
||||
*/
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_NORMAL
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK
|
||||
#else
|
||||
#define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_FAST_NP
|
||||
#define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE_NP
|
||||
#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP
|
||||
#endif
|
||||
|
||||
#define ITHREAD_CANCELED PTHREAD_CANCELED
|
||||
|
||||
|
||||
@@ -181,8 +189,11 @@ extern "C" {
|
||||
* Returns EINVAL if the kind is not supported.
|
||||
* See man page for pthread_mutexattr_setkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
|
||||
#else
|
||||
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ithread_mutexattr_getkind_np
|
||||
@@ -203,7 +214,11 @@ extern "C" {
|
||||
* Always returns 0.
|
||||
* See man page for pthread_mutexattr_getkind_np
|
||||
*****************************************************************************/
|
||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
|
||||
#else
|
||||
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@@ -527,26 +542,29 @@ extern "C" {
|
||||
#define imillisleep(x) usleep(1000*x)
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
// set up declspec for dll export to make functions visible to library users
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
/* set up declspec for dll export to make functions visible to library users */
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
|
||||
|
||||
//NK: Added for satisfying the gcc compiler
|
||||
#ifndef PTHREAD_MUTEX_RECURSIVE
|
||||
/* NK: Added for satisfying the gcc compiler */
|
||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ITHREADH
|
||||
#endif /* ITHREADH */
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef STATS
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: CmpThreadPoolJob
|
||||
@@ -92,6 +90,10 @@ FreeThreadPoolJob( ThreadPool * tp,
|
||||
static int
|
||||
SetPolicyType( PolicyType in )
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
/* TODO not currently working... */
|
||||
return 0;
|
||||
#else
|
||||
#ifdef WIN32
|
||||
return sched_setscheduler( 0, in);
|
||||
#else
|
||||
@@ -101,6 +103,7 @@ SetPolicyType( PolicyType in )
|
||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||
return sched_setscheduler( 0, in, ¤t );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -128,7 +131,7 @@ SetPriority( ThreadPriority priority )
|
||||
int midPriority = 0;
|
||||
struct sched_param newPriority;
|
||||
|
||||
pthread_getschedparam( ithread_self( ), ¤tPolicy,
|
||||
pthread_getschedparam( ithread_self(), ¤tPolicy,
|
||||
&newPriority );
|
||||
minPriority = sched_get_priority_min( currentPolicy );
|
||||
maxPriority = sched_get_priority_max( currentPolicy );
|
||||
@@ -150,7 +153,7 @@ SetPriority( ThreadPriority priority )
|
||||
|
||||
newPriority.sched_priority = actPriority;
|
||||
|
||||
return pthread_setschedparam( ithread_self( ), currentPolicy,
|
||||
return pthread_setschedparam( ithread_self(), currentPolicy,
|
||||
&newPriority );
|
||||
|
||||
}
|
||||
@@ -217,10 +220,8 @@ BumpPriority( ThreadPool * tp )
|
||||
//starvation time
|
||||
//bump priority (add to higher priority Q)
|
||||
|
||||
STATSONLY( tp->stats.totalJobsMQ++;
|
||||
);
|
||||
STATSONLY( tp->stats.totalTimeMQ += diffTime;
|
||||
);
|
||||
STATSONLY( tp->stats.totalJobsMQ++; )
|
||||
STATSONLY( tp->stats.totalTimeMQ += diffTime; )
|
||||
|
||||
ListDelNode( &tp->medJobQ, tp->medJobQ.head.next, 0 );
|
||||
ListAddTail( &tp->highJobQ, tempJob );
|
||||
@@ -238,10 +239,8 @@ BumpPriority( ThreadPool * tp )
|
||||
//starvation time
|
||||
//bump priority (add to higher priority Q)
|
||||
|
||||
STATSONLY( tp->stats.totalJobsLQ++;
|
||||
);
|
||||
STATSONLY( tp->stats.totalTimeLQ += diffTime;
|
||||
);
|
||||
STATSONLY( tp->stats.totalJobsLQ++; )
|
||||
STATSONLY( tp->stats.totalTimeLQ += diffTime; )
|
||||
|
||||
ListDelNode( &tp->lowJobQ, tp->lowJobQ.head.next, 0 );
|
||||
ListAddTail( &tp->medJobQ, tempJob );
|
||||
@@ -290,14 +289,26 @@ SetRelTimeout( struct timespec *time,
|
||||
* ThreadPoolStats *stats must be valid non null stats structure
|
||||
*****************************************************************************/
|
||||
#ifdef STATS
|
||||
static void StatsInit( ThreadPoolStats * stats ) {
|
||||
assert( stats != NULL ); stats->totalIdleTime = 0; stats->totalJobsHQ = 0; stats->totalJobsLQ = 0; stats->totalJobsMQ = 0; stats->totalTimeHQ = 0; stats->totalTimeMQ = 0; stats->totalTimeLQ = 0; stats->totalWorkTime = 0; stats->totalIdleTime = 0; stats->avgWaitHQ = 0; //average wait in HQ
|
||||
stats->avgWaitMQ = 0; //average wait in MQ
|
||||
static void StatsInit( ThreadPoolStats * stats )
|
||||
{
|
||||
assert( stats != NULL );
|
||||
stats->totalIdleTime = 0;
|
||||
stats->totalJobsHQ = 0;
|
||||
stats->totalJobsLQ = 0;
|
||||
stats->totalJobsMQ = 0;
|
||||
stats->totalTimeHQ = 0;
|
||||
stats->totalTimeMQ = 0;
|
||||
stats->totalTimeLQ = 0;
|
||||
stats->totalWorkTime = 0;
|
||||
stats->totalIdleTime = 0;
|
||||
stats->avgWaitHQ = 0;
|
||||
stats->avgWaitMQ = 0;
|
||||
stats->avgWaitLQ = 0;
|
||||
stats->workerThreads = 0;
|
||||
stats->idleThreads = 0;
|
||||
stats->persistentThreads = 0;
|
||||
stats->maxThreads = 0; stats->totalThreads = 0;}
|
||||
stats->maxThreads = 0; stats->totalThreads = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -343,16 +354,16 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
* Parameters:
|
||||
*
|
||||
*****************************************************************************/
|
||||
static void SetSeed( ) {
|
||||
static void SetSeed() {
|
||||
struct timeb t;
|
||||
|
||||
ftime( &t );
|
||||
#if defined(WIN32)
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ).p );
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id().p );
|
||||
#elif defined(__FreeBSD__)
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ) );
|
||||
srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id() );
|
||||
#else
|
||||
srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) );
|
||||
srand( ( unsigned int )t.millitm + ithread_get_current_thread_id() );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -372,8 +383,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
*****************************************************************************/
|
||||
static void *WorkerThread( void *arg ) {
|
||||
|
||||
STATSONLY( time_t start = 0;
|
||||
)
|
||||
STATSONLY( time_t start = 0; )
|
||||
|
||||
ThreadPoolJob *job = NULL;
|
||||
ListNode *head = NULL;
|
||||
@@ -397,10 +407,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
|
||||
SetSeed( );
|
||||
SetSeed();
|
||||
|
||||
STATSONLY( time( &start );
|
||||
);
|
||||
STATSONLY( time( &start ); )
|
||||
|
||||
while( 1 ) {
|
||||
|
||||
@@ -415,12 +424,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|
||||
retCode = 0;
|
||||
|
||||
STATSONLY( tp->stats.idleThreads++;
|
||||
);
|
||||
STATSONLY( tp->stats.totalWorkTime += ( time( NULL ) - start );
|
||||
); //work time
|
||||
STATSONLY( time( &start );
|
||||
); //idle time
|
||||
STATSONLY( tp->stats.idleThreads++; )
|
||||
STATSONLY( tp->stats.totalWorkTime += ( time( NULL ) - start ); ) //work time
|
||||
STATSONLY( time( &start ); ) // idle time
|
||||
|
||||
if( persistent == 1 ) {
|
||||
//Persistent thread
|
||||
@@ -428,8 +434,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
tp->persistentThreads--;
|
||||
}
|
||||
|
||||
STATSONLY( if( persistent == 0 )
|
||||
tp->stats.workerThreads--; );
|
||||
STATSONLY( if( persistent == 0 ) tp->stats.workerThreads--; )
|
||||
|
||||
//Check for a job or shutdown
|
||||
while( ( tp->lowJobQ.size == 0 )
|
||||
@@ -450,7 +455,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
&& ( ( tp->totalThreads ) >
|
||||
tp->attr.maxThreads ) ) ) {
|
||||
|
||||
STATSONLY( tp->stats.idleThreads-- );
|
||||
STATSONLY( tp->stats.idleThreads--; )
|
||||
|
||||
tp->totalThreads--;
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
@@ -472,12 +477,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|
||||
}
|
||||
|
||||
STATSONLY( tp->stats.idleThreads--;
|
||||
);
|
||||
STATSONLY( tp->stats.totalIdleTime += ( time( NULL ) - start );
|
||||
); //idle time
|
||||
STATSONLY( time( &start );
|
||||
); //work time
|
||||
STATSONLY( tp->stats.idleThreads--; )
|
||||
STATSONLY( tp->stats.totalIdleTime += ( time( NULL ) - start ); ) // idle time
|
||||
STATSONLY( time( &start ); ) // work time
|
||||
|
||||
//bump priority of starved jobs
|
||||
BumpPriority( tp );
|
||||
@@ -509,34 +511,33 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
|
||||
} else {
|
||||
STATSONLY( tp->stats.workerThreads++ );
|
||||
STATSONLY( tp->stats.workerThreads++; )
|
||||
persistent = 0;
|
||||
|
||||
//Pick the highest priority job
|
||||
if( tp->highJobQ.size > 0 ) {
|
||||
head = ListHead( &tp->highJobQ );
|
||||
job = ( ThreadPoolJob * ) head->item;
|
||||
STATSONLY( CalcWaitTime
|
||||
( tp, HIGH_PRIORITY, job ) );
|
||||
STATSONLY( CalcWaitTime( tp, HIGH_PRIORITY, job ); )
|
||||
ListDelNode( &tp->highJobQ, head, 0 );
|
||||
|
||||
} else if( tp->medJobQ.size > 0 ) {
|
||||
head = ListHead( &tp->medJobQ );
|
||||
job = ( ThreadPoolJob * ) head->item;
|
||||
STATSONLY( CalcWaitTime( tp, MED_PRIORITY, job ) );
|
||||
STATSONLY( CalcWaitTime( tp, MED_PRIORITY, job ); )
|
||||
ListDelNode( &tp->medJobQ, head, 0 );
|
||||
|
||||
} else if( tp->lowJobQ.size > 0 ) {
|
||||
head = ListHead( &tp->lowJobQ );
|
||||
job = ( ThreadPoolJob * ) head->item;
|
||||
STATSONLY( CalcWaitTime( tp, LOW_PRIORITY, job ) );
|
||||
STATSONLY( CalcWaitTime( tp, LOW_PRIORITY, job ); )
|
||||
ListDelNode( &tp->lowJobQ, head, 0 );
|
||||
|
||||
} else {
|
||||
|
||||
// Should never get here
|
||||
assert( 0 );
|
||||
STATSONLY( tp->stats.workerThreads-- );
|
||||
STATSONLY( tp->stats.workerThreads--; )
|
||||
tp->totalThreads--;
|
||||
ithread_cond_broadcast( &tp->start_and_shutdown );
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
@@ -641,9 +642,11 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|
||||
}
|
||||
|
||||
STATSONLY( if( tp->stats.maxThreads < tp->totalThreads ) {
|
||||
tp->stats.maxThreads = tp->totalThreads;}
|
||||
)
|
||||
#ifdef STATS
|
||||
if( tp->stats.maxThreads < tp->totalThreads ) {
|
||||
tp->stats.maxThreads = tp->totalThreads;
|
||||
}
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -671,7 +674,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
threads = tp->totalThreads - tp->persistentThreads;
|
||||
|
||||
while( ( threads == 0 )
|
||||
|| ( ( jobs / threads ) > tp->attr.jobsPerThread ) ) {
|
||||
|| ( ( jobs / threads ) >= tp->attr.jobsPerThread ) ) {
|
||||
|
||||
if( CreateWorker( tp ) != 0 )
|
||||
return;
|
||||
@@ -763,7 +766,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
JOBFREELISTSIZE );
|
||||
assert( retCode == 0 );
|
||||
|
||||
STATSONLY( StatsInit( &tp->stats ) );
|
||||
STATSONLY( StatsInit( &tp->stats ); )
|
||||
|
||||
retCode += ListInit( &tp->highJobQ, CmpThreadPoolJob, NULL );
|
||||
assert( retCode == 0 );
|
||||
@@ -906,6 +909,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
int rc = EOUTOFMEM;
|
||||
|
||||
int tempId = -1;
|
||||
int totalJobs;
|
||||
|
||||
ThreadPoolJob *temp = NULL;
|
||||
|
||||
@@ -922,6 +926,13 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
|| ( job->priority == MED_PRIORITY )
|
||||
|| ( job->priority == HIGH_PRIORITY ) );
|
||||
|
||||
totalJobs = tp->highJobQ.size + tp->lowJobQ.size + tp->medJobQ.size;
|
||||
if (totalJobs >= tp->attr.maxJobsTotal) {
|
||||
fprintf(stderr, "total jobs = %d, too many jobs", totalJobs);
|
||||
ithread_mutex_unlock( &tp->mutex );
|
||||
return rc;
|
||||
}
|
||||
|
||||
if( jobId == NULL )
|
||||
jobId = &tempId;
|
||||
|
||||
@@ -1267,6 +1278,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
attr->minThreads = DEFAULT_MIN_THREADS;
|
||||
attr->schedPolicy = DEFAULT_POLICY;
|
||||
attr->starvationTime = DEFAULT_STARVATION_TIME;
|
||||
attr->maxJobsTotal = DEFAULT_MAX_JOBS_TOTAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1518,6 +1530,29 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default:
|
||||
stats->totalIdleTime );}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetMaxJobsTotal
|
||||
*
|
||||
* Description:
|
||||
* Sets the maximum number jobs that can be qeued totally.
|
||||
* Parameters:
|
||||
* attr - must be valid thread pool attributes.
|
||||
* maxJobsTotal - maximum number of jobs
|
||||
* Returns:
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMaxJobsTotal( ThreadPoolAttr * attr,
|
||||
int maxJobsTotal ) {
|
||||
assert( attr != NULL );
|
||||
|
||||
if( attr == NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
attr->maxJobsTotal = maxJobsTotal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetStats
|
||||
*
|
||||
|
||||
228
upnp/Makefile.am
228
upnp/Makefile.am
@@ -1,164 +1,154 @@
|
||||
# $Id: Makefile.am,v 1.10 2006/04/08 15:22:22 r3mi Exp $
|
||||
|
||||
#
|
||||
# "Makefile.am" for "libupnp/upnp"
|
||||
#
|
||||
# Copyright (C) 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
# Copyright (C) 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
#
|
||||
|
||||
SUBDIRS = doc
|
||||
SUBDIRS = doc . sample
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/inc \
|
||||
-I$(top_srcdir)/threadutil/inc \
|
||||
-I$(top_srcdir)/ixml/inc
|
||||
AM_CPPFLAGS = \
|
||||
-I$(srcdir)/inc \
|
||||
-I$(top_srcdir)/threadutil/inc \
|
||||
-I$(top_srcdir)/ixml/inc
|
||||
|
||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
|
||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
||||
|
||||
LDADD = libupnp.la \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
$(top_builddir)/ixml/libixml.la
|
||||
LDADD = \
|
||||
libupnp.la \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
$(top_builddir)/ixml/libixml.la
|
||||
|
||||
|
||||
upnpincludedir = $(includedir)/upnp
|
||||
upnpinclude_HEADERS = inc/upnp.h
|
||||
upnpincludedir = $(includedir)/upnp
|
||||
upnpinclude_HEADERS = inc/upnp.h
|
||||
nodist_upnpinclude_HEADERS = inc/upnpconfig.h
|
||||
if ENABLE_TOOLS
|
||||
upnpinclude_HEADERS += inc/upnptools.h
|
||||
upnpinclude_HEADERS += inc/upnptools.h
|
||||
endif
|
||||
if ENABLE_DEBUG
|
||||
upnpinclude_HEADERS += inc/upnpdebug.h
|
||||
upnpinclude_HEADERS += inc/upnpdebug.h
|
||||
endif
|
||||
|
||||
lib_LTLIBRARIES = libupnp.la
|
||||
|
||||
libupnp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/inc
|
||||
libupnp_la_LDFLAGS = -version-info $(LT_VERSION_UPNP) \
|
||||
-export-symbols-regex '^Upnp.*' \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
$(top_builddir)/ixml/libixml.la
|
||||
lib_LTLIBRARIES = libupnp.la
|
||||
|
||||
libupnp_la_SOURCES = \
|
||||
src/inc/config.h \
|
||||
src/inc/client_table.h src/inc/global.h \
|
||||
src/inc/md5.h src/inc/ssdplib.h \
|
||||
src/inc/unixutil.h src/inc/urlconfig.h \
|
||||
src/inc/gmtdate.h src/inc/membuffer.h \
|
||||
src/inc/server.h src/inc/statcodes.h \
|
||||
src/inc/upnpapi.h src/inc/utilall.h \
|
||||
src/inc/gena_ctrlpt.h src/inc/http_client.h \
|
||||
src/inc/miniserver.h src/inc/service_table.h \
|
||||
src/inc/statuscodes.h src/inc/upnpclosesocket.h \
|
||||
src/inc/util.h src/inc/gena_device.h \
|
||||
src/inc/httpparser.h src/inc/netall.h \
|
||||
src/inc/soaplib.h src/inc/strintmap.h \
|
||||
src/inc/upnp_timeout.h src/inc/uuid.h \
|
||||
src/inc/gena.h src/inc/httpreadwrite.h \
|
||||
src/inc/parsetools.h src/inc/sock.h \
|
||||
src/inc/sysdep.h src/inc/uri.h \
|
||||
src/inc/webserver.h
|
||||
libupnp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/inc
|
||||
|
||||
libupnp_la_LDFLAGS = \
|
||||
-version-info $(LT_VERSION_UPNP) \
|
||||
-export-symbols-regex '^Upnp.*' \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
$(top_builddir)/ixml/libixml.la
|
||||
|
||||
libupnp_la_SOURCES = \
|
||||
src/inc/config.h \
|
||||
src/inc/client_table.h \
|
||||
src/inc/gena.h \
|
||||
src/inc/gena_ctrlpt.h \
|
||||
src/inc/gena_device.h \
|
||||
src/inc/global.h \
|
||||
src/inc/gmtdate.h \
|
||||
src/inc/http_client.h \
|
||||
src/inc/httpparser.h \
|
||||
src/inc/httpreadwrite.h \
|
||||
src/inc/md5.h \
|
||||
src/inc/membuffer.h \
|
||||
src/inc/miniserver.h \
|
||||
src/inc/netall.h \
|
||||
src/inc/parsetools.h \
|
||||
src/inc/server.h \
|
||||
src/inc/service_table.h \
|
||||
src/inc/soaplib.h \
|
||||
src/inc/sock.h \
|
||||
src/inc/statcodes.h \
|
||||
src/inc/statuscodes.h \
|
||||
src/inc/strintmap.h \
|
||||
src/inc/ssdplib.h \
|
||||
src/inc/sysdep.h \
|
||||
src/inc/unixutil.h \
|
||||
src/inc/upnpapi.h \
|
||||
src/inc/upnpclosesocket.h \
|
||||
src/inc/upnp_timeout.h \
|
||||
src/inc/uri.h \
|
||||
src/inc/urlconfig.h \
|
||||
src/inc/util.h \
|
||||
src/inc/utilall.h \
|
||||
src/inc/uuid.h \
|
||||
src/inc/webserver.h
|
||||
|
||||
# ssdp
|
||||
libupnp_la_SOURCES += src/ssdp/ssdp_device.c src/ssdp/ssdp_ctrlpt.c \
|
||||
src/ssdp/ssdp_server.c
|
||||
libupnp_la_SOURCES += \
|
||||
src/ssdp/ssdp_device.c \
|
||||
src/ssdp/ssdp_ctrlpt.c \
|
||||
src/ssdp/ssdp_server.c
|
||||
|
||||
# soap
|
||||
libupnp_la_SOURCES += src/soap/soap_device.c src/soap/soap_ctrlpt.c \
|
||||
src/soap/soap_common.c
|
||||
libupnp_la_SOURCES += \
|
||||
src/soap/soap_device.c \
|
||||
src/soap/soap_ctrlpt.c \
|
||||
src/soap/soap_common.c
|
||||
|
||||
# genlib
|
||||
libupnp_la_SOURCES += \
|
||||
src/genlib/miniserver/miniserver.c \
|
||||
src/genlib/service_table/service_table.c \
|
||||
src/genlib/util/membuffer.c \
|
||||
src/genlib/util/strintmap.c \
|
||||
src/genlib/util/upnp_timeout.c \
|
||||
src/genlib/util/util.c \
|
||||
src/genlib/client_table/client_table.c \
|
||||
src/genlib/net/sock.c \
|
||||
src/genlib/net/http/httpparser.c \
|
||||
src/genlib/net/http/httpreadwrite.c \
|
||||
src/genlib/net/http/statcodes.c \
|
||||
src/genlib/net/http/webserver.c \
|
||||
src/genlib/net/http/parsetools.c \
|
||||
src/genlib/net/uri/uri.c
|
||||
libupnp_la_SOURCES += \
|
||||
src/genlib/miniserver/miniserver.c \
|
||||
src/genlib/service_table/service_table.c \
|
||||
src/genlib/util/membuffer.c \
|
||||
src/genlib/util/strintmap.c \
|
||||
src/genlib/util/upnp_timeout.c \
|
||||
src/genlib/util/util.c \
|
||||
src/genlib/client_table/client_table.c \
|
||||
src/genlib/net/sock.c \
|
||||
src/genlib/net/http/httpparser.c \
|
||||
src/genlib/net/http/httpreadwrite.c \
|
||||
src/genlib/net/http/statcodes.c \
|
||||
src/genlib/net/http/webserver.c \
|
||||
src/genlib/net/http/parsetools.c \
|
||||
src/genlib/net/uri/uri.c
|
||||
|
||||
# gena
|
||||
libupnp_la_SOURCES += src/gena/gena_device.c src/gena/gena_ctrlpt.c \
|
||||
src/gena/gena_callback2.c
|
||||
libupnp_la_SOURCES += \
|
||||
src/gena/gena_device.c \
|
||||
src/gena/gena_ctrlpt.c \
|
||||
src/gena/gena_callback2.c
|
||||
|
||||
# api
|
||||
libupnp_la_SOURCES += src/api/upnpapi.c
|
||||
libupnp_la_SOURCES += src/api/upnpapi.c
|
||||
if ENABLE_TOOLS
|
||||
libupnp_la_SOURCES += src/api/upnptools.c
|
||||
libupnp_la_SOURCES += src/api/upnptools.c
|
||||
endif
|
||||
if ENABLE_DEBUG
|
||||
libupnp_la_SOURCES += src/api/upnpdebug.c
|
||||
libupnp_la_SOURCES += src/api/upnpdebug.c
|
||||
endif
|
||||
|
||||
|
||||
# uuid
|
||||
libupnp_la_SOURCES += src/uuid/md5.c src/uuid/sysdep.c src/uuid/uuid.c
|
||||
libupnp_la_SOURCES += \
|
||||
src/uuid/md5.c \
|
||||
src/uuid/sysdep.c \
|
||||
src/uuid/uuid.c
|
||||
|
||||
|
||||
# urlconfig
|
||||
libupnp_la_SOURCES += src/urlconfig/urlconfig.c
|
||||
|
||||
|
||||
# samples
|
||||
noinst_PROGRAMS =
|
||||
if ENABLE_SAMPLES
|
||||
if ENABLE_CLIENT
|
||||
noinst_PROGRAMS += upnp_tv_ctrlpt
|
||||
upnp_tv_ctrlpt_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
-I$(srcdir)/sample/common/ \
|
||||
-I$(srcdir)/sample/tvctrlpt
|
||||
endif
|
||||
if ENABLE_DEVICE
|
||||
noinst_PROGRAMS += upnp_tv_device
|
||||
upnp_tv_device_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
-I$(srcdir)/sample/common/ \
|
||||
-I$(srcdir)/sample/tvdevice
|
||||
endif
|
||||
endif
|
||||
upnp_tv_device_SOURCES = \
|
||||
sample/common/sample_util.c \
|
||||
sample/common/sample_util.h \
|
||||
sample/tvdevice/upnp_tv_device.c \
|
||||
sample/tvdevice/upnp_tv_device.h \
|
||||
sample/tvdevice/linux/upnp_tv_device_main.c
|
||||
upnp_tv_ctrlpt_SOURCES = \
|
||||
sample/common/sample_util.c \
|
||||
sample/common/sample_util.h \
|
||||
sample/tvctrlpt/upnp_tv_ctrlpt.c \
|
||||
sample/tvctrlpt/upnp_tv_ctrlpt.h \
|
||||
sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c
|
||||
|
||||
if WITH_DOCDIR
|
||||
docdir = @DOCDIR@
|
||||
examplesdir = $(docdir)/examples
|
||||
examples_DATA = $(upnp_tv_ctrlpt_SOURCES) $(upnp_tv_device_SOURCES)
|
||||
endif
|
||||
libupnp_la_SOURCES += src/urlconfig/urlconfig.c
|
||||
|
||||
|
||||
# check / distcheck tests
|
||||
check_PROGRAMS = test_init
|
||||
TESTS = test_init
|
||||
|
||||
test_init_SOURCES = test/test_init.c
|
||||
check_PROGRAMS = test_init
|
||||
TESTS = test_init
|
||||
test_init_SOURCES = test/test_init.c
|
||||
|
||||
|
||||
EXTRA_DIST = LICENSE \
|
||||
sample/tvdevice/web/tvcontrolSCPD.xml \
|
||||
sample/tvdevice/web/tvdevicedesc.xml \
|
||||
sample/tvdevice/web/tvdevicepres.html \
|
||||
sample/tvdevice/web/tvpictureSCPD.xml \
|
||||
src/inc/inet_pton.h \
|
||||
src/inet_pton.c \
|
||||
src/win_dll.c
|
||||
|
||||
|
||||
|
||||
CLEANFILES = IUpnpErrFile.txt IUpnpInfoFile.txt
|
||||
|
||||
EXTRA_DIST = \
|
||||
LICENSE \
|
||||
src/inc/inet_pton.h \
|
||||
src/inet_pton.c \
|
||||
src/win_dll.c
|
||||
|
||||
|
||||
CLEANFILES = \
|
||||
IUpnpErrFile.txt \
|
||||
IUpnpInfoFile.txt
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# "Makefile.am" for "libunp/upnp/doc"
|
||||
#
|
||||
# (C) Copyright 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
# (C) Copyright 2005 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
#
|
||||
##########################################################################
|
||||
#
|
||||
|
||||
Binary file not shown.
451
upnp/inc/upnp.h
451
upnp/inc/upnp.h
@@ -1,83 +1,123 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 UPNP_H
|
||||
#define UPNP_H
|
||||
|
||||
/** @name The API */
|
||||
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
|
||||
#if defined MYLIB_LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 != 64
|
||||
#if defined __GNUC__
|
||||
#warning libupnp requires largefile mode - use AC_SYS_LARGEFILE
|
||||
#else
|
||||
#error libupnp requires largefile mode - use AC_SYS_LARGEFILE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <time.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
#include "ixml.h"
|
||||
#include "upnpconfig.h"
|
||||
#if UPNP_HAVE_DEBUG
|
||||
# include "upnpdebug.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
// set up declspec for dll export to make functions visible to library users
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#ifndef UPNP_STATIC_LIB
|
||||
#ifdef LIBUPNP_EXPORTS
|
||||
/* set up declspec for dll export to make functions visible to library users */
|
||||
#define EXPORT_SPEC __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#endif
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
/* define some things the M$ VC++ doesn't know */
|
||||
#define UPNP_INLINE
|
||||
typedef __int64 int64_t;
|
||||
#define PRId64 "I64d"
|
||||
#define PRIzu "lu"
|
||||
#endif
|
||||
#ifdef UPNP_USE_BCBPP
|
||||
/* define some things Borland Builder doesn't know */
|
||||
#define UPNP_INLINE inline
|
||||
typedef __int64 int64_t;
|
||||
#warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here
|
||||
#define PRId64 "I64d"
|
||||
#define PRIzu "zu"
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_SPEC
|
||||
#define EXPORT_SPEC
|
||||
#define UPNP_INLINE inline
|
||||
/* Invented this macro so that we can live a little longer with MSVC lack of C99. */
|
||||
#define PRIzu "zu"
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define UpnpCloseSocket close
|
||||
#else
|
||||
#define UpnpCloseSocket closesocket
|
||||
#endif
|
||||
#define UPNP_SOCKETERROR -1
|
||||
#define UPNP_INVALID_SOCKET -1
|
||||
#ifndef WIN32
|
||||
#define SOCKET int
|
||||
#endif
|
||||
/*
|
||||
* Defining this macro here gives some interesting information about unused
|
||||
* functions in the code. Of course, this should never go uncommented on a
|
||||
* release.
|
||||
*/
|
||||
/*#define inline*/
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#define UpnpCloseSocket close
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <time.h>
|
||||
#define UpnpCloseSocket closesocket
|
||||
#define fseeko fseek
|
||||
#endif
|
||||
#define UPNP_SOCKETERROR -1
|
||||
#define UPNP_INVALID_SOCKET -1
|
||||
#ifndef WIN32
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#define NUM_HANDLE 200
|
||||
#define LINE_SIZE 180
|
||||
@@ -87,7 +127,6 @@
|
||||
#define SERL_NUMR_SIZE 64
|
||||
#define MODL_DESC_SIZE 64
|
||||
#define UPNP_INFINITE -1
|
||||
|
||||
#define UPNP_USING_CHUNKED -3
|
||||
#define UPNP_UNTIL_CLOSE -4
|
||||
|
||||
@@ -99,7 +138,7 @@
|
||||
* code means. Refer to the documentation for each function for a
|
||||
* description of what an error code means in that context.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** @name UPNP_E_SUCCESS [0]
|
||||
* {\tt UPNP_E_SUCCESS} signifies that the operation completed successfully.
|
||||
@@ -107,35 +146,35 @@
|
||||
* the operation was successfully transmitted on the network. The result of
|
||||
* the entire operation comes as part of the callback for that operation.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SUCCESS 0
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INVALID_HANDLE [-100]
|
||||
* {\tt UPNP_E_INVALID_HANDLE} signifies that the handle passed to a
|
||||
* function is not a recognized as a valid handle.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_HANDLE -100
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INVALID_PARAM [-101]
|
||||
* {\tt UPNP_E_INVALID_PARAM} signifies that one or more of the parameters
|
||||
* passed to the function is not valid. Refer to the documentation for each
|
||||
* function for more information on the valid ranges of the parameters.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_PARAM -101
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_OUTOF_HANDLE [-102]
|
||||
* {\tt UPNP_E_OUTOF_HANDLE} signifies that the SDK does not have any
|
||||
* more space for additional handles. The SDK allocates space for only
|
||||
* a few handles in order to conserve memory.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_OUTOF_HANDLE -102
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_OUTOF_CONTEXT -103
|
||||
|
||||
@@ -144,9 +183,9 @@
|
||||
* currently available to complete the operation. Most operations require
|
||||
* some free memory in order to complete their work.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_OUTOF_MEMORY -104
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INIT [-105]
|
||||
* {\tt UPNP_E_INIT} signifies that the SDK has already been
|
||||
@@ -154,9 +193,9 @@
|
||||
* Any additional initialization attempts simply return this error with
|
||||
* no other ill effects.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INIT -105
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_BUFFER_TOO_SMALL -106
|
||||
|
||||
@@ -165,9 +204,9 @@
|
||||
* to {\bf UpnpRegisterRootDevice} or {\bf UpnpRegisterRootDevice2} is an
|
||||
* invalid description document.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_DESC -107
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INVALID_URL [-108]
|
||||
* {\tt UPNP_E_INVALID_URL} signifies that a URL passed into the function
|
||||
@@ -175,9 +214,9 @@
|
||||
* URL itself might be malformed (e.g. have invalid characters in it) or
|
||||
* the host might be unreachable.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_URL -108
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_INVALID_SID -109
|
||||
#define UPNP_E_INVALID_DEVICE -110
|
||||
@@ -188,18 +227,18 @@
|
||||
* {\bf UpnpAcceptSubscriptionExt} to signify that the device ID/service
|
||||
* ID pair does not refer to a valid service.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_SERVICE -111
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_BAD_RESPONSE [-113]
|
||||
* {\tt UPNP_E_BAD_RESPONSE} signifies that the response received from the
|
||||
* remote side of a connection is not correct for the protocol. This applies
|
||||
* to the GENA, SOAP, and HTTP protocols.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_BAD_RESPONSE -113
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_BAD_REQUEST -114
|
||||
|
||||
@@ -208,26 +247,26 @@
|
||||
* invalid. This can be because the DOM document passed to the function was
|
||||
* malformed or the action message is not correct for the given action.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_ACTION -115
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_FINISH [-116]
|
||||
* {\tt UPNP_E_FINISH} signifies that {\bf UpnpInit} has not been called, or
|
||||
* that {\bf UpnpFinish} has already been called. None of the API functions
|
||||
* operate until {\bf UpnpInit} successfully completes.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_FINISH -116
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INIT_FAILED [-117]
|
||||
* {\tt UPNP_E_INIT_FAILED} signifies that {\bf UpnpInit} cannot complete.
|
||||
* The typical reason is failure to allocate sufficient resources.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INIT_FAILED -117
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_URL_TOO_BIG [-118]
|
||||
* {\tt UPNP_E_URL_TOO_BIG} signifies that the URL passed into a function
|
||||
@@ -243,18 +282,18 @@
|
||||
* message (e.g. {\bf UpnpSubscribe}), GENA event notifications (e.g. {\bf
|
||||
* UpnpNotify}), and HTTP transfers (e.g. {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_BAD_HTTPMSG -119
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_ALREADY_REGISTERED [-120]
|
||||
* {\tt UPNP_E_ALREADY_REGISTERED} signifies that a client or a device is
|
||||
* already registered. The SDK currently has a limit of one registered
|
||||
* client and one registered device per process.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_ALREADY_REGISTERED -120
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_NETWORK_ERROR [-200]
|
||||
* {\tt UPNP_E_NETWORK_ERROR} signifies that a network error occurred. It
|
||||
@@ -263,9 +302,9 @@
|
||||
* failed to read the local IP address or had problems configuring one of
|
||||
* the sockets.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_NETWORK_ERROR -200
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_SOCKET_WRITE [-201]
|
||||
* {\tt UPNP_E_SOCKET_WRITE} signifies an error writing to a socket. This
|
||||
@@ -274,9 +313,9 @@
|
||||
* control (e.g. {\bf UpnpSendAction}), eventing (e.g. {\bf UpnpNotify}),
|
||||
* and HTTP functions (e.g. {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SOCKET_WRITE -201
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_SOCKET_READ [-202]
|
||||
* {\tt UPNP_E_SOCKET_READ} signifies an error reading from a socket. This
|
||||
@@ -285,9 +324,9 @@
|
||||
* control (e.g. {\bf UpnpSendAction}), eventing (e.g. {\bf UpnpNotify}),
|
||||
* and HTTP functions (e.g. {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SOCKET_READ -202
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_SOCKET_BIND [-203]
|
||||
* {\tt UPNP_E_SOCKET_BIND} signifies that the SDK had a problem binding
|
||||
@@ -297,9 +336,9 @@
|
||||
* (e.g. {\bf UpnpNotify}), and HTTP functions (e.g.
|
||||
* {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SOCKET_BIND -203
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_SOCKET_CONNECT [-204]
|
||||
* {\tt UPNP_E_SOCKET_CONNECT} signifies that the SDK had a problem
|
||||
@@ -309,9 +348,9 @@
|
||||
* (e.g. {\bf UpnpNotify}), and HTTP functions (e.g.
|
||||
* {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SOCKET_CONNECT -204
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_OUTOF_SOCKET [-205]
|
||||
* {\tt UPNP_E_OUTOF_SOCKET} signifies that the SDK cannot create any
|
||||
@@ -321,36 +360,36 @@
|
||||
* (e.g. {\bf UpnpNotify}), and HTTP functions (e.g.
|
||||
* {\bf UpnpDownloadXmlDoc}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_OUTOF_SOCKET -205
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_LISTEN [-206]
|
||||
* {\tt UPNP_E_LISTEN} signifies that the SDK had a problem setting the
|
||||
* socket to listen for incoming connections. This error only happens during
|
||||
* initialization (i.e. {\bf UpnpInit}).
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_LISTEN -206
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_TIMEDOUT [-207]
|
||||
* {\tt UPNP_E_TIMEDOUT} signifies that too much time elapsed before the
|
||||
* required number of bytes were sent or received over a socket. This error
|
||||
* can be returned by any function that performs network operations.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_TIMEDOUT -207
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_SOCKET_ERROR [-208]
|
||||
* {\tt UPNP_E_SOCKET_ERROR} is the generic socket error code for
|
||||
* conditions not covered by other error codes. This error can be returned
|
||||
* by any function that performs network operations.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SOCKET_ERROR -208
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_FILE_WRITE_ERROR -209
|
||||
|
||||
@@ -359,9 +398,9 @@
|
||||
* error can be returned by any function that allows for external
|
||||
* cancelation.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_CANCELED -210
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_EVENT_PROTOCOL -300
|
||||
|
||||
@@ -369,58 +408,58 @@
|
||||
* {\tt UPNP_E_SUBSCRIBE_UNACCEPTED} signifies that a subscription
|
||||
* request was rejected from the remote side.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_SUBSCRIBE_UNACCEPTED -301
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_UNSUBSCRIBE_UNACCAPTED [-302]
|
||||
* {\tt UPNP_E_UNSUBSCRIBE_UNACCEPTED} signifies that an unsubscribe
|
||||
* request was rejected from the remote side.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_NOTIFY_UNACCEPTED [-303]
|
||||
* {\tt UPNP_E_NOTIFY_UNACCEPTED} signifies that the remote host did not
|
||||
* accept the notify sent from the local device.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_NOTIFY_UNACCEPTED -303
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INVALID_ARGUMENT [-501]
|
||||
* {\tt UPNP_E_INVALID_ARGUMENT} signifies that one or more of the parameters
|
||||
* passed to a function is invalid. Refer to the individual function
|
||||
* descriptions for the acceptable ranges for parameters.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INVALID_ARGUMENT -501
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_FILE_NOT_FOUND [-502]
|
||||
* {\tt UPNP_E_FILE_NOT_FOUND} signifies that the filename passed
|
||||
* to one of the device registration functions was not found or was not
|
||||
* accessible.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_FILE_NOT_FOUND -502
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_FILE_READ_ERROR [-503]
|
||||
* {\tt UPNP_E_FILE_READ_ERROR} signifies an error when reading a file.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_FILE_READ_ERROR -503
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_EXT_NOT_XML [-504]
|
||||
* {\tt UPNP_E_EXT_NOT_XML} signifies that the file name of the description
|
||||
* document passed to {\bf UpnpRegisterRootDevice2} does not end in ".xml".
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_EXT_NOT_XML -504
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#define UPNP_E_NO_WEB_SERVER -505
|
||||
#define UPNP_E_OUTOF_BOUNDS -506
|
||||
@@ -429,26 +468,26 @@
|
||||
* {\tt UPNP_E_NOT_FOUND} signifies that the response to a SOAP request
|
||||
* did not contain the required XML constructs.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_NOT_FOUND -507
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
/** @name UPNP_E_INTERNAL_ERROR [-911]
|
||||
* {\tt UPNP_E_INTERNAL_ERROR} is the generic error code for internal
|
||||
* conditions not covered by other error codes.
|
||||
*/
|
||||
//@{
|
||||
/*! @{ */
|
||||
#define UPNP_E_INTERNAL_ERROR -911
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
// SOAP-related error codes
|
||||
/* SOAP-related error codes */
|
||||
#define UPNP_SOAP_E_INVALID_ACTION 401
|
||||
#define UPNP_SOAP_E_INVALID_ARGS 402
|
||||
#define UPNP_SOAP_E_OUT_OF_SYNC 403
|
||||
#define UPNP_SOAP_E_INVALID_VAR 404
|
||||
#define UPNP_SOAP_E_ACTION_FAILED 501
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#ifndef OUT
|
||||
#define OUT
|
||||
@@ -462,10 +501,12 @@
|
||||
#define INOUT
|
||||
#endif
|
||||
|
||||
#include "upnpdebug.h"
|
||||
|
||||
enum UpnpOpenFileMode{UPNP_READ, UPNP_WRITE};
|
||||
|
||||
/// @name Constants, Structures, and Types
|
||||
//@{
|
||||
/*! @name Constants, Structures, and Types */
|
||||
/*! @{ */
|
||||
|
||||
/** Returned when a control point application registers with {\bf
|
||||
* UpnpRegisterClient}. Client handles can only be used with
|
||||
@@ -488,9 +529,9 @@ typedef int UpnpDevice_Handle;
|
||||
|
||||
enum Upnp_EventType_e {
|
||||
|
||||
//
|
||||
// Control callbacks
|
||||
//
|
||||
/*
|
||||
* Control callbacks
|
||||
*/
|
||||
|
||||
/** Received by a device when a control point issues a control
|
||||
* request. The {\bf Event} parameter contains a pointer to a {\bf
|
||||
@@ -518,9 +559,9 @@ enum Upnp_EventType_e {
|
||||
|
||||
UPNP_CONTROL_GET_VAR_COMPLETE,
|
||||
|
||||
//
|
||||
// Discovery callbacks
|
||||
//
|
||||
/*
|
||||
* Discovery callbacks
|
||||
*/
|
||||
|
||||
/** Received by a control point when a new device or service is available.
|
||||
* The {\bf Event} parameter contains a pointer to a {\bf
|
||||
@@ -549,9 +590,9 @@ enum Upnp_EventType_e {
|
||||
|
||||
UPNP_DISCOVERY_SEARCH_TIMEOUT,
|
||||
|
||||
//
|
||||
// Eventing callbacks
|
||||
//
|
||||
/*
|
||||
* Eventing callbacks
|
||||
*/
|
||||
|
||||
/** Received by a device when a subscription arrives.
|
||||
* The {\bf Event} parameter contains a pointer to a {\bf
|
||||
@@ -782,10 +823,10 @@ struct Upnp_Event
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// This typedef is required by Doc++ to parse the last entry of the
|
||||
// Upnp_Discovery structure correctly.
|
||||
//
|
||||
/*
|
||||
* This typedef is required by Doc++ to parse the last entry of the
|
||||
* Upnp_Discovery structure correctly.
|
||||
*/
|
||||
|
||||
typedef struct sockaddr_in SOCKADDRIN;
|
||||
|
||||
@@ -875,7 +916,7 @@ struct File_Info
|
||||
/** The length of the file. A length less than 0 indicates the size
|
||||
* is unknown, and data will be sent until 0 bytes are returned from
|
||||
* a read call. */
|
||||
int file_length;
|
||||
off_t file_length;
|
||||
|
||||
/** The time at which the contents of the file was modified;
|
||||
* The time system is always local (not GMT). */
|
||||
@@ -969,7 +1010,7 @@ struct UpnpVirtualDirCallbacks
|
||||
int (*seek) (
|
||||
IN UpnpWebFileHandle fileHnd, /** The handle of the file to move the
|
||||
file pointer. */
|
||||
IN long offset, /** The number of bytes to move in the
|
||||
IN off_t offset, /** The number of bytes to move in the
|
||||
file. Positive values move foward and
|
||||
negative values move backward. Note
|
||||
that this must be positive if the
|
||||
@@ -1030,14 +1071,14 @@ typedef int (*Upnp_FunPtr) (
|
||||
IN void *Cookie
|
||||
);
|
||||
|
||||
//@} // Constants, Structures, and Types
|
||||
/*! @} */ /* Constants, Structures, and Types */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
#endif /* __cplusplus */
|
||||
|
||||
///@name Initialization and Registration
|
||||
//@{
|
||||
/*! @name Initialization and Registration */
|
||||
/*! @{ */
|
||||
/** Initializes the Linux SDK for UPnP Devices. This function must be called
|
||||
* before any other API function can be called. It should be called
|
||||
* only once. Subsequent calls to this API return a {\tt UPNP_E_INIT}
|
||||
@@ -1348,18 +1389,18 @@ EXPORT_SPEC int UpnpSetMaxContentLength(
|
||||
for incoming SOAP actions, in bytes. */
|
||||
);
|
||||
|
||||
//@} // Initialization and Registration
|
||||
/*! @} */ /* Initialization and Registration */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// D I S C O V E R Y //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* *
|
||||
* D I S C O V E R Y *
|
||||
* *
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
///@name Discovery
|
||||
//@{
|
||||
/*! @name Discovery */
|
||||
/*! @{ */
|
||||
|
||||
/** {\bf UpnpSearchAsync} searches for devices matching the given
|
||||
* search target. The function returns immediately and the SDK
|
||||
@@ -1418,18 +1459,18 @@ EXPORT_SPEC int UpnpSendAdvertisement(
|
||||
the announcements. */
|
||||
);
|
||||
|
||||
//@} // Discovery
|
||||
/*! @} */ /* Discovery */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// C O N T R O L //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* *
|
||||
* C O N T R O L *
|
||||
* *
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
///@name Control
|
||||
//@{
|
||||
/*! @name Control */
|
||||
/*! @{ */
|
||||
|
||||
/** {\bf UpnpGetServiceVarStatus} queries the state of a state
|
||||
* variable of a service on another device. This is a synchronous call.
|
||||
@@ -1652,18 +1693,18 @@ EXPORT_SPEC int UpnpSendActionExAsync(
|
||||
passed to the callback when invoked. */
|
||||
);
|
||||
|
||||
//@} // Control
|
||||
/*! @} */ /* Control */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// E V E N T I N G //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* *
|
||||
* E V E N T I N G *
|
||||
* *
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
///@name Eventing
|
||||
//@{
|
||||
/*! @name Eventing */
|
||||
/*! @{ */
|
||||
|
||||
/** {\bf UpnpAcceptSubscription} accepts a subscription request and sends
|
||||
* out the current state of the eventable variables for a service.
|
||||
@@ -2166,19 +2207,19 @@ EXPORT_SPEC int UpnpUnSubscribeAsync(
|
||||
callback function when invoked. */
|
||||
);
|
||||
|
||||
//@} // Eventing
|
||||
/*! @} */ /* Eventing */
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// C L I E N T - A P I //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* *
|
||||
* C L I E N T - A P I *
|
||||
* *
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
///@name Control Point HTTP API
|
||||
//@{
|
||||
/*! @name Control Point HTTP API */
|
||||
/*! @{ */
|
||||
|
||||
/** {\bf UpnpDownloadUrlItem} downloads a file specified in a URL.
|
||||
* The SDK allocates the memory for {\bf outBuf} and the
|
||||
@@ -2571,18 +2612,18 @@ EXPORT_SPEC int UpnpDownloadXmlDoc(
|
||||
XML document. */
|
||||
);
|
||||
|
||||
//@} // Control Point HTTP API
|
||||
/*! @} */ /* Control Point HTTP API */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// W E B S E R V E R A P I //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* *
|
||||
* W E B S E R V E R A P I *
|
||||
* *
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
///@name Web Server API
|
||||
//@{
|
||||
/*! @name Web Server API */
|
||||
/*! @{ */
|
||||
|
||||
/** {\bf UpnpSetWebServerRootDir} sets the document root directory for
|
||||
* the internal web server. This directory is considered the
|
||||
@@ -2698,13 +2739,13 @@ EXPORT_SPEC void UpnpFree(
|
||||
IN void *item /* The item to free. */
|
||||
);
|
||||
|
||||
//@} // Web Server API
|
||||
/*! @} */ /* Web Server API */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
#endif /* __cplusplus */
|
||||
|
||||
//@} The API
|
||||
/*! @} */ /* The API */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
// -*- C -*-
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/* -*- C -*- */
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 UPNP_CONFIG_H
|
||||
#define UPNP_CONFIG_H
|
||||
@@ -91,6 +91,5 @@
|
||||
#undef UPNP_HAVE_TOOLS
|
||||
|
||||
|
||||
#endif // UPNP_CONFIG_H
|
||||
|
||||
#endif /* UPNP_CONFIG_H */
|
||||
|
||||
|
||||
@@ -1,43 +1,41 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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 UPNP_DEBUG_H
|
||||
#define UPNP_DEBUG_H
|
||||
|
||||
#include "upnp.h"
|
||||
#include "upnpconfig.h"
|
||||
|
||||
// Function declarations only if debug compiled into the library
|
||||
#if UPNP_HAVE_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -49,7 +47,7 @@ extern "C" {
|
||||
The UPnP SDK contains other features to aid in debugging.
|
||||
*/
|
||||
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
/** @name Upnp_LogLevel
|
||||
* The user has the option to select 4 different types of debugging levels,
|
||||
@@ -70,18 +68,25 @@ extern "C" {
|
||||
* \end{itemize}
|
||||
*/
|
||||
|
||||
typedef enum Upnp_Module {SSDP,SOAP,GENA,TPOOL,MSERV,DOM,API, HTTP} Dbg_Module;
|
||||
//@{
|
||||
typedef enum Upnp_Module {
|
||||
SSDP,
|
||||
SOAP,
|
||||
GENA,
|
||||
TPOOL,
|
||||
MSERV,
|
||||
DOM,
|
||||
API,
|
||||
HTTP
|
||||
} Dbg_Module;
|
||||
|
||||
/*! @{ */
|
||||
typedef enum Upnp_LogLevel_e {
|
||||
UPNP_CRITICAL,
|
||||
UPNP_PACKET,
|
||||
UPNP_INFO,
|
||||
UPNP_ALL
|
||||
} Upnp_LogLevel;
|
||||
//@}
|
||||
|
||||
// for backward compatibility
|
||||
#define Dbg_Level Upnp_LogLevel
|
||||
/*! @} */
|
||||
|
||||
|
||||
/**
|
||||
@@ -98,26 +103,32 @@ typedef enum Upnp_LogLevel_e {
|
||||
*
|
||||
* Description:
|
||||
* This functions initializes the log files
|
||||
*
|
||||
* Returns: int
|
||||
* -1 : If fails
|
||||
* UPNP_E_SUCCESS : if success
|
||||
***************************************************************************/
|
||||
#ifdef DEBUG
|
||||
int UpnpInitLog();
|
||||
|
||||
// for backward compatibility
|
||||
#define InitLog UpnpInitLog
|
||||
#else
|
||||
static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; }
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : UpnpSetLogLevel
|
||||
*
|
||||
* Parameters: void
|
||||
* Parameters: Upnp_LogLevel log_level
|
||||
*
|
||||
* Description:
|
||||
* This functions set the log level (see {\tt Upnp_LogLevel}
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
void UpnpSetLogLevel (Upnp_LogLevel);
|
||||
#ifdef DEBUG
|
||||
void UpnpSetLogLevel(Upnp_LogLevel log_level);
|
||||
#else
|
||||
static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -129,10 +140,11 @@ void UpnpSetLogLevel (Upnp_LogLevel);
|
||||
* This functions closes the log files
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void UpnpCloseLog();
|
||||
|
||||
// for backward compatibility
|
||||
#define CloseLog UpnpCloseLog
|
||||
#else
|
||||
static UPNP_INLINE void UpnpCloseLog() {}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -149,17 +161,22 @@ void UpnpCloseLog();
|
||||
* per the requested banner
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName);
|
||||
|
||||
// for backward compatibility
|
||||
#define SetLogFileNames UpnpSetLogFileNames
|
||||
#ifdef DEBUG
|
||||
void UpnpSetLogFileNames(
|
||||
const char *ErrFileName,
|
||||
const char *InfoFileName);
|
||||
#else
|
||||
static UPNP_INLINE void UpnpSetLogFileNames(
|
||||
const char *ErrFileName,
|
||||
const char *InfoFileName) {}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : UpnpGetDebugFile
|
||||
*
|
||||
* Parameters:
|
||||
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
@@ -171,17 +188,47 @@ void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName);
|
||||
* NULL : if the module is turn off for debug
|
||||
* else returns the right file descriptor
|
||||
***************************************************************************/
|
||||
FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module);
|
||||
#ifdef DEBUG
|
||||
FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module);
|
||||
#else
|
||||
static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
// for backward compatibility
|
||||
#define GetDebugFile UpnpGetDebugFile
|
||||
|
||||
/***************************************************************************
|
||||
* Function : DebugAtThisLevel
|
||||
*
|
||||
* Parameters:
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
*
|
||||
* Description:
|
||||
* This functions returns true if debug output should be done in this
|
||||
* module.
|
||||
*
|
||||
* Returns: int
|
||||
***************************************************************************/
|
||||
#ifdef DEBUG
|
||||
int DebugAtThisLevel(
|
||||
IN Upnp_LogLevel DLevel,
|
||||
IN Dbg_Module Module);
|
||||
#else
|
||||
static UPNP_INLINE int DebugAtThisLevel(
|
||||
IN Upnp_LogLevel DLevel,
|
||||
IN Dbg_Module Module) { return 0; }
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : UpnpPrintf
|
||||
*
|
||||
* Parameters:
|
||||
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
@@ -198,6 +245,7 @@ FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module);
|
||||
* debug statement is coming
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
||||
const char* DbgFileName, int DbgLineNo,
|
||||
const char* FmtStr,
|
||||
@@ -206,6 +254,15 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
||||
__attribute__((format (__printf__, 5, 6)))
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
static UPNP_INLINE void UpnpPrintf(
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
const char* DbgFileName,
|
||||
int DbgLineNo,
|
||||
const char* FmtStr,
|
||||
...) {}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -222,8 +279,19 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module,
|
||||
* per the requested banner
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
void UpnpDisplayBanner (FILE *fd,
|
||||
const char** lines, size_t size, int starlength);
|
||||
#ifdef DEBUG
|
||||
void UpnpDisplayBanner(
|
||||
FILE *fd,
|
||||
const char **lines,
|
||||
size_t size,
|
||||
int starlength);
|
||||
#else
|
||||
static UPNP_INLINE void UpnpDisplayBanner(
|
||||
FILE *fd,
|
||||
const char **lines,
|
||||
size_t size,
|
||||
int starlength) {}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -240,19 +308,23 @@ void UpnpDisplayBanner (FILE *fd,
|
||||
* debug statement is coming to the log file
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
void UpnpDisplayFileAndLine (FILE *fd, const char *DbgFileName, int DbgLineNo);
|
||||
|
||||
|
||||
//@}
|
||||
#ifdef DEBUG
|
||||
void UpnpDisplayFileAndLine(
|
||||
FILE *fd,
|
||||
const char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static UPNP_INLINE void UpnpDisplayFileAndLine(
|
||||
FILE *fd,
|
||||
const char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // UPNP_HAVE_DEBUG
|
||||
|
||||
#endif // UPNP_DEBUG_H
|
||||
|
||||
|
||||
#endif /* UPNP_DEBUG_H */
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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 INTEL OR
|
||||
* CONTRIBUTORS 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/** @name Optional Tool APIs
|
||||
* The Linux SDK for UPnP Devices contains some additional, optional
|
||||
@@ -36,14 +36,14 @@
|
||||
* size in the SDK. Refer to the README for details.
|
||||
*/
|
||||
|
||||
//@{
|
||||
/*! @{ */
|
||||
|
||||
#ifndef UPNP_TOOLS_H
|
||||
#define UPNP_TOOLS_H
|
||||
|
||||
#include "upnp.h"
|
||||
|
||||
// Function declarations only if tools compiled into the library
|
||||
/* Function declarations only if tools compiled into the library */
|
||||
#if UPNP_HAVE_TOOLS
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -217,14 +217,13 @@ EXPORT_SPEC const char * UpnpGetErrorMessage(
|
||||
int errorcode /** The SDK error code to convert. */
|
||||
);
|
||||
|
||||
//@}
|
||||
/*! @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // UPNP_HAVE_TOOLS
|
||||
|
||||
#endif // UPNP_TOOLS_H
|
||||
#endif /* UPNP_HAVE_TOOLS */
|
||||
|
||||
#endif /* UPNP_TOOLS_H */
|
||||
|
||||
|
||||
86
upnp/sample/Makefile.am
Normal file
86
upnp/sample/Makefile.am
Normal file
@@ -0,0 +1,86 @@
|
||||
#
|
||||
# "Makefile.am" for "libupnp/upnp/sample"
|
||||
#
|
||||
# Copyright (C) 2007 Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
|
||||
#
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/upnp/inc \
|
||||
-I$(top_srcdir)/threadutil/inc \
|
||||
-I$(top_srcdir)/ixml/inc
|
||||
|
||||
AM_CFLAGS = $(PTHREAD_CFLAGS)
|
||||
|
||||
AM_LDFLAGS = $(PTHREAD_LIBS)
|
||||
|
||||
LDADD = \
|
||||
$(top_builddir)/upnp/libupnp.la \
|
||||
$(top_builddir)/threadutil/libthreadutil.la \
|
||||
$(top_builddir)/ixml/libixml.la
|
||||
|
||||
|
||||
# samples
|
||||
noinst_PROGRAMS =
|
||||
if ENABLE_SAMPLES
|
||||
if ENABLE_CLIENT
|
||||
noinst_PROGRAMS += upnp_tv_ctrlpt
|
||||
upnp_tv_ctrlpt_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
-I$(srcdir)/common/ \
|
||||
-I$(srcdir)/tvctrlpt
|
||||
if ENABLE_DEVICE
|
||||
noinst_PROGRAMS += upnp_tv_combo
|
||||
upnp_tv_combo_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
-I$(srcdir)/common/ \
|
||||
-I$(srcdir)/tvcombo
|
||||
endif
|
||||
endif
|
||||
if ENABLE_DEVICE
|
||||
noinst_PROGRAMS += upnp_tv_device
|
||||
upnp_tv_device_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
-I$(srcdir)/common/ \
|
||||
-I$(srcdir)/tvdevice
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
upnp_tv_device_SOURCES = \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvdevice/upnp_tv_device.c \
|
||||
tvdevice/upnp_tv_device.h \
|
||||
tvdevice/linux/upnp_tv_device_main.c
|
||||
|
||||
|
||||
upnp_tv_ctrlpt_SOURCES = \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvctrlpt/upnp_tv_ctrlpt.c \
|
||||
tvctrlpt/upnp_tv_ctrlpt.h \
|
||||
tvctrlpt/linux/upnp_tv_ctrlpt_main.c
|
||||
|
||||
upnp_tv_combo_SOURCES = \
|
||||
common/sample_util.c \
|
||||
common/sample_util.h \
|
||||
tvcombo/upnp_tv_ctrlpt.c \
|
||||
tvcombo/upnp_tv_ctrlpt.h \
|
||||
tvcombo/upnp_tv_device.c \
|
||||
tvcombo/upnp_tv_device.h \
|
||||
tvcombo/linux/upnp_tv_combo_main.c
|
||||
|
||||
|
||||
if WITH_DOCUMENTATION
|
||||
examplesdir = $(docdir)/examples
|
||||
examples_DATA = \
|
||||
$(upnp_tv_ctrlpt_SOURCES) \
|
||||
$(upnp_tv_device_SOURCES)
|
||||
endif
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
tvdevice/web/tvcontrolSCPD.xml \
|
||||
tvdevice/web/tvdevicedesc.xml \
|
||||
tvdevice/web/tvdevicepres.html \
|
||||
tvdevice/web/tvpictureSCPD.xml
|
||||
|
||||
489
upnp/sample/tvcombo/linux/upnp_tv_combo_main.c
Normal file
489
upnp/sample/tvcombo/linux/upnp_tv_combo_main.c
Normal file
@@ -0,0 +1,489 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "sample_util.h"
|
||||
#include "upnp_tv_ctrlpt.h"
|
||||
#include "upnp_tv_device.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
Tags for valid commands issued at the command prompt
|
||||
*/
|
||||
enum cmdloop_tvcmds {
|
||||
PRTHELP = 0, PRTFULLHELP, POWON, POWOFF,
|
||||
SETCHAN, SETVOL, SETCOL, SETTINT, SETCONT, SETBRT,
|
||||
CTRLACTION, PICTACTION, CTRLGETVAR, PICTGETVAR,
|
||||
PRTDEV, LSTDEV, REFRESH, EXITCMD
|
||||
};
|
||||
|
||||
/*
|
||||
Data structure for parsing commands from the command line
|
||||
*/
|
||||
struct cmdloop_commands {
|
||||
char *str; // the string
|
||||
int cmdnum; // the command
|
||||
int numargs; // the number of arguments
|
||||
char *args; // the args
|
||||
} cmdloop_commands;
|
||||
|
||||
/*
|
||||
Mappings between command text names, command tag,
|
||||
and required command arguments for command line
|
||||
commands
|
||||
*/
|
||||
static struct cmdloop_commands cmdloop_cmdlist[] = {
|
||||
{"Help", PRTHELP, 1, ""},
|
||||
{"HelpFull", PRTFULLHELP, 1, ""},
|
||||
{"ListDev", LSTDEV, 1, ""},
|
||||
{"Refresh", REFRESH, 1, ""},
|
||||
{"PrintDev", PRTDEV, 2, "<devnum>"},
|
||||
{"PowerOn", POWON, 2, "<devnum>"},
|
||||
{"PowerOff", POWOFF, 2, "<devnum>"},
|
||||
{"SetChannel", SETCHAN, 3, "<devnum> <channel (int)>"},
|
||||
{"SetVolume", SETVOL, 3, "<devnum> <volume (int)>"},
|
||||
{"SetColor", SETCOL, 3, "<devnum> <color (int)>"},
|
||||
{"SetTint", SETTINT, 3, "<devnum> <tint (int)>"},
|
||||
{"SetContrast", SETCONT, 3, "<devnum> <contrast (int)>"},
|
||||
{"SetBrightness", SETBRT, 3, "<devnum> <brightness (int)>"},
|
||||
{"CtrlAction", CTRLACTION, 2, "<devnum> <action (string)>"},
|
||||
{"PictAction", PICTACTION, 2, "<devnum> <action (string)>"},
|
||||
{"CtrlGetVar", CTRLGETVAR, 2, "<devnum> <varname (string)>"},
|
||||
{"PictGetVar", PICTGETVAR, 2, "<devnum> <varname (string)>"},
|
||||
{"Exit", EXITCMD, 1, ""}
|
||||
};
|
||||
|
||||
void
|
||||
linux_print( const char *string )
|
||||
{
|
||||
puts( string );
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* TvCtrlPointPrintHelp
|
||||
*
|
||||
* Description:
|
||||
* Print help info for this application.
|
||||
********************************************************************************/
|
||||
void
|
||||
TvCtrlPointPrintShortHelp( void )
|
||||
{
|
||||
SampleUtil_Print( "Commands:" );
|
||||
SampleUtil_Print( " Help" );
|
||||
SampleUtil_Print( " HelpFull" );
|
||||
SampleUtil_Print( " ListDev" );
|
||||
SampleUtil_Print( " Refresh" );
|
||||
SampleUtil_Print( " PrintDev <devnum>" );
|
||||
SampleUtil_Print( " PowerOn <devnum>" );
|
||||
SampleUtil_Print( " PowerOff <devnum>" );
|
||||
SampleUtil_Print( " SetChannel <devnum> <channel>" );
|
||||
SampleUtil_Print( " SetVolume <devnum> <volume>" );
|
||||
SampleUtil_Print( " SetColor <devnum> <color>" );
|
||||
SampleUtil_Print( " SetTint <devnum> <tint>" );
|
||||
SampleUtil_Print( " SetContrast <devnum> <contrast>" );
|
||||
SampleUtil_Print( " SetBrightness <devnum> <brightness>" );
|
||||
SampleUtil_Print( " CtrlAction <devnum> <action>" );
|
||||
SampleUtil_Print( " PictAction <devnum> <action>" );
|
||||
SampleUtil_Print( " CtrlGetVar <devnum> <varname>" );
|
||||
SampleUtil_Print( " PictGetVar <devnum> <action>" );
|
||||
SampleUtil_Print( " Exit" );
|
||||
}
|
||||
|
||||
void
|
||||
TvCtrlPointPrintLongHelp( void )
|
||||
{
|
||||
SampleUtil_Print( "" );
|
||||
SampleUtil_Print( "******************************" );
|
||||
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. While registers a tv device itself." );
|
||||
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( " 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( " PrintDev <devnum>" );
|
||||
SampleUtil_Print( " Print the state table for the device <devnum>." );
|
||||
SampleUtil_Print( " e.g., 'PrintDev 1' prints the state table for the first" );
|
||||
SampleUtil_Print( " device in the device list." );
|
||||
SampleUtil_Print( " PowerOn <devnum>" );
|
||||
SampleUtil_Print( " Sends the PowerOn action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>." );
|
||||
SampleUtil_Print( " PowerOff <devnum>" );
|
||||
SampleUtil_Print( " Sends the PowerOff action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>." );
|
||||
SampleUtil_Print( " SetChannel <devnum> <channel>" );
|
||||
SampleUtil_Print( " Sends the SetChannel action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the channel to be changed" );
|
||||
SampleUtil_Print( " to <channel>." );
|
||||
SampleUtil_Print( " SetVolume <devnum> <volume>" );
|
||||
SampleUtil_Print( " Sends the SetVolume action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the volume to be changed" );
|
||||
SampleUtil_Print( " to <volume>." );
|
||||
SampleUtil_Print( " SetColor <devnum> <color>" );
|
||||
SampleUtil_Print( " Sends the SetColor action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the color to be changed" );
|
||||
SampleUtil_Print( " to <color>." );
|
||||
SampleUtil_Print( " SetTint <devnum> <tint>" );
|
||||
SampleUtil_Print( " Sends the SetTint action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the tint to be changed" );
|
||||
SampleUtil_Print( " to <tint>." );
|
||||
SampleUtil_Print( " SetContrast <devnum> <contrast>" );
|
||||
SampleUtil_Print( " Sends the SetContrast action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the contrast to be changed" );
|
||||
SampleUtil_Print( " to <contrast>." );
|
||||
SampleUtil_Print( " SetBrightness <devnum> <brightness>" );
|
||||
SampleUtil_Print( " Sends the SetBrightness action to the Control Service of" );
|
||||
SampleUtil_Print( " device <devnum>, requesting the brightness to be changed" );
|
||||
SampleUtil_Print( " to <brightness>." );
|
||||
SampleUtil_Print( " CtrlAction <devnum> <action>" );
|
||||
SampleUtil_Print( " Sends an action request specified by the string <action>" );
|
||||
SampleUtil_Print( " to the Control Service of device <devnum>. This command" );
|
||||
SampleUtil_Print( " only works for actions that have no arguments." );
|
||||
SampleUtil_Print( " (e.g., \"CtrlAction 1 IncreaseChannel\")" );
|
||||
SampleUtil_Print( " PictAction <devnum> <action>" );
|
||||
SampleUtil_Print( " Sends an action request specified by the string <action>" );
|
||||
SampleUtil_Print( " to the Picture Service of device <devnum>. This command" );
|
||||
SampleUtil_Print( " only works for actions that have no arguments." );
|
||||
SampleUtil_Print( " (e.g., \"PictAction 1 DecreaseContrast\")" );
|
||||
SampleUtil_Print( " CtrlGetVar <devnum> <varname>" );
|
||||
SampleUtil_Print( " Requests the value of a variable specified by the string <varname>" );
|
||||
SampleUtil_Print( " from the Control Service of device <devnum>." );
|
||||
SampleUtil_Print( " (e.g., \"CtrlGetVar 1 Volume\")" );
|
||||
SampleUtil_Print( " PictGetVar <devnum> <action>" );
|
||||
SampleUtil_Print( " Requests the value of a variable specified by the string <varname>" );
|
||||
SampleUtil_Print( " from the Picture Service of device <devnum>." );
|
||||
SampleUtil_Print( " (e.g., \"PictGetVar 1 Tint\")" );
|
||||
SampleUtil_Print( " Exit" );
|
||||
SampleUtil_Print( " Exits the control point application." );
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* TvCtrlPointPrintCommands
|
||||
*
|
||||
* Description:
|
||||
* Print the list of valid command line commands to the user
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
********************************************************************************/
|
||||
void
|
||||
TvCtrlPointPrintCommands()
|
||||
{
|
||||
int i;
|
||||
int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands );
|
||||
|
||||
SampleUtil_Print( "Valid Commands:" );
|
||||
for( i = 0; i < numofcmds; i++ ) {
|
||||
SampleUtil_Print( " %-14s %s", cmdloop_cmdlist[i].str,
|
||||
cmdloop_cmdlist[i].args );
|
||||
}
|
||||
SampleUtil_Print( "" );
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* TvCtrlPointCommandLoop
|
||||
*
|
||||
* Description:
|
||||
* Function that receives commands from the user at the command prompt
|
||||
* during the lifetime of the control point, and calls the appropriate
|
||||
* functions for those commands.
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
********************************************************************************/
|
||||
void *
|
||||
TvCtrlPointCommandLoop( void *args )
|
||||
{
|
||||
char cmdline[100];
|
||||
|
||||
while( 1 ) {
|
||||
SampleUtil_Print( "\n>> " );
|
||||
fgets( cmdline, 100, stdin );
|
||||
TvCtrlPointProcessCommand( cmdline );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
TvCtrlPointProcessCommand( char *cmdline )
|
||||
{
|
||||
char cmd[100];
|
||||
char strarg[100];
|
||||
int arg_val_err = -99999;
|
||||
int arg1 = arg_val_err;
|
||||
int arg2 = arg_val_err;
|
||||
int cmdnum = -1;
|
||||
int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands );
|
||||
int cmdfound = 0;
|
||||
int i,
|
||||
rc;
|
||||
int invalidargs = 0;
|
||||
int validargs;
|
||||
|
||||
validargs = sscanf( cmdline, "%s %d %d", cmd, &arg1, &arg2 );
|
||||
|
||||
for( i = 0; i < numofcmds; i++ ) {
|
||||
if( strcasecmp( cmd, cmdloop_cmdlist[i].str ) == 0 ) {
|
||||
cmdnum = cmdloop_cmdlist[i].cmdnum;
|
||||
cmdfound++;
|
||||
if( validargs != cmdloop_cmdlist[i].numargs )
|
||||
invalidargs++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !cmdfound ) {
|
||||
SampleUtil_Print( "Command not found; try 'Help'" );
|
||||
return TV_SUCCESS;
|
||||
}
|
||||
|
||||
if( invalidargs ) {
|
||||
SampleUtil_Print( "Invalid arguments; try 'Help'" );
|
||||
return TV_SUCCESS;
|
||||
}
|
||||
|
||||
switch ( cmdnum ) {
|
||||
case PRTHELP:
|
||||
TvCtrlPointPrintShortHelp();
|
||||
break;
|
||||
|
||||
case PRTFULLHELP:
|
||||
TvCtrlPointPrintLongHelp();
|
||||
break;
|
||||
|
||||
case POWON:
|
||||
TvCtrlPointSendPowerOn( arg1 );
|
||||
break;
|
||||
|
||||
case POWOFF:
|
||||
TvCtrlPointSendPowerOff( arg1 );
|
||||
break;
|
||||
|
||||
case SETCHAN:
|
||||
TvCtrlPointSendSetChannel( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case SETVOL:
|
||||
TvCtrlPointSendSetVolume( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case SETCOL:
|
||||
TvCtrlPointSendSetColor( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case SETTINT:
|
||||
TvCtrlPointSendSetTint( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case SETCONT:
|
||||
TvCtrlPointSendSetContrast( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case SETBRT:
|
||||
TvCtrlPointSendSetBrightness( arg1, arg2 );
|
||||
break;
|
||||
|
||||
case CTRLACTION:
|
||||
/*
|
||||
re-parse commandline since second arg is string
|
||||
*/
|
||||
validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg );
|
||||
if( 3 == validargs )
|
||||
TvCtrlPointSendAction( TV_SERVICE_CONTROL, arg1, strarg,
|
||||
NULL, NULL, 0 );
|
||||
else
|
||||
invalidargs++;
|
||||
break;
|
||||
|
||||
case PICTACTION:
|
||||
/*
|
||||
re-parse commandline since second arg is string
|
||||
*/
|
||||
validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg );
|
||||
if( 3 == validargs )
|
||||
TvCtrlPointSendAction( TV_SERVICE_PICTURE, arg1, strarg,
|
||||
NULL, NULL, 0 );
|
||||
else
|
||||
invalidargs++;
|
||||
break;
|
||||
|
||||
case CTRLGETVAR:
|
||||
/*
|
||||
re-parse commandline since second arg is string
|
||||
*/
|
||||
validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg );
|
||||
if( 3 == validargs )
|
||||
TvCtrlPointGetVar( TV_SERVICE_CONTROL, arg1, strarg );
|
||||
else
|
||||
invalidargs++;
|
||||
break;
|
||||
|
||||
case PICTGETVAR:
|
||||
/*
|
||||
re-parse commandline since second arg is string
|
||||
*/
|
||||
validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg );
|
||||
if( 3 == validargs )
|
||||
TvCtrlPointGetVar( TV_SERVICE_PICTURE, arg1, strarg );
|
||||
else
|
||||
invalidargs++;
|
||||
break;
|
||||
|
||||
case PRTDEV:
|
||||
TvCtrlPointPrintDevice( arg1 );
|
||||
break;
|
||||
|
||||
case LSTDEV:
|
||||
TvCtrlPointPrintList();
|
||||
break;
|
||||
|
||||
case REFRESH:
|
||||
TvCtrlPointRefresh();
|
||||
break;
|
||||
|
||||
case EXITCMD:
|
||||
rc = TvCtrlPointStop();
|
||||
exit( rc );
|
||||
break;
|
||||
|
||||
default:
|
||||
SampleUtil_Print( "Command not implemented; see 'Help'" );
|
||||
break;
|
||||
}
|
||||
|
||||
if( invalidargs )
|
||||
SampleUtil_Print( "Invalid args in command; see 'Help'" );
|
||||
|
||||
return TV_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
device_main( int argc, char **argv )
|
||||
{
|
||||
|
||||
unsigned int portTemp = 0;
|
||||
char *ip_address = NULL,
|
||||
*desc_doc_name = NULL,
|
||||
*web_dir_path = NULL;
|
||||
unsigned int port = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
SampleUtil_Initialize( linux_print );
|
||||
|
||||
// Parse options
|
||||
for( i = 1; i < argc; i++ ) {
|
||||
if( strcmp( argv[i], "-ip" ) == 0 ) {
|
||||
ip_address = argv[++i];
|
||||
} else if( strcmp( argv[i], "-port" ) == 0 ) {
|
||||
sscanf( argv[++i], "%u", &portTemp );
|
||||
} else if( strcmp( argv[i], "-desc" ) == 0 ) {
|
||||
desc_doc_name = argv[++i];
|
||||
} else if( strcmp( argv[i], "-webdir" ) == 0 ) {
|
||||
web_dir_path = argv[++i];
|
||||
} else if( strcmp( argv[i], "-help" ) == 0 ) {
|
||||
SampleUtil_Print( "Usage: %s -ip ipaddress -port port"
|
||||
" -desc desc_doc_name -webdir web_dir_path"
|
||||
" -help (this message)\n", argv[0] );
|
||||
SampleUtil_Print( "\tipaddress: IP address of the device"
|
||||
" (must match desc. doc)\n" );
|
||||
SampleUtil_Print( "\t\te.g.: 192.168.0.4\n" );
|
||||
SampleUtil_Print( "\tport: Port number to use for "
|
||||
"receiving UPnP messages (must match desc. doc)\n" );
|
||||
SampleUtil_Print( "\t\te.g.: 5431\n" );
|
||||
SampleUtil_Print
|
||||
( "\tdesc_doc_name: name of device description document\n" );
|
||||
SampleUtil_Print( "\t\te.g.: tvcombodesc.xml\n" );
|
||||
SampleUtil_Print
|
||||
( "\tweb_dir_path: Filesystem path where web files "
|
||||
"related to the device are stored\n" );
|
||||
SampleUtil_Print( "\t\te.g.: /upnp/sample/web\n" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
port = ( unsigned short )portTemp;
|
||||
|
||||
return TvDeviceStart(
|
||||
ip_address, port, desc_doc_name, web_dir_path, linux_print );
|
||||
}
|
||||
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
int rc;
|
||||
ithread_t cmdloop_thread;
|
||||
int sig;
|
||||
sigset_t sigs_to_catch;
|
||||
int code;
|
||||
|
||||
device_main(argc, argv);
|
||||
rc = TvCtrlPointStart( linux_print, NULL );
|
||||
if( rc != TV_SUCCESS ) {
|
||||
SampleUtil_Print( "Error starting UPnP TV Control Point" );
|
||||
return rc;
|
||||
}
|
||||
// start a command loop thread
|
||||
code =
|
||||
ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop,
|
||||
NULL );
|
||||
|
||||
/*
|
||||
Catch Ctrl-C and properly shutdown
|
||||
*/
|
||||
sigemptyset( &sigs_to_catch );
|
||||
sigaddset( &sigs_to_catch, SIGINT );
|
||||
sigwait( &sigs_to_catch, &sig );
|
||||
|
||||
SampleUtil_Print( "Shutting down on signal %d...", sig );
|
||||
TvDeviceStop();
|
||||
rc = TvCtrlPointStop();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
1409
upnp/sample/tvcombo/upnp_tv_ctrlpt.c
Normal file
1409
upnp/sample/tvcombo/upnp_tv_ctrlpt.c
Normal file
File diff suppressed because it is too large
Load Diff
158
upnp/sample/tvcombo/upnp_tv_ctrlpt.h
Normal file
158
upnp/sample/tvcombo/upnp_tv_ctrlpt.h
Normal file
@@ -0,0 +1,158 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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 UPNP_TV_CTRLPT_H
|
||||
#define UPNP_TV_CTRLPT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ithread.h"
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "upnp.h"
|
||||
#include "upnptools.h"
|
||||
#include "sample_util.h"
|
||||
|
||||
#define TV_SERVICE_SERVCOUNT 2
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
#define TV_CONTROL_POWER 0
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
#define TV_PICTURE_COLOR 0
|
||||
#define TV_PICTURE_TINT 1
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
#define TV_PICTURE_BRIGHTNESS 3
|
||||
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
|
||||
#define TV_SUCCESS 0
|
||||
#define TV_ERROR (-1)
|
||||
#define TV_WARNING 1
|
||||
|
||||
/* This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
extern char TvDeviceType[];
|
||||
extern char *TvServiceType[];
|
||||
extern char *TvServiceName[];
|
||||
extern char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS];
|
||||
extern char TvVarCount[];
|
||||
|
||||
struct tv_service {
|
||||
char ServiceId[NAME_SIZE];
|
||||
char ServiceType[NAME_SIZE];
|
||||
char *VariableStrVal[TV_MAXVARS];
|
||||
char EventURL[NAME_SIZE];
|
||||
char ControlURL[NAME_SIZE];
|
||||
char SID[NAME_SIZE];
|
||||
};
|
||||
|
||||
extern struct TvDeviceNode *GlobalDeviceList;
|
||||
|
||||
struct TvDevice {
|
||||
char UDN[250];
|
||||
char DescDocURL[250];
|
||||
char FriendlyName[250];
|
||||
char PresURL[250];
|
||||
int AdvrTimeOut;
|
||||
struct tv_service TvService[TV_SERVICE_SERVCOUNT];
|
||||
};
|
||||
|
||||
struct TvDeviceNode {
|
||||
struct TvDevice device;
|
||||
struct TvDeviceNode *next;
|
||||
};
|
||||
|
||||
extern ithread_mutex_t DeviceListMutex;
|
||||
|
||||
extern UpnpClient_Handle ctrlpt_handle;
|
||||
|
||||
void TvCtrlPointPrintHelp( void );
|
||||
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
|
||||
int TvCtrlPointRemoveDevice(char*);
|
||||
int TvCtrlPointRemoveAll( void );
|
||||
int TvCtrlPointRefresh( void );
|
||||
|
||||
|
||||
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
|
||||
int TvCtrlPointSendActionNumericArg(int devnum, int service, char *actionName, char *paramName, int paramValue);
|
||||
int TvCtrlPointSendPowerOn(int devnum);
|
||||
int TvCtrlPointSendPowerOff(int devnum);
|
||||
int TvCtrlPointSendSetChannel(int, int);
|
||||
int TvCtrlPointSendSetVolume(int, int);
|
||||
int TvCtrlPointSendSetColor(int, int);
|
||||
int TvCtrlPointSendSetTint(int, int);
|
||||
int TvCtrlPointSendSetContrast(int, int);
|
||||
int TvCtrlPointSendSetBrightness(int, int);
|
||||
|
||||
int TvCtrlPointGetVar(int, int, char*);
|
||||
int TvCtrlPointGetPower(int devnum);
|
||||
int TvCtrlPointGetChannel(int);
|
||||
int TvCtrlPointGetVolume(int);
|
||||
int TvCtrlPointGetColor(int);
|
||||
int TvCtrlPointGetTint(int);
|
||||
int TvCtrlPointGetContrast(int);
|
||||
int TvCtrlPointGetBrightness(int);
|
||||
|
||||
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
||||
int TvCtrlPointPrintList( void );
|
||||
int TvCtrlPointPrintDevice(int);
|
||||
void TvCtrlPointAddDevice (IXML_Document *, char *, int);
|
||||
void TvCtrlPointHandleGetVar(char *,char *,DOMString);
|
||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
|
||||
void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
|
||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||
void TvCtrlPointVerifyTimeouts(int);
|
||||
void TvCtrlPointPrintCommands( void );
|
||||
void* TvCtrlPointCommandLoop( void* );
|
||||
int TvCtrlPointStart( print_string printFunctionPtr, state_update updateFunctionPtr );
|
||||
int TvCtrlPointStop( void );
|
||||
int TvCtrlPointProcessCommand( char *cmdline );
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif //UPNP_TV_CTRLPT_H
|
||||
2031
upnp/sample/tvcombo/upnp_tv_device.c
Normal file
2031
upnp/sample/tvcombo/upnp_tv_device.c
Normal file
File diff suppressed because it is too large
Load Diff
638
upnp/sample/tvcombo/upnp_tv_device.h
Normal file
638
upnp/sample/tvcombo/upnp_tv_device.h
Normal file
@@ -0,0 +1,638 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "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 INTEL OR
|
||||
// CONTRIBUTORS 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 UPNP_TV_DEVICE_H
|
||||
#define UPNP_TV_DEVICE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ithread.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "upnp.h"
|
||||
#include "sample_util.h"
|
||||
|
||||
//Color constants
|
||||
#define MAX_COLOR 10
|
||||
#define MIN_COLOR 1
|
||||
|
||||
//Brightness constants
|
||||
#define MAX_BRIGHTNESS 10
|
||||
#define MIN_BRIGHTNESS 1
|
||||
|
||||
//Power constants
|
||||
#define POWER_ON 1
|
||||
#define POWER_OFF 0
|
||||
|
||||
//Tint constants
|
||||
#define MAX_TINT 10
|
||||
#define MIN_TINT 1
|
||||
|
||||
//Volume constants
|
||||
#define MAX_VOLUME 10
|
||||
#define MIN_VOLUME 1
|
||||
|
||||
//Contrast constants
|
||||
#define MAX_CONTRAST 10
|
||||
#define MIN_CONTRAST 1
|
||||
|
||||
//Channel constants
|
||||
#define MAX_CHANNEL 100
|
||||
#define MIN_CHANNEL 1
|
||||
|
||||
//Number of services.
|
||||
#define TV_SERVICE_SERVCOUNT 2
|
||||
|
||||
//Index of control service
|
||||
#define TV_SERVICE_CONTROL 0
|
||||
|
||||
//Index of picture service
|
||||
#define TV_SERVICE_PICTURE 1
|
||||
|
||||
//Number of control variables
|
||||
#define TV_CONTROL_VARCOUNT 3
|
||||
|
||||
//Index of power variable
|
||||
#define TV_CONTROL_POWER 0
|
||||
|
||||
//Index of channel variable
|
||||
#define TV_CONTROL_CHANNEL 1
|
||||
|
||||
//Index of volume variable
|
||||
#define TV_CONTROL_VOLUME 2
|
||||
|
||||
//Number of picture variables
|
||||
#define TV_PICTURE_VARCOUNT 4
|
||||
|
||||
//Index of color variable
|
||||
#define TV_PICTURE_COLOR 0
|
||||
|
||||
//Index of tint variable
|
||||
#define TV_PICTURE_TINT 1
|
||||
|
||||
//Index of contrast variable
|
||||
#define TV_PICTURE_CONTRAST 2
|
||||
|
||||
//Index of brightness variable
|
||||
#define TV_PICTURE_BRIGHTNESS 3
|
||||
|
||||
//Max value length
|
||||
#define TV_MAX_VAL_LEN 5
|
||||
|
||||
//Max actions
|
||||
#define TV_MAXACTIONS 12
|
||||
|
||||
/* This should be the maximum VARCOUNT from above */
|
||||
#define TV_MAXVARS TV_PICTURE_VARCOUNT
|
||||
|
||||
|
||||
extern char TvDeviceType[];
|
||||
|
||||
extern char *TvServiceType[];
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* upnp_action
|
||||
*
|
||||
* Description:
|
||||
* Prototype for all actions. For each action that a service
|
||||
* implements, there is a corresponding function with this prototype.
|
||||
* Pointers to these functions, along with action names, are stored
|
||||
* in the service table. When an action request comes in the action
|
||||
* name is matched, and the appropriate function is called.
|
||||
* Each function returns UPNP_E_SUCCESS, on success, and a nonzero
|
||||
* error code on failure.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * request - document of action request
|
||||
* IXML_Document **out - action result
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
|
||||
char **errorString);
|
||||
|
||||
/* Structure for storing Tv Service
|
||||
identifiers and state table */
|
||||
struct TvService {
|
||||
|
||||
char UDN[NAME_SIZE]; /* Universally Unique Device Name */
|
||||
char ServiceId[NAME_SIZE];
|
||||
char ServiceType[NAME_SIZE];
|
||||
char *VariableName[TV_MAXVARS];
|
||||
char *VariableStrVal[TV_MAXVARS];
|
||||
char *ActionNames[TV_MAXACTIONS];
|
||||
upnp_action actions[TV_MAXACTIONS];
|
||||
unsigned int VariableCount;
|
||||
};
|
||||
|
||||
//Array of service structures
|
||||
extern struct TvService tv_service_table[];
|
||||
|
||||
//Device handle returned from sdk
|
||||
extern UpnpDevice_Handle device_handle;
|
||||
|
||||
|
||||
/* Mutex for protecting the global state table data
|
||||
in a multi-threaded, asynchronous environment.
|
||||
All functions should lock this mutex before reading
|
||||
or writing the state table data. */
|
||||
extern ithread_mutex_t TVDevMutex;
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SetActionTable
|
||||
*
|
||||
* Description:
|
||||
* Initializes the action table for the specified service.
|
||||
* Note that
|
||||
* knowledge of the service description is
|
||||
* assumed. Action names are hardcoded.
|
||||
* Parameters:
|
||||
* int serviceType - one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE
|
||||
* struct TvService *out - service containing action table to set.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int SetActionTable(int serviceType, struct TvService * out);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceStateTableInit
|
||||
*
|
||||
* Description:
|
||||
* Initialize the device state table for
|
||||
* this TvDevice, pulling identifier info
|
||||
* from the description Document. Note that
|
||||
* knowledge of the service description is
|
||||
* assumed. State table variables and default
|
||||
* values are currently hardcoded in this file
|
||||
* rather than being read from service description
|
||||
* documents.
|
||||
*
|
||||
* Parameters:
|
||||
* DescDocURL -- The description document URL
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceStateTableInit(char*);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleSubscriptionRequest
|
||||
*
|
||||
* Description:
|
||||
* Called during a subscription request callback. If the
|
||||
* subscription request is for this device and either its
|
||||
* control service or picture service, then accept it.
|
||||
*
|
||||
* Parameters:
|
||||
* sr_event -- The subscription request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleGetVarRequest
|
||||
*
|
||||
* Description:
|
||||
* Called during a get variable request callback. If the
|
||||
* request is for this device and either its control service
|
||||
* or picture service, then respond with the variable value.
|
||||
*
|
||||
* Parameters:
|
||||
* cgv_event -- The control get variable request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleActionRequest
|
||||
*
|
||||
* Description:
|
||||
* Called during an action request callback. If the
|
||||
* request is for this device and either its control service
|
||||
* or picture service, then perform the action and respond.
|
||||
*
|
||||
* Parameters:
|
||||
* ca_event -- The control action request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceCallbackEventHandler
|
||||
*
|
||||
* Description:
|
||||
* The callback handler registered with the SDK while registering
|
||||
* root device. Dispatches the request to the appropriate procedure
|
||||
* based on the value of EventType. The four requests handled by the
|
||||
* device are:
|
||||
* 1) Event Subscription requests.
|
||||
* 2) Get Variable requests.
|
||||
* 3) Action requests.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* EventType -- The type of callback event
|
||||
* Event -- Data structure containing event data
|
||||
* Cookie -- Optional data specified during callback registration
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceCallbackEventHandler(Upnp_EventType, void*, void*);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceSetServiceTableVar
|
||||
*
|
||||
* Description:
|
||||
* Update the TvDevice service state table, and notify all subscribed
|
||||
* control points of the updated state. Note that since this function
|
||||
* blocks on the mutex TVDevMutex, to avoid a hang this function should
|
||||
* not be called within any other function that currently has this mutex
|
||||
* locked.
|
||||
*
|
||||
* Parameters:
|
||||
* service -- The service number (TV_SERVICE_CONTROL or TV_SERVICE_PICTURE)
|
||||
* variable -- The variable number (TV_CONTROL_POWER, TV_CONTROL_CHANNEL,
|
||||
* TV_CONTROL_VOLUME, TV_PICTURE_COLOR, TV_PICTURE_TINT,
|
||||
* TV_PICTURE_CONTRAST, or TV_PICTURE_BRIGHTNESS)
|
||||
* value -- The string representation of the new value
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
|
||||
|
||||
//Control Service Actions
|
||||
|
||||
/******************************************************************************
|
||||
* TvDevicePowerOn
|
||||
*
|
||||
* Description:
|
||||
* Turn the power on.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - document of action request
|
||||
* IXML_Document **out - action result
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDevicePowerOff
|
||||
*
|
||||
* Description:
|
||||
* Turn the power off.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - document of action request
|
||||
* IXML_Document **out - action result
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceSetChannel
|
||||
*
|
||||
* Description:
|
||||
* Change the channel, update the TvDevice control service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseChannel
|
||||
*
|
||||
* Description:
|
||||
* Increase the channel.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseChannel
|
||||
*
|
||||
* Description:
|
||||
* Decrease the channel.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
/******************************************************************************
|
||||
* TvDeviceSetVolume
|
||||
*
|
||||
* Description:
|
||||
* Change the volume, update the TvDevice control service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseVolume
|
||||
*
|
||||
* Description:
|
||||
* Increase the volume.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
||||
OUT char **errorString);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseVolume
|
||||
*
|
||||
* Description:
|
||||
* Decrease the volume.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
||||
OUT char **errorString);
|
||||
|
||||
|
||||
//Picture Service Actions
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceSetColor
|
||||
*
|
||||
* Description:
|
||||
* Change the color, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseColor
|
||||
*
|
||||
* Description:
|
||||
* Increase the color.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseColor
|
||||
*
|
||||
* Description:
|
||||
* Decrease the color.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceSetTint
|
||||
*
|
||||
* Description:
|
||||
* Change the tint, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseTint
|
||||
*
|
||||
* Description:
|
||||
* Increase tint.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseTint
|
||||
*
|
||||
* Description:
|
||||
* Decrease tint.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/*****************************************************************************
|
||||
* TvDeviceSetContrast
|
||||
*
|
||||
* Description:
|
||||
* Change the contrast, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
****************************************************************************/
|
||||
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseContrast
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Increase the contrast.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseContrast
|
||||
*
|
||||
* Description:
|
||||
* Decrease the contrast.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceSetBrightness
|
||||
*
|
||||
* Description:
|
||||
* Change the brightness, update the TvDevice picture service
|
||||
* state table, and notify all subscribed control points of the
|
||||
* updated state.
|
||||
*
|
||||
* Parameters:
|
||||
* brightness -- The brightness value to change to.
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceIncreaseBrightness
|
||||
*
|
||||
* Description:
|
||||
* Increase brightness.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceDecreaseBrightness
|
||||
*
|
||||
* Description:
|
||||
* Decrease brightnesss.
|
||||
*
|
||||
* Parameters:
|
||||
* IXML_Document * in - action request document
|
||||
* IXML_Document **out - action result document
|
||||
* char **errorString - errorString (in case action was unsuccessful)
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
||||
OUT char **errorString);
|
||||
|
||||
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
||||
char *web_dir_path, print_string pfun);
|
||||
int TvDeviceStop();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1974,9 +1974,7 @@ TvDeviceStart( char *ip_address,
|
||||
ip_address = UpnpGetServerIpAddress( );
|
||||
}
|
||||
|
||||
if( port == 0 ) {
|
||||
port = UpnpGetServerPort( );
|
||||
}
|
||||
|
||||
SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n",
|
||||
ip_address, port );
|
||||
|
||||
37
upnp/sample/web/tvcombodesc.xml
Normal file
37
upnp/sample/web/tvcombodesc.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<root xmlns="urn:schemas-upnp-org:device-1-0">
|
||||
<specVersion>
|
||||
<major>1</major>
|
||||
<minor>0</minor>
|
||||
</specVersion>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:tvdevice:1</deviceType>
|
||||
<friendlyName>UPnP Television Emulator</friendlyName>
|
||||
<manufacturer>TV Manufacturer Name</manufacturer>
|
||||
<manufacturerURL>http://www.manufacturer.com</manufacturerURL>
|
||||
<modelDescription>UPnP Television Device Emulator 1.0</modelDescription>
|
||||
<modelName>TVEmulator</modelName>
|
||||
<modelNumber>1.0</modelNumber>
|
||||
<modelURL>http://www.manufacturer.com/TVEmulator/</modelURL>
|
||||
<serialNumber>123456789001</serialNumber>
|
||||
<UDN>uuid:Upnp-TVEmulator-1_0-1234567890002</UDN>
|
||||
<UPC>123456789</UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:tvcontrol:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:tvcontrol1</serviceId>
|
||||
<controlURL>/upnp/control/tvcontrol1</controlURL>
|
||||
<eventSubURL>/upnp/event/tvcontrol1</eventSubURL>
|
||||
<SCPDURL>/tvcontrolSCPD.xml</SCPDURL>
|
||||
</service>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:tvpicture:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:tvpicture1</serviceId>
|
||||
<controlURL>/upnp/control/tvpicture1</controlURL>
|
||||
<eventSubURL>/upnp/event/tvpicture1</eventSubURL>
|
||||
<SCPDURL>/tvpictureSCPD.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
<presentationURL>/tvdevicepres.html</presentationURL>
|
||||
</device>
|
||||
</root>
|
||||
@@ -7,7 +7,6 @@
|
||||
</specVersion>
|
||||
|
||||
|
||||
|
||||
<actionList>
|
||||
|
||||
<action>
|
||||
@@ -38,6 +37,12 @@
|
||||
<name>SetChannel</name>
|
||||
<argumentList>
|
||||
|
||||
<argument>
|
||||
<name>Channel</name>
|
||||
<relatedStateVariable>Channel</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>NewChannel</name>
|
||||
<retval />
|
||||
@@ -45,11 +50,6 @@
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>Channel</name>
|
||||
<relatedStateVariable>Channel</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
@@ -80,6 +80,11 @@
|
||||
<action>
|
||||
<name>SetVolume</name>
|
||||
<argumentList>
|
||||
<argument>
|
||||
<name>Volume</name>
|
||||
<relatedStateVariable>Volume</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>NewVolume</name>
|
||||
@@ -87,11 +92,6 @@
|
||||
<relatedStateVariable>Volume</relatedStateVariable>
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
<argument>
|
||||
<name>Volume</name>
|
||||
<relatedStateVariable>Volume</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
@@ -124,9 +124,6 @@
|
||||
|
||||
</actionList>
|
||||
|
||||
|
||||
|
||||
|
||||
<serviceStateTable>
|
||||
|
||||
<stateVariable sendEvents="yes">
|
||||
@@ -12,6 +12,12 @@
|
||||
<action>
|
||||
<name>SetColor</name>
|
||||
<argumentList>
|
||||
<argument>
|
||||
<name>Color</name>
|
||||
<relatedStateVariable>Color</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>NewColor</name>
|
||||
<retval />
|
||||
@@ -19,11 +25,6 @@
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>Color</name>
|
||||
<relatedStateVariable>Color</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
@@ -54,19 +55,19 @@
|
||||
<action>
|
||||
<name>SetTint</name>
|
||||
<argumentList>
|
||||
<argument>
|
||||
<argument>
|
||||
<name>Tint</name>
|
||||
<relatedStateVariable>Tint</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
<argument>
|
||||
<name>NewTint</name>
|
||||
<retval />
|
||||
<relatedStateVariable>Tint</relatedStateVariable>
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>Tint</name>
|
||||
<relatedStateVariable>Tint</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
@@ -96,18 +97,18 @@
|
||||
<action>
|
||||
<name>SetContrast</name>
|
||||
<argumentList>
|
||||
<argument>
|
||||
<argument>
|
||||
<name>Contrast</name>
|
||||
<relatedStateVariable>Contrast</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
<argument>
|
||||
<name>NewContrast</name>
|
||||
<retval />
|
||||
<relatedStateVariable>Contrast</relatedStateVariable>
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
<argument>
|
||||
<name>Contrast</name>
|
||||
<relatedStateVariable>Contrast</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
@@ -137,19 +138,17 @@
|
||||
<action>
|
||||
<name>SetBrightness</name>
|
||||
<argumentList>
|
||||
|
||||
<argument>
|
||||
<name>Brightness</name>
|
||||
<relatedStateVariable>Brightness</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
<argument>
|
||||
<name>NewBrightness</name>
|
||||
<retval />
|
||||
<relatedStateVariable>Brightness</relatedStateVariable>
|
||||
<direction>out</direction>
|
||||
</argument>
|
||||
|
||||
<argument>
|
||||
<name>Brightness</name>
|
||||
<relatedStateVariable>Brightness</relatedStateVariable>
|
||||
<direction>in</direction>
|
||||
</argument>
|
||||
</argumentList>
|
||||
</action>
|
||||
|
||||
@@ -182,7 +181,6 @@
|
||||
</actionList>
|
||||
|
||||
|
||||
|
||||
<serviceStateTable>
|
||||
|
||||
<stateVariable sendEvents="yes">
|
||||
File diff suppressed because it is too large
Load Diff
@@ -94,12 +94,13 @@ UpnpSetLogFileNames ( IN const char *ErrFileName,
|
||||
*
|
||||
* Description:
|
||||
* This functions initializes the log files
|
||||
*
|
||||
* Returns: int
|
||||
* -1 : If fails
|
||||
* UPNP_E_SUCCESS : if success
|
||||
***************************************************************************/
|
||||
int
|
||||
UpnpInitLog( )
|
||||
UpnpInitLog()
|
||||
{
|
||||
ithread_mutex_init( &GlobalDebugMutex, NULL );
|
||||
|
||||
@@ -116,7 +117,7 @@ UpnpInitLog( )
|
||||
/***************************************************************************
|
||||
* Function : UpnpSetLogLevel
|
||||
*
|
||||
* Parameters: void
|
||||
* Parameters: Upnp_LogLevel log_level
|
||||
*
|
||||
* Description:
|
||||
* This functions set the log level (see {\tt Upnp_LogLevel}
|
||||
@@ -139,7 +140,7 @@ UpnpSetLogLevel (Upnp_LogLevel log_level)
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
void
|
||||
UpnpCloseLog( )
|
||||
UpnpCloseLog()
|
||||
{
|
||||
if( DEBUG_TARGET == 1 ) {
|
||||
fflush( ErrFileHnd );
|
||||
@@ -152,11 +153,47 @@ UpnpCloseLog( )
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : DebugAtThisLevel
|
||||
*
|
||||
* Parameters:
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
*
|
||||
* Description:
|
||||
* This functions returns true if debug output should be done in this
|
||||
* module.
|
||||
*
|
||||
* Returns: int
|
||||
***************************************************************************/
|
||||
#ifdef DEBUG
|
||||
int DebugAtThisLevel(
|
||||
IN Upnp_LogLevel DLevel,
|
||||
IN Dbg_Module Module)
|
||||
{
|
||||
int ret = g_log_level >= DLevel;
|
||||
ret &=
|
||||
DEBUG_ALL ||
|
||||
(Module == SSDP && DEBUG_SSDP ) ||
|
||||
(Module == SOAP && DEBUG_SOAP ) ||
|
||||
(Module == GENA && DEBUG_GENA ) ||
|
||||
(Module == TPOOL && DEBUG_TPOOL) ||
|
||||
(Module == MSERV && DEBUG_MSERV) ||
|
||||
(Module == DOM && DEBUG_DOM ) ||
|
||||
(Module == HTTP && DEBUG_HTTP );
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : UpnpPrintf
|
||||
*
|
||||
* Parameters:
|
||||
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
@@ -173,71 +210,53 @@ UpnpCloseLog( )
|
||||
* statement is coming
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
DBGONLY( void UpnpPrintf( IN Upnp_LogLevel DLevel,
|
||||
IN Dbg_Module Module,
|
||||
IN const char *DbgFileName,
|
||||
IN int DbgLineNo,
|
||||
IN const char *FmtStr,
|
||||
... ) {
|
||||
#ifdef DEBUG
|
||||
void UpnpPrintf(
|
||||
IN Upnp_LogLevel DLevel,
|
||||
IN Dbg_Module Module,
|
||||
IN const char *DbgFileName,
|
||||
IN int DbgLineNo,
|
||||
IN const char *FmtStr,
|
||||
... )
|
||||
{
|
||||
va_list ArgList;
|
||||
|
||||
va_list ArgList;
|
||||
va_start( ArgList, FmtStr );
|
||||
if( g_log_level < DLevel ) return; if( DEBUG_ALL == 0 ) {
|
||||
switch ( Module ) {
|
||||
case SSDP:
|
||||
if( DEBUG_SSDP == 1 ) break;
|
||||
else
|
||||
return; case SOAP:
|
||||
if( DEBUG_SOAP == 1 ) break;
|
||||
else
|
||||
return; case GENA:
|
||||
if( DEBUG_GENA == 1 ) break;
|
||||
else
|
||||
return; case TPOOL:
|
||||
if( DEBUG_TPOOL == 1 ) break;
|
||||
else
|
||||
return; case MSERV:
|
||||
if( DEBUG_MSERV == 1 ) break;
|
||||
else
|
||||
return; case DOM:
|
||||
if( DEBUG_DOM == 1 ) break;
|
||||
else
|
||||
return; case HTTP:
|
||||
if( DEBUG_HTTP == 1 ) break;
|
||||
else
|
||||
return; case API:
|
||||
if( DEBUG_API == 1 ) break;
|
||||
else
|
||||
return; default:
|
||||
return;}
|
||||
}
|
||||
if (!DebugAtThisLevel(DLevel, Module)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ithread_mutex_lock( &GlobalDebugMutex ); if( DEBUG_TARGET == 0 ) {
|
||||
if( DbgFileName ) {
|
||||
UpnpDisplayFileAndLine( stdout, DbgFileName, DbgLineNo );}
|
||||
vfprintf( stdout, FmtStr, ArgList ); fflush( stdout );}
|
||||
else
|
||||
{
|
||||
if( DLevel == 0 ) {
|
||||
if( DbgFileName ) {
|
||||
UpnpDisplayFileAndLine( ErrFileHnd, DbgFileName, DbgLineNo );}
|
||||
vfprintf( ErrFileHnd, FmtStr, ArgList ); fflush( ErrFileHnd );}
|
||||
else
|
||||
{
|
||||
if( DbgFileName ) {
|
||||
UpnpDisplayFileAndLine( InfoFileHnd, DbgFileName, DbgLineNo );}
|
||||
vfprintf( InfoFileHnd, FmtStr, ArgList ); fflush( InfoFileHnd );}
|
||||
}
|
||||
va_end( ArgList ); ithread_mutex_unlock( &GlobalDebugMutex );}
|
||||
|
||||
)
|
||||
ithread_mutex_lock(&GlobalDebugMutex);
|
||||
va_start(ArgList, FmtStr);
|
||||
if (!DEBUG_TARGET) {
|
||||
if( DbgFileName ) {
|
||||
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
|
||||
}
|
||||
vfprintf(stdout, FmtStr, ArgList);
|
||||
fflush(stdout);
|
||||
} else if (DLevel == 0) {
|
||||
if (DbgFileName) {
|
||||
UpnpDisplayFileAndLine(ErrFileHnd, DbgFileName, DbgLineNo);
|
||||
}
|
||||
vfprintf(ErrFileHnd, FmtStr, ArgList);
|
||||
fflush(ErrFileHnd);
|
||||
} else {
|
||||
if (DbgFileName) {
|
||||
UpnpDisplayFileAndLine(InfoFileHnd, DbgFileName, DbgLineNo);
|
||||
}
|
||||
vfprintf(InfoFileHnd, FmtStr, ArgList);
|
||||
fflush(InfoFileHnd);
|
||||
}
|
||||
va_end(ArgList);
|
||||
ithread_mutex_unlock(&GlobalDebugMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Function : UpnpGetDebugFile
|
||||
*
|
||||
* Parameters:
|
||||
* IN Dbg_Level DLevel: The level of the debug logging. It will decide
|
||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
||||
* whether debug statement will go to standard output,
|
||||
* or any of the log files.
|
||||
* IN Dbg_Module Module: debug will go in the name of this module
|
||||
@@ -249,46 +268,26 @@ return; default:
|
||||
* NULL : if the module is turn off for debug
|
||||
* else returns the right file descriptor
|
||||
***************************************************************************/
|
||||
DBGONLY( FILE * GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module ) {
|
||||
if( g_log_level < DLevel ) return NULL; if( DEBUG_ALL == 0 ) {
|
||||
switch ( Module ) {
|
||||
case SSDP:
|
||||
if( DEBUG_SSDP == 1 ) break;
|
||||
else
|
||||
return NULL; case SOAP:
|
||||
if( DEBUG_SOAP == 1 ) break;
|
||||
else
|
||||
return NULL; case GENA:
|
||||
if( DEBUG_GENA == 1 ) break;
|
||||
else
|
||||
return NULL; case TPOOL:
|
||||
if( DEBUG_TPOOL == 1 ) break;
|
||||
else
|
||||
return NULL; case MSERV:
|
||||
if( DEBUG_MSERV == 1 ) break;
|
||||
else
|
||||
return NULL; case DOM:
|
||||
if( DEBUG_DOM == 1 ) break;
|
||||
else
|
||||
return NULL; case API:
|
||||
if( DEBUG_API == 1 ) break;
|
||||
else
|
||||
return NULL; default:
|
||||
return NULL;}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
|
||||
{
|
||||
FILE *ret;
|
||||
|
||||
if( DEBUG_TARGET == 0 ) {
|
||||
return stdout;}
|
||||
else
|
||||
{
|
||||
if( DLevel == 0 ) {
|
||||
return ErrFileHnd;}
|
||||
else
|
||||
{
|
||||
return InfoFileHnd;}
|
||||
}
|
||||
}
|
||||
)
|
||||
if (!DebugAtThisLevel(DLevel, Module)) {
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (!DEBUG_TARGET) {
|
||||
ret = stdout;
|
||||
} else if (DLevel == 0) {
|
||||
ret = ErrFileHnd;
|
||||
} else {
|
||||
ret = InfoFileHnd;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -305,17 +304,26 @@ return NULL; default:
|
||||
* debug statement is coming to the log file
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
DBGONLY( void UpnpDisplayFileAndLine( IN FILE * fd,
|
||||
IN const char *DbgFileName,
|
||||
IN int DbgLineNo ) {
|
||||
int starlength = 66;
|
||||
const char *lines[2];
|
||||
char FileAndLine[500]; lines[0] = "DEBUG"; if( DbgFileName ) {
|
||||
sprintf( FileAndLine, "FILE: %s, LINE: %d", DbgFileName,
|
||||
DbgLineNo ); lines[1] = FileAndLine;}
|
||||
|
||||
UpnpDisplayBanner( fd, lines, 2, starlength ); fflush( fd );}
|
||||
)
|
||||
#ifdef DEBUG
|
||||
void UpnpDisplayFileAndLine(
|
||||
IN FILE * fd,
|
||||
IN const char *DbgFileName,
|
||||
IN int DbgLineNo)
|
||||
{
|
||||
int starlength = 66;
|
||||
const char *lines[2];
|
||||
char FileAndLine[500];
|
||||
lines[0] = "DEBUG";
|
||||
if (DbgFileName) {
|
||||
sprintf(FileAndLine,
|
||||
"FILE: %s, LINE: %d",
|
||||
DbgFileName, DbgLineNo);
|
||||
lines[1] = FileAndLine;
|
||||
}
|
||||
UpnpDisplayBanner(fd, lines, 2, starlength);
|
||||
fflush(fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@@ -332,47 +340,58 @@ return NULL; default:
|
||||
* per the requested banner
|
||||
* Returns: void
|
||||
***************************************************************************/
|
||||
DBGONLY( void UpnpDisplayBanner( IN FILE * fd,
|
||||
IN const char **lines,
|
||||
IN size_t size,
|
||||
IN int starLength ) {
|
||||
char *stars = ( char * )malloc( starLength + 1 );
|
||||
const char *line = NULL;
|
||||
int leftMarginLength = starLength / 2 + 1;
|
||||
int rightMarginLength = starLength / 2 + 1;
|
||||
char *leftMargin = ( char * )malloc( leftMarginLength );
|
||||
char *rightMargin = ( char * )malloc( rightMarginLength );
|
||||
int i = 0;
|
||||
int LineSize = 0;
|
||||
char *currentLine = ( char * )malloc( starLength + 1 );
|
||||
memset( stars, '*', starLength );
|
||||
stars[starLength] = 0;
|
||||
memset( leftMargin, 0, leftMarginLength );
|
||||
memset( rightMargin, 0, rightMarginLength );
|
||||
fprintf( fd, "\n%s\n", stars ); for( i = 0; i < size; i++ ) {
|
||||
LineSize = strlen( lines[i] );
|
||||
line = lines[i]; while( LineSize > ( starLength - 2 ) ) {
|
||||
memcpy( currentLine, line, ( starLength - 2 ) );
|
||||
currentLine[( starLength - 2 )] = 0;
|
||||
fprintf( fd, "*%s*\n", currentLine );
|
||||
LineSize -= ( starLength - 2 ); line += ( starLength - 2 );}
|
||||
#ifdef DEBUG
|
||||
void UpnpDisplayBanner(
|
||||
IN FILE * fd,
|
||||
IN const char **lines,
|
||||
IN size_t size,
|
||||
IN int starLength)
|
||||
{
|
||||
int leftMarginLength = starLength / 2 + 1;
|
||||
int rightMarginLength = starLength / 2 + 1;
|
||||
int i = 0;
|
||||
int LineSize = 0;
|
||||
int starLengthMinus2 = starLength - 2;
|
||||
|
||||
if( LineSize % 2 == 0 ) {
|
||||
leftMarginLength = rightMarginLength =
|
||||
( ( starLength - 2 ) - LineSize ) / 2;}
|
||||
else
|
||||
{
|
||||
leftMarginLength = ( ( starLength - 2 ) - LineSize ) / 2;
|
||||
rightMarginLength =
|
||||
( ( starLength - 2 ) - LineSize ) / 2 + 1;}
|
||||
char *leftMargin = ( char * )malloc( leftMarginLength );
|
||||
char *rightMargin = ( char * )malloc( rightMarginLength );
|
||||
char *stars = ( char * )malloc( starLength + 1 );
|
||||
char *currentLine = ( char * )malloc( starLength + 1 );
|
||||
const char *line = NULL;
|
||||
|
||||
memset( leftMargin, ' ', leftMarginLength );
|
||||
memset( rightMargin, ' ', rightMarginLength );
|
||||
leftMargin[leftMarginLength] = 0;
|
||||
rightMargin[rightMarginLength] = 0;
|
||||
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );}
|
||||
memset( stars, '*', starLength );
|
||||
stars[starLength] = 0;
|
||||
memset( leftMargin, 0, leftMarginLength );
|
||||
memset( rightMargin, 0, rightMarginLength );
|
||||
fprintf( fd, "\n%s\n", stars );
|
||||
for( i = 0; i < size; i++ ) {
|
||||
LineSize = strlen( lines[i] );
|
||||
line = lines[i];
|
||||
while( LineSize > starLengthMinus2 ) {
|
||||
memcpy( currentLine, line, starLengthMinus2 );
|
||||
currentLine[starLengthMinus2] = 0;
|
||||
fprintf( fd, "*%s*\n", currentLine );
|
||||
LineSize -= starLengthMinus2;
|
||||
line += starLengthMinus2;
|
||||
}
|
||||
leftMarginLength = (starLengthMinus2 - LineSize)/2;
|
||||
if( LineSize % 2 == 0 ) {
|
||||
rightMarginLength = leftMarginLength;
|
||||
} else {
|
||||
rightMarginLength = leftMarginLength + 1;
|
||||
}
|
||||
memset( leftMargin, ' ', leftMarginLength );
|
||||
memset( rightMargin, ' ', rightMarginLength );
|
||||
leftMargin[leftMarginLength] = 0;
|
||||
rightMargin[rightMarginLength] = 0;
|
||||
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
|
||||
}
|
||||
fprintf( fd, "%s\n\n", stars );
|
||||
|
||||
free( currentLine );
|
||||
free( stars );
|
||||
free( rightMargin );
|
||||
free( leftMargin );
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf( fd, "%s\n\n", stars );
|
||||
free( leftMargin );
|
||||
free( rightMargin ); free( stars ); free( currentLine );}
|
||||
)
|
||||
|
||||
@@ -196,11 +196,12 @@ addToAction( IN int response,
|
||||
|
||||
if( response ) {
|
||||
sprintf( ActBuff,
|
||||
"<u:%sResponse xmlns:u=\"%s\"></u:%sResponse>",
|
||||
ActionName, ServType, ActionName );
|
||||
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
||||
ActionName, ServType, ActionName );
|
||||
} else {
|
||||
sprintf( ActBuff, "<u:%s xmlns:u=\"%s\"></u:%s>",
|
||||
ActionName, ServType, ActionName );
|
||||
sprintf( ActBuff,
|
||||
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
||||
ActionName, ServType, ActionName );
|
||||
}
|
||||
|
||||
rc = ixmlParseBufferEx( ActBuff, ActionDoc );
|
||||
@@ -255,8 +256,8 @@ makeAction( IN int response,
|
||||
IN const char *Arg,
|
||||
IN va_list ArgList )
|
||||
{
|
||||
const char *ArgName,
|
||||
*ArgValue;
|
||||
const char *ArgName;
|
||||
const char *ArgValue;
|
||||
char *ActBuff;
|
||||
int Idx = 0;
|
||||
IXML_Document *ActionDoc;
|
||||
@@ -274,11 +275,13 @@ makeAction( IN int response,
|
||||
}
|
||||
|
||||
if( response ) {
|
||||
sprintf( ActBuff, "<u:%sResponse xmlns:u=\"%s\"></u:%sResponse>",
|
||||
ActionName, ServType, ActionName );
|
||||
sprintf( ActBuff,
|
||||
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
||||
ActionName, ServType, ActionName );
|
||||
} else {
|
||||
sprintf( ActBuff, "<u:%s xmlns:u=\"%s\"></u:%s>",
|
||||
ActionName, ServType, ActionName );
|
||||
sprintf( ActBuff,
|
||||
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
||||
ActionName, ServType, ActionName );
|
||||
}
|
||||
|
||||
if( ixmlParseBufferEx( ActBuff, &ActionDoc ) != IXML_SUCCESS ) {
|
||||
@@ -295,7 +298,7 @@ makeAction( IN int response,
|
||||
if( NumArg > 0 ) {
|
||||
//va_start(ArgList, Arg);
|
||||
ArgName = Arg;
|
||||
while( Idx++ != NumArg ) {
|
||||
for ( ; ; ) {
|
||||
ArgValue = va_arg( ArgList, const char * );
|
||||
|
||||
if( ArgName != NULL ) {
|
||||
@@ -310,7 +313,11 @@ makeAction( IN int response,
|
||||
ixmlNode_appendChild( node, ( IXML_Node * ) Ele );
|
||||
}
|
||||
|
||||
ArgName = va_arg( ArgList, const char * );
|
||||
if (++Idx < NumArg) {
|
||||
ArgName = va_arg( ArgList, const char * );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//va_end(ArgList);
|
||||
}
|
||||
|
||||
@@ -93,37 +93,35 @@ genaCallback( IN http_parser_t * parser,
|
||||
xboolean found_function = FALSE;
|
||||
|
||||
if( request->method == HTTPMETHOD_SUBSCRIBE ) {
|
||||
DEVICEONLY( found_function = TRUE;
|
||||
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL )
|
||||
{
|
||||
// renew subscription
|
||||
gena_process_subscription_renewal_request
|
||||
( info, request );}
|
||||
else
|
||||
{
|
||||
// subscribe
|
||||
gena_process_subscription_request( info, request );}
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
found_function = TRUE;
|
||||
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) {
|
||||
// renew subscription
|
||||
gena_process_subscription_renewal_request
|
||||
( info, request );
|
||||
} else {
|
||||
// subscribe
|
||||
gena_process_subscription_request( info, request );
|
||||
}
|
||||
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||
"got subscription request\n" );
|
||||
} else if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
|
||||
found_function = TRUE;
|
||||
// unsubscribe
|
||||
gena_process_unsubscribe_request( info, request );
|
||||
#endif
|
||||
} else if( request->method == HTTPMETHOD_NOTIFY ) {
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
found_function = TRUE;
|
||||
// notify
|
||||
gena_process_notification_event( info, request );
|
||||
#endif
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||
"got subscription request\n" ); )
|
||||
)
|
||||
}
|
||||
else
|
||||
if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
|
||||
DEVICEONLY( found_function = TRUE;
|
||||
// unsubscribe
|
||||
gena_process_unsubscribe_request( info,
|
||||
request ); )
|
||||
} else if( request->method == HTTPMETHOD_NOTIFY ) {
|
||||
CLIENTONLY( found_function = TRUE;
|
||||
// notify
|
||||
gena_process_notification_event( info, request ); )
|
||||
}
|
||||
|
||||
if( !found_function ) {
|
||||
if( !found_function ) {
|
||||
// handle missing functions of device or ctrl pt
|
||||
error_respond( info, HTTP_NOT_IMPLEMENTED, request );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // EXCLUDE_GENA
|
||||
|
||||
|
||||
@@ -72,14 +72,14 @@ GenaAutoRenewSubscription( IN void *input )
|
||||
int eventType = 0;
|
||||
|
||||
if( AUTO_RENEW_TIME == 0 ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA SUB EXPIRED" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA SUB EXPIRED" );
|
||||
sub_struct->ErrCode = UPNP_E_SUCCESS;
|
||||
send_callback = 1;
|
||||
eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED;
|
||||
} else {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA AUTO RENEW" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA AUTO RENEW" );
|
||||
if( ( ( sub_struct->ErrCode = genaRenewSubscription( event->handle,
|
||||
sub_struct->
|
||||
Sid,
|
||||
@@ -93,17 +93,17 @@ GenaAutoRenewSubscription( IN void *input )
|
||||
}
|
||||
}
|
||||
if( send_callback ) {
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
free_upnp_timeout( event );
|
||||
return;
|
||||
}
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"HANDLE IS VALID" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"HANDLE IS VALID" );
|
||||
callback_fun = handle_info->Callback;
|
||||
cookie = handle_info->Cookie;
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
//make callback
|
||||
|
||||
callback_fun( eventType, event->Event, cookie );
|
||||
@@ -219,10 +219,11 @@ gena_unsubscribe( IN char *url,
|
||||
// make request msg
|
||||
membuffer_init( &request );
|
||||
request.size_inc = 30;
|
||||
return_code = http_MakeMessage( &request, 1, 1,
|
||||
"q" "ssc" "U" "c",
|
||||
HTTPMETHOD_UNSUBSCRIBE, &dest_url,
|
||||
"SID: ", sid );
|
||||
return_code = http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"q" "ssc" "Uc",
|
||||
HTTPMETHOD_UNSUBSCRIBE, &dest_url,
|
||||
"SID: ", sid );
|
||||
|
||||
//Not able to make the message so destroy the existing buffer
|
||||
if( return_code != 0 ) {
|
||||
@@ -305,20 +306,21 @@ gena_subscribe( IN char *url,
|
||||
request.size_inc = 30;
|
||||
if( renewal_sid ) {
|
||||
// renew subscription
|
||||
return_code = http_MakeMessage( &request, 1, 1,
|
||||
"q" "ssc" "ssc" "c",
|
||||
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
||||
"SID: ", renewal_sid,
|
||||
"TIMEOUT: Second-", timeout_str );
|
||||
return_code = http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"q" "ssc" "sscc",
|
||||
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
||||
"SID: ", renewal_sid,
|
||||
"TIMEOUT: Second-", timeout_str );
|
||||
} else {
|
||||
// subscribe
|
||||
return_code = http_MakeMessage( &request, 1, 1,
|
||||
"q" "sssdsscc",
|
||||
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
||||
"CALLBACK: <http://", LOCAL_HOST,
|
||||
":", LOCAL_PORT,
|
||||
"/>\r\n" "NT: upnp:event\r\n"
|
||||
"TIMEOUT: Second-", timeout_str );
|
||||
return_code = http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"q" "sssdsc" "sc" "sscc",
|
||||
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
||||
"CALLBACK: <http://", LOCAL_HOST, ":", LOCAL_PORT, "/>",
|
||||
"NT: upnp:event",
|
||||
"TIMEOUT: Second-", timeout_str );
|
||||
}
|
||||
if( return_code != 0 ) {
|
||||
return return_code;
|
||||
@@ -395,9 +397,9 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
||||
http_parser_t response;
|
||||
|
||||
while( TRUE ) {
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
@@ -415,7 +417,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
||||
RemoveClientSubClientSID( &handle_info->ClientSubList,
|
||||
sub_copy.sid );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return_code = gena_unsubscribe( sub_copy.EventURL,
|
||||
sub_copy.ActualSID, &response );
|
||||
@@ -427,7 +429,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
||||
}
|
||||
|
||||
freeClientSubList( handle_info->ClientSubList );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return return_code;
|
||||
}
|
||||
|
||||
@@ -447,6 +449,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle )
|
||||
* return UPNP_E_SUCCESS if service response is OK else
|
||||
* returns appropriate error
|
||||
***************************************************************************/
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
int
|
||||
genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
||||
IN const Upnp_SID in_sid )
|
||||
@@ -457,25 +460,25 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
||||
client_subscription sub_copy;
|
||||
http_parser_t response;
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// validate handle and sid
|
||||
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
if( ( sub =
|
||||
GetClientSubClientSID( handle_info->ClientSubList, in_sid ) )
|
||||
== NULL ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SID;
|
||||
}
|
||||
|
||||
return_code = copy_client_subscription( sub, &sub_copy );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return_code = gena_unsubscribe( sub_copy.EventURL, sub_copy.ActualSID,
|
||||
&response );
|
||||
@@ -486,19 +489,20 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
||||
|
||||
free_client_subscription( &sub_copy );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : genaSubscribe
|
||||
@@ -522,6 +526,7 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle,
|
||||
* return UPNP_E_SUCCESS if service response is OK else
|
||||
* returns appropriate error
|
||||
***************************************************************************/
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
int
|
||||
genaSubscribe( IN UpnpClient_Handle client_handle,
|
||||
IN char *PublisherURL,
|
||||
@@ -536,28 +541,28 @@ genaSubscribe( IN UpnpClient_Handle client_handle,
|
||||
struct Handle_Info *handle_info;
|
||||
char *EventURL = NULL;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA SUBSCRIBE BEGIN" ) );
|
||||
HandleLock( );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA SUBSCRIBE BEGIN" );
|
||||
HandleLock();
|
||||
|
||||
memset( out_sid, 0, sizeof( Upnp_SID ) );
|
||||
|
||||
// validate handle
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
// subscribe
|
||||
SubscribeLock( );
|
||||
SubscribeLock();
|
||||
return_code =
|
||||
gena_subscribe( PublisherURL, TimeOut, NULL, &ActualSID );
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( return_code != UPNP_E_SUCCESS ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||
"SUBSCRIBE FAILED in transfer error code: %d returned\n",
|
||||
return_code ) );
|
||||
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||
"SUBSCRIBE FAILED in transfer error code: %d returned\n",
|
||||
return_code );
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
@@ -603,10 +608,11 @@ genaSubscribe( IN UpnpClient_Handle client_handle,
|
||||
free( EventURL );
|
||||
free( newSubscription );
|
||||
}
|
||||
HandleUnlock( );
|
||||
SubscribeUnlock( );
|
||||
HandleUnlock();
|
||||
SubscribeUnlock();
|
||||
return return_code;
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : genaRenewSubscription
|
||||
@@ -641,17 +647,17 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
char *ActualSID;
|
||||
ThreadPoolJob tempJob;
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// validate handle and sid
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
if( ( sub = GetClientSubClientSID( handle_info->ClientSubList,
|
||||
in_sid ) ) == NULL ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SID;
|
||||
}
|
||||
// remove old events
|
||||
@@ -661,13 +667,13 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
free_upnp_timeout( ( upnp_timeout * ) tempJob.arg );
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"REMOVED AUTO RENEW EVENT" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"REMOVED AUTO RENEW EVENT" );
|
||||
|
||||
sub->RenewEventId = -1;
|
||||
return_code = copy_client_subscription( sub, &sub_copy );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
if( return_code != HTTP_SUCCESS ) {
|
||||
return return_code;
|
||||
@@ -675,10 +681,10 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
|
||||
return_code = gena_subscribe( sub_copy.EventURL, TimeOut,
|
||||
sub_copy.ActualSID, &ActualSID );
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
if( return_code == UPNP_E_SUCCESS ) {
|
||||
free( ActualSID );
|
||||
}
|
||||
@@ -691,7 +697,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
// network failure (remove client sub)
|
||||
RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid );
|
||||
free_client_subscription( &sub_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return return_code;
|
||||
}
|
||||
// get subscription
|
||||
@@ -699,7 +705,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
in_sid ) ) == NULL ) {
|
||||
free( ActualSID );
|
||||
free_client_subscription( &sub_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SID;
|
||||
}
|
||||
// store actual sid
|
||||
@@ -712,7 +718,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle,
|
||||
RemoveClientSubClientSID( &handle_info->ClientSubList, sub->sid );
|
||||
}
|
||||
free_client_subscription( &sub_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return return_code;
|
||||
}
|
||||
|
||||
@@ -793,12 +799,12 @@ gena_process_notification_event( IN SOCKINFO * info,
|
||||
return;
|
||||
}
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// get client info
|
||||
if( GetClientHandleInfo( &client_handle, &handle_info ) != HND_CLIENT ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
ixmlDocument_free( ChangedVars );
|
||||
|
||||
return;
|
||||
@@ -811,20 +817,20 @@ gena_process_notification_event( IN SOCKINFO * info,
|
||||
// (if we are in the middle)
|
||||
// this is to avoid mistakenly rejecting the first event if we
|
||||
// receive it before the subscription response
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
// try and get Subscription Lock
|
||||
// (in case we are in the process of subscribing)
|
||||
SubscribeLock( );
|
||||
SubscribeLock();
|
||||
|
||||
// get HandleLock again
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetClientHandleInfo( &client_handle, &handle_info )
|
||||
!= HND_CLIENT ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||
SubscribeUnlock( );
|
||||
HandleUnlock( );
|
||||
SubscribeUnlock();
|
||||
HandleUnlock();
|
||||
ixmlDocument_free( ChangedVars );
|
||||
|
||||
return;
|
||||
@@ -834,17 +840,17 @@ gena_process_notification_event( IN SOCKINFO * info,
|
||||
GetClientSubActualSID( handle_info->ClientSubList,
|
||||
&sid ) ) == NULL ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||
SubscribeUnlock( );
|
||||
HandleUnlock( );
|
||||
SubscribeUnlock();
|
||||
HandleUnlock();
|
||||
ixmlDocument_free( ChangedVars );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SubscribeUnlock( );
|
||||
SubscribeUnlock();
|
||||
} else {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
ixmlDocument_free( ChangedVars );
|
||||
|
||||
return;
|
||||
@@ -862,7 +868,7 @@ gena_process_notification_event( IN SOCKINFO * info,
|
||||
callback = handle_info->Callback;
|
||||
cookie = handle_info->Cookie;
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
// make callback with event struct
|
||||
// In future, should find a way of mainting
|
||||
|
||||
@@ -62,19 +62,19 @@ genaUnregisterDevice( IN UpnpDevice_Handle device_handle )
|
||||
{
|
||||
struct Handle_Info *handle_info;
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||
"genaUnregisterDevice : BAD Handle : %d\n",
|
||||
device_handle ) );
|
||||
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||
"genaUnregisterDevice : BAD Handle : %d\n",
|
||||
device_handle );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
freeServiceTable( &handle_info->ServiceTable );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ free_notify_struct( IN notify_thread_struct * input )
|
||||
*
|
||||
* Note : called by genaNotify
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
notify_send_and_recv( IN uri_type * destination_url,
|
||||
IN membuffer * mid_msg,
|
||||
IN char *propertySet,
|
||||
@@ -203,12 +203,12 @@ notify_send_and_recv( IN uri_type * destination_url,
|
||||
SOCKINFO info;
|
||||
|
||||
// connect
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||
"gena notify to: %.*s\n",
|
||||
destination_url->hostport.text.size,
|
||||
destination_url->hostport.text.buff ); )
|
||||
UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__,
|
||||
"gena notify to: %.*s\n",
|
||||
(int)destination_url->hostport.text.size,
|
||||
destination_url->hostport.text.buff );
|
||||
|
||||
conn_fd = http_Connect( destination_url, &url );
|
||||
conn_fd = http_Connect( destination_url, &url );
|
||||
if( conn_fd < 0 ) {
|
||||
return conn_fd; // return UPNP error
|
||||
}
|
||||
@@ -219,9 +219,11 @@ notify_send_and_recv( IN uri_type * destination_url,
|
||||
}
|
||||
// make start line and HOST header
|
||||
membuffer_init( &start_msg );
|
||||
if( http_MakeMessage( &start_msg, 1, 1,
|
||||
"q" "s",
|
||||
HTTPMETHOD_NOTIFY, &url, mid_msg->buf ) != 0 ) {
|
||||
if (http_MakeMessage(
|
||||
&start_msg, 1, 1,
|
||||
"q" "s",
|
||||
HTTPMETHOD_NOTIFY, &url,
|
||||
mid_msg->buf ) != 0 ) {
|
||||
membuffer_destroy( &start_msg );
|
||||
sock_destroy( &info, SD_BOTH );
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
@@ -296,11 +298,12 @@ genaNotify( IN char *headers,
|
||||
|
||||
// make 'end' msg (the part that won't vary with the destination)
|
||||
endmsg.size_inc = 30;
|
||||
if( http_MakeMessage( &mid_msg, 1, 1,
|
||||
"s" "ssc" "sdcc",
|
||||
headers,
|
||||
"SID: ", sub->sid,
|
||||
"SEQ: ", sub->ToSendEventKey ) != 0 ) {
|
||||
if( http_MakeMessage(
|
||||
&mid_msg, 1, 1,
|
||||
"s" "ssc" "sdcc",
|
||||
headers,
|
||||
"SID: ", sub->sid,
|
||||
"SEQ: ", sub->ToSendEventKey ) != 0 ) {
|
||||
membuffer_destroy( &mid_msg );
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
}
|
||||
@@ -362,12 +365,12 @@ genaNotifyThread( IN void *input )
|
||||
struct Handle_Info *handle_info;
|
||||
ThreadPoolJob job;
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
//validate context
|
||||
|
||||
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free_notify_struct( in );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,7 +380,7 @@ genaNotifyThread( IN void *input )
|
||||
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL )
|
||||
|| ( ( copy_subscription( sub, &sub_copy ) != HTTP_SUCCESS ) ) ) {
|
||||
free_notify_struct( in );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
//If the event is out of order push it back to the job queue
|
||||
@@ -389,22 +392,22 @@ genaNotifyThread( IN void *input )
|
||||
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
|
||||
|
||||
freeSubscription( &sub_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
//send the notify
|
||||
return_code = genaNotify( in->headers, in->propertySet, &sub_copy );
|
||||
|
||||
freeSubscription( &sub_copy );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free_notify_struct( in );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
//validate context
|
||||
@@ -413,7 +416,7 @@ genaNotifyThread( IN void *input )
|
||||
|| ( !service->active )
|
||||
|| ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL ) ) {
|
||||
free_notify_struct( in );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,7 +430,7 @@ genaNotifyThread( IN void *input )
|
||||
}
|
||||
|
||||
free_notify_struct( in );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -474,8 +477,8 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
|
||||
notify_thread_struct *thread_struct = NULL;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA BEGIN INITIAL NOTIFY " ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA BEGIN INITIAL NOTIFY " );
|
||||
|
||||
reference_count = ( int * )malloc( sizeof( int ) );
|
||||
|
||||
@@ -501,13 +504,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
strcpy( UDN_copy, UDN );
|
||||
strcpy( servId_copy, servId );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
@@ -516,26 +519,25 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SERVICE;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ",
|
||||
UDN, servId ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ",
|
||||
UDN, servId );
|
||||
|
||||
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
||||
( sub->active ) ) {
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SID;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ",
|
||||
sid ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ", sid );
|
||||
|
||||
sub->active = 1;
|
||||
|
||||
@@ -546,13 +548,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return return_code;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n",
|
||||
propertySet ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n",
|
||||
propertySet );
|
||||
|
||||
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
||||
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
||||
@@ -566,12 +568,12 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( servId_copy );
|
||||
free( reference_count );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
}
|
||||
|
||||
sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: "
|
||||
"%d\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||
"%"PRIzu"\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||
strlen( propertySet ) + 1 );
|
||||
|
||||
//schedule thread for initial notification
|
||||
@@ -618,7 +620,7 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
free( headers );
|
||||
}
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
@@ -665,8 +667,8 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
|
||||
notify_thread_struct *thread_struct = NULL;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA BEGIN INITIAL NOTIFY EXT" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENA BEGIN INITIAL NOTIFY EXT" );
|
||||
reference_count = ( int * )malloc( sizeof( int ) );
|
||||
|
||||
if( reference_count == NULL ) {
|
||||
@@ -691,13 +693,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
strcpy( UDN_copy, UDN );
|
||||
strcpy( servId_copy, servId );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_HANDLE;
|
||||
}
|
||||
|
||||
@@ -706,24 +708,23 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SERVICE;
|
||||
}
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n",
|
||||
UDN, servId ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n",
|
||||
UDN, servId );
|
||||
|
||||
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
||||
( sub->active ) ) {
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return GENA_E_BAD_SID;
|
||||
}
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s",
|
||||
sid ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", sid );
|
||||
|
||||
sub->active = 1;
|
||||
|
||||
@@ -732,13 +733,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return UPNP_E_INVALID_PARAM;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENERATED PROPERY SET IN INIT EXT NOTIFY: %s",
|
||||
propertySet ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"GENERATED PROPERY SET IN INIT EXT NOTIFY: %s",
|
||||
propertySet );
|
||||
|
||||
headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) +
|
||||
strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH +
|
||||
@@ -751,7 +752,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
free( servId_copy );
|
||||
free( reference_count );
|
||||
ixmlFreeDOMString( propertySet );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
}
|
||||
|
||||
@@ -801,7 +802,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
free( thread_struct );
|
||||
free( headers );
|
||||
}
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
@@ -896,7 +897,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle,
|
||||
"%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||
(long) strlen( propertySet ) + 1 );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE )
|
||||
return_code = GENA_E_BAD_HANDLE;
|
||||
@@ -956,7 +957,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle,
|
||||
free( servId_copy );
|
||||
}
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
@@ -1058,7 +1059,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle,
|
||||
" upnp:event\r\nNTS: upnp:propchange\r\n",
|
||||
(long) strlen( propertySet ) + 1 );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
return_code = GENA_E_BAD_HANDLE;
|
||||
@@ -1120,7 +1121,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle,
|
||||
free( UDN_copy );
|
||||
free( servId_copy );
|
||||
}
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
@@ -1165,10 +1166,14 @@ respond_ok( IN SOCKINFO * info,
|
||||
|
||||
membuffer_init( &response );
|
||||
response.size_inc = 30;
|
||||
if( http_MakeMessage( &response, major, minor,
|
||||
"R" "D" "S" "N" "Xc" "ssc" "sc" "c",
|
||||
HTTP_OK, 0, X_USER_AGENT,
|
||||
"SID: ", sub->sid, timeout_str ) != 0 ) {
|
||||
if( http_MakeMessage(
|
||||
&response, major, minor,
|
||||
"R" "D" "S" "N" "Xc" "ssc" "scc",
|
||||
HTTP_OK,
|
||||
(off_t)0,
|
||||
X_USER_AGENT,
|
||||
"SID: ", sub->sid,
|
||||
timeout_str ) != 0 ) {
|
||||
membuffer_destroy( &response );
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
@@ -1310,8 +1315,8 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
memptr callback_hdr;
|
||||
memptr timeout_hdr;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request Received:\n" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request Received:\n" );
|
||||
|
||||
if( httpmsg_find_hdr( request, HDR_NT, &nt_hdr ) == NULL ) {
|
||||
error_respond( info, HTTP_BAD_REQUEST, request );
|
||||
@@ -1340,18 +1345,17 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
return;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"SubscriptionRequest for event URL path: %s\n",
|
||||
event_url_path );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"SubscriptionRequest for event URL path: %s\n",
|
||||
event_url_path );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// CURRENTLY, ONLY ONE DEVICE
|
||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free( event_url_path );
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
||||
@@ -1360,28 +1364,28 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
|
||||
if( service == NULL || !service->active ) {
|
||||
error_respond( info, HTTP_NOT_FOUND, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request: Number of Subscriptions already %d\n "
|
||||
"Max Subscriptions allowed: %d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request: Number of Subscriptions already %d\n "
|
||||
"Max Subscriptions allowed: %d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions );
|
||||
|
||||
// too many subscriptions
|
||||
if( handle_info->MaxSubscriptions != -1 &&
|
||||
service->TotalSubscriptions >= handle_info->MaxSubscriptions ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// generate new subscription
|
||||
sub = ( subscription * ) malloc( sizeof( subscription ) );
|
||||
if( sub == NULL ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
sub->eventKey = 0;
|
||||
@@ -1398,13 +1402,13 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
&sub->DeliveryURLs ) ) == 0 ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
if( return_code == UPNP_E_OUTOF_MEMORY ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// set the timeout
|
||||
@@ -1440,7 +1444,7 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
// respond OK
|
||||
if( respond_ok( info, time_out, sub, request ) != UPNP_E_SUCCESS ) {
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
//add to subscription list
|
||||
@@ -1457,7 +1461,7 @@ gena_process_subscription_request( IN SOCKINFO * info,
|
||||
callback_fun = handle_info->Callback;
|
||||
cookie = handle_info->Cookie;
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
//make call back with request struct
|
||||
//in the future should find a way of mainting
|
||||
@@ -1520,7 +1524,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
||||
return;
|
||||
}
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
@@ -1537,22 +1541,21 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
||||
!service->active ||
|
||||
( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Renew request: Number of subscriptions already: %d\n "
|
||||
"Max Subscriptions allowed:%d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions );
|
||||
)
|
||||
// too many subscriptions
|
||||
if( handle_info->MaxSubscriptions != -1 &&
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Renew request: Number of subscriptions already: %d\n "
|
||||
"Max Subscriptions allowed:%d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions );
|
||||
// too many subscriptions
|
||||
if( handle_info->MaxSubscriptions != -1 &&
|
||||
service->TotalSubscriptions > handle_info->MaxSubscriptions ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
RemoveSubscriptionSID( sub->sid, service );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// set the timeout
|
||||
@@ -1591,7 +1594,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info,
|
||||
RemoveSubscriptionSID( sub->sid, service );
|
||||
}
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1644,13 +1647,13 @@ gena_process_unsubscribe_request( IN SOCKINFO * info,
|
||||
return;
|
||||
}
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
// CURRENTLY, ONLY SUPPORT ONE DEVICE
|
||||
if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
membuffer_destroy( &event_url_path );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
||||
@@ -1663,14 +1666,14 @@ gena_process_unsubscribe_request( IN SOCKINFO * info,
|
||||
//CheckSubscriptionSID(sid, service) == NULL )
|
||||
{
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveSubscriptionSID( sid, service );
|
||||
error_respond( info, HTTP_OK, request ); // success
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
}
|
||||
|
||||
#endif // INCLUDE_DEVICE_APIS
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
|
||||
#define socklen_t int
|
||||
typedef int socklen_t;
|
||||
#define EAFNOSUPPORT 97
|
||||
#endif
|
||||
#include "unixutil.h"
|
||||
@@ -106,16 +106,16 @@ SetHTTPGetCallback( MiniServerCallback callback )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : SetSoapCallback
|
||||
* Function : SetSoapCallback
|
||||
*
|
||||
* Parameters :
|
||||
* MiniServerCallback callback ; - SOAP Callback to be invoked
|
||||
* Parameters :
|
||||
* MiniServerCallback callback ; - SOAP Callback to be invoked
|
||||
*
|
||||
* Description : Set SOAP Callback
|
||||
* Description : Set SOAP Callback
|
||||
*
|
||||
* Return : void
|
||||
* Return : void
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void
|
||||
SetSoapCallback( MiniServerCallback callback )
|
||||
@@ -174,11 +174,9 @@ dispatch_request( IN SOCKINFO * info,
|
||||
case HTTPMETHOD_NOTIFY:
|
||||
case HTTPMETHOD_SUBSCRIBE:
|
||||
case HTTPMETHOD_UNSUBSCRIBE:
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: got GENA msg\n", info->socket );
|
||||
)
|
||||
callback = gGenaCallback;
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: got GENA msg\n", info->socket );
|
||||
callback = gGenaCallback;
|
||||
break;
|
||||
|
||||
//HTTP server call
|
||||
@@ -217,7 +215,7 @@ dispatch_request( IN SOCKINFO * info,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
handle_error( IN SOCKINFO * info,
|
||||
int http_error_code,
|
||||
int major,
|
||||
@@ -275,12 +273,10 @@ handle_request( void *args )
|
||||
struct mserv_request_t *request = ( struct mserv_request_t * )args;
|
||||
int connfd = request->connfd;
|
||||
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: READING\n", connfd );
|
||||
)
|
||||
//parser_request_init( &parser ); ////LEAK_FIX_MK
|
||||
hmsg = &parser.msg;
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: READING\n", connfd );
|
||||
//parser_request_init( &parser ); ////LEAK_FIX_MK
|
||||
hmsg = &parser.msg;
|
||||
|
||||
if( sock_init_with_ip( &info, connfd, request->foreign_ip_addr,
|
||||
request->foreign_ip_port ) != UPNP_E_SUCCESS ) {
|
||||
@@ -295,12 +291,10 @@ handle_request( void *args )
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: PROCESSING...\n", connfd );
|
||||
)
|
||||
// dispatch
|
||||
http_error_code = dispatch_request( &info, &parser );
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: PROCESSING...\n", connfd );
|
||||
// dispatch
|
||||
http_error_code = dispatch_request( &info, &parser );
|
||||
if( http_error_code != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
@@ -316,11 +310,9 @@ handle_request( void *args )
|
||||
handle_error( &info, http_error_code, major, minor );
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: COMPLETE\n", connfd );
|
||||
)
|
||||
sock_destroy( &info, SD_BOTH ); //should shutdown completely
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver %d: COMPLETE\n", connfd );
|
||||
sock_destroy( &info, SD_BOTH ); //should shutdown completely
|
||||
|
||||
httpmsg_destroy( hmsg );
|
||||
free( request );
|
||||
@@ -341,7 +333,7 @@ handle_request( void *args )
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
schedule_request_job( IN int connfd,
|
||||
IN struct sockaddr_in *clientAddr )
|
||||
{
|
||||
@@ -352,11 +344,9 @@ schedule_request_job( IN int connfd,
|
||||
( struct mserv_request_t * )
|
||||
malloc( sizeof( struct mserv_request_t ) );
|
||||
if( request == NULL ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv %d: out of memory\n", connfd );
|
||||
)
|
||||
shutdown( request->connfd, SD_BOTH );
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv %d: out of memory\n", connfd );
|
||||
shutdown( request->connfd, SD_BOTH );
|
||||
UpnpCloseSocket( connfd );
|
||||
return;
|
||||
}
|
||||
@@ -369,11 +359,9 @@ schedule_request_job( IN int connfd,
|
||||
TPJobSetFreeFunction( &job, free_handle_request_arg );
|
||||
TPJobSetPriority( &job, MED_PRIORITY );
|
||||
|
||||
if( ThreadPoolAdd( &gRecvThreadPool, &job, NULL ) != 0 ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv %d: cannot schedule request\n", connfd );
|
||||
)
|
||||
if( ThreadPoolAdd( &gMiniServerThreadPool, &job, NULL ) != 0 ) {
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv %d: cannot schedule request\n", connfd );
|
||||
free( request );
|
||||
shutdown( connfd, SD_BOTH );
|
||||
UpnpCloseSocket( connfd );
|
||||
@@ -446,11 +434,9 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
||||
|
||||
if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) ==
|
||||
UPNP_SOCKETERROR ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in select call !!!\n" );
|
||||
)
|
||||
continue;
|
||||
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in select call !!!\n" );
|
||||
continue;
|
||||
} else {
|
||||
|
||||
if( FD_ISSET( miniServSock, &rdSet ) ) {
|
||||
@@ -459,12 +445,10 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
||||
( struct sockaddr * )&clientAddr,
|
||||
&clientLen );
|
||||
if( connectHnd == UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver: Error"
|
||||
" in accepting connection\n" );
|
||||
)
|
||||
continue;
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"miniserver: Error"
|
||||
" in accepting connection\n" );
|
||||
continue;
|
||||
}
|
||||
schedule_request_job( connectHnd, &clientAddr );
|
||||
}
|
||||
@@ -489,24 +473,19 @@ RunMiniServer( MiniServerSockArray * miniSock )
|
||||
&clientLen );
|
||||
if( byteReceived > 0 ) {
|
||||
requestBuf[byteReceived] = '\0';
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"Received response !!! %s From host %s \n",
|
||||
requestBuf,
|
||||
inet_ntoa( clientAddr.sin_addr ) );
|
||||
)
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
||||
"Received multicast packet: \n %s\n",
|
||||
requestBuf );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"Received response !!! %s From host %s \n",
|
||||
requestBuf, inet_ntoa( clientAddr.sin_addr ) );
|
||||
UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
|
||||
"Received multicast packet: \n %s\n",
|
||||
requestBuf );
|
||||
|
||||
if( NULL != strstr( requestBuf, "ShutDown" ) )
|
||||
if( NULL != strstr( requestBuf, "ShutDown" ) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
shutdown( miniServSock, SD_BOTH );
|
||||
@@ -555,12 +534,10 @@ get_port( int sockfd )
|
||||
}
|
||||
|
||||
port = ntohs( sockinfo.sin_port );
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"sockfd = %d, .... port = %d\n", sockfd, port );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"sockfd = %d, .... port = %d\n", sockfd, port );
|
||||
|
||||
return port;
|
||||
return port;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@@ -623,16 +600,10 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
||||
//THIS MAY CAUSE TCP TO BECOME LESS RELIABLE
|
||||
//HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv start: resuseaddr set\n" );
|
||||
)
|
||||
|
||||
sockError = setsockopt( listenfd,
|
||||
SOL_SOCKET,
|
||||
SO_REUSEADDR,
|
||||
( const char * )&reuseaddr_on,
|
||||
sizeof( int )
|
||||
);
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv start: resuseaddr set\n" );
|
||||
sockError = setsockopt( listenfd, SOL_SOCKET, SO_REUSEADDR,
|
||||
( const char * )&reuseaddr_on, sizeof( int ));
|
||||
if( sockError == UPNP_SOCKETERROR ) {
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpCloseSocket( listenfd );
|
||||
@@ -651,6 +622,11 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
||||
sizeof( struct sockaddr_in )
|
||||
);
|
||||
if( sockError == UPNP_SOCKETERROR ) {
|
||||
#ifdef WIN32
|
||||
errCode = WSAGetLastError();
|
||||
#else
|
||||
errCode = errno;
|
||||
#endif
|
||||
if( errno == EADDRINUSE )
|
||||
errCode = 1;
|
||||
} else
|
||||
@@ -660,18 +636,16 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
||||
}
|
||||
|
||||
if( sockError == UPNP_SOCKETERROR ) {
|
||||
DBGONLY( perror( "mserv start: bind failed" );
|
||||
)
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
perror( "mserv start: bind failed" );
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpCloseSocket( listenfd );
|
||||
return UPNP_E_SOCKET_BIND; // bind failed
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv start: bind success\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
|
||||
"mserv start: bind success\n" );
|
||||
|
||||
success = listen( listenfd, SOMAXCONN );
|
||||
success = listen( listenfd, SOMAXCONN );
|
||||
if( success == UPNP_SOCKETERROR ) {
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpCloseSocket( listenfd );
|
||||
@@ -689,11 +663,10 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
||||
|
||||
if( ( miniServerStopSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) ==
|
||||
UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
MSERV, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" );
|
||||
)
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
MSERV, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" );
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpCloseSocket( listenfd );
|
||||
return UPNP_E_OUTOF_SOCKET;
|
||||
}
|
||||
@@ -706,11 +679,10 @@ get_miniserver_sockets( MiniServerSockArray * out,
|
||||
if( bind( miniServerStopSock, ( struct sockaddr * )&serverAddr,
|
||||
sizeof( serverAddr ) ) == UPNP_SOCKETERROR ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
MSERV, __FILE__, __LINE__,
|
||||
"Error in binding localhost!!!\n" );
|
||||
)
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
MSERV, __FILE__, __LINE__,
|
||||
"Error in binding localhost!!!\n" );
|
||||
shutdown( listenfd, SD_BOTH );
|
||||
UpnpCloseSocket( listenfd );
|
||||
shutdown( miniServerStopSock, SD_BOTH );
|
||||
UpnpCloseSocket( miniServerStopSock );
|
||||
@@ -800,7 +772,7 @@ StartMiniServer( unsigned short listen_port )
|
||||
|
||||
TPJobSetFreeFunction( &job, ( free_routine ) free );
|
||||
|
||||
success = ThreadPoolAddPersistent( &gRecvThreadPool, &job, NULL );
|
||||
success = ThreadPoolAddPersistent( &gMiniServerThreadPool, &job, NULL );
|
||||
|
||||
if( success < 0 ) {
|
||||
shutdown( miniSocket->miniServerSock, SD_BOTH );
|
||||
@@ -872,11 +844,9 @@ StopMiniServer( void )
|
||||
|
||||
sock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||
if( sock == UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" );
|
||||
)
|
||||
return 0;
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
while( gMServState != MSERV_IDLE ) {
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
* messages.
|
||||
************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For strcasestr() in string.h
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -100,7 +101,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************* scanner **************/
|
||||
/************* scanner *************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -108,19 +109,19 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
|
||||
#define TOKCHAR_LF 0xA
|
||||
|
||||
/************************************************************************
|
||||
* Function : scanner_init
|
||||
* Function : scanner_init
|
||||
*
|
||||
* Parameters :
|
||||
* OUT scanner_t* scanner ; Scanner Object to be initialized
|
||||
* IN membuffer* bufptr ; Buffer to be copied
|
||||
* Parameters :
|
||||
* OUT scanner_t* scanner ; Scanner Object to be initialized
|
||||
* IN membuffer* bufptr ; Buffer to be copied
|
||||
*
|
||||
* Description : Intialize scanner
|
||||
* Description : Intialize scanner
|
||||
*
|
||||
* Return : void ;
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
scanner_init( OUT scanner_t * scanner,
|
||||
IN membuffer * bufptr )
|
||||
{
|
||||
@@ -130,72 +131,72 @@ scanner_init( OUT scanner_t * scanner,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : is_separator_char
|
||||
* Function : is_separator_char
|
||||
*
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested against used separator values
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested against used separator values
|
||||
*
|
||||
* Description : Finds the separator character.
|
||||
* Description : Finds the separator character.
|
||||
*
|
||||
* Return : xboolean ;
|
||||
* Return : xboolean ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
is_separator_char( IN char c )
|
||||
{
|
||||
return strchr( " \t()<>@,;:\\\"/[]?={}", c ) != NULL;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : is_identifier_char
|
||||
* Function : is_identifier_char
|
||||
*
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested for separator values
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested for separator values
|
||||
*
|
||||
* Description : Calls the function to indentify separator character
|
||||
* Description : Calls the function to indentify separator character
|
||||
*
|
||||
* Return : xboolean ;
|
||||
* Return : xboolean ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
is_identifier_char( IN char c )
|
||||
{
|
||||
return ( c >= 32 && c <= 126 ) && !is_separator_char( c );
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : is_control_char
|
||||
* Function : is_control_char
|
||||
*
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested for a control character
|
||||
* Parameters :
|
||||
* IN char c ; character to be tested for a control character
|
||||
*
|
||||
* Description : Determines if the passed value is a control character
|
||||
* Description : Determines if the passed value is a control character
|
||||
*
|
||||
* Return : xboolean ;
|
||||
* Return : xboolean ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
is_control_char( IN char c )
|
||||
{
|
||||
return ( ( c >= 0 && c <= 31 ) || ( c == 127 ) );
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : is_qdtext_char
|
||||
* Function : is_qdtext_char
|
||||
*
|
||||
* Parameters :
|
||||
* IN char cc ; character to be tested for CR/LF
|
||||
* Parameters :
|
||||
* IN char cc ; character to be tested for CR/LF
|
||||
*
|
||||
* Description : Checks to see if the passed in value is CR/LF
|
||||
* Description : Checks to see if the passed in value is CR/LF
|
||||
*
|
||||
* Return : xboolean ;
|
||||
* Return : xboolean ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
is_qdtext_char( IN char cc )
|
||||
{
|
||||
unsigned char c = ( unsigned char )cc;
|
||||
@@ -213,22 +214,22 @@ is_qdtext_char( IN char cc )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : scanner_get_token
|
||||
* Function : scanner_get_token
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* token ; Token
|
||||
* OUT token_type_t* tok_type ; Type of token
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* token ; Token
|
||||
* OUT token_type_t* tok_type ; Type of token
|
||||
*
|
||||
* Description : reads next token from the input stream
|
||||
* note: 0 and is used as a marker, and will not be valid in a quote
|
||||
* Description : reads next token from the input stream
|
||||
* note: 0 and is used as a marker, and will not be valid in a quote
|
||||
*
|
||||
* Return : parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE -- not enuf chars to get a token
|
||||
* PARSE_FAILURE -- bad msg format
|
||||
* Return : parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE -- not enuf chars to get a token
|
||||
* PARSE_FAILURE -- bad msg format
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static parse_status_t
|
||||
scanner_get_token( INOUT scanner_t * scanner,
|
||||
@@ -363,38 +364,40 @@ scanner_get_token( INOUT scanner_t * scanner,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : scanner_get_str
|
||||
* Function : scanner_get_str
|
||||
*
|
||||
* Parameters :
|
||||
* IN scanner_t* scanner ; Scanner Object
|
||||
* Parameters :
|
||||
* IN scanner_t* scanner ; Scanner Object
|
||||
*
|
||||
* Description : returns ptr to next char in string
|
||||
* Description : returns ptr to next char in string
|
||||
*
|
||||
* Return : char* ;
|
||||
* Return : char* ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE char *
|
||||
static UPNP_INLINE char *
|
||||
scanner_get_str( IN scanner_t * scanner )
|
||||
{
|
||||
return scanner->msg->buf + scanner->cursor;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : scanner_pushback
|
||||
* Function : scanner_pushback
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN size_t pushback_bytes ; Bytes to be moved back
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN size_t pushback_bytes ; Bytes to be moved back
|
||||
*
|
||||
* Description : Move back by a certain number of bytes.
|
||||
* This is used to put back one or more tokens back into the input
|
||||
* Description : Move back by a certain number of bytes.
|
||||
* This is used to put back one or more tokens back into the input
|
||||
*
|
||||
* Return : void ;
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
#warning The only use of the function 'scanner_pushback()' in the code is commented out.
|
||||
#warning 'scanner_pushback()' is a good candidate for removal.
|
||||
static UPNP_INLINE void
|
||||
scanner_pushback( INOUT scanner_t * scanner,
|
||||
IN size_t pushback_bytes )
|
||||
{
|
||||
@@ -403,34 +406,34 @@ scanner_pushback( INOUT scanner_t * scanner,
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************* end of scanner **************/
|
||||
/************* end of scanner **************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************* parser **************/
|
||||
/************* parser **************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************* http_message_t **************/
|
||||
/************* http_message_t **************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpmsg_compare
|
||||
* Function : httpmsg_compare
|
||||
*
|
||||
* Parameters :
|
||||
* void* param1 ;
|
||||
* void* param2 ;
|
||||
* Parameters :
|
||||
* void* param1 ;
|
||||
* void* param2 ;
|
||||
*
|
||||
* Description : Compares name id in the http headers.
|
||||
* Description : Compares name id in the http headers.
|
||||
*
|
||||
* Return : int ;
|
||||
* Return : int ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static int
|
||||
httpmsg_compare( void *param1,
|
||||
@@ -444,16 +447,16 @@ httpmsg_compare( void *param1,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpheader_free
|
||||
* Function : httpheader_free
|
||||
*
|
||||
* Parameters :
|
||||
* void *msg ;
|
||||
* Parameters :
|
||||
* void *msg ;
|
||||
*
|
||||
* Description : Free memory allocated for the http header
|
||||
* Description : Free memory allocated for the http header
|
||||
*
|
||||
* Return : void ;
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static void
|
||||
httpheader_free( void *msg )
|
||||
@@ -466,16 +469,16 @@ httpheader_free( void *msg )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpmsg_init
|
||||
* Function : httpmsg_init
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT http_message_t* msg ; HTTP Message Object
|
||||
* Parameters :
|
||||
* INOUT http_message_t* msg ; HTTP Message Object
|
||||
*
|
||||
* Description : Initialize and allocate memory for http message
|
||||
* Description : Initialize and allocate memory for http message
|
||||
*
|
||||
* Return : void ;
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void
|
||||
httpmsg_init( INOUT http_message_t * msg )
|
||||
@@ -489,16 +492,16 @@ httpmsg_init( INOUT http_message_t * msg )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpmsg_destroy
|
||||
* Function : httpmsg_destroy
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT http_message_t* msg ; HTTP Message Object
|
||||
* Parameters :
|
||||
* INOUT http_message_t* msg ; HTTP Message Object
|
||||
*
|
||||
* Description : Free memory allocated for the http message
|
||||
* Description : Free memory allocated for the http message
|
||||
*
|
||||
* Return : void ;
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void
|
||||
httpmsg_destroy( INOUT http_message_t * msg )
|
||||
@@ -515,19 +518,19 @@ httpmsg_destroy( INOUT http_message_t * msg )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpmsg_find_hdr_str
|
||||
* Function : httpmsg_find_hdr_str
|
||||
*
|
||||
* Parameters :
|
||||
* IN http_message_t* msg ; HTTP Message Object
|
||||
* IN const char* header_name ; Header name to be compared with
|
||||
* Parameters :
|
||||
* IN http_message_t* msg ; HTTP Message Object
|
||||
* IN const char* header_name ; Header name to be compared with
|
||||
*
|
||||
* Description : Compares the header name with the header names stored
|
||||
* in the linked list of messages
|
||||
* Description : Compares the header name with the header names stored
|
||||
* in the linked list of messages
|
||||
*
|
||||
* Return : http_header_t* - Pointer to a header on success;
|
||||
* NULL on failure
|
||||
* Return : http_header_t* - Pointer to a header on success;
|
||||
* NULL on failure
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
http_header_t *
|
||||
httpmsg_find_hdr_str( IN http_message_t * msg,
|
||||
@@ -552,19 +555,19 @@ httpmsg_find_hdr_str( IN http_message_t * msg,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : httpmsg_find_hdr
|
||||
* Function : httpmsg_find_hdr
|
||||
*
|
||||
* Parameters :
|
||||
* IN http_message_t* msg ; HTTP Message Object
|
||||
* IN int header_name_id ; Header Name ID to be compared with
|
||||
* OUT memptr* value ; Buffer to get the ouput to.
|
||||
* Parameters :
|
||||
* IN http_message_t* msg ; HTTP Message Object
|
||||
* IN int header_name_id ; Header Name ID to be compared with
|
||||
* OUT memptr* value ; Buffer to get the ouput to.
|
||||
*
|
||||
* Description : Finds header from a list, with the given 'name_id'.
|
||||
* Description : Finds header from a list, with the given 'name_id'.
|
||||
*
|
||||
* Return : http_header_t* - Pointer to a header on success; *
|
||||
* NULL on failure
|
||||
* Return : http_header_t* - Pointer to a header on success;
|
||||
* NULL on failure
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
http_header_t *
|
||||
httpmsg_find_hdr( IN http_message_t * msg,
|
||||
@@ -597,23 +600,23 @@ httpmsg_find_hdr( IN http_message_t * msg,
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************* http_parser_t **************/
|
||||
/************* http_parser_t **************/
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Function : skip_blank_lines
|
||||
* Function : skip_blank_lines
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
*
|
||||
* Description : skips blank lines at the start of a msg.
|
||||
* Description : skips blank lines at the start of a msg.
|
||||
*
|
||||
* Return : int ;
|
||||
* Return : int ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
skip_blank_lines( INOUT scanner_t * scanner )
|
||||
{
|
||||
memptr token;
|
||||
@@ -636,21 +639,21 @@ skip_blank_lines( INOUT scanner_t * scanner )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : skip_lws
|
||||
* Function : skip_lws
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
*
|
||||
* Description : skip linear whitespace.
|
||||
* Description : skip linear whitespace.
|
||||
*
|
||||
* Return : int ;
|
||||
* PARSE_OK: (LWS)* removed from input
|
||||
* PARSE_FAILURE: bad input
|
||||
* PARSE_INCOMPLETE: incomplete input
|
||||
* Return : int ;
|
||||
* PARSE_OK: (LWS)* removed from input
|
||||
* PARSE_FAILURE: bad input
|
||||
* PARSE_INCOMPLETE: incomplete input
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
skip_lws( INOUT scanner_t * scanner )
|
||||
{
|
||||
memptr token;
|
||||
@@ -689,23 +692,23 @@ skip_lws( INOUT scanner_t * scanner )
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : match_non_ws_string
|
||||
* Function : match_non_ws_string
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* str ; Buffer to get the scanner buffer contents.
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* str ; Buffer to get the scanner buffer contents.
|
||||
*
|
||||
* Description : Match a string without whitespace or CRLF (%S)
|
||||
* Description : Match a string without whitespace or CRLF (%S)
|
||||
*
|
||||
* Return : XINLINE parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_NO_MATCH
|
||||
* PARSE_FAILURE
|
||||
* PARSE_INCOMPLETE
|
||||
* Return : UPNP_INLINE parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_NO_MATCH
|
||||
* PARSE_FAILURE
|
||||
* PARSE_INCOMPLETE
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
match_non_ws_string( INOUT scanner_t * scanner,
|
||||
OUT memptr * str )
|
||||
{
|
||||
@@ -753,25 +756,25 @@ match_non_ws_string( INOUT scanner_t * scanner,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : match_raw_value
|
||||
* Function : match_raw_value
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* raw_value ; Buffer to get the scanner buffer
|
||||
* contents
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* raw_value ; Buffer to get the scanner buffer
|
||||
* contents
|
||||
*
|
||||
* Description : Matches a raw value in a the input; value's length
|
||||
* can be 0 or more. Whitespace after value is trimmed. On success,
|
||||
* scanner points the CRLF that ended the value
|
||||
* Description : Matches a raw value in a the input; value's length
|
||||
* can be 0 or more. Whitespace after value is trimmed. On success,
|
||||
* scanner points the CRLF that ended the value
|
||||
*
|
||||
* Return : parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE
|
||||
* PARSE_FAILURE
|
||||
* Return : parse_status_t ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE
|
||||
* PARSE_FAILURE
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
match_raw_value( INOUT scanner_t * scanner,
|
||||
OUT memptr * raw_value )
|
||||
{
|
||||
@@ -848,9 +851,9 @@ match_raw_value( INOUT scanner_t * scanner,
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN int base : Base of number in the string;
|
||||
* valid values: 10 or 16
|
||||
* OUT int* value ; Number stored here
|
||||
* IN int base : Base of number in the string;
|
||||
* valid values: 10 or 16
|
||||
* OUT int* value ; Number stored here
|
||||
*
|
||||
* Description: Matches an unsigned integer value in the input. The
|
||||
* integer is returned in 'value'. Except for PARSE_OK result, the
|
||||
@@ -862,7 +865,7 @@ match_raw_value( INOUT scanner_t * scanner,
|
||||
* PARSE_FAILURE -- bad input
|
||||
* PARSE_INCOMPLETE
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
match_int( INOUT scanner_t * scanner,
|
||||
IN int base,
|
||||
OUT int *value )
|
||||
@@ -909,8 +912,8 @@ match_int( INOUT scanner_t * scanner,
|
||||
* Function: read_until_crlf
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* OUT memptr* str ; Buffer to copy scanner buffer contents to
|
||||
* INOUT scanner_t* scanner ;Scanner Object
|
||||
* OUT memptr* str ; Buffer to copy scanner buffer contents to
|
||||
*
|
||||
* Description: Reads data until end of line; the crlf at the end of
|
||||
* line is not consumed. On error, scanner is not restored. On
|
||||
@@ -921,7 +924,7 @@ match_int( INOUT scanner_t * scanner,
|
||||
* PARSE_FAILURE
|
||||
* PARSE_INCOMPLETE
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
read_until_crlf( INOUT scanner_t * scanner,
|
||||
OUT memptr * str )
|
||||
{
|
||||
@@ -962,7 +965,9 @@ read_until_crlf( INOUT scanner_t * scanner,
|
||||
* PARSE_FAILURE
|
||||
* PARSE_INCOMPLETE
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
#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 good candidate for removal.
|
||||
static UPNP_INLINE int
|
||||
skip_to_end_of_header( INOUT scanner_t * scanner )
|
||||
{
|
||||
memptr dummy_raw_value;
|
||||
@@ -976,10 +981,10 @@ skip_to_end_of_header( INOUT scanner_t * scanner )
|
||||
* Function: match_char
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN char c ; Character to be compared with
|
||||
* IN xboolean case_sensitive; Flag indicating whether comparison should
|
||||
* be case sensitive
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN char c ; Character to be compared with
|
||||
* IN xboolean case_sensitive; Flag indicating whether
|
||||
* comparison should be case sensitive
|
||||
*
|
||||
* Description: Compares a character to the next char in the scanner;
|
||||
* on error, scanner chars are not restored
|
||||
@@ -989,7 +994,7 @@ skip_to_end_of_header( INOUT scanner_t * scanner )
|
||||
* PARSE_NO_MATCH
|
||||
* PARSE_INCOMPLETE
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
match_char( INOUT scanner_t * scanner,
|
||||
IN char c,
|
||||
IN xboolean case_sensitive )
|
||||
@@ -1044,24 +1049,24 @@ match_char( INOUT scanner_t * scanner,
|
||||
// PARSE_NO_MATCH -- input does not match pattern
|
||||
|
||||
/************************************************************************
|
||||
* Function : vfmatch
|
||||
* Function : vfmatch
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN const char* fmt ; Pattern Format
|
||||
* va_list argp ; List of variable arguments
|
||||
* Parameters :
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN const char* fmt ; Pattern Format
|
||||
* va_list argp ; List of variable arguments
|
||||
*
|
||||
* Description : Extracts variable parameters depending on the passed
|
||||
* in format parameter. Parses data also based on the passed in
|
||||
* format parameter.
|
||||
* Description : Extracts variable parameters depending on the passed
|
||||
* in format parameter. Parses data also based on the passed in
|
||||
* format parameter.
|
||||
*
|
||||
* Return : int ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE
|
||||
* PARSE_FAILURE - bad input
|
||||
* PARSE_NO_MATCH - input does not match pattern
|
||||
* Return : int ;
|
||||
* PARSE_OK
|
||||
* PARSE_INCOMPLETE
|
||||
* PARSE_FAILURE - bad input
|
||||
* PARSE_NO_MATCH - input does not match pattern
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static int
|
||||
vfmatch( INOUT scanner_t * scanner,
|
||||
@@ -1244,8 +1249,8 @@ vfmatch( INOUT scanner_t * scanner,
|
||||
* Function: match
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN const char* fmt; Pattern format
|
||||
* INOUT scanner_t* scanner ; Scanner Object
|
||||
* IN const char* fmt; Pattern format
|
||||
* ...
|
||||
*
|
||||
* Description: matches a variable parameter list and takes necessary
|
||||
@@ -1275,9 +1280,9 @@ match( INOUT scanner_t * scanner,
|
||||
* Function: matchstr
|
||||
*
|
||||
* Parameters:
|
||||
* IN char *str ; String to be matched
|
||||
* IN size_t slen ; Length of the string
|
||||
* IN const char* fmt ; Pattern format
|
||||
* IN char *str ; String to be matched
|
||||
* IN size_t slen ; Length of the string
|
||||
* IN const char* fmt ; Pattern format
|
||||
* ...
|
||||
*
|
||||
* Description: Matches a variable parameter list with a string
|
||||
@@ -1336,7 +1341,7 @@ matchstr( IN char *str,
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
parser_init( OUT http_parser_t * parser )
|
||||
{
|
||||
memset( parser, 0, sizeof( http_parser_t ) );
|
||||
@@ -1871,7 +1876,7 @@ parser_parse_headers_old( INOUT http_parser_t * parser )
|
||||
* PARSE_FAILURE -- entity length > content-length value
|
||||
* PARSE_SUCCESS
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
parser_parse_entity_using_clen( INOUT http_parser_t * parser )
|
||||
{
|
||||
//int entity_length;
|
||||
@@ -1918,7 +1923,7 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
|
||||
* PARSE_FAILURE -- entity length > content-length value
|
||||
* PARSE_SUCCESS
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
parser_parse_chunky_body( INOUT http_parser_t * parser )
|
||||
{
|
||||
parse_status_t status;
|
||||
@@ -1963,7 +1968,7 @@ parser_parse_chunky_body( INOUT http_parser_t * parser )
|
||||
* PARSE_FAILURE -- entity length > content-length value
|
||||
* PARSE_SUCCESS
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
parser_parse_chunky_headers( INOUT http_parser_t * parser )
|
||||
{
|
||||
parse_status_t status;
|
||||
@@ -2003,7 +2008,7 @@ parser_parse_chunky_headers( INOUT http_parser_t * parser )
|
||||
* PARSE_SUCCESS
|
||||
* PARSE_CONTINUE_1
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
parser_parse_chunky_entity( INOUT http_parser_t * parser )
|
||||
{
|
||||
scanner_t *scanner = &parser->scanner;
|
||||
@@ -2019,10 +2024,9 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser )
|
||||
status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy );
|
||||
if( status != PARSE_OK ) {
|
||||
scanner->cursor = save_pos;
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"CHUNK COULD NOT BE PARSED\n" ); )
|
||||
return status;
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"CHUNK COULD NOT BE PARSED\n" );
|
||||
return status;
|
||||
}
|
||||
// remove chunk info just matched; just retain data
|
||||
membuffer_delete( &parser->msg.msg, save_pos,
|
||||
@@ -2055,7 +2059,7 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser )
|
||||
* Returns:
|
||||
* PARSE_INCOMPLETE_ENTITY
|
||||
************************************************************************/
|
||||
static XINLINE parse_status_t
|
||||
static UPNP_INLINE parse_status_t
|
||||
parser_parse_entity_until_close( INOUT http_parser_t * parser )
|
||||
{
|
||||
size_t cursor;
|
||||
@@ -2090,7 +2094,7 @@ parser_parse_entity_until_close( INOUT http_parser_t * parser )
|
||||
* PARSE_FAILURE
|
||||
* PARSE_COMPLETE -- no more reading to do
|
||||
************************************************************************/
|
||||
XINLINE parse_status_t
|
||||
UPNP_INLINE parse_status_t
|
||||
parser_get_entity_read_method( INOUT http_parser_t * parser )
|
||||
{
|
||||
http_message_t *hmsg = &parser->msg;
|
||||
@@ -2148,11 +2152,10 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
||||
if( raw_find_str( &hdr_value, "chunked" ) >= 0 ) {
|
||||
// read method to use chunked transfer encoding
|
||||
parser->ent_position = ENTREAD_USING_CHUNKED;
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"Found Chunked Encoding ....\n" ); )
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"Found Chunked Encoding ....\n" );
|
||||
|
||||
return PARSE_CONTINUE_1;
|
||||
return PARSE_CONTINUE_1;
|
||||
}
|
||||
}
|
||||
// * use content length
|
||||
@@ -2196,7 +2199,7 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
||||
* PARSE_FAILURE
|
||||
* PARSE_COMPLETE -- no more reading to do
|
||||
************************************************************************/
|
||||
XINLINE parse_status_t
|
||||
UPNP_INLINE parse_status_t
|
||||
parser_parse_entity( INOUT http_parser_t * parser )
|
||||
{
|
||||
parse_status_t status = PARSE_OK;
|
||||
@@ -2261,7 +2264,7 @@ parser_request_init( OUT http_parser_t * parser )
|
||||
* Function: parser_response_init
|
||||
*
|
||||
* Parameters:
|
||||
* OUT http_parser_t* parser ; HTTP Parser object
|
||||
* OUT http_parser_t* parser ; HTTP Parser object
|
||||
* IN http_method_t request_method ; Request method
|
||||
*
|
||||
* Description: Initializes parser object for a response
|
||||
@@ -2340,9 +2343,9 @@ parser_parse( INOUT http_parser_t * parser )
|
||||
*
|
||||
* Parameters:
|
||||
* INOUT http_parser_t* parser ; HTTP Parser Object
|
||||
* IN const char* buf ; buffer to be appended to the parser
|
||||
* buffer
|
||||
* IN size_t buf_length ; Size of the buffer
|
||||
* IN const char* buf ; buffer to be appended to the parser
|
||||
* buffer
|
||||
* IN size_t buf_length ; Size of the buffer
|
||||
*
|
||||
* Description: The parser function. Depending on the position of the
|
||||
* parser object the actual parsing function is invoked
|
||||
@@ -2372,7 +2375,7 @@ parser_append( INOUT http_parser_t * parser,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
********** end of parser ***********
|
||||
********** end of parser ***********
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
@@ -2380,7 +2383,7 @@ parser_append( INOUT http_parser_t * parser,
|
||||
*
|
||||
* Parameters:
|
||||
* IN memptr* raw_value ; Buffer to be converted
|
||||
* IN int base ; Base to use for conversion
|
||||
* IN int base ; Base to use for conversion
|
||||
*
|
||||
* Description: Converts raw character data to long-integer value
|
||||
*
|
||||
@@ -2421,28 +2424,42 @@ raw_to_int( IN memptr * raw_value,
|
||||
*
|
||||
* Description: Find a substring from raw character string buffer
|
||||
*
|
||||
* Side effects: raw_value is transformed to lowercase.
|
||||
*
|
||||
* Returns:
|
||||
* int - index at which the substring is found.
|
||||
************************************************************************/
|
||||
int
|
||||
raw_find_str( IN memptr * raw_value,
|
||||
raw_find_str( IN memptr *raw_value,
|
||||
IN const char *str )
|
||||
{
|
||||
char c;
|
||||
char *ptr;
|
||||
int i = 0;
|
||||
|
||||
c = raw_value->buf[raw_value->length]; // save
|
||||
raw_value->buf[raw_value->length] = 0; // null-terminate
|
||||
// save
|
||||
c = raw_value->buf[raw_value->length];
|
||||
|
||||
// Make it lowercase
|
||||
for (i = 0; raw_value->buf[i]; ++i) {
|
||||
raw_value->buf[i] = tolower(raw_value->buf[i]);
|
||||
}
|
||||
|
||||
// null-terminate
|
||||
raw_value->buf[raw_value->length] = 0;
|
||||
|
||||
// Find the substring position
|
||||
ptr = strstr( raw_value->buf, str );
|
||||
|
||||
raw_value->buf[raw_value->length] = c; // restore
|
||||
// restore the "length" byte
|
||||
raw_value->buf[raw_value->length] = c;
|
||||
|
||||
if( ptr == 0 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ptr - raw_value->buf; // return index
|
||||
// return index
|
||||
return ptr - raw_value->buf;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@@ -2455,7 +2472,7 @@ raw_find_str( IN memptr * raw_value,
|
||||
* nameConverts a http_method id stored in the HTTP Method
|
||||
*
|
||||
* Returns:
|
||||
* const char* ptr - Ptr to the HTTP Method *
|
||||
* const char* ptr - Ptr to the HTTP Method
|
||||
************************************************************************/
|
||||
const char *
|
||||
method_to_str( IN http_method_t method )
|
||||
@@ -2480,40 +2497,38 @@ method_to_str( IN http_method_t method )
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void
|
||||
print_http_headers( http_message_t * hmsg )
|
||||
{
|
||||
|
||||
ListNode *node;
|
||||
|
||||
//NNS: dlist_node *node;
|
||||
// NNS: dlist_node *node;
|
||||
http_header_t *header;
|
||||
|
||||
// print start line
|
||||
if( hmsg->is_request ) {
|
||||
//printf( "method = %d, version = %d.%d, url = %.*s\n",
|
||||
// hmsg->method, hmsg->major_version, hmsg->minor_version,
|
||||
// hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
|
||||
printf( "method = %d, version = %d.%d, url = %.*s\n",
|
||||
hmsg->method, hmsg->major_version, hmsg->minor_version,
|
||||
(int)hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff);
|
||||
} else {
|
||||
// printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
|
||||
// hmsg->status_code, hmsg->major_version, hmsg->minor_version,
|
||||
// (int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
||||
printf( "resp status = %d, version = %d.%d, status msg = %.*s\n",
|
||||
hmsg->status_code, hmsg->major_version, hmsg->minor_version,
|
||||
(int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
||||
}
|
||||
|
||||
// print headers
|
||||
|
||||
node = ListHead( &hmsg->headers );
|
||||
//NNS: node = dlist_first_node( &hmsg->headers );
|
||||
// NNS: node = dlist_first_node( &hmsg->headers );
|
||||
while( node != NULL ) {
|
||||
|
||||
header = ( http_header_t * ) node->item;
|
||||
//NNS: header = (http_header_t *)node->data;
|
||||
//printf( "hdr name: %.*s, value: %.*s\n",
|
||||
// (int)header->name.length, header->name.buf,
|
||||
// (int)header->value.length, header->value.buf );
|
||||
// NNS: header = (http_header_t *)node->data;
|
||||
printf( "hdr name: %.*s, value: %.*s\n",
|
||||
(int)header->name.length, header->name.buf,
|
||||
(int)header->value.length, header->value.buf );
|
||||
|
||||
node = ListNext( &hmsg->headers, node );
|
||||
|
||||
//NNS: node = dlist_next( &hmsg->headers, node );
|
||||
// NNS: node = dlist_next( &hmsg->headers, node );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -118,7 +118,7 @@ static xboolean gInitialized = FALSE;
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
init_table( IN const char *encoded_str,
|
||||
OUT const char *table[],
|
||||
IN int tbl_size )
|
||||
@@ -144,7 +144,7 @@ init_table( IN const char *encoded_str,
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
init_tables( void )
|
||||
{
|
||||
init_table( Http1xxStr, Http1xxCodes, NUM_1XX_CODES );
|
||||
|
||||
@@ -37,6 +37,12 @@
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef UPNP_USE_BCBPP
|
||||
#ifndef UPNP_USE_MSVCPP
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "util.h"
|
||||
#include "strintmap.h"
|
||||
#include "membuffer.h"
|
||||
@@ -49,7 +55,7 @@
|
||||
#include "ssdplib.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include "ithread.h"
|
||||
@@ -199,7 +205,7 @@ extern str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES];
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
media_list_init( void )
|
||||
{
|
||||
int i;
|
||||
@@ -237,7 +243,7 @@ media_list_init( void )
|
||||
* 0 on success;
|
||||
* -1 on error
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
search_extension( IN const char *extension,
|
||||
OUT const char **con_type,
|
||||
OUT const char **con_subtype )
|
||||
@@ -284,7 +290,7 @@ search_extension( IN const char *extension,
|
||||
* 0 - On Sucess
|
||||
* UPNP_E_OUTOF_MEMORY - on memory allocation failures
|
||||
************************************************************************/
|
||||
XINLINE int
|
||||
UPNP_INLINE int
|
||||
get_content_type( IN const char *filename,
|
||||
OUT DOMString * content_type )
|
||||
{
|
||||
@@ -342,7 +348,7 @@ get_content_type( IN const char *filename,
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
glob_alias_init( void )
|
||||
{
|
||||
struct xml_alias_t *alias = &gAliasDoc;
|
||||
@@ -364,7 +370,7 @@ glob_alias_init( void )
|
||||
* Returns:
|
||||
* BOOLEAN
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
is_valid_alias( IN const struct xml_alias_t *alias )
|
||||
{
|
||||
return alias->doc.buf != NULL;
|
||||
@@ -631,13 +637,13 @@ get_file_info( IN const char *filename,
|
||||
|
||||
rc = get_content_type( filename, &info->content_type );
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"file info: %s, length: %d, last_mod=%s readable=%d\n",
|
||||
filename, info->file_length,
|
||||
asctime( gmtime( &info->last_modified ) ),
|
||||
info->is_readable ); )
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
|
||||
filename, (long long)info->file_length,
|
||||
asctime( gmtime( &info->last_modified ) ),
|
||||
info->is_readable );
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@@ -694,7 +700,7 @@ web_server_set_root_dir( IN const char *root_dir )
|
||||
* TRUE - On Success
|
||||
* FALSE if request is not an alias
|
||||
************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
get_alias( IN const char *request_file,
|
||||
OUT struct xml_alias_t *alias,
|
||||
OUT struct File_Info *info )
|
||||
@@ -871,8 +877,8 @@ StrTok( char **Src,
|
||||
************************************************************************/
|
||||
int
|
||||
GetNextRange( char **SrcRangeStr,
|
||||
int *FirstByte,
|
||||
int *LastByte )
|
||||
off_t *FirstByte,
|
||||
off_t *LastByte )
|
||||
{
|
||||
char *Ptr,
|
||||
*Tok;
|
||||
@@ -936,11 +942,11 @@ GetNextRange( char **SrcRangeStr,
|
||||
************************************************************************/
|
||||
int
|
||||
CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
|
||||
long FileLength,
|
||||
off_t FileLength,
|
||||
OUT struct SendInstruction *Instr )
|
||||
{
|
||||
|
||||
int FirstByte,
|
||||
off_t FirstByte,
|
||||
LastByte;
|
||||
char *RangeInput,
|
||||
*Ptr;
|
||||
@@ -984,28 +990,36 @@ CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
|
||||
|
||||
Instr->RangeOffset = FirstByte;
|
||||
Instr->ReadSendSize = LastByte - FirstByte + 1;
|
||||
sprintf( Instr->RangeHeader, "CONTENT-RANGE: bytes %d-%d/%ld\r\n", FirstByte, LastByte, FileLength ); //Data between two range.
|
||||
sprintf( Instr->RangeHeader,
|
||||
"CONTENT-RANGE: bytes %"PRId64"-%"PRId64"/%"PRId64"\r\n",
|
||||
(int64_t)FirstByte,
|
||||
(int64_t)LastByte,
|
||||
(int64_t)FileLength ); //Data between two range.
|
||||
} else if( FirstByte >= 0 && LastByte == -1
|
||||
&& FirstByte < FileLength ) {
|
||||
Instr->RangeOffset = FirstByte;
|
||||
Instr->ReadSendSize = FileLength - FirstByte;
|
||||
sprintf( Instr->RangeHeader,
|
||||
"CONTENT-RANGE: bytes %d-%ld/%ld\r\n", FirstByte,
|
||||
FileLength - 1, FileLength );
|
||||
"CONTENT-RANGE: bytes %"PRId64"-%"PRId64"/%"PRId64"\r\n",
|
||||
(int64_t)FirstByte,
|
||||
(int64_t)(FileLength - 1),
|
||||
(int64_t)FileLength );
|
||||
} else if( FirstByte == -1 && LastByte > 0 ) {
|
||||
if( LastByte >= FileLength ) {
|
||||
Instr->RangeOffset = 0;
|
||||
Instr->ReadSendSize = FileLength;
|
||||
sprintf( Instr->RangeHeader,
|
||||
"CONTENT-RANGE: bytes 0-%ld/%ld\r\n",
|
||||
FileLength - 1, FileLength );
|
||||
"CONTENT-RANGE: bytes 0-%"PRId64"/%"PRId64"\r\n",
|
||||
(int64_t)(FileLength - 1),
|
||||
(int64_t)FileLength );
|
||||
} else {
|
||||
Instr->RangeOffset = FileLength - LastByte;
|
||||
Instr->ReadSendSize = LastByte;
|
||||
sprintf( Instr->RangeHeader,
|
||||
"CONTENT-RANGE: bytes %ld-%ld/%ld\r\n",
|
||||
FileLength - LastByte + 1, FileLength,
|
||||
FileLength );
|
||||
"CONTENT-RANGE: bytes %"PRId64"-%"PRId64"/%"PRId64"\r\n",
|
||||
(int64_t)(FileLength - LastByte + 1),
|
||||
(int64_t)FileLength,
|
||||
(int64_t)FileLength );
|
||||
}
|
||||
} else {
|
||||
free( RangeInput );
|
||||
@@ -1042,7 +1056,7 @@ CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
|
||||
int
|
||||
CheckOtherHTTPHeaders( IN http_message_t * Req,
|
||||
OUT struct SendInstruction *RespInstr,
|
||||
int FileSize )
|
||||
off_t FileSize )
|
||||
{
|
||||
http_header_t *header;
|
||||
ListNode *node;
|
||||
@@ -1184,7 +1198,6 @@ process_request( IN http_message_t * req,
|
||||
int code;
|
||||
int err_code;
|
||||
|
||||
//membuffer content_type;
|
||||
char *request_doc;
|
||||
struct File_Info finfo;
|
||||
xboolean using_alias;
|
||||
@@ -1194,7 +1207,7 @@ process_request( IN http_message_t * req,
|
||||
int resp_major,
|
||||
resp_minor;
|
||||
xboolean alias_grabbed;
|
||||
int dummy;
|
||||
size_t dummy;
|
||||
struct UpnpVirtualDirCallbacks *pVirtualDirCallback;
|
||||
|
||||
print_http_headers( req );
|
||||
@@ -1208,7 +1221,6 @@ process_request( IN http_message_t * req,
|
||||
// init
|
||||
request_doc = NULL;
|
||||
finfo.content_type = NULL;
|
||||
//membuffer_init( &content_type );
|
||||
alias_grabbed = FALSE;
|
||||
err_code = HTTP_INTERNAL_SERVER_ERROR; // default error
|
||||
using_virtual_dir = FALSE;
|
||||
@@ -1362,7 +1374,7 @@ process_request( IN http_message_t * req,
|
||||
|
||||
RespInstr->ReadSendSize = finfo.file_length;
|
||||
|
||||
//Check other header field.
|
||||
// Check other header field.
|
||||
if( ( err_code =
|
||||
CheckOtherHTTPHeaders( req, RespInstr,
|
||||
finfo.file_length ) ) != HTTP_OK ) {
|
||||
@@ -1376,85 +1388,80 @@ process_request( IN http_message_t * req,
|
||||
}
|
||||
|
||||
if( RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
|
||||
|
||||
/* - PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net>
|
||||
* added X-User-Agent header
|
||||
*/
|
||||
|
||||
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
//Transfer-Encoding: chunked
|
||||
// K means add chunky header ang G means range header.
|
||||
if( http_MakeMessage( headers, resp_major, resp_minor, "RTGKDstcSXcCc", HTTP_PARTIAL_CONTENT, // status code
|
||||
// RespInstr->ReadSendSize,// content length
|
||||
finfo.content_type,
|
||||
// content_type.buf, // content type
|
||||
RespInstr, // Range
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
// Transfer-Encoding: chunked
|
||||
if (http_MakeMessage(
|
||||
headers, resp_major, resp_minor,
|
||||
"R" "T" "GKD" "s" "tcS" "XcCc",
|
||||
HTTP_PARTIAL_CONTENT, // status code
|
||||
finfo.content_type, // content type
|
||||
RespInstr, // range info
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
} else if( RespInstr->IsRangeActive && !RespInstr->IsChunkActive ) {
|
||||
|
||||
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
//Transfer-Encoding: chunked
|
||||
// K means add chunky header ang G means range header.
|
||||
if( http_MakeMessage( headers, resp_major, resp_minor, "RNTGDstcSXcCc", HTTP_PARTIAL_CONTENT, // status code
|
||||
RespInstr->ReadSendSize, // content length
|
||||
finfo.content_type,
|
||||
//content_type.buf, // content type
|
||||
RespInstr, //Range Info
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
// Transfer-Encoding: chunked
|
||||
if (http_MakeMessage(
|
||||
headers, resp_major, resp_minor,
|
||||
"R" "N" "T" "GD" "s" "tcS" "XcCc",
|
||||
HTTP_PARTIAL_CONTENT, // status code
|
||||
RespInstr->ReadSendSize, // content length
|
||||
finfo.content_type, // content type
|
||||
RespInstr, // range info
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
} else if( !RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
|
||||
|
||||
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
//Transfer-Encoding: chunked
|
||||
// K means add chunky header ang G means range header.
|
||||
if( http_MakeMessage( headers, resp_major, resp_minor, "RKTDstcSXcCc", HTTP_OK, // status code
|
||||
//RespInstr->ReadSendSize,// content length
|
||||
finfo.content_type,
|
||||
// content_type.buf, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
// Transfer-Encoding: chunked
|
||||
if (http_MakeMessage(
|
||||
headers, resp_major, resp_minor,
|
||||
"RK" "TD" "s" "tcS" "XcCc",
|
||||
HTTP_OK, // status code
|
||||
finfo.content_type, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
} else {
|
||||
if( RespInstr->ReadSendSize >= 0 ) {
|
||||
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
//Transfer-Encoding: chunked
|
||||
// K means add chunky header ang G means range header.
|
||||
if( http_MakeMessage( headers, resp_major, resp_minor, "RNTDstcSXcCc", HTTP_OK, // status code
|
||||
RespInstr->ReadSendSize, // content length
|
||||
finfo.content_type,
|
||||
//content_type.buf, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
} else { // !RespInstr->IsRangeActive && !RespInstr->IsChunkActive
|
||||
if (RespInstr->ReadSendSize >= 0) {
|
||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
// Transfer-Encoding: chunked
|
||||
if (http_MakeMessage(
|
||||
headers, resp_major, resp_minor,
|
||||
"R" "N" "TD" "s" "tcS" "XcCc",
|
||||
HTTP_OK, // status code
|
||||
RespInstr->ReadSendSize, // content length
|
||||
finfo.content_type, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
} else {
|
||||
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
//Transfer-Encoding: chunked
|
||||
// K means add chunky header ang G means range header.
|
||||
if( http_MakeMessage( headers, resp_major, resp_minor, "RTDstcSXcCc", HTTP_OK, // status code
|
||||
//RespInstr->ReadSendSize,// content length
|
||||
finfo.content_type,
|
||||
//content_type.buf, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||
// Transfer-Encoding: chunked
|
||||
if (http_MakeMessage(
|
||||
headers, resp_major, resp_minor,
|
||||
"R" "TD" "s" "tcS" "XcCc",
|
||||
HTTP_OK, // status code
|
||||
finfo.content_type, // content type
|
||||
"LAST-MODIFIED: ",
|
||||
&finfo.last_modified,
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -- PATCH END -- */
|
||||
|
||||
if( req->method == HTTPMETHOD_HEAD ) {
|
||||
*rtype = RESP_HEADERS;
|
||||
@@ -1468,8 +1475,8 @@ process_request( IN http_message_t * req,
|
||||
*rtype = RESP_FILEDOC;
|
||||
}
|
||||
|
||||
//simple get http 0.9 as specified in http 1.0
|
||||
//don't send headers
|
||||
// simple get http 0.9 as specified in http 1.0
|
||||
// don't send headers
|
||||
if( req->method == HTTPMETHOD_SIMPLEGET ) {
|
||||
membuffer_destroy( headers );
|
||||
}
|
||||
@@ -1479,7 +1486,6 @@ process_request( IN http_message_t * req,
|
||||
error_handler:
|
||||
free( request_doc );
|
||||
ixmlFreeDOMString( finfo.content_type );
|
||||
// membuffer_destroy( &content_type );
|
||||
if( err_code != UPNP_E_SUCCESS && alias_grabbed ) {
|
||||
alias_release( alias );
|
||||
}
|
||||
@@ -1580,14 +1586,11 @@ http_RecvPostMessage( http_parser_t * parser,
|
||||
}
|
||||
} else if( num_read == 0 ) {
|
||||
if( ok_on_close ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||
parser->msg.msg.buf );
|
||||
//print_http_headers( &parser->msg );
|
||||
)
|
||||
|
||||
parser->position = POS_COMPLETE;
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||
parser->msg.msg.buf );
|
||||
print_http_headers( &parser->msg );
|
||||
parser->position = POS_COMPLETE;
|
||||
} else {
|
||||
// partial msg
|
||||
parser->http_error_code = HTTP_BAD_REQUEST; // or response
|
||||
@@ -1738,12 +1741,12 @@ web_server_callback( IN http_parser_t * parser,
|
||||
&RespInstr );
|
||||
//Send response.
|
||||
|
||||
/* - PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net>
|
||||
* added X-User-Agent header
|
||||
*/
|
||||
http_MakeMessage( &headers, 1, 1, "RTDSXcCc", ret,
|
||||
"text/html", X_USER_AGENT );
|
||||
/* - PATCH END --- */
|
||||
http_MakeMessage(
|
||||
&headers, 1, 1,
|
||||
"RTDSXcCc",
|
||||
ret,
|
||||
"text/html",
|
||||
X_USER_AGENT );
|
||||
|
||||
http_SendMessage( info, &timeout, "b", headers.buf,
|
||||
headers.length );
|
||||
@@ -1754,10 +1757,9 @@ web_server_callback( IN http_parser_t * parser,
|
||||
}
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"webserver: request processed...\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||
"webserver: request processed...\n" );
|
||||
|
||||
membuffer_destroy( &headers );
|
||||
membuffer_destroy( &headers );
|
||||
membuffer_destroy( &filename );
|
||||
}
|
||||
|
||||
@@ -34,8 +34,11 @@
|
||||
************************************************************************/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <osreldate.h>
|
||||
#if __FreeBSD_version < 601103
|
||||
#include <lwres/netdb.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "uri.h"
|
||||
|
||||
@@ -125,7 +128,7 @@ is_unreserved( char in )
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
is_escaped( char *in )
|
||||
is_escaped( const char *in )
|
||||
{
|
||||
|
||||
if( ( in[0] == '%' ) && ( isxdigit( in[1] ) ) && isxdigit( in[2] ) ) {
|
||||
@@ -157,7 +160,7 @@ is_escaped( char *in )
|
||||
int
|
||||
replace_escaped( char *in,
|
||||
int index,
|
||||
int *max )
|
||||
size_t *max )
|
||||
{
|
||||
int tempInt = 0;
|
||||
char tempChar = 0;
|
||||
@@ -204,7 +207,7 @@ replace_escaped( char *in,
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
parse_uric( char *in,
|
||||
parse_uric( const char *in,
|
||||
int max,
|
||||
token * out )
|
||||
{
|
||||
@@ -364,16 +367,20 @@ free_URL_list( URL_list * list )
|
||||
* uri_type *in ; URI object
|
||||
*
|
||||
* Description : Function useful in debugging for printing a parsed uri.
|
||||
* Compiled out with DBGONLY macro.
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY( void print_uri( uri_type * in ) {
|
||||
print_token( &in->scheme );
|
||||
print_token( &in->hostport.text );
|
||||
print_token( &in->pathquery ); print_token( &in->fragment );} )
|
||||
#ifdef DEBUG
|
||||
void print_uri( uri_type *in )
|
||||
{
|
||||
print_token( &in->scheme );
|
||||
print_token( &in->hostport.text );
|
||||
print_token( &in->pathquery );
|
||||
print_token( &in->fragment );
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : print_token
|
||||
@@ -382,20 +389,23 @@ DBGONLY( void print_uri( uri_type * in ) {
|
||||
* token * in ; token
|
||||
*
|
||||
* Description : Function useful in debugging for printing a token.
|
||||
* Compiled out with DBGONLY macro.
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY( void print_token( token * in ) {
|
||||
int i = 0;
|
||||
printf( "Token Size : %d\n\'", in->size );
|
||||
for( i = 0; i < in->size; i++ ) {
|
||||
putchar( in->buff[i] );}
|
||||
putchar( '\'' ); putchar( '\n' );}
|
||||
|
||||
)
|
||||
#ifdef DEBUG
|
||||
void print_token(token * in)
|
||||
{
|
||||
int i = 0;
|
||||
printf( "Token Size : %"PRIzu"\n\'", in->size );
|
||||
for( i = 0; i < in->size; i++ ) {
|
||||
putchar( in->buff[i] );
|
||||
}
|
||||
putchar( '\'' );
|
||||
putchar( '\n' );
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : token_string_casecmp
|
||||
@@ -414,8 +424,10 @@ DBGONLY( void print_token( token * in ) {
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int token_string_casecmp( token * in1,
|
||||
char *in2 ) {
|
||||
int token_string_casecmp(
|
||||
token * in1,
|
||||
char *in2 )
|
||||
{
|
||||
int in2_length = strlen( in2 );
|
||||
|
||||
if( in1->size != in2_length )
|
||||
@@ -496,12 +508,12 @@ token_cmp( token * in1,
|
||||
************************************************************************/
|
||||
int
|
||||
parse_port( int max,
|
||||
char *port,
|
||||
const char *port,
|
||||
unsigned short *out )
|
||||
{
|
||||
|
||||
char *finger = port;
|
||||
char *max_ptr = finger + max;
|
||||
const char *finger = port;
|
||||
const char *max_ptr = finger + max;
|
||||
unsigned short temp = 0;
|
||||
|
||||
while( ( finger < max_ptr ) && ( isdigit( *finger ) ) ) {
|
||||
@@ -533,7 +545,7 @@ parse_port( int max,
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
parse_hostport( char *in,
|
||||
parse_hostport( const char *in,
|
||||
int max,
|
||||
hostport_type * out )
|
||||
{
|
||||
@@ -611,14 +623,16 @@ parse_hostport( char *in,
|
||||
int errCode = 0;
|
||||
|
||||
//call gethostbyname_r (reentrant form of gethostbyname)
|
||||
#if defined(WIN32)
|
||||
// TODO: Use autoconf to discover this rather than the
|
||||
// platform-specific stuff below
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
h=gethostbyname(temp_host_name);
|
||||
#elif defined(SPARC_SOLARIS)
|
||||
errCode = gethostbyname_r( temp_host_name,
|
||||
&h,
|
||||
temp_hostbyname_buff,
|
||||
BUFFER_SIZE, &errcode );
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) && __FreeBSD_version < 601103
|
||||
h = lwres_gethostbyname_r( temp_host_name,
|
||||
&h_buf,
|
||||
temp_hostbyname_buff,
|
||||
@@ -681,7 +695,7 @@ parse_hostport( char *in,
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
parse_scheme( char *in,
|
||||
parse_scheme( const char *in,
|
||||
int max,
|
||||
token * out )
|
||||
{
|
||||
@@ -731,7 +745,7 @@ parse_scheme( char *in,
|
||||
************************************************************************/
|
||||
int
|
||||
remove_escaped_chars( INOUT char *in,
|
||||
INOUT int *size )
|
||||
INOUT size_t *size )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -785,9 +799,8 @@ remove_dots( char *in,
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
|
||||
Segments[0] = NULL;
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"REMOVE_DOTS: before: %s\n", in ) );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"REMOVE_DOTS: before: %s\n", in );
|
||||
while( ( copyFrom < max ) && ( *copyFrom != '?' )
|
||||
&& ( *copyFrom != '#' ) ) {
|
||||
|
||||
@@ -832,9 +845,8 @@ remove_dots( char *in,
|
||||
}
|
||||
( *copyTo ) = 0;
|
||||
free( Segments );
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"REMOVE_DOTS: after: %s\n", in ) );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"REMOVE_DOTS: after: %s\n", in );
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -994,7 +1006,7 @@ resolve_rel_url( char *base_url,
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
parse_uri( char *in,
|
||||
parse_uri( const char *in,
|
||||
int max,
|
||||
uri_type * out )
|
||||
{
|
||||
@@ -1067,15 +1079,15 @@ parse_uri( char *in,
|
||||
int
|
||||
parse_uri_and_unescape( char *in,
|
||||
int max,
|
||||
uri_type * out )
|
||||
uri_type *out )
|
||||
{
|
||||
int ret;
|
||||
|
||||
if( ( ret = parse_uri( in, max, out ) ) != HTTP_SUCCESS )
|
||||
return ret;
|
||||
if( out->pathquery.size > 0 )
|
||||
remove_escaped_chars( out->pathquery.buff, &out->pathquery.size );
|
||||
remove_escaped_chars( (char *)out->pathquery.buff, &out->pathquery.size );
|
||||
if( out->fragment.size > 0 )
|
||||
remove_escaped_chars( out->fragment.buff, &out->fragment.size );
|
||||
remove_escaped_chars( (char *)out->fragment.buff, &out->fragment.size );
|
||||
return HTTP_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ FindServiceEventURLPath( service_table * table,
|
||||
************************************************************************/
|
||||
service_info *
|
||||
FindServiceControlURLPath( service_table * table,
|
||||
char *controlURLPath )
|
||||
const char *controlURLPath )
|
||||
{
|
||||
service_info *finger = NULL;
|
||||
uri_type parsed_url;
|
||||
@@ -433,7 +433,7 @@ FindServiceControlURLPath( service_table * table,
|
||||
*
|
||||
* Parameters :
|
||||
* service_info *service ;Service whose information is to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints information from the
|
||||
@@ -443,38 +443,54 @@ FindServiceControlURLPath( service_table * table,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY( void printService( service_info * service, Dbg_Level level,
|
||||
Dbg_Module module ) {
|
||||
if( service ) {
|
||||
if( service->serviceType )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceType: %s\n", service->serviceType );
|
||||
if( service->serviceId )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "serviceId: %s\n",
|
||||
service->serviceId ); if( service->SCPDURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "SCPDURL: %s\n",
|
||||
service->SCPDURL ); if( service->controlURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "controlURL: %s\n",
|
||||
service->controlURL ); if( service->eventURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "eventURL: %s\n",
|
||||
service->eventURL ); if( service->UDN )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n",
|
||||
service->UDN ); if( service->active )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is active\n" );
|
||||
else
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is inactive\n" );}
|
||||
}
|
||||
|
||||
)
|
||||
#ifdef DEBUG
|
||||
void printService(
|
||||
service_info *service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module )
|
||||
{
|
||||
if( service ) {
|
||||
if( service->serviceType ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceType: %s\n", service->serviceType );
|
||||
}
|
||||
if( service->serviceId ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceId: %s\n", service->serviceId );
|
||||
}
|
||||
if( service->SCPDURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"SCPDURL: %s\n", service->SCPDURL );
|
||||
}
|
||||
if( service->controlURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"controlURL: %s\n", service->controlURL );
|
||||
}
|
||||
if( service->eventURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"eventURL: %s\n", service->eventURL );
|
||||
}
|
||||
if( service->UDN ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"UDN: %s\n\n", service->UDN );
|
||||
}
|
||||
if( service->active ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is active\n" );
|
||||
} else {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is inactive\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : printServiceList
|
||||
*
|
||||
* Parameters :
|
||||
* service_info *service ; Service whose information is to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints information of each
|
||||
@@ -484,43 +500,55 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY( void printServiceList( service_info * service,
|
||||
Dbg_Level level,
|
||||
Dbg_Module module ) {
|
||||
while( service ) {
|
||||
if( service->serviceType )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceType: %s\n", service->serviceType );
|
||||
if( service->serviceId )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceId: %s\n", service->serviceId );
|
||||
if( service->SCPDURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"SCPDURL: %s\n", service->SCPDURL );
|
||||
if( service->controlURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"controlURL: %s\n", service->controlURL );
|
||||
if( service->eventURL )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"eventURL: %s\n", service->eventURL );
|
||||
if( service->UDN )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n",
|
||||
service->UDN ); if( service->active )
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is active\n" );
|
||||
else
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is inactive\n" );
|
||||
service = service->next;}
|
||||
}
|
||||
)
|
||||
#ifdef DEBUG
|
||||
void printServiceList(
|
||||
service_info * service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module )
|
||||
{
|
||||
while( service ) {
|
||||
if( service->serviceType ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceType: %s\n", service->serviceType );
|
||||
}
|
||||
if( service->serviceId ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"serviceId: %s\n", service->serviceId );
|
||||
}
|
||||
if( service->SCPDURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"SCPDURL: %s\n", service->SCPDURL );
|
||||
}
|
||||
if( service->controlURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"controlURL: %s\n", service->controlURL );
|
||||
}
|
||||
if( service->eventURL ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"eventURL: %s\n", service->eventURL );
|
||||
}
|
||||
if( service->UDN ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"UDN: %s\n\n", service->UDN );
|
||||
}
|
||||
if( service->active ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is active\n" );
|
||||
} else {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Service is inactive\n" );
|
||||
}
|
||||
service = service->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : printServiceTable
|
||||
*
|
||||
* Parameters :
|
||||
* service_table * table ; Service table to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints the URL base of the table
|
||||
@@ -531,15 +559,18 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY( void printServiceTable( service_table * table,
|
||||
Dbg_Level level,
|
||||
Dbg_Module module ) {
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"URL_BASE: %s\n", table->URLBase );
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Services: \n" );
|
||||
printServiceList( table->serviceList, level, module );}
|
||||
)
|
||||
#ifdef DEBUG
|
||||
void printServiceTable(
|
||||
service_table * table,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module )
|
||||
{
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"URL_BASE: %s\n", table->URLBase );
|
||||
UpnpPrintf( level, module, __FILE__, __LINE__,
|
||||
"Services: \n" );
|
||||
printServiceList( table->serviceList, level, module );}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : freeService
|
||||
@@ -554,7 +585,7 @@ DBGONLY( void printService( service_info * service, Dbg_Level level,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void freeService( service_info * in )
|
||||
void freeService( service_info * in )
|
||||
{
|
||||
if( in ) {
|
||||
if( in->serviceType )
|
||||
@@ -664,7 +695,7 @@ DOMString
|
||||
getElementValue( IXML_Node * node )
|
||||
{
|
||||
IXML_Node *child = ( IXML_Node * ) ixmlNode_getFirstChild( node );
|
||||
DOMString temp = NULL;
|
||||
const DOMString temp = NULL;
|
||||
|
||||
if( ( child != 0 ) && ( ixmlNode_getNodeType( child ) == eTEXT_NODE ) ) {
|
||||
temp = ixmlNode_getNodeValue( child );
|
||||
@@ -849,12 +880,10 @@ getServiceList( IXML_Node * node,
|
||||
( !
|
||||
( current->controlURL =
|
||||
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"BAD OR MISSING CONTROL URL" ) );
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"CONTROL URL SET TO NULL IN SERVICE INFO" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"BAD OR MISSING CONTROL URL" );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"CONTROL URL SET TO NULL IN SERVICE INFO" );
|
||||
current->controlURL = NULL;
|
||||
fail = 0;
|
||||
}
|
||||
@@ -870,12 +899,10 @@ getServiceList( IXML_Node * node,
|
||||
( !
|
||||
( current->eventURL =
|
||||
resolve_rel_url( URLBase, tempDOMString ) ) ) ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"BAD OR MISSING EVENT URL" ) );
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"EVENT URL SET TO NULL IN SERVICE INFO" ) );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"BAD OR MISSING EVENT URL" );
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"EVENT URL SET TO NULL IN SERVICE INFO" );
|
||||
current->eventURL = NULL;
|
||||
fail = 0;
|
||||
}
|
||||
@@ -908,20 +935,20 @@ getServiceList( IXML_Node * node,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : getAllServiceList
|
||||
* Function : getAllServiceList
|
||||
*
|
||||
* Parameters :
|
||||
* IXML_Node *node ; XML node information
|
||||
* char * URLBase ; provides Base URL to resolve relative URL
|
||||
* service_info **out_end ; service added is returned to the output
|
||||
* parameter
|
||||
* Parameters :
|
||||
* IXML_Node *node ; XML node information
|
||||
* char * URLBase ; provides Base URL to resolve relative URL
|
||||
* service_info **out_end ; service added is returned to the output
|
||||
* parameter
|
||||
*
|
||||
* Description : Returns pointer to service info after getting the
|
||||
* Description : Returns pointer to service info after getting the
|
||||
* sub-elements of the service info.
|
||||
*
|
||||
* Return : service_info * ;
|
||||
* Return : service_info * ;
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
************************************************************************/
|
||||
service_info *
|
||||
getAllServiceList( IXML_Node * node,
|
||||
@@ -1092,20 +1119,20 @@ addServiceTable( IXML_Node * node,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : getServiceTable
|
||||
*
|
||||
* Parameters :
|
||||
* IXML_Node *node ; XML node information
|
||||
* service_table *out ; output parameter which will contain the
|
||||
* service list and URL
|
||||
* const char *DefaultURLBase ; Default base URL on which the URL
|
||||
* will be returned.
|
||||
*
|
||||
* Description : Retrieve service from the table
|
||||
*
|
||||
* Return : int ;
|
||||
*
|
||||
* Note :
|
||||
* Function : getServiceTable
|
||||
*
|
||||
* Parameters :
|
||||
* IXML_Node *node ; XML node information
|
||||
* service_table *out ; output parameter which will contain the
|
||||
* service list and URL
|
||||
* const char *DefaultURLBase ; Default base URL on which the URL
|
||||
* will be returned.
|
||||
*
|
||||
* Description : Retrieve service from the table
|
||||
*
|
||||
* Return : int ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int
|
||||
getServiceTable( IXML_Node * node,
|
||||
@@ -1126,9 +1153,8 @@ getServiceTable( IXML_Node * node,
|
||||
}
|
||||
}
|
||||
|
||||
if( ( out->serviceList = getAllServiceList( root, out->URLBase,
|
||||
&out->
|
||||
endServiceList ) ) ) {
|
||||
if( ( out->serviceList = getAllServiceList(
|
||||
root, out->URLBase, &out->endServiceList ) ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ memptr_cmp_nocase( IN memptr * m,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
membuffer_initialize( INOUT membuffer * m )
|
||||
{
|
||||
m->buf = NULL;
|
||||
@@ -331,9 +331,10 @@ membuffer_assign( INOUT membuffer * m,
|
||||
return return_code;
|
||||
}
|
||||
// copy
|
||||
memcpy( m->buf, buf, buf_len );
|
||||
m->buf[buf_len] = 0; // null-terminate
|
||||
|
||||
if( buf_len ) {
|
||||
memcpy( m->buf, buf, buf_len );
|
||||
m->buf[buf_len] = 0; // null-terminate
|
||||
}
|
||||
m->length = buf_len;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -95,6 +95,17 @@
|
||||
#define MAX_THREADS 12
|
||||
//@}
|
||||
|
||||
/** @name MAX_JOBS_TOTAL
|
||||
* The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
|
||||
* that can be queued. If this limit is reached further jobs will be thrown
|
||||
* to avoid memory exhaustion. The default value 100.
|
||||
* (Added by Axis.)
|
||||
*/
|
||||
|
||||
//@{
|
||||
#define MAX_JOBS_TOTAL 100
|
||||
//@}
|
||||
|
||||
/** @name DEFAULT_SOAP_CONTENT_LENGTH
|
||||
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
||||
* This prevents devices that have a misbehaving web server to send
|
||||
@@ -293,27 +304,6 @@
|
||||
|
||||
|
||||
|
||||
/** @name DBGONLY
|
||||
The {\bf DBGONLY} macro allows code to be marked so that it
|
||||
is only included in the DEBUG build and not the release. To
|
||||
use this macro, put the code inside of the parentheses:
|
||||
|
||||
{\tt DBGONLY(int i;)}
|
||||
|
||||
This will cause a declaration of the integer {\tt i} only
|
||||
in the debug build.
|
||||
*/
|
||||
|
||||
//@{
|
||||
#ifdef DEBUG
|
||||
# define DBGONLY(x) x
|
||||
#else
|
||||
# define DBGONLY(x)
|
||||
#endif
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
#undef EXCLUDE_WEB_SERVER
|
||||
#undef EXCLUDE_MINISERVER
|
||||
#ifdef INTERNAL_WEB_SERVER
|
||||
@@ -348,13 +338,6 @@
|
||||
# define CLIENTONLY(x)
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
# define DEVICEONLY(x) x
|
||||
#else
|
||||
# define DEVICEONLY(x)
|
||||
#endif
|
||||
|
||||
//@}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -89,25 +89,26 @@
|
||||
#define DEFAULT_TIMEOUT 1801
|
||||
|
||||
|
||||
|
||||
extern ithread_mutex_t GlobalClientSubscribeMutex;
|
||||
|
||||
//Lock the subscription
|
||||
// Lock the subscription
|
||||
#define SubscribeLock() \
|
||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \
|
||||
"Trying Subscribe Lock")); \
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||
"Trying Subscribe Lock"); \
|
||||
ithread_mutex_lock(&GlobalClientSubscribeMutex); \
|
||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe Lock");)
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||
"Subscribe Lock");
|
||||
|
||||
//Unlock the subscription
|
||||
// Unlock the subscription
|
||||
#define SubscribeUnlock() \
|
||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \
|
||||
"Trying Subscribe UnLock")); \
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||
"Trying Subscribe UnLock"); \
|
||||
ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
|
||||
DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe UnLock");)
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
|
||||
"Subscribe UnLock");
|
||||
|
||||
|
||||
//Structure to send NOTIFY message to all subscribed control points
|
||||
// Structure to send NOTIFY message to all subscribed control points
|
||||
typedef struct NOTIFY_THREAD_STRUCT {
|
||||
char * headers;
|
||||
DOMString propertySet;
|
||||
@@ -161,11 +162,13 @@ EXTERN_C void genaCallback (IN http_parser_t *parser,
|
||||
* return UPNP_E_SUCCESS if service response is OK else
|
||||
* returns appropriate error
|
||||
***************************************************************************/
|
||||
CLIENTONLY(
|
||||
EXTERN_C int genaSubscribe(UpnpClient_Handle client_handle,
|
||||
char * PublisherURL,
|
||||
int * TimeOut,
|
||||
Upnp_SID out_sid );)
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
EXTERN_C int genaSubscribe(
|
||||
UpnpClient_Handle client_handle,
|
||||
char * PublisherURL,
|
||||
int * TimeOut,
|
||||
Upnp_SID out_sid );
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@@ -184,8 +187,11 @@ CLIENTONLY(
|
||||
* return UPNP_E_SUCCESS if service response is OK else
|
||||
* returns appropriate error
|
||||
***************************************************************************/
|
||||
CLIENTONLY(EXTERN_C int genaUnSubscribe(UpnpClient_Handle client_handle,
|
||||
const Upnp_SID in_sid);)
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
EXTERN_C int genaUnSubscribe(
|
||||
UpnpClient_Handle client_handle,
|
||||
const Upnp_SID in_sid);
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : genaUnregisterClient
|
||||
@@ -202,8 +208,9 @@ CLIENTONLY(EXTERN_C int genaUnSubscribe(UpnpClient_Handle client_handle,
|
||||
* Returns: int
|
||||
* return UPNP_E_SUCCESS if successful else returns appropriate error
|
||||
***************************************************************************/
|
||||
CLIENTONLY(EXTERN_C int genaUnregisterClient(
|
||||
UpnpClient_Handle client_handle);)
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
EXTERN_C int genaUnregisterClient(UpnpClient_Handle client_handle);
|
||||
#endif
|
||||
|
||||
//server
|
||||
/************************************************************************
|
||||
@@ -218,8 +225,9 @@ CLIENTONLY(EXTERN_C int genaUnregisterClient(
|
||||
* Returns: int
|
||||
* returns UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE
|
||||
****************************************************************************/
|
||||
DEVICEONLY(EXTERN_C int genaUnregisterDevice(
|
||||
UpnpDevice_Handle device_handle);)
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaUnregisterDevice(UpnpDevice_Handle device_handle);
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@@ -242,10 +250,12 @@ DEVICEONLY(EXTERN_C int genaUnregisterDevice(
|
||||
* return UPNP_E_SUCCESS if service response is OK else
|
||||
* returns appropriate error
|
||||
***************************************************************************/
|
||||
CLIENTONLY(EXTERN_C int genaRenewSubscription(
|
||||
IN UpnpClient_Handle client_handle,
|
||||
IN const Upnp_SID in_sid,
|
||||
OUT int * TimeOut);)
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
EXTERN_C int genaRenewSubscription(
|
||||
IN UpnpClient_Handle client_handle,
|
||||
IN const Upnp_SID in_sid,
|
||||
OUT int * TimeOut);
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Function : genaNotifyAll
|
||||
*
|
||||
@@ -265,33 +275,40 @@ CLIENTONLY(EXTERN_C int genaRenewSubscription(
|
||||
* Note : This function is similar to the genaNotifyAllExt. The only difference
|
||||
* is it takes event variable array instead of xml document.
|
||||
****************************************************************************/
|
||||
DEVICEONLY(EXTERN_C int genaNotifyAll(UpnpDevice_Handle device_handle,
|
||||
char *UDN,
|
||||
char *servId,
|
||||
char **VarNames,
|
||||
char **VarValues,
|
||||
int var_count
|
||||
);)
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaNotifyAll(
|
||||
UpnpDevice_Handle device_handle,
|
||||
char *UDN,
|
||||
char *servId,
|
||||
char **VarNames,
|
||||
char **VarValues,
|
||||
int var_count);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaNotifyAllExt
|
||||
* Function : genaNotifyAllExt
|
||||
*
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle : Device handle
|
||||
* IN char *UDN : Device udn
|
||||
* IN char *servId : Service ID
|
||||
* IN IXML_Document *PropSet : XML document Event varible property set
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle : Device handle
|
||||
* IN char *UDN : Device udn
|
||||
* IN char *servId : Service ID
|
||||
* IN IXML_Document *PropSet : XML document Event varible property set
|
||||
*
|
||||
* Description : This function sends a notification to all the subscribed
|
||||
* Description : This function sends a notification to all the subscribed
|
||||
* control points
|
||||
*
|
||||
* Return : int
|
||||
* Return : int
|
||||
*
|
||||
* Note : This function is similar to the genaNotifyAll. the only difference
|
||||
* is it takes the document instead of event variable array
|
||||
* Note : This function is similar to the genaNotifyAll. the only difference
|
||||
* is it takes the document instead of event variable array
|
||||
****************************************************************************/
|
||||
DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle,
|
||||
char *UDN, char *servId,IN IXML_Document *PropSet);)
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaNotifyAllExt(
|
||||
UpnpDevice_Handle device_handle,
|
||||
char *UDN,
|
||||
char *servId,
|
||||
IN IXML_Document *PropSet);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaInitNotify
|
||||
@@ -314,13 +331,15 @@ DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle,
|
||||
* Note : No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
****************************************************************************/
|
||||
DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN char **VarNames,
|
||||
IN char **VarValues,
|
||||
IN int var_count,
|
||||
IN Upnp_SID sid);)
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN char **VarNames,
|
||||
IN char **VarValues,
|
||||
IN int var_count,
|
||||
IN Upnp_SID sid);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaInitNotifyExt
|
||||
@@ -342,12 +361,14 @@ DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
|
||||
* Note : No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
****************************************************************************/
|
||||
DEVICEONLY(EXTERN_C int genaInitNotifyExt(
|
||||
IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN IXML_Document *PropSet,
|
||||
IN Upnp_SID sid);)
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaInitNotifyExt(
|
||||
IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN IXML_Document *PropSet,
|
||||
IN Upnp_SID sid);
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
||||
@@ -96,7 +96,7 @@ typedef struct SOCKET_BUFFER{
|
||||
//holds a pointer into a larger array
|
||||
typedef struct TOKEN {
|
||||
char * buff;
|
||||
int size;
|
||||
size_t size;
|
||||
} token;
|
||||
|
||||
|
||||
@@ -214,37 +214,101 @@ EXTERN_C ssize_t readLine(int fd, char *out, int max, int *timeout);
|
||||
EXTERN_C int remove_dots(char * in, int size);
|
||||
|
||||
|
||||
DBGONLY(EXTERN_C void print_http_request(http_message
|
||||
*message,Dbg_Level DLevel,
|
||||
Dbg_Module Module,char *DbgFileName,
|
||||
int DbgLineNo););
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_http_request(
|
||||
http_message *message,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_http_request(
|
||||
http_message *message,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
DBGONLY(EXTERN_C void print_http_response(http_message *message,
|
||||
Dbg_Level DLevel,
|
||||
Dbg_Module Module,char *DbgFileName,
|
||||
int DbgLineNo););
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_http_response(
|
||||
http_message *message,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_http_response(
|
||||
http_message *message,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
DBGONLY(EXTERN_C void print_token( token * in,
|
||||
Dbg_Level DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo););
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_token(
|
||||
token *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_token(
|
||||
token *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
DBGONLY(EXTERN_C void print_status_line(http_status *in,
|
||||
Dbg_Level DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo););
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_status_line(
|
||||
http_status *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_status_line(
|
||||
http_status *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
DBGONLY(EXTERN_C void print_request_line(http_request *in,
|
||||
Dbg_Level DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,int DbgLineNo));
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_request_line(
|
||||
http_request *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_request_line(
|
||||
http_request *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
DBGONLY(EXTERN_C void print_uri( uri_type *in,
|
||||
Dbg_Level DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo););
|
||||
#ifdef DEBUG
|
||||
EXTERN_C void print_uri(
|
||||
uri_type *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo);
|
||||
#else
|
||||
static inline void print_uri(
|
||||
uri_type *in,
|
||||
Upnp_LogLevel DLevel,
|
||||
Dbg_Module Module,
|
||||
char *DbgFileName,
|
||||
int DbgLineNo) {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -456,6 +456,8 @@ int raw_to_int( IN memptr* raw_value, int base );
|
||||
*
|
||||
* Description: Find a substring from raw character string buffer
|
||||
*
|
||||
* Side effects: raw_value is transformed to lowercase.
|
||||
*
|
||||
* Returns:
|
||||
* int - index at which the substring is found.
|
||||
************************************************************************/
|
||||
@@ -486,7 +488,11 @@ const char* method_to_str( IN http_method_t method );
|
||||
* Returns:
|
||||
* void
|
||||
************************************************************************/
|
||||
void print_http_headers( IN http_message_t* hmsg );
|
||||
#ifdef DEBUG
|
||||
void print_http_headers( IN http_message_t *hmsg );
|
||||
#else
|
||||
static UPNP_INLINE void print_http_headers( IN http_message_t *hmsg ) {}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
@@ -494,3 +500,4 @@ void print_http_headers( IN http_message_t* hmsg );
|
||||
|
||||
|
||||
#endif // GENLIB_NET_HTTP_HTTPPARSER_H
|
||||
|
||||
|
||||
@@ -475,6 +475,7 @@ int http_SendStatusResponse( IN SOCKINFO *info, IN int http_status_code,
|
||||
* memory ptr
|
||||
* 'c': (no args) appends CRLF "\r\n"
|
||||
* 'd': arg = int number // appends decimal number
|
||||
* 'h': arg = off_t number // appends off_t number
|
||||
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
||||
* 'D': (no args) appends HTTP DATE: header
|
||||
* 'S': (no args) appends HTTP SERVER: header
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define socklen_t int
|
||||
typedef int socklen_t;
|
||||
#define EAFNOSUPPORT 97
|
||||
|
||||
/*
|
||||
|
||||
@@ -51,8 +51,7 @@ typedef struct // memptr
|
||||
// note: Total length/capacity should not exceed MAX_INT
|
||||
typedef struct // membuffer
|
||||
{
|
||||
char *buf; // mem buffer; must not write
|
||||
// beyond buf[length-1] (read/write)
|
||||
char *buf; // mem buffer; must not write beyond buf[length-1] (read/write)
|
||||
size_t length; // length of buffer (read-only)
|
||||
size_t capacity; // total allocated memory (read-only)
|
||||
size_t size_inc; // used to increase size; MUST be > 0; (read/write)
|
||||
@@ -148,8 +147,7 @@ int memptr_cmp_nocase( IN memptr* m, IN const char* s );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int membuffer_set_size( INOUT membuffer* m,
|
||||
IN size_t new_length );
|
||||
int membuffer_set_size( INOUT membuffer* m, IN size_t new_length );
|
||||
|
||||
/************************************************************************
|
||||
* Function : membuffer_init
|
||||
@@ -200,8 +198,7 @@ void membuffer_destroy( INOUT membuffer* m );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int membuffer_assign( INOUT membuffer* m, IN const void* buf,
|
||||
IN size_t buf_len );
|
||||
int membuffer_assign( INOUT membuffer* m, IN const void* buf, IN size_t buf_len );
|
||||
|
||||
/************************************************************************
|
||||
* Function : membuffer_assign_str
|
||||
@@ -237,8 +234,7 @@ int membuffer_assign_str( INOUT membuffer* m, IN const char* c_str );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int membuffer_append( INOUT membuffer* m, IN const void* buf,
|
||||
IN size_t buf_len );
|
||||
int membuffer_append( INOUT membuffer* m, IN const void* buf, IN size_t buf_len );
|
||||
|
||||
/************************************************************************
|
||||
* Function : membuffer_append_str
|
||||
@@ -276,8 +272,7 @@ int membuffer_append_str( INOUT membuffer* m, IN const char* c_str );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int membuffer_insert( INOUT membuffer* m, IN const void* buf,
|
||||
IN size_t buf_len, int index );
|
||||
int membuffer_insert( INOUT membuffer* m, IN const void* buf, IN size_t buf_len, int index );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@@ -298,8 +293,7 @@ int membuffer_insert( INOUT membuffer* m, IN const void* buf,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void membuffer_delete( INOUT membuffer* m, IN int index,
|
||||
IN size_t num_bytes );
|
||||
void membuffer_delete( INOUT membuffer* m, IN int index, IN size_t num_bytes );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@@ -336,8 +330,7 @@ char* membuffer_detach( INOUT membuffer* m );
|
||||
* Note : 'new_buf' must be allocted using malloc or realloc so
|
||||
* that it can be freed using free()
|
||||
************************************************************************/
|
||||
void membuffer_attach( INOUT membuffer* m, IN char* new_buf,
|
||||
IN size_t buf_len );
|
||||
void membuffer_attach( INOUT membuffer* m, IN char* new_buf, IN size_t buf_len );
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -88,7 +88,11 @@ void SetHTTPGetCallback( MiniServerCallback callback );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
void SetSoapCallback( MiniServerCallback callback );
|
||||
#else
|
||||
static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : SetGenaCallback
|
||||
|
||||
@@ -47,7 +47,7 @@ extern "C" {
|
||||
|
||||
#define SID_SIZE 41
|
||||
|
||||
DEVICEONLY(
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
|
||||
typedef struct SUBSCRIPTION {
|
||||
Upnp_SID sid;
|
||||
@@ -61,18 +61,19 @@ typedef struct SUBSCRIPTION {
|
||||
|
||||
|
||||
typedef struct SERVICE_INFO {
|
||||
DOMString serviceType;
|
||||
DOMString serviceId;
|
||||
DOMString serviceType;
|
||||
DOMString serviceId;
|
||||
char *SCPDURL ;
|
||||
char *controlURL;
|
||||
char *eventURL;
|
||||
DOMString UDN;
|
||||
DOMString UDN;
|
||||
int active;
|
||||
int TotalSubscriptions;
|
||||
subscription *subscriptionList;
|
||||
subscription *subscriptionList;
|
||||
struct SERVICE_INFO *next;
|
||||
} service_info;
|
||||
|
||||
|
||||
typedef struct SERVICE_TABLE {
|
||||
DOMString URLBase;
|
||||
service_info *serviceList;
|
||||
@@ -80,7 +81,7 @@ typedef struct SERVICE_TABLE {
|
||||
} service_table;
|
||||
|
||||
|
||||
/* Functions for Subscriptions */
|
||||
/* Functions for Subscriptions */
|
||||
|
||||
/************************************************************************
|
||||
* Function : copy_subscription
|
||||
@@ -246,14 +247,14 @@ service_info * FindServiceEventURLPath( service_table *table,
|
||||
* Note :
|
||||
************************************************************************/
|
||||
service_info * FindServiceControlURLPath( service_table *table,
|
||||
char * controlURLPath);
|
||||
const char * controlURLPath);
|
||||
|
||||
/************************************************************************
|
||||
* Function : printService
|
||||
*
|
||||
* Parameters :
|
||||
* service_info *service ;Service whose information is to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints information from the
|
||||
@@ -263,16 +264,24 @@ service_info * FindServiceControlURLPath( service_table *table,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY(void printService(service_info *service,Dbg_Level
|
||||
level,
|
||||
Dbg_Module module));
|
||||
#ifdef DEBUG
|
||||
void printService(
|
||||
service_info *service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module);
|
||||
#else
|
||||
static UPNP_INLINE void printService(
|
||||
service_info *service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : printServiceList
|
||||
*
|
||||
* Parameters :
|
||||
* service_info *service ; Service whose information is to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints information of each
|
||||
@@ -282,15 +291,24 @@ DBGONLY(void printService(service_info *service,Dbg_Level
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY(void printServiceList(service_info *service,
|
||||
Dbg_Level level, Dbg_Module module));
|
||||
#ifdef DEBUG
|
||||
void printServiceList(
|
||||
service_info *service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module);
|
||||
#else
|
||||
static UPNP_INLINE void printServiceList(
|
||||
service_info *service,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : printServiceTable
|
||||
*
|
||||
* Parameters :
|
||||
* service_table * table ; Service table to be printed
|
||||
* Dbg_Level level ; Debug level specified to the print function
|
||||
* Upnp_LogLevel level ; Debug level specified to the print function
|
||||
* Dbg_Module module ; Debug module specified to the print function
|
||||
*
|
||||
* Description : For debugging purposes prints the URL base of the table
|
||||
@@ -301,9 +319,17 @@ DBGONLY(void printServiceList(service_info *service,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY(void printServiceTable(service_table *
|
||||
table,Dbg_Level
|
||||
level,Dbg_Module module));
|
||||
#ifdef DEBUG
|
||||
void printServiceTable(
|
||||
service_table *table,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module);
|
||||
#else
|
||||
static UPNP_INLINE void printServiceTable(
|
||||
service_table *table,
|
||||
Upnp_LogLevel level,
|
||||
Dbg_Module module) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : freeService
|
||||
@@ -451,10 +477,11 @@ int getSubElement(const char *element_name, IXML_Node *node,
|
||||
IXML_Node **out);
|
||||
|
||||
|
||||
) /* DEVICEONLY */
|
||||
#endif /* INCLUDE_DEVICE_APIS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SERVICE_TABLE */
|
||||
|
||||
|
||||
@@ -33,28 +33,28 @@
|
||||
#define SOAPLIB_H
|
||||
|
||||
|
||||
//SOAP module API to be called in Upnp-Dk API
|
||||
// SOAP module API to be called in Upnp-Dk API
|
||||
/****************************************************************************
|
||||
* Function : soap_device_callback
|
||||
* Function : soap_device_callback
|
||||
*
|
||||
* Parameters :
|
||||
* IN http_parser_t *parser : Parsed request received by the device
|
||||
* IN http_message_t* request : HTTP request
|
||||
* INOUT SOCKINFO *info : socket info
|
||||
* Parameters :
|
||||
* IN http_parser_t *parser : Parsed request received by the device
|
||||
* IN http_message_t* request : HTTP request
|
||||
* INOUT SOCKINFO *info : socket info
|
||||
*
|
||||
* Description : This is a callback called by minisever after receiving
|
||||
* the request from the control point. This function will start
|
||||
* processing the request. It calls handle_invoke_action to handle the
|
||||
* SOAP action
|
||||
* Description : This is a callback called by minisever after receiving
|
||||
* the request from the control point. This function will start
|
||||
* processing the request. It calls handle_invoke_action to handle the
|
||||
* SOAP action
|
||||
*
|
||||
* Return : void
|
||||
* Return : void
|
||||
*
|
||||
* Note :
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
void soap_device_callback(
|
||||
IN http_parser_t *parser,
|
||||
IN http_message_t* request,
|
||||
INOUT SOCKINFO *info );
|
||||
IN http_parser_t *parser,
|
||||
IN http_message_t* request,
|
||||
INOUT SOCKINFO *info );
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -80,7 +80,7 @@ typedef enum SsdpCmdType{SSDP_ERROR=-1,
|
||||
#define SSDP_IP "239.255.255.250"
|
||||
#define SSDP_PORT 1900
|
||||
#define NUM_TRY 3
|
||||
#define NUM_COPY 2
|
||||
#define NUM_COPY 1
|
||||
#define THREAD_LIMIT 50
|
||||
#define COMMAND_LEN 300
|
||||
|
||||
@@ -211,8 +211,15 @@ int Make_Socket_NoBlocking (int sock);
|
||||
* Returns: void *
|
||||
* 1 if successful else appropriate error
|
||||
***************************************************************************/
|
||||
void ssdp_handle_device_request( IN http_message_t* hmsg,
|
||||
IN struct sockaddr_in* dest_addr );
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
void ssdp_handle_device_request(
|
||||
IN http_message_t* hmsg,
|
||||
IN struct sockaddr_in* dest_addr );
|
||||
#else
|
||||
static inline void ssdp_handle_device_request(
|
||||
IN http_message_t* hmsg,
|
||||
IN struct sockaddr_in* dest_addr ) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : ssdp_handle_ctrlpt_msg
|
||||
@@ -221,10 +228,10 @@ void ssdp_handle_device_request( IN http_message_t* hmsg,
|
||||
* IN http_message_t* hmsg: SSDP message from the device
|
||||
* IN struct sockaddr_in* dest_addr: Address of the device
|
||||
* IN xboolean timeout: timeout kept by the control point while sending
|
||||
* search message
|
||||
* search message
|
||||
* IN void* cookie: Cookie stored by the control point application.
|
||||
* This cookie will be returned to the control point
|
||||
* in the callback
|
||||
* This cookie will be returned to the control point
|
||||
* in the callback
|
||||
*
|
||||
* Description:
|
||||
* This function handles the ssdp messages from the devices. These
|
||||
@@ -234,10 +241,11 @@ void ssdp_handle_device_request( IN http_message_t* hmsg,
|
||||
* Returns: void
|
||||
*
|
||||
***************************************************************************/
|
||||
void ssdp_handle_ctrlpt_msg( IN http_message_t* hmsg,
|
||||
IN struct sockaddr_in* dest_addr,
|
||||
IN xboolean timeout,
|
||||
IN void* cookie );
|
||||
void ssdp_handle_ctrlpt_msg(
|
||||
IN http_message_t* hmsg,
|
||||
IN struct sockaddr_in* dest_addr,
|
||||
IN xboolean timeout,
|
||||
IN void* cookie );
|
||||
|
||||
/************************************************************************
|
||||
* Function : unique_service_name
|
||||
@@ -245,7 +253,7 @@ void ssdp_handle_ctrlpt_msg( IN http_message_t* hmsg,
|
||||
* Parameters:
|
||||
* IN char *cmd: Service Name string
|
||||
* OUT SsdpEvent *Evt: The SSDP event structure partially filled
|
||||
* by all the function.
|
||||
* by all the function.
|
||||
*
|
||||
* Description:
|
||||
* This function fills the fields of the event structure like DeviceType,
|
||||
@@ -326,12 +334,10 @@ int ssdp_request_type(IN char * cmd, OUT SsdpEvent * Evt);
|
||||
* Function : SearchByTarget
|
||||
*
|
||||
* Parameters:
|
||||
* IN int Mx:Number of seconds to wait, to collect all the
|
||||
* responses.
|
||||
* char *St: Search target.
|
||||
* void *Cookie: cookie provided by control point application. This
|
||||
* cokie will be returned to application in the
|
||||
* callback.
|
||||
* IN int Mx:Number of seconds to wait, to collect all the responses.
|
||||
* char *St: Search target.
|
||||
* void *Cookie: cookie provided by control point application. This
|
||||
* cokie will be returned to application in the callback.
|
||||
*
|
||||
* Description:
|
||||
* This function creates and send the search request for a specific URL.
|
||||
@@ -345,12 +351,11 @@ int SearchByTarget(IN int Mx, IN char *St, IN void *Cookie);
|
||||
* Function : DeviceAdvertisement
|
||||
*
|
||||
* Parameters:
|
||||
* IN char * DevType : type of the device
|
||||
* IN int RootDev: flag to indicate if the device is root device
|
||||
* IN char * nt : value of NT
|
||||
* IN char * usn :
|
||||
* IN char * location :Location URL.
|
||||
* IN int duration :Service duration in sec.
|
||||
* IN char *DevType : type of the device
|
||||
* IN int RootDev : flag to indicate if the device is root device
|
||||
* IN char *Udn :
|
||||
* IN char *Location: Location URL.
|
||||
* IN int Duration : Service duration in sec.
|
||||
*
|
||||
* Description:
|
||||
* This function creates the device advertisement request based on
|
||||
@@ -359,8 +364,12 @@ int SearchByTarget(IN int Mx, IN char *St, IN void *Cookie);
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int DeviceAdvertisement(IN char * DevType, int RootDev,char * Udn,
|
||||
IN char * Location, IN int Duration);
|
||||
int DeviceAdvertisement(
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char *Udn,
|
||||
IN char *Location,
|
||||
IN int Duration);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
@@ -369,10 +378,10 @@ int DeviceAdvertisement(IN char * DevType, int RootDev,char * Udn,
|
||||
* Parameters:
|
||||
* IN char *DevType: Device Type.
|
||||
* IN int RootDev:1 means root device.
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char *Udn: Device UDN
|
||||
* IN char *_Server:
|
||||
* IN char * Location: Location URL
|
||||
* IN int Duration :Device duration in sec.
|
||||
* IN char *Location: Location URL
|
||||
* IN int Duration :Device duration in sec.
|
||||
*
|
||||
* Description:
|
||||
* This function creates a HTTP device shutdown request packet
|
||||
@@ -381,12 +390,13 @@ int DeviceAdvertisement(IN char * DevType, int RootDev,char * Udn,
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int DeviceShutdown( IN char * DevType,
|
||||
IN int RootDev,
|
||||
IN char * Udn,
|
||||
IN char * _Server,
|
||||
IN char * Location,
|
||||
IN int Duration );
|
||||
int DeviceShutdown(
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char *Udn,
|
||||
IN char *_Server,
|
||||
IN char *Location,
|
||||
IN int Duration);
|
||||
|
||||
/************************************************************************
|
||||
* Function : DeviceReply
|
||||
@@ -395,10 +405,10 @@ int DeviceShutdown( IN char * DevType,
|
||||
* IN struct sockaddr_in * DestAddr:destination IP address.
|
||||
* IN char *DevType: Device type
|
||||
* IN int RootDev: 1 means root device 0 means embedded device.
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char * Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
|
||||
* IN char *Udn: Device UDN
|
||||
* IN char *Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
*
|
||||
* Description:
|
||||
* This function creates the reply packet based on the input parameter,
|
||||
* and send it to the client address given in its input parameter DestAddr.
|
||||
@@ -406,11 +416,12 @@ int DeviceShutdown( IN char * DevType,
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int DeviceReply(IN struct sockaddr_in * DestAddr,
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char * Udn,
|
||||
IN char * Location, IN int Duration);
|
||||
int DeviceReply(
|
||||
IN struct sockaddr_in * DestAddr,
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char *Udn,
|
||||
IN char *Location, IN int Duration);
|
||||
|
||||
/************************************************************************
|
||||
* Function : SendReply
|
||||
@@ -421,8 +432,8 @@ int DeviceReply(IN struct sockaddr_in * DestAddr,
|
||||
* IN int RootDev: 1 means root device 0 means embedded device.
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char *_Server:
|
||||
* IN char * Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
* IN char *Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
* IN int ByType:
|
||||
*
|
||||
* Description:
|
||||
@@ -432,13 +443,14 @@ int DeviceReply(IN struct sockaddr_in * DestAddr,
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int SendReply(IN struct sockaddr_in * DestAddr,
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char * Udn,
|
||||
IN char * Location,
|
||||
IN int Duration,
|
||||
IN int ByType );
|
||||
int SendReply(
|
||||
IN struct sockaddr_in * DestAddr,
|
||||
IN char *DevType,
|
||||
IN int RootDev,
|
||||
IN char *Udn,
|
||||
IN char *Location,
|
||||
IN int Duration,
|
||||
IN int ByType );
|
||||
|
||||
/************************************************************************
|
||||
* Function : ServiceAdvertisement
|
||||
@@ -447,55 +459,55 @@ int SendReply(IN struct sockaddr_in * DestAddr,
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char *ServType: Service Type.
|
||||
* IN char * Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
|
||||
* IN int Duration :Life time of this device.
|
||||
*
|
||||
* Description:
|
||||
* This function creates the advertisement packet based
|
||||
* on the input parameter, and send it to the multicast channel.
|
||||
|
||||
*
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int ServiceAdvertisement( IN char * Udn,
|
||||
IN char * ServType,
|
||||
IN char * Location,
|
||||
IN int Duration);
|
||||
int ServiceAdvertisement(
|
||||
IN char *Udn,
|
||||
IN char *ServType,
|
||||
IN char *Location,
|
||||
IN int Duration);
|
||||
|
||||
/************************************************************************
|
||||
* Function : ServiceReply
|
||||
*
|
||||
* Parameters:
|
||||
* IN struct sockaddr_in *DestAddr:
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char *Udn: Device UDN
|
||||
* IN char *ServType: Service Type.
|
||||
* IN char *Server: Not used
|
||||
* IN char * Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
|
||||
* IN char *Location: Location of Device description document.
|
||||
* IN int Duration :Life time of this device.
|
||||
*
|
||||
* Description:
|
||||
* This function creates the advertisement packet based
|
||||
* on the input parameter, and send it to the multicast channel.
|
||||
|
||||
*
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int ServiceReply(IN struct sockaddr_in *DestAddr,
|
||||
IN char * ServType,
|
||||
IN char * Udn,
|
||||
IN char * Location,
|
||||
IN int Duration);
|
||||
int ServiceReply(
|
||||
IN struct sockaddr_in *DestAddr,
|
||||
IN char *ServType,
|
||||
IN char *Udn,
|
||||
IN char *Location,
|
||||
IN int Duration);
|
||||
|
||||
/************************************************************************
|
||||
* Function : ServiceShutdown
|
||||
*
|
||||
* Parameters:
|
||||
* IN char * Udn: Device UDN
|
||||
* IN char *Udn: Device UDN
|
||||
* IN char *ServType: Service Type.
|
||||
* IN char * Location: Location of Device description document.
|
||||
* IN int Duration :Service duration in sec.
|
||||
|
||||
* IN char *Location: Location of Device description document.
|
||||
* IN int Duration :Service duration in sec.
|
||||
*
|
||||
* Description:
|
||||
* This function creates a HTTP service shutdown request packet
|
||||
* and sent it to the multicast channel through RequestHandler.
|
||||
@@ -503,16 +515,18 @@ int ServiceReply(IN struct sockaddr_in *DestAddr,
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int ServiceShutdown( IN char * Udn, IN char * ServType,
|
||||
IN char * Location,
|
||||
IN int Duration);
|
||||
int ServiceShutdown(
|
||||
IN char *Udn,
|
||||
IN char *ServType,
|
||||
IN char *Location,
|
||||
IN int Duration);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function : advertiseAndReplyThread
|
||||
*
|
||||
* Parameters:
|
||||
* IN void *data: Structure containing the search request
|
||||
* IN void *data: Structure containing the search request
|
||||
*
|
||||
* Description:
|
||||
* This function is a wrapper function to reply the search request
|
||||
@@ -521,20 +535,21 @@ int ServiceShutdown( IN char * Udn, IN char * ServType,
|
||||
* Returns: void *
|
||||
* always return NULL
|
||||
***************************************************************************/
|
||||
void * advertiseAndReplyThread(IN void * data);
|
||||
void *advertiseAndReplyThread(IN void * data);
|
||||
|
||||
/************************************************************************
|
||||
* Function : AdvertiseAndReply
|
||||
*
|
||||
* Parameters:
|
||||
* IN int AdFlag: -1 = Send shutdown, 0 = send reply,
|
||||
* 1 = Send Advertisement
|
||||
* IN int AdFlag: -1 = Send shutdown,
|
||||
* 0 = send reply,
|
||||
* 1 = Send Advertisement
|
||||
* IN UpnpDevice_Handle Hnd: Device handle
|
||||
* IN enum SsdpSearchType SearchType:Search type for sending replies
|
||||
* IN struct sockaddr_in *DestAddr:Destination address
|
||||
* IN char *DeviceType:Device type
|
||||
* IN char *DeviceType:Device type
|
||||
* IN char *DeviceUDN:Device UDN
|
||||
* IN char *ServiceType:Service type
|
||||
* IN char *ServiceType:Service type
|
||||
* IN int Exp:Advertisement age
|
||||
*
|
||||
* Description:
|
||||
@@ -543,13 +558,14 @@ void * advertiseAndReplyThread(IN void * data);
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int AdvertiseAndReply(IN int AdFlag,
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
IN enum SsdpSearchType SearchType,
|
||||
IN struct sockaddr_in *DestAddr,
|
||||
IN char *DeviceType,
|
||||
IN char *DeviceUDN,
|
||||
IN char *ServiceType, int Exp);
|
||||
int AdvertiseAndReply(
|
||||
IN int AdFlag,
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
IN enum SsdpSearchType SearchType,
|
||||
IN struct sockaddr_in *DestAddr,
|
||||
IN char *DeviceType,
|
||||
IN char *DeviceUDN,
|
||||
IN char *ServiceType, int Exp);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,12 +36,11 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#define XINLINE
|
||||
|
||||
#define socklen_t int
|
||||
#define EAFNOSUPPORT 97
|
||||
typedef int socklen_t;
|
||||
#define EAFNOSUPPORT 97
|
||||
#endif
|
||||
|
||||
#endif // GENLIB_NET_UNIXUTIL_H
|
||||
|
||||
|
||||
@@ -71,33 +71,46 @@ struct Handle_Info
|
||||
Upnp_FunPtr Callback; // Callback function pointer.
|
||||
char * Cookie;
|
||||
|
||||
DEVICEONLY(char DescURL[LINE_SIZE];) // URL for the use of SSDP
|
||||
DEVICEONLY(char DescXML[LINE_SIZE];) // XML file path for device
|
||||
//description
|
||||
// Device Only
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
char DescURL[LINE_SIZE]; // URL for the use of SSDP
|
||||
char DescXML[LINE_SIZE]; // XML file path for device
|
||||
//description
|
||||
|
||||
DEVICEONLY(int MaxAge;) // Advertisement timeout
|
||||
DEVICEONLY(IXML_Document *DescDocument;) // Description parsed in
|
||||
//terms of DOM document
|
||||
DEVICEONLY(IXML_NodeList *DeviceList;) // List of devices in the
|
||||
//description document
|
||||
DEVICEONLY(IXML_NodeList *ServiceList;) // List of services in the
|
||||
// description document
|
||||
DEVICEONLY(service_table ServiceTable;) //table holding subscriptions and
|
||||
int MaxAge; // Advertisement timeout
|
||||
IXML_Document *DescDocument;// Description parsed in
|
||||
//terms of DOM document
|
||||
IXML_NodeList *DeviceList; // List of devices in the
|
||||
//description document
|
||||
IXML_NodeList *ServiceList; // List of services in the
|
||||
// description document
|
||||
service_table ServiceTable; //table holding subscriptions and
|
||||
//URL information
|
||||
DEVICEONLY(int MaxSubscriptions;)
|
||||
DEVICEONLY(int MaxSubscriptionTimeOut;)
|
||||
int MaxSubscriptions;
|
||||
int MaxSubscriptionTimeOut;
|
||||
#endif
|
||||
|
||||
//Client only
|
||||
CLIENTONLY(client_subscription * ClientSubList;) //client subscription list
|
||||
CLIENTONLY(LinkedList SsdpSearchList;) // active ssdp searches
|
||||
// Client only
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
client_subscription *ClientSubList; //client subscription list
|
||||
LinkedList SsdpSearchList; // active ssdp searches
|
||||
#endif
|
||||
int aliasInstalled; // 0 = not installed; otherwise installed
|
||||
} ;
|
||||
};
|
||||
|
||||
extern ithread_mutex_t GlobalHndMutex;
|
||||
Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo);
|
||||
|
||||
#define HandleLock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Lock")); ithread_mutex_lock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"LOCK"));
|
||||
#define HandleUnlock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Unlock")); ithread_mutex_unlock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Unlock"));
|
||||
#define HandleLock() \
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Lock"); \
|
||||
ithread_mutex_lock(&GlobalHndMutex); \
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "LOCK");
|
||||
|
||||
#define HandleUnlock() \
|
||||
UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock"); \
|
||||
ithread_mutex_unlock(&GlobalHndMutex); \
|
||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlock");
|
||||
|
||||
Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out,
|
||||
struct Handle_Info **HndInfo);
|
||||
Upnp_Handle_Type GetDeviceHandleInfo(int *device_handle_out,
|
||||
@@ -111,7 +124,7 @@ extern unsigned short LOCAL_PORT;
|
||||
extern TimerThread gTimerThread;
|
||||
extern ThreadPool gRecvThreadPool;
|
||||
extern ThreadPool gSendThreadPool;
|
||||
|
||||
extern ThreadPool gMiniServerThreadPool;
|
||||
|
||||
typedef enum {
|
||||
SUBSCRIBE,
|
||||
|
||||
@@ -86,8 +86,8 @@ enum uriType { absolute, relative };
|
||||
/* Buffer used in parsinghttp messages, urls, etc. generally this simply
|
||||
* holds a pointer into a larger array */
|
||||
typedef struct TOKEN {
|
||||
char * buff;
|
||||
int size;
|
||||
const char *buff;
|
||||
size_t size;
|
||||
} token;
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ typedef struct URL_LIST {
|
||||
* Parameters :
|
||||
* char * in ; string of characters
|
||||
* int index ; index at which to start checking the characters
|
||||
* int *max ;
|
||||
* size_t *max ;
|
||||
*
|
||||
* Description : Replaces an escaped sequence with its unescaped version
|
||||
* as in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
||||
@@ -137,7 +137,7 @@ typedef struct URL_LIST {
|
||||
* string are shifted over, and NULL characters are placed at the
|
||||
* end of the string.
|
||||
************************************************************************/
|
||||
int replace_escaped(char * in, int index, int *max);
|
||||
int replace_escaped(char * in, int index, size_t *max);
|
||||
|
||||
/************************************************************************
|
||||
* Function : copy_URL_list
|
||||
@@ -182,13 +182,16 @@ void free_URL_list(URL_list * list);
|
||||
* uri_type *in ; URI object
|
||||
*
|
||||
* Description : Function useful in debugging for printing a parsed uri.
|
||||
* Compiled out with DBGONLY macro.
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
DBGONLY(void print_uri( uri_type *in);)
|
||||
#ifdef DEBUG
|
||||
void print_uri(uri_type *in);
|
||||
#else
|
||||
static UPNP_INLINE void print_uri(uri_type *in) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : print_token
|
||||
@@ -197,13 +200,16 @@ DBGONLY(void print_uri( uri_type *in);)
|
||||
* token * in ;
|
||||
*
|
||||
* Description : Function useful in debugging for printing a token.
|
||||
* Compiled out with DBGONLY macro.
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void print_token( token * in);
|
||||
#ifdef DEBUG
|
||||
void print_token(token *in);
|
||||
#else
|
||||
static UPNP_INLINE void print_token(token * in) {}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : token_string_casecmp
|
||||
@@ -276,7 +282,7 @@ int token_cmp( token *in1, token *in2);
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int parse_port(int max, char * port, unsigned short int * out);
|
||||
int parse_port(int max, const char *port, unsigned short int *out);
|
||||
|
||||
/************************************************************************
|
||||
* Function : parse_hostport
|
||||
@@ -296,14 +302,14 @@ int parse_port(int max, char * port, unsigned short int * out);
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int parse_hostport( char* in, int max, hostport_type *out );
|
||||
int parse_hostport(const char *in, int max, hostport_type *out );
|
||||
|
||||
/************************************************************************
|
||||
* Function : remove_escaped_chars
|
||||
*
|
||||
* Parameters :
|
||||
* INOUT char *in ; string of characters to be modified
|
||||
* INOUT int *size ; size limit for the number of characters
|
||||
* INOUT size_t *size ; size limit for the number of characters
|
||||
*
|
||||
* Description : removes http escaped characters such as: "%20" and
|
||||
* replaces them with their character representation. i.e.
|
||||
@@ -315,7 +321,7 @@ int parse_hostport( char* in, int max, hostport_type *out );
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int remove_escaped_chars(char *in,int *size);
|
||||
int remove_escaped_chars(char *in, size_t *size);
|
||||
|
||||
/************************************************************************
|
||||
* Function : remove_dots
|
||||
@@ -391,7 +397,7 @@ char * resolve_rel_url( char * base_url, char * rel_url);
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
int parse_uri( char * in, int max, uri_type * out);
|
||||
int parse_uri(const char * in, int max, uri_type * out);
|
||||
|
||||
/************************************************************************
|
||||
* Function : parse_uri_and_unescape
|
||||
|
||||
@@ -47,12 +47,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NO_DEBUG
|
||||
#define DBG(x)
|
||||
#else
|
||||
#define DBG(x) x
|
||||
#endif
|
||||
|
||||
#define GEMD_OUT_OF_MEMORY -1
|
||||
#define EVENT_TIMEDOUT -2
|
||||
#define EVENT_TERMINATE -3
|
||||
@@ -142,31 +136,28 @@ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen
|
||||
#endif
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
// C specific
|
||||
#ifndef __cplusplus
|
||||
|
||||
#ifndef WIN32
|
||||
#define XINLINE inline
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#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 Sleep
|
||||
#define usleep(a) Sleep((a)/1000)
|
||||
#define sleep(a) Sleep((a)*1000)
|
||||
#define usleep(a) Sleep((a)/1000)
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* GENLIB_UTIL_UTIL_H */
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ struct SendInstruction
|
||||
int IsRangeActive;
|
||||
int IsTrailers;
|
||||
char RangeHeader[200];
|
||||
long RangeOffset;
|
||||
long ReadSendSize; // Read from local source and send on the network.
|
||||
off_t RangeOffset;
|
||||
off_t ReadSendSize; // Read from local source and send on the network.
|
||||
long RecvWriteSize; // Recv from the network and write into local file.
|
||||
|
||||
//Later few more member could be added depending on the requirement.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define socklen_t int
|
||||
typedef int socklen_t;
|
||||
#define EAFNOSUPPORT 97
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
|
||||
@@ -212,11 +212,11 @@ dom_find_deep_node( IN char *names[],
|
||||
*
|
||||
* Note :The given node must have a text node as its first child
|
||||
****************************************************************************/
|
||||
static DOMString
|
||||
static const DOMString
|
||||
get_node_value( IN IXML_Node * node )
|
||||
{
|
||||
IXML_Node *text_node = NULL;
|
||||
DOMString text_value = NULL;
|
||||
const DOMString text_value = NULL;
|
||||
|
||||
text_node = ixmlNode_getFirstChild( node );
|
||||
if( text_node == NULL ) {
|
||||
@@ -244,20 +244,21 @@ get_node_value( IN IXML_Node * node )
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
get_host_and_path( IN char *ctrl_url,
|
||||
OUT memptr * host,
|
||||
OUT memptr * path,
|
||||
OUT const memptr *host,
|
||||
OUT const memptr *path,
|
||||
OUT uri_type * url )
|
||||
{
|
||||
if( parse_uri( ctrl_url, strlen( ctrl_url ), url ) != HTTP_SUCCESS ) {
|
||||
return -1;
|
||||
}
|
||||
host->buf = url->hostport.text.buff;
|
||||
host->length = url->hostport.text.size;
|
||||
// This is done to ensure that the buffer is kept const
|
||||
((memptr *)host)->buf = (char *)url->hostport.text.buff;
|
||||
((memptr *)host)->length = url->hostport.text.size;
|
||||
|
||||
path->buf = url->pathquery.buff;
|
||||
path->length = url->pathquery.size;
|
||||
((memptr *)path)->buf = (char *)url->pathquery.buff;
|
||||
((memptr *)path)->length = url->pathquery.size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -276,7 +277,7 @@ get_host_and_path( IN char *ctrl_url,
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
get_action_name( IN char *action,
|
||||
OUT memptr * name )
|
||||
{
|
||||
@@ -302,7 +303,7 @@ get_action_name( IN char *action,
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
add_man_header( INOUT membuffer * headers )
|
||||
{
|
||||
char *soap_action_hdr;
|
||||
@@ -414,12 +415,12 @@ get_response_value( IN http_message_t * hmsg,
|
||||
IXML_Node *error_node = NULL;
|
||||
IXML_Document *doc = NULL;
|
||||
char *node_str = NULL;
|
||||
char *temp_str = NULL;
|
||||
const char *temp_str = NULL;
|
||||
DOMString error_node_str = NULL;
|
||||
int err_code;
|
||||
xboolean done = FALSE;
|
||||
char *names[5];
|
||||
DOMString nodeValue;
|
||||
const DOMString nodeValue;
|
||||
|
||||
err_code = UPNP_E_BAD_RESPONSE; // default error
|
||||
|
||||
@@ -601,25 +602,27 @@ SoapSendAction( IN char *action_url,
|
||||
char *upnp_error_str;
|
||||
xboolean got_response = FALSE;
|
||||
|
||||
off_t content_length;
|
||||
char *xml_start =
|
||||
// "<?xml version=\"1.0\"?>\n" required??
|
||||
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
|
||||
"<s:Envelope "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
|
||||
"<s:Body>";
|
||||
char *xml_end = "</s:Body>\n" "</s:Envelope>\n";
|
||||
int xml_start_len;
|
||||
int xml_end_len;
|
||||
int action_str_len;
|
||||
char *xml_end =
|
||||
"</s:Body>\r\n"
|
||||
"</s:Envelope>\r\n\r\n";
|
||||
size_t xml_start_len;
|
||||
size_t xml_end_len;
|
||||
size_t action_str_len;
|
||||
|
||||
*response_node = NULL; // init
|
||||
|
||||
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Inside SoapSendAction():" );
|
||||
)
|
||||
// init
|
||||
membuffer_init( &request );
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Inside SoapSendAction():" );
|
||||
// init
|
||||
membuffer_init( &request );
|
||||
membuffer_init( &responsename );
|
||||
|
||||
// print action
|
||||
@@ -638,24 +641,30 @@ SoapSendAction( IN char *action_url,
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"path=%.*s, hostport=%.*s\n",
|
||||
url.pathquery.size, url.pathquery.buff,
|
||||
url.hostport.text.size,
|
||||
url.hostport.text.buff ); )
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"path=%.*s, hostport=%.*s\n",
|
||||
(int)url.pathquery.size,
|
||||
url.pathquery.buff,
|
||||
(int)url.hostport.text.size,
|
||||
url.hostport.text.buff );
|
||||
|
||||
xml_start_len = strlen( xml_start );
|
||||
xml_start_len = strlen( xml_start );
|
||||
xml_end_len = strlen( xml_end );
|
||||
action_str_len = strlen( action_str );
|
||||
|
||||
// make request msg
|
||||
request.size_inc = 50;
|
||||
if( http_MakeMessage( &request, 1, 1, "q" "N" "s" "sssbs" "U" "c" "bbb", SOAPMETHOD_POST, &url, xml_start_len + action_str_len + xml_end_len, // content-length
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"", service_type, "#", name.buf,
|
||||
name.length, "\"\r\n", xml_start, xml_start_len,
|
||||
action_str, action_str_len, xml_end,
|
||||
xml_end_len ) != 0 ) {
|
||||
content_length = xml_start_len + action_str_len + xml_end_len;
|
||||
if (http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"q" "N" "s" "sssbsc" "Uc" "b" "b" "b",
|
||||
SOAPMETHOD_POST, &url,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"", service_type, "#", name.buf, name.length, "\"",
|
||||
xml_start, xml_start_len,
|
||||
action_str, action_str_len,
|
||||
xml_end, xml_end_len ) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
@@ -684,7 +693,7 @@ SoapSendAction( IN char *action_url,
|
||||
err_code = ret_code;
|
||||
}
|
||||
|
||||
error_handler:
|
||||
error_handler:
|
||||
ixmlFreeDOMString( action_str );
|
||||
membuffer_destroy( &request );
|
||||
membuffer_destroy( &responsename );
|
||||
@@ -736,30 +745,35 @@ SoapSendActionEx( IN char *action_url,
|
||||
xboolean got_response = FALSE;
|
||||
|
||||
char *xml_start =
|
||||
// "<?xml version=\"1.0\"?>\n" required??
|
||||
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n";
|
||||
char *xml_body_start = "<s:Body>";
|
||||
char *xml_end = "</s:Body>\n" "</s:Envelope>\n";
|
||||
int xml_start_len;
|
||||
int xml_end_len;
|
||||
char *xml_header_start = "<s:Header>\n";
|
||||
char *xml_header_end = "</s:Header>\n";
|
||||
int xml_header_start_len;
|
||||
int xml_header_end_len;
|
||||
int xml_header_str_len;
|
||||
int action_str_len;
|
||||
int xml_body_start_len;
|
||||
"<s:Envelope "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n";
|
||||
char *xml_header_start =
|
||||
"<s:Header>\r\n";
|
||||
char *xml_header_end =
|
||||
"</s:Header>\r\n";
|
||||
char *xml_body_start =
|
||||
"<s:Body>";
|
||||
char *xml_end =
|
||||
"</s:Body>\r\n"
|
||||
"</s:Envelope>\r\n";
|
||||
size_t xml_start_len;
|
||||
size_t xml_header_start_len;
|
||||
size_t xml_header_str_len;
|
||||
size_t xml_header_end_len;
|
||||
size_t xml_body_start_len;
|
||||
size_t action_str_len;
|
||||
size_t xml_end_len;
|
||||
off_t content_length;
|
||||
|
||||
*response_node = NULL; // init
|
||||
|
||||
err_code = UPNP_E_OUTOF_MEMORY; // default error
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Inside SoapSendActionEx():" );
|
||||
)
|
||||
// init
|
||||
membuffer_init( &request );
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Inside SoapSendActionEx():" );
|
||||
// init
|
||||
membuffer_init( &request );
|
||||
membuffer_init( &responsename );
|
||||
|
||||
// header string
|
||||
@@ -783,13 +797,14 @@ SoapSendActionEx( IN char *action_url,
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"path=%.*s, hostport=%.*s\n",
|
||||
url.pathquery.size, url.pathquery.buff,
|
||||
url.hostport.text.size,
|
||||
url.hostport.text.buff ); )
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"path=%.*s, hostport=%.*s\n",
|
||||
(int)url.pathquery.size,
|
||||
url.pathquery.buff,
|
||||
(int)url.hostport.text.size,
|
||||
url.hostport.text.buff );
|
||||
|
||||
xml_start_len = strlen( xml_start );
|
||||
xml_start_len = strlen( xml_start );
|
||||
xml_body_start_len = strlen( xml_body_start );
|
||||
xml_end_len = strlen( xml_end );
|
||||
action_str_len = strlen( action_str );
|
||||
@@ -800,17 +815,24 @@ SoapSendActionEx( IN char *action_url,
|
||||
|
||||
// make request msg
|
||||
request.size_inc = 50;
|
||||
if( http_MakeMessage( &request, 1, 1, "q" "N" "s" "sssbs" "U" "c" "bbbbbbb", SOAPMETHOD_POST, &url, xml_start_len + xml_header_start_len + xml_header_str_len + xml_header_end_len + xml_body_start_len + action_str_len + xml_end_len, // content-length
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"", service_type, "#", name.buf,
|
||||
name.length, "\"\r\n",
|
||||
xml_start, xml_start_len,
|
||||
xml_header_start, xml_header_start_len,
|
||||
xml_header_str, xml_header_str_len,
|
||||
xml_header_end, xml_header_end_len,
|
||||
xml_body_start, xml_body_start_len,
|
||||
action_str, action_str_len,
|
||||
xml_end, xml_end_len ) != 0 ) {
|
||||
content_length =
|
||||
xml_start_len +
|
||||
xml_header_start_len + xml_header_str_len + xml_header_end_len +
|
||||
xml_body_start_len + action_str_len + xml_end_len;
|
||||
if (http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"q" "N" "s" "sssbsc" "Uc" "b" "b" "b" "b" "b" "b" "b",
|
||||
SOAPMETHOD_POST, &url,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"", service_type, "#", name.buf, name.length, "\"",
|
||||
xml_start, xml_start_len,
|
||||
xml_header_start, xml_header_start_len,
|
||||
xml_header_str, xml_header_str_len,
|
||||
xml_header_end, xml_header_end_len,
|
||||
xml_body_start, xml_body_start_len,
|
||||
action_str, action_str_len,
|
||||
xml_end, xml_end_len ) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
@@ -873,24 +895,28 @@ SoapGetServiceVarStatus( IN char *action_url,
|
||||
IN char *var_name,
|
||||
OUT char **var_value )
|
||||
{
|
||||
memptr host; // value for HOST header
|
||||
memptr path; // ctrl path in first line in msg
|
||||
const memptr host; // value for HOST header
|
||||
const memptr path; // ctrl path in first line in msg
|
||||
uri_type url;
|
||||
membuffer request;
|
||||
int ret_code;
|
||||
http_parser_t response;
|
||||
int upnp_error_code;
|
||||
|
||||
off_t content_length;
|
||||
char *xml_start =
|
||||
// "<?xml version=\"1.0\"?>\n" required??
|
||||
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
|
||||
"<s:Body>\n"
|
||||
"<u:QueryStateVariable xmlns:u=\"urn:schemas-upnp-org:control-1-0\">\n"
|
||||
"<s:Envelope "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
|
||||
"<s:Body>\r\n"
|
||||
"<u:QueryStateVariable xmlns:u=\"urn:schemas-upnp-org:control-1-0\">\r\n"
|
||||
"<u:varName>";
|
||||
|
||||
char *xml_end = "</u:varName>\n"
|
||||
"</u:QueryStateVariable>\n" "</s:Body>\n" "</s:Envelope>\n";
|
||||
char *xml_end =
|
||||
"</u:varName>\r\n"
|
||||
"</u:QueryStateVariable>\r\n"
|
||||
"</s:Body>\r\n"
|
||||
"</s:Envelope>\r\n";
|
||||
|
||||
*var_value = NULL; // return NULL in case of an error
|
||||
|
||||
@@ -902,11 +928,16 @@ SoapGetServiceVarStatus( IN char *action_url,
|
||||
}
|
||||
// make headers
|
||||
request.size_inc = 50;
|
||||
if( http_MakeMessage( &request, 1, 1, "Q" "sbc" "N" "s" "s" "U" "c" "sss", SOAPMETHOD_POST, path.buf, path.length, "HOST: ", host.buf, host.length, strlen( xml_start ) + strlen( var_name ) + strlen( xml_end ), // content-length
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"urn:schemas"
|
||||
"-upnp-org:control-1-0#QueryStateVariable\"\r\n",
|
||||
xml_start, var_name, xml_end ) != 0 ) {
|
||||
content_length = strlen( xml_start ) + strlen( var_name ) + strlen( xml_end );
|
||||
if (http_MakeMessage(
|
||||
&request, 1, 1,
|
||||
"Q" "sbc" "N" "s" "s" "Ucc" "sss",
|
||||
SOAPMETHOD_POST, path.buf, path.length,
|
||||
"HOST: ", host.buf, host.length,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"SOAPACTION: \"urn:schemas-upnp-org:control-1-0#QueryStateVariable\"",
|
||||
xml_start, var_name, xml_end ) != 0 ) {
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
}
|
||||
// send msg and get reply
|
||||
|
||||
@@ -85,7 +85,7 @@ const char *ContentTypeHeader =
|
||||
* 0 if successful else returns appropriate error.
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
get_request_type( IN http_message_t * request,
|
||||
OUT memptr * action_name )
|
||||
{
|
||||
@@ -189,7 +189,7 @@ send_error_response( IN SOCKINFO * info,
|
||||
IN const char *err_msg,
|
||||
IN http_message_t * hmsg )
|
||||
{
|
||||
int content_length;
|
||||
off_t content_length;
|
||||
int timeout_secs = SOAP_TIMEOUT;
|
||||
int major,
|
||||
minor;
|
||||
@@ -228,20 +228,19 @@ send_error_response( IN SOCKINFO * info,
|
||||
|
||||
// make headers
|
||||
membuffer_init( &headers );
|
||||
/* -- PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net> */
|
||||
if( http_MakeMessage( &headers, major, minor,
|
||||
"RNsDsSXc" "sssss",
|
||||
500,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"EXT:\r\n",
|
||||
X_USER_AGENT,
|
||||
start_body, err_code_str, mid_body, err_msg,
|
||||
end_body ) != 0 ) {
|
||||
if (http_MakeMessage(
|
||||
&headers, major, minor,
|
||||
"RNsDsSXcc" "sssss",
|
||||
500,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"EXT:\r\n",
|
||||
X_USER_AGENT,
|
||||
start_body, err_code_str, mid_body, err_msg,
|
||||
end_body ) != 0 ) {
|
||||
membuffer_destroy( &headers );
|
||||
return; // out of mem
|
||||
}
|
||||
/*-- PATCH END - */
|
||||
// send err msg
|
||||
http_SendMessage( info, &timeout_secs, "b",
|
||||
headers.buf, headers.length );
|
||||
@@ -263,17 +262,16 @@ send_error_response( IN SOCKINFO * info,
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
send_var_query_response( IN SOCKINFO * info,
|
||||
IN const char *var_value,
|
||||
IN http_message_t * hmsg )
|
||||
{
|
||||
int content_length;
|
||||
off_t content_length;
|
||||
int timeout_secs = SOAP_TIMEOUT;
|
||||
int major,
|
||||
minor;
|
||||
int major;
|
||||
int minor;
|
||||
const char *start_body =
|
||||
// "<?xml version=\"1.0\"?>\n" required??
|
||||
"<s:Envelope "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
|
||||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
|
||||
@@ -297,19 +295,18 @@ send_var_query_response( IN SOCKINFO * info,
|
||||
// make headers
|
||||
membuffer_init( &response );
|
||||
|
||||
/* -- PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net> */
|
||||
if( http_MakeMessage( &response, major, minor,
|
||||
"RNsDsSXcc" "sss",
|
||||
HTTP_OK,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"EXT:\r\n",
|
||||
X_USER_AGENT,
|
||||
start_body, var_value, end_body ) != 0 ) {
|
||||
if (http_MakeMessage(
|
||||
&response, major, minor,
|
||||
"RNsDsSXcc" "sss",
|
||||
HTTP_OK,
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"EXT:\r\n",
|
||||
X_USER_AGENT,
|
||||
start_body, var_value, end_body ) != 0 ) {
|
||||
membuffer_destroy( &response );
|
||||
return; // out of mem
|
||||
}
|
||||
/* -- PATCH END - */
|
||||
|
||||
// send msg
|
||||
http_SendMessage( info, &timeout_secs, "b",
|
||||
@@ -329,12 +326,12 @@ send_var_query_response( IN SOCKINFO * info,
|
||||
* Description : This function separates the action node from
|
||||
* the root DOM node.
|
||||
*
|
||||
* Return : static XINLINE int
|
||||
* Return : static UPNP_INLINE int
|
||||
* 0 if successful, or -1 if fails.
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
get_action_node( IN IXML_Document * TempDoc,
|
||||
IN char *NodeName,
|
||||
OUT IXML_Document ** RespNode )
|
||||
@@ -347,11 +344,10 @@ get_action_node( IN IXML_Document * TempDoc,
|
||||
int ret_code = -1; // error, by default
|
||||
IXML_NodeList *nl = NULL;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"get_action_node(): node name =%s\n ", NodeName );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"get_action_node(): node name =%s\n ", NodeName );
|
||||
|
||||
* RespNode = NULL;
|
||||
*RespNode = NULL;
|
||||
|
||||
// Got the Envelope node here
|
||||
EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc );
|
||||
@@ -603,13 +599,13 @@ get_device_info( IN http_message_t * request,
|
||||
service_info *serv_info;
|
||||
char save_char;
|
||||
int ret_code = -1; // error by default
|
||||
char *control_url;
|
||||
const char *control_url;
|
||||
char *actionName = NULL;
|
||||
|
||||
// null-terminate pathquery of url
|
||||
control_url = request->uri.pathquery.buff;
|
||||
save_char = control_url[request->uri.pathquery.size];
|
||||
control_url[request->uri.pathquery.size] = '\0';
|
||||
((char *)control_url)[request->uri.pathquery.size] = '\0';
|
||||
|
||||
HandleLock( );
|
||||
|
||||
@@ -666,7 +662,7 @@ get_device_info( IN http_message_t * request,
|
||||
ret_code = 0;
|
||||
|
||||
error_handler:
|
||||
control_url[request->uri.pathquery.size] = save_char; // restore
|
||||
((char *)control_url)[request->uri.pathquery.size] = save_char; // restore
|
||||
HandleUnlock( );
|
||||
return ret_code;
|
||||
}
|
||||
@@ -685,7 +681,7 @@ get_device_info( IN http_message_t * request,
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
send_action_response( IN SOCKINFO * info,
|
||||
IN IXML_Document * action_resp,
|
||||
IN http_message_t * request )
|
||||
@@ -695,7 +691,7 @@ send_action_response( IN SOCKINFO * info,
|
||||
int major,
|
||||
minor;
|
||||
int err_code;
|
||||
int content_length;
|
||||
off_t content_length;
|
||||
int ret_code;
|
||||
int timeout_secs = SOAP_TIMEOUT;
|
||||
static char *start_body =
|
||||
@@ -717,17 +713,22 @@ send_action_response( IN SOCKINFO * info,
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
content_length = strlen( start_body ) + strlen( xml_response ) +
|
||||
content_length =
|
||||
strlen( start_body ) +
|
||||
strlen( xml_response ) +
|
||||
strlen( end_body );
|
||||
|
||||
// make headers
|
||||
/* -- PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net> */
|
||||
if( http_MakeMessage( &headers, major, minor, "RNsDsSXcc", HTTP_OK, // status code
|
||||
content_length, ContentTypeHeader, "EXT:\r\n", X_USER_AGENT // EXT header
|
||||
) != 0 ) {
|
||||
if (http_MakeMessage(
|
||||
&headers, major, minor,
|
||||
"RNsDsSXcc",
|
||||
HTTP_OK, // status code
|
||||
content_length,
|
||||
ContentTypeHeader,
|
||||
"EXT:\r\n",
|
||||
X_USER_AGENT) != 0 ) {
|
||||
goto error_handler;
|
||||
}
|
||||
/* -- PATCH END - */
|
||||
|
||||
// send whole msg
|
||||
ret_code = http_SendMessage( info, &timeout_secs, "bbbb",
|
||||
@@ -736,15 +737,15 @@ send_action_response( IN SOCKINFO * info,
|
||||
xml_response, strlen( xml_response ),
|
||||
end_body, strlen( end_body ) );
|
||||
|
||||
DBGONLY( if( ret_code != 0 ) {
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Failed to send response: err code = %d\n",
|
||||
ret_code );}
|
||||
)
|
||||
if( ret_code != 0 ) {
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Failed to send response: err code = %d\n",
|
||||
ret_code );
|
||||
}
|
||||
|
||||
err_code = 0;
|
||||
err_code = 0;
|
||||
|
||||
error_handler:
|
||||
error_handler:
|
||||
ixmlFreeDOMString( xml_response );
|
||||
membuffer_destroy( &headers );
|
||||
if( err_code != 0 ) {
|
||||
@@ -768,7 +769,7 @@ send_action_response( IN SOCKINFO * info,
|
||||
* returns 0 if successful else returns -1.
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
get_var_name( IN IXML_Document * TempDoc,
|
||||
OUT char *VarName )
|
||||
{
|
||||
@@ -778,7 +779,7 @@ get_var_name( IN IXML_Document * TempDoc,
|
||||
IXML_Node *VarNameNode = NULL;
|
||||
IXML_Node *VarNode = NULL;
|
||||
const DOMString StNodeName = NULL;
|
||||
DOMString Temp = NULL;
|
||||
const DOMString Temp = NULL;
|
||||
int ret_val = -1;
|
||||
|
||||
// Got the Envelop node here
|
||||
@@ -812,14 +813,13 @@ get_var_name( IN IXML_Document * TempDoc,
|
||||
Temp = ixmlNode_getNodeValue( VarNode );
|
||||
linecopy( VarName, Temp );
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Received query for variable name %s\n",
|
||||
VarName );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Received query for variable name %s\n",
|
||||
VarName );
|
||||
|
||||
ret_val = 0; // success
|
||||
ret_val = 0; // success
|
||||
|
||||
error_handler:
|
||||
error_handler:
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ get_var_name( IN IXML_Document * TempDoc,
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
handle_query_variable( IN SOCKINFO * info,
|
||||
IN http_message_t * request,
|
||||
IN IXML_Document * xml_doc )
|
||||
@@ -876,8 +876,8 @@ handle_query_variable( IN SOCKINFO * info,
|
||||
// send event
|
||||
soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie );
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Return from callback for var request\n" ) );
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Return from callback for var request\n" );
|
||||
|
||||
// validate, and handle result
|
||||
if( variable.CurrentVal == NULL ) {
|
||||
@@ -966,8 +966,8 @@ handle_invoke_action( IN SOCKINFO * info,
|
||||
action.ErrCode = UPNP_E_SUCCESS;
|
||||
action.CtrlPtIPAddr = info->foreign_ip_addr;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Calling Callback\n" ) );
|
||||
UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__,
|
||||
"Calling Callback\n" );
|
||||
|
||||
soap_event_callback( UPNP_CONTROL_ACTION_REQUEST, &action, cookie );
|
||||
|
||||
|
||||
@@ -125,16 +125,16 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg,
|
||||
|
||||
// we are assuming that there can be only one client supported at a time
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// copy
|
||||
ctrlpt_callback = ctrlpt_info->Callback;
|
||||
ctrlpt_cookie = ctrlpt_info->Cookie;
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
// search timeout
|
||||
if( timeout ) {
|
||||
@@ -268,9 +268,9 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg,
|
||||
return; // bad reply
|
||||
}
|
||||
//check each current search
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
node = ListHead( &ctrlpt_info->SsdpSearchList );
|
||||
@@ -344,7 +344,7 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg,
|
||||
node = ListNext( &ctrlpt_info->SsdpSearchList, node );
|
||||
}
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
//ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, ¶m, cookie );
|
||||
}
|
||||
}
|
||||
@@ -353,11 +353,11 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg,
|
||||
* Function : process_reply
|
||||
*
|
||||
* Parameters:
|
||||
* IN char* request_buf: the response came from the device
|
||||
* IN int buf_len: The length of the response buffer
|
||||
* IN struct sockaddr_in* dest_addr: The address of the device
|
||||
* IN void *cookie : cookie passed by the control point application
|
||||
* at the time of sending search message
|
||||
* IN char* request_buf: the response came from the device
|
||||
* IN int buf_len: The length of the response buffer
|
||||
* IN struct sockaddr_in* dest_addr: The address of the device
|
||||
* IN void *cookie : cookie passed by the control point application
|
||||
* at the time of sending search message
|
||||
*
|
||||
* Description:
|
||||
* This function processes reply recevied from a search
|
||||
@@ -365,7 +365,9 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg,
|
||||
* Returns: void
|
||||
*
|
||||
***************************************************************************/
|
||||
static XINLINE void
|
||||
#warning There are currently no uses of the function 'process_reply()' in the code.
|
||||
#warning 'process_reply()' is a good candidate for removal.
|
||||
static UPNP_INLINE void
|
||||
process_reply( IN char *request_buf,
|
||||
IN int buf_len,
|
||||
IN struct sockaddr_in *dest_addr,
|
||||
@@ -391,14 +393,14 @@ process_reply( IN char *request_buf,
|
||||
* Function : CreateClientRequestPacket
|
||||
*
|
||||
* Parameters:
|
||||
* IN char * RqstBuf:Output string in HTTP format.
|
||||
* IN char *SearchTarget:Search Target
|
||||
* IN int Mx dest_addr: Number of seconds to wait to
|
||||
* collect all the responses
|
||||
* IN char * RqstBuf:Output string in HTTP format.
|
||||
* IN char *SearchTarget:Search Target
|
||||
* IN int Mx dest_addr: Number of seconds to wait to
|
||||
* collect all the responses
|
||||
*
|
||||
* Description:
|
||||
* This function creates a HTTP search request packet
|
||||
* depending on the input parameter.
|
||||
* depending on the input parameter.
|
||||
*
|
||||
* Returns: void
|
||||
*
|
||||
@@ -456,13 +458,13 @@ searchExpired( void *arg )
|
||||
void *cookie = NULL;
|
||||
int found = 0;
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
|
||||
//remove search target from search list
|
||||
|
||||
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
|
||||
free( id );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -483,7 +485,7 @@ searchExpired( void *arg )
|
||||
}
|
||||
node = ListNext( &ctrlpt_info->SsdpSearchList, node );
|
||||
}
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
if( found ) {
|
||||
ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie );
|
||||
@@ -536,11 +538,10 @@ SearchByTarget( IN int Mx,
|
||||
if( ReqBuf == NULL )
|
||||
return UPNP_E_OUTOF_MEMORY;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
">>> SSDP SEND >>>\n%s\n", ReqBuf );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
">>> SSDP SEND >>>\n%s\n", ReqBuf );
|
||||
|
||||
timeTillRead = Mx;
|
||||
timeTillRead = Mx;
|
||||
|
||||
if( timeTillRead < MIN_SEARCH_TIME ) {
|
||||
timeTillRead = MIN_SEARCH_TIME;
|
||||
@@ -559,9 +560,9 @@ SearchByTarget( IN int Mx,
|
||||
FD_SET( gSsdpReqSocket, &wrSet );
|
||||
|
||||
//add search criteria to list
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
free( ReqBuf );
|
||||
return UPNP_E_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -582,33 +583,30 @@ SearchByTarget( IN int Mx,
|
||||
newArg->timeoutEventId = ( *id );
|
||||
|
||||
ListAddTail( &ctrlpt_info->SsdpSearchList, newArg );
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
setsockopt( gSsdpReqSocket, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
( char * )&addr, sizeof( addr ) );
|
||||
|
||||
if( select( gSsdpReqSocket + 1, NULL, &wrSet, NULL, NULL )
|
||||
== UPNP_SOCKETERROR ) {
|
||||
DBGONLY( if( errno == EBADF ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler:An invalid file descriptor"
|
||||
" was givenin one of the sets. \n" );}
|
||||
else
|
||||
if( errno == EINTR ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler: A non blocked "
|
||||
"signal was caught. \n" );}
|
||||
else
|
||||
if( errno == EINVAL ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler: n is negative. \n" );}
|
||||
else
|
||||
if( errno == ENOMEM ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB : RequestHandler:select was unable to "
|
||||
"allocate memory for internal tables.\n" );}
|
||||
)
|
||||
shutdown( gSsdpReqSocket, SD_BOTH );
|
||||
if( errno == EBADF ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler:An invalid file descriptor"
|
||||
" was givenin one of the sets. \n" );
|
||||
} else if( errno == EINTR ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler: A non blocked "
|
||||
"signal was caught. \n" );
|
||||
} else if( errno == EINVAL ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB :RequestHandler: n is negative. \n" );
|
||||
} else if( errno == ENOMEM ) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB : RequestHandler:select was unable to "
|
||||
"allocate memory for internal tables.\n" );
|
||||
}
|
||||
shutdown( gSsdpReqSocket, SD_BOTH );
|
||||
UpnpCloseSocket( gSsdpReqSocket );
|
||||
free( ReqBuf );
|
||||
return UPNP_E_INTERNAL_ERROR;
|
||||
|
||||
@@ -43,19 +43,19 @@
|
||||
#include "unixutil.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#define MSGTYPE_SHUTDOWN 0
|
||||
#define MSGTYPE_SHUTDOWN 0
|
||||
#define MSGTYPE_ADVERTISEMENT 1
|
||||
#define MSGTYPE_REPLY 2
|
||||
#define MSGTYPE_REPLY 2
|
||||
|
||||
/************************************************************************
|
||||
* Function : advertiseAndReplyThread
|
||||
*
|
||||
* Parameters:
|
||||
* IN void *data: Structure containing the search request
|
||||
* IN void *data: Structure containing the search request
|
||||
*
|
||||
* Description:
|
||||
* This function is a wrapper function to reply the search request
|
||||
@@ -84,8 +84,8 @@ advertiseAndReplyThread( IN void *data )
|
||||
* Function : ssdp_handle_device_request
|
||||
*
|
||||
* Parameters:
|
||||
* IN http_message_t* hmsg: SSDP search request from the control point
|
||||
* IN struct sockaddr_in* dest_addr: The address info of control point
|
||||
* IN http_message_t* hmsg: SSDP search request from the control point
|
||||
* IN struct sockaddr_in* dest_addr: The address info of control point
|
||||
*
|
||||
* Description:
|
||||
* This function handles the search request. It do the sanity checks of
|
||||
@@ -95,6 +95,7 @@ advertiseAndReplyThread( IN void *data )
|
||||
* Returns: void *
|
||||
* 1 if successful else appropriate error
|
||||
***************************************************************************/
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
void
|
||||
ssdp_handle_device_request( IN http_message_t * hmsg,
|
||||
IN struct sockaddr_in *dest_addr )
|
||||
@@ -135,30 +136,30 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
|
||||
return; // bad ST header
|
||||
}
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
// device info
|
||||
if( GetDeviceHandleInfo( &handle, &dev_info ) != HND_DEVICE ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return; // no info found
|
||||
}
|
||||
maxAge = dev_info->MaxAge;
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"ssdp_handle_device_request with Cmd %d SEARCH\n",
|
||||
event.Cmd );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"MAX-AGE = %d\n", maxAge );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"MX = %d\n", event.Mx );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"DeviceType = %s\n", event.DeviceType );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"DeviceUuid = %s\n", event.UDN );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"ServiceType = %s\n", event.ServiceType ); )
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"ssdp_handle_device_request with Cmd %d SEARCH\n",
|
||||
event.Cmd );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"MAX-AGE = %d\n", maxAge );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"MX = %d\n", event.Mx );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"DeviceType = %s\n", event.DeviceType );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"DeviceUuid = %s\n", event.UDN );
|
||||
UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__,
|
||||
"ServiceType = %s\n", event.ServiceType );
|
||||
|
||||
threadArg =
|
||||
threadArg =
|
||||
( SsdpSearchReply * ) malloc( sizeof( SsdpSearchReply ) );
|
||||
|
||||
if( threadArg == NULL ) {
|
||||
@@ -185,11 +186,12 @@ ssdp_handle_device_request( IN http_message_t * hmsg,
|
||||
mx = 1;
|
||||
}
|
||||
|
||||
replyTime = rand( ) % mx;
|
||||
replyTime = rand() % mx;
|
||||
|
||||
TimerThreadSchedule( &gTimerThread, replyTime, REL_SEC, &job,
|
||||
SHORT_TERM, NULL );
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Function : NewRequestHandler
|
||||
@@ -220,9 +222,9 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr,
|
||||
|
||||
ReplySock = socket( AF_INET, SOCK_DGRAM, 0 );
|
||||
if( ReplySock == UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB: New Request Handler:"
|
||||
"Error in socket operation !!!\n" ) );
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP_LIB: New Request Handler:"
|
||||
"Error in socket operation !!!\n" );
|
||||
|
||||
return UPNP_E_OUTOF_SOCKET;
|
||||
}
|
||||
@@ -234,16 +236,25 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr,
|
||||
|
||||
for( Index = 0; Index < NumPacket; Index++ ) {
|
||||
int rc;
|
||||
|
||||
// The reason to keep this loop is purely historical/documentation,
|
||||
// according to section 9.2 of HTTPU spec:
|
||||
//
|
||||
// "If a multicast resource would send a response(s) to any copy of the
|
||||
// request, it SHOULD send its response(s) to each copy of the request
|
||||
// it receives. It MUST NOT repeat its response(s) per copy of the
|
||||
// reuqest."
|
||||
//
|
||||
// http://www.upnp.org/download/draft-goland-http-udp-04.txt
|
||||
//
|
||||
// So, NUM_COPY has been changed from 2 to 1.
|
||||
NumCopy = 0;
|
||||
while( NumCopy < NUM_COPY ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
">>> SSDP SEND >>>\n%s\n",
|
||||
*( RqPacket + Index ) );
|
||||
)
|
||||
rc = sendto( ReplySock, *( RqPacket + Index ),
|
||||
strlen( *( RqPacket + Index ) ),
|
||||
0, ( struct sockaddr * )DestAddr, socklen );
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
">>> SSDP SEND >>>\n%s\n",
|
||||
*( RqPacket + Index ) );
|
||||
rc = sendto( ReplySock, *( RqPacket + Index ),
|
||||
strlen( *( RqPacket + Index ) ),
|
||||
0, ( struct sockaddr * )DestAddr, socklen );
|
||||
imillisleep( SSDP_PAUSE );
|
||||
++NumCopy;
|
||||
}
|
||||
@@ -295,16 +306,16 @@ CreateServicePacket( IN int msg_type,
|
||||
*packet = NULL;
|
||||
|
||||
if( msg_type == MSGTYPE_REPLY ) {
|
||||
/* -- PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net> */
|
||||
ret_code = http_MakeMessage( &buf, 1, 1,
|
||||
"R" "sdc" "D" "s" "ssc" "S" "Xc" "ssc"
|
||||
"ssc" "c", HTTP_OK,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"EXT:\r\n", "LOCATION: ", location,
|
||||
X_USER_AGENT,
|
||||
"ST: ", nt, "USN: ", usn );
|
||||
/* -- PATCH END - */
|
||||
|
||||
ret_code = http_MakeMessage(
|
||||
&buf, 1, 1,
|
||||
"R" "sdc" "D" "sc" "ssc" "S" "Xc" "ssc" "sscc",
|
||||
HTTP_OK,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"EXT:",
|
||||
"LOCATION: ", location,
|
||||
X_USER_AGENT,
|
||||
"ST: ", nt,
|
||||
"USN: ", usn);
|
||||
if( ret_code != 0 ) {
|
||||
return;
|
||||
}
|
||||
@@ -320,15 +331,17 @@ CreateServicePacket( IN int msg_type,
|
||||
// NOTE: The CACHE-CONTROL and LOCATION headers are not present in
|
||||
// a shutdown msg, but are present here for MS WinMe interop.
|
||||
|
||||
/* -- PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net> */
|
||||
ret_code = http_MakeMessage( &buf, 1, 1,
|
||||
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc"
|
||||
"S" "Xc" "ssc" "c", HTTPMETHOD_NOTIFY, "*",
|
||||
1, "HOST: ", SSDP_IP, ":", SSDP_PORT,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"LOCATION: ", location, "NT: ", nt,
|
||||
"NTS: ", nts, X_USER_AGENT, "USN: ", usn );
|
||||
/* -- PATCH END - */
|
||||
ret_code = http_MakeMessage(
|
||||
&buf, 1, 1,
|
||||
"Q" "sssdc" "sdc" "ssc" "ssc" "ssc" "S" "Xc" "sscc",
|
||||
HTTPMETHOD_NOTIFY, "*",
|
||||
1, "HOST: ", SSDP_IP, ":", SSDP_PORT,
|
||||
"CACHE-CONTROL: max-age=", duration,
|
||||
"LOCATION: ", location,
|
||||
"NT: ", nt,
|
||||
"NTS: ", nts,
|
||||
X_USER_AGENT,
|
||||
"USN: ", usn );
|
||||
if( ret_code != 0 ) {
|
||||
return;
|
||||
}
|
||||
@@ -376,11 +389,10 @@ DeviceAdvertisement( IN char *DevType,
|
||||
char *msgs[3];
|
||||
int ret_code;
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function SendDeviceAdvertisemenrt\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function SendDeviceAdvertisemenrt\n" );
|
||||
|
||||
DestAddr.sin_family = AF_INET;
|
||||
DestAddr.sin_family = AF_INET;
|
||||
DestAddr.sin_addr.s_addr = inet_addr( SSDP_IP );
|
||||
DestAddr.sin_port = htons( SSDP_PORT );
|
||||
|
||||
@@ -771,11 +783,11 @@ DeviceShutdown( IN char *DevType,
|
||||
Mil_Usn, Location, Duration, &msgs[0] );
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function DeviceShutdown\n" ); )
|
||||
// both root and sub-devices need to send these two messages
|
||||
CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn,
|
||||
Location, Duration, &msgs[1] );
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"In function DeviceShutdown\n" );
|
||||
// both root and sub-devices need to send these two messages
|
||||
CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn,
|
||||
Location, Duration, &msgs[1] );
|
||||
|
||||
sprintf( Mil_Usn, "%s::%s", Udn, DevType );
|
||||
CreateServicePacket( MSGTYPE_SHUTDOWN, DevType, Mil_Usn,
|
||||
|
||||
@@ -91,14 +91,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
* Returns: int
|
||||
* UPNP_E_SUCCESS if successful else appropriate error
|
||||
***************************************************************************/
|
||||
int AdvertiseAndReply( IN int AdFlag,
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
IN enum SsdpSearchType SearchType,
|
||||
IN struct sockaddr_in *DestAddr,
|
||||
IN char *DeviceType,
|
||||
IN char *DeviceUDN,
|
||||
IN char *ServiceType,
|
||||
int Exp )
|
||||
int AdvertiseAndReply( IN int AdFlag,
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
IN enum SsdpSearchType SearchType,
|
||||
IN struct sockaddr_in *DestAddr,
|
||||
IN char *DeviceType,
|
||||
IN char *DeviceUDN,
|
||||
IN char *ServiceType,
|
||||
int Exp )
|
||||
{
|
||||
int i,
|
||||
j;
|
||||
@@ -112,17 +112,17 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
IXML_Node *tmpNode = NULL;
|
||||
IXML_Node *tmpNode2 = NULL;
|
||||
IXML_Node *textNode = NULL;
|
||||
DOMString tmpStr;
|
||||
const DOMString tmpStr;
|
||||
char SERVER[200];
|
||||
|
||||
DBGONLY( const DOMString dbgStr;
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
||||
AdFlag ); )
|
||||
const DOMString dbgStr;
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Inside AdvertiseAndReply with AdFlag = %d\n",
|
||||
AdFlag );
|
||||
|
||||
HandleLock( );
|
||||
HandleLock();
|
||||
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
|
||||
HandleUnlock( );
|
||||
HandleUnlock();
|
||||
return UPNP_E_INVALID_HANDLE;
|
||||
}
|
||||
defaultExp = SInfo->MaxAge;
|
||||
@@ -139,24 +139,20 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
// parse the device list and send advertisements/replies
|
||||
for( i = 0;; i++ ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Entering new device list with i = %d\n\n",
|
||||
i );
|
||||
)
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Entering new device list with i = %d\n\n", i );
|
||||
|
||||
tmpNode = ixmlNodeList_item( SInfo->DeviceList, i );
|
||||
tmpNode = ixmlNodeList_item( SInfo->DeviceList, i );
|
||||
if( tmpNode == NULL ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Exiting new device list with i = %d\n\n",
|
||||
i );
|
||||
)
|
||||
break;
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Exiting new device list with i = %d\n\n", i );
|
||||
break;
|
||||
}
|
||||
|
||||
DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Extracting device type once for %s\n",
|
||||
dbgStr ); )
|
||||
"Extracting device type once for %s\n",
|
||||
dbgStr );
|
||||
// extract device type
|
||||
ixmlNodeList_free( nodeList );
|
||||
nodeList = NULL;
|
||||
@@ -167,15 +163,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr ); )
|
||||
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr );
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type\n" );
|
||||
|
||||
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
||||
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
||||
if( tmpNode2 == NULL ) {
|
||||
continue;
|
||||
}
|
||||
@@ -184,11 +179,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type \n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type \n" );
|
||||
|
||||
tmpStr = ixmlNode_getNodeValue( textNode );
|
||||
tmpStr = ixmlNode_getNodeValue( textNode );
|
||||
if( tmpStr == NULL ) {
|
||||
continue;
|
||||
}
|
||||
@@ -198,47 +192,41 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type = %s\n", devType );
|
||||
if( tmpNode == NULL ) {
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"TempNode is NULL\n" );}
|
||||
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr ); )
|
||||
// extract UDN
|
||||
ixmlNodeList_free( nodeList );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting device type = %s\n", devType );
|
||||
if( tmpNode == NULL ) {
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"TempNode is NULL\n" );
|
||||
}
|
||||
dbgStr = ixmlNode_getNodeName( tmpNode );
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Extracting UDN for %s\n", dbgStr );
|
||||
// extract UDN
|
||||
ixmlNodeList_free( nodeList );
|
||||
nodeList = NULL;
|
||||
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
||||
tmpNode, "UDN" );
|
||||
if( nodeList == NULL ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
continue;
|
||||
}
|
||||
tmpNode2 = ixmlNodeList_item( nodeList, 0 );
|
||||
if( tmpNode2 == NULL ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
)
|
||||
continue;
|
||||
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
continue;
|
||||
}
|
||||
textNode = ixmlNode_getFirstChild( tmpNode2 );
|
||||
if( textNode == NULL ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
)
|
||||
continue;
|
||||
UpnpPrintf( UPNP_CRITICAL, API, __FILE__,
|
||||
__LINE__, "UDN not found!!!\n" );
|
||||
continue;
|
||||
}
|
||||
tmpStr = ixmlNode_getNodeValue( textNode );
|
||||
if( tmpStr == NULL ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||
"UDN not found!!!!\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||
"UDN not found!!!!\n" );
|
||||
continue;
|
||||
}
|
||||
strcpy( UDNstr, tmpStr );
|
||||
@@ -246,9 +234,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Sending UDNStr = %s \n", UDNstr );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Sending UDNStr = %s \n", UDNstr );
|
||||
if( AdFlag ) {
|
||||
// send the device advertisement
|
||||
if( AdFlag == 1 ) {
|
||||
@@ -278,22 +265,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
{
|
||||
if( DeviceUDN != NULL && strlen( DeviceUDN ) != 0 ) {
|
||||
if( strcasecmp( DeviceUDN, UDNstr ) ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, API, __FILE__,
|
||||
__LINE__,
|
||||
"DeviceUDN=%s and search "
|
||||
"UDN=%s did not match\n",
|
||||
UDNstr, DeviceUDN );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceUDN=%s and search "
|
||||
"UDN=%s did not match\n",
|
||||
UDNstr, DeviceUDN );
|
||||
break;
|
||||
} else {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, API, __FILE__,
|
||||
__LINE__,
|
||||
"DeviceUDN=%s and search "
|
||||
"UDN=%s MATCH\n", UDNstr,
|
||||
DeviceUDN );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceUDN=%s and search "
|
||||
"UDN=%s MATCH\n", UDNstr,
|
||||
DeviceUDN );
|
||||
SendReply( DestAddr, devType, 0,
|
||||
UDNstr, SInfo->DescURL,
|
||||
defaultExp, 0 );
|
||||
@@ -306,25 +287,18 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
if( !strncasecmp
|
||||
( DeviceType, devType,
|
||||
strlen( DeviceType ) ) ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceType=%s and search devType=%s MATCH\n",
|
||||
devType, DeviceType );
|
||||
)
|
||||
SendReply( DestAddr, devType, 0, UDNstr,
|
||||
SInfo->DescURL, defaultExp, 1 );
|
||||
}
|
||||
|
||||
DBGONLY(
|
||||
else
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__,
|
||||
__LINE__,
|
||||
"DeviceType=%s and search devType=%s"
|
||||
" DID NOT MATCH\n",
|
||||
devType, DeviceType );
|
||||
)
|
||||
|
||||
break;
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceType=%s and search devType=%s MATCH\n",
|
||||
devType, DeviceType );
|
||||
SendReply( DestAddr, devType, 0, UDNstr,
|
||||
SInfo->DescURL, defaultExp, 1 );
|
||||
} else {
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"DeviceType=%s and search devType=%s"
|
||||
" DID NOT MATCH\n",
|
||||
devType, DeviceType );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -332,11 +306,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
}
|
||||
// send service advertisements for services corresponding
|
||||
// to the same device
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Sending service Advertisement\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Sending service Advertisement\n" );
|
||||
|
||||
tmpNode = ixmlNodeList_item( SInfo->ServiceList, i );
|
||||
tmpNode = ixmlNodeList_item( SInfo->ServiceList, i );
|
||||
if( tmpNode == NULL ) {
|
||||
continue;
|
||||
}
|
||||
@@ -345,10 +318,9 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * )
|
||||
tmpNode, "service" );
|
||||
if( nodeList == NULL ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Service not found 3\n" );
|
||||
)
|
||||
continue;
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"Service not found 3\n" );
|
||||
continue;
|
||||
}
|
||||
for( j = 0;; j++ ) {
|
||||
tmpNode = ixmlNodeList_item( nodeList, j );
|
||||
@@ -357,15 +329,11 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
|
||||
ixmlNodeList_free( tmpNodeList );
|
||||
tmpNodeList = NULL;
|
||||
tmpNodeList = ixmlElement_getElementsByTagName( ( IXML_Element
|
||||
* ) tmpNode,
|
||||
"serviceType" );
|
||||
|
||||
tmpNodeList = ixmlElement_getElementsByTagName(
|
||||
( IXML_Element *)tmpNode, "serviceType" );
|
||||
if( tmpNodeList == NULL ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||
"ServiceType not found \n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
|
||||
"ServiceType not found \n" );
|
||||
continue;
|
||||
}
|
||||
tmpNode2 = ixmlNodeList_item( tmpNodeList, 0 );
|
||||
@@ -386,19 +354,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"ServiceType = %s\n", servType );
|
||||
)
|
||||
if( AdFlag ) {
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"ServiceType = %s\n", servType );
|
||||
if( AdFlag ) {
|
||||
if( AdFlag == 1 ) {
|
||||
ServiceAdvertisement( UDNstr, servType,
|
||||
SInfo->DescURL, Exp );
|
||||
} else // AdFlag == -1
|
||||
{
|
||||
} else { // AdFlag == -1
|
||||
ServiceShutdown( UDNstr, servType,
|
||||
SInfo->DescURL, Exp );
|
||||
}
|
||||
|
||||
} else {
|
||||
switch ( SearchType ) {
|
||||
case SSDP_ALL:
|
||||
@@ -433,11 +398,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
||||
ixmlNodeList_free( nodeList );
|
||||
nodeList = NULL;
|
||||
}
|
||||
DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Exiting AdvertiseAndReply : \n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
||||
"Exiting AdvertiseAndReply : \n" );
|
||||
|
||||
HandleUnlock( );
|
||||
HandleUnlock( );
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
|
||||
@@ -677,7 +641,7 @@ free_ssdp_event_handler_data( void *the_data )
|
||||
* Returns: xboolean
|
||||
* returns TRUE if msg is valid else FALSE
|
||||
***************************************************************************/
|
||||
static XINLINE xboolean
|
||||
static UPNP_INLINE xboolean
|
||||
valid_ssdp_msg( IN http_message_t * hmsg )
|
||||
{
|
||||
memptr hdr_value;
|
||||
@@ -719,7 +683,7 @@ valid_ssdp_msg( IN http_message_t * hmsg )
|
||||
* Returns: int
|
||||
* 0 if successful -1 if error
|
||||
***************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
start_event_handler( void *Data )
|
||||
{
|
||||
|
||||
@@ -733,20 +697,18 @@ start_event_handler( void *Data )
|
||||
if( status == PARSE_FAILURE ) {
|
||||
if( parser->msg.method != HTTPMETHOD_NOTIFY ||
|
||||
!parser->valid_ssdp_notify_hack ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP recvd bad msg code = %d\n",
|
||||
status );
|
||||
)
|
||||
// ignore bad msg, or not enuf mem
|
||||
goto error_handler;
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP recvd bad msg code = %d\n",
|
||||
status );
|
||||
// ignore bad msg, or not enuf mem
|
||||
goto error_handler;
|
||||
}
|
||||
// valid notify msg
|
||||
} else if( status != PARSE_SUCCESS ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP recvd bad msg code = %d\n", status );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"SSDP recvd bad msg code = %d\n", status );
|
||||
|
||||
goto error_handler;
|
||||
goto error_handler;
|
||||
}
|
||||
// check msg
|
||||
if( !valid_ssdp_msg( &parser->msg ) ) {
|
||||
@@ -784,14 +746,10 @@ ssdp_event_handler_thread( void *the_data )
|
||||
// send msg to device or ctrlpt
|
||||
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
|
||||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
|
||||
|
||||
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr,
|
||||
FALSE, NULL );
|
||||
);
|
||||
FALSE, NULL ););
|
||||
} else {
|
||||
|
||||
DEVICEONLY( ssdp_handle_device_request( hmsg, &data->dest_addr );
|
||||
);
|
||||
ssdp_handle_device_request( hmsg, &data->dest_addr );
|
||||
}
|
||||
|
||||
// free data
|
||||
@@ -863,21 +821,18 @@ readFromSSDPSocket( SOCKET socket )
|
||||
if( byteReceived > 0 ) {
|
||||
|
||||
requestBuf[byteReceived] = '\0';
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, SSDP,
|
||||
UpnpPrintf( UPNP_INFO, SSDP,
|
||||
__FILE__, __LINE__,
|
||||
"Received response !!! "
|
||||
"%s From host %s \n",
|
||||
requestBuf,
|
||||
inet_ntoa( clientAddr.sin_addr ) );
|
||||
)
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_PACKET, SSDP,
|
||||
__FILE__, __LINE__,
|
||||
"Received multicast packet:"
|
||||
"\n %s\n", requestBuf );
|
||||
)
|
||||
//add thread pool job to handle request
|
||||
if( data != NULL ) {
|
||||
UpnpPrintf( UPNP_PACKET, SSDP, __FILE__, __LINE__,
|
||||
"Received multicast packet:"
|
||||
"\n %s\n", requestBuf );
|
||||
//add thread pool job to handle request
|
||||
if( data != NULL ) {
|
||||
data->parser.msg.msg.length += byteReceived;
|
||||
// null-terminate
|
||||
data->parser.msg.msg.buf[byteReceived] = 0;
|
||||
@@ -891,7 +846,6 @@ readFromSSDPSocket( SOCKET socket )
|
||||
free_ssdp_event_handler_data( data );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
free_ssdp_event_handler_data( data );
|
||||
}
|
||||
@@ -922,12 +876,13 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
struct ip_mreq ssdpMcastAddr;
|
||||
struct sockaddr_in ssdpAddr;
|
||||
int option = 1;
|
||||
struct in_addr addr;
|
||||
|
||||
CLIENTONLY( if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
||||
== UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" ); )
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" );
|
||||
return UPNP_E_OUTOF_SOCKET;}
|
||||
setsockopt( ssdpReqSock,
|
||||
IPPROTO_IP,
|
||||
@@ -937,11 +892,10 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
|
||||
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
||||
== UPNP_INVALID_SOCKET ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" );
|
||||
)
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in socket operation !!!\n" );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||
return UPNP_E_OUTOF_SOCKET;
|
||||
}
|
||||
@@ -950,11 +904,10 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR,
|
||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in set reuse addr !!!\n" );
|
||||
)
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in set reuse addr !!!\n" );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
UpnpCloseSocket( ssdpSock );
|
||||
@@ -965,11 +918,10 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in set reuse port !!!\n" );
|
||||
)
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in set reuse port !!!\n" );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
UpnpCloseSocket( ssdpSock );
|
||||
@@ -985,10 +937,9 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
if( bind
|
||||
( ssdpSock, ( struct sockaddr * )&ssdpAddr,
|
||||
sizeof( ssdpAddr ) ) != 0 ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in binding !!!\n" );
|
||||
)
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in binding !!!\n" );
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
UpnpCloseSocket( ssdpSock );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
@@ -997,31 +948,40 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
||||
}
|
||||
|
||||
memset( ( void * )&ssdpMcastAddr, 0, sizeof( struct ip_mreq ) );
|
||||
ssdpMcastAddr.imr_interface.s_addr = htonl( INADDR_ANY );
|
||||
ssdpMcastAddr.imr_interface.s_addr = inet_addr( LOCAL_HOST );
|
||||
ssdpMcastAddr.imr_multiaddr.s_addr = inet_addr( SSDP_IP );
|
||||
if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||
( char * )&ssdpMcastAddr,
|
||||
sizeof( struct ip_mreq ) ) != 0 ) {
|
||||
DBGONLY( UpnpPrintf
|
||||
( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in joining" " multicast group !!!\n" );
|
||||
)
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in joining" " multicast group !!!\n" );
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
UpnpCloseSocket( ssdpSock );
|
||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
/* Set multicast interface. */
|
||||
memset( ( void * )&addr, 0, sizeof( struct in_addr ));
|
||||
addr.s_addr = inet_addr(LOCAL_HOST);
|
||||
if (setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
(char *)&addr, sizeof addr) != 0) {
|
||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||
"Couldn't set multicast interface.\n" );
|
||||
/* This is probably not a critical error, so let's continue. */
|
||||
}
|
||||
|
||||
// result is not checked becuase it will fail in WinMe and Win9x.
|
||||
setsockopt( ssdpSock, IPPROTO_IP,
|
||||
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
||||
( char * )&option, sizeof( option ) ) != 0 ) {
|
||||
DBGONLY( UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in setting broadcast !!!\n" );
|
||||
)
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
UpnpPrintf( UPNP_CRITICAL,
|
||||
SSDP, __FILE__, __LINE__,
|
||||
"Error in setting broadcast !!!\n" );
|
||||
shutdown( ssdpSock, SD_BOTH );
|
||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||
UpnpCloseSocket( ssdpSock );
|
||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE void
|
||||
static UPNP_INLINE void
|
||||
addrToString( IN const struct sockaddr_in *addr,
|
||||
OUT char ipaddr_port[] )
|
||||
{
|
||||
@@ -87,7 +87,7 @@ addrToString( IN const struct sockaddr_in *addr,
|
||||
*
|
||||
* Note : 'newAlias' should be freed using free()
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
calc_alias( IN const char *alias,
|
||||
IN const char *rootPath,
|
||||
OUT char **newAlias )
|
||||
@@ -148,7 +148,7 @@ calc_alias( IN const char *alias,
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
static XINLINE int
|
||||
static UPNP_INLINE int
|
||||
calc_descURL( IN const char *ipPortStr,
|
||||
IN const char *alias,
|
||||
OUT char descURL[LINE_SIZE] )
|
||||
@@ -168,11 +168,10 @@ calc_descURL( IN const char *ipPortStr,
|
||||
strcat( descURL, ipPortStr );
|
||||
strcat( descURL, alias );
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"desc url: %s\n", descURL );
|
||||
)
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"desc url: %s\n", descURL );
|
||||
|
||||
return UPNP_E_SUCCESS;
|
||||
return UPNP_E_SUCCESS;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@@ -213,7 +212,7 @@ config_description_doc( INOUT IXML_Document * doc,
|
||||
IXML_Node *rootNode = NULL;
|
||||
IXML_Node *urlbase_node = NULL;
|
||||
char *urlBaseStr = "URLBase";
|
||||
DOMString domStr = NULL;
|
||||
const DOMString domStr = NULL;
|
||||
uri_type uri;
|
||||
int err_code;
|
||||
int len;
|
||||
@@ -408,18 +407,16 @@ configure_urlbase( INOUT IXML_Document * doc,
|
||||
goto error_handler;
|
||||
}
|
||||
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"desc url: %s\n", docURL );
|
||||
)
|
||||
DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"doc = %s\n", xml_str );
|
||||
)
|
||||
// store in web server
|
||||
err_code =
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"desc url: %s\n", docURL );
|
||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||
"doc = %s\n", xml_str );
|
||||
// store in web server
|
||||
err_code =
|
||||
web_server_set_alias( new_alias, xml_str, strlen( xml_str ),
|
||||
last_modified );
|
||||
|
||||
error_handler:
|
||||
error_handler:
|
||||
free( root_path );
|
||||
free( new_alias );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user