Compare commits

...

145 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
593b8d0a2b Fixes in configure.ac for release. 2010-10-20 11:11:45 -02:00
Marcelo Roberto Jimenez
890c1b6ef8 Disable debug for release. 2010-10-20 10:36:11 -02:00
Marcelo Roberto Jimenez
c127a3a87e Add docs/doxygen to .gitignore. 2010-10-20 10:35:15 -02:00
Marcelo Roberto Jimenez
bd5758186c White spaces. 2010-10-20 10:29:45 -02:00
Marcelo Roberto Jimenez
cc472bc2cd Doxygen and indentation for sock. 2010-10-20 09:05:42 -02:00
Marcelo Roberto Jimenez
6128296e5f Doxygen and indentation for miniserver. 2010-10-20 08:56:06 -02:00
Marcelo Roberto Jimenez
d84c6a7e9f Indent plus Doxygen in webserver. 2010-10-20 01:28:37 -02:00
Marcelo Roberto Jimenez
113ebd1f91 Slightly better implementation for ToUpperCase(). 2010-10-20 00:36:47 -02:00
Marcelo Roberto Jimenez
bf1450bf81 Fix a long date memory leak in webserver.c:StrStr(). 2010-10-20 00:29:08 -02:00
Marcelo Roberto Jimenez
56b9c75056 Changelog fix. 2010-10-19 16:11:39 -02:00
Marcelo Roberto Jimenez
2bdc9e075e Bug fix in select of miniserver.c
Fix a bug in miniserver.c, in which maxMiniSock was wrongly declared as
unsigned int and as a result it was beeng set to ((unsigned int)(-1)).
As a result, after beeing incremented, it became zero, and this value
was beeing used in the select() call.

Thanks to Fabrice Fontaine for helping and testing with this issue.
2010-10-19 15:49:36 -02:00
Marcelo Roberto Jimenez
923eee2393 Don't ask, UTF-8 mess? 2010-10-15 12:54:00 -03:00
Marcelo Roberto Jimenez
f74746ff3f Fix for 100% CPU issue in select() in miniserv.c. I have also removed
the sleep() call, it was just a workaround.

SF Bug Tracker [ 3086852 ] 99% CPU loop in miniserver.c on a non ipv6
system.

Submitted by: Jin ( jin_eld ) - 2010-10-13 19:29:13 UTC

I cross compiled libupnp 1.6.7 for ARM9 using the --disable-ipv6
option, my system is an ipv4 only setup.

I do not know why this problem only appears when running the app in the
background (for instance using nohup &), but then it starts using 99%
CPU.

I traced the problem down to the select() call in miniserver.c in the
RunMiniServer() function. Select returns code 1, but errno is set to
"Socket operation on non-socket", I also see this when running my app
under strace.

I set all ...Sock6 variables to INVALID_SOCKET to make sure that they
do not get added to the FD_SET and the problem is gone.
2010-10-15 12:41:36 -03:00
Marcelo Roberto Jimenez
8401a59ed5 New function, sock_close(). 2010-10-15 12:25:35 -03:00
Marcelo Roberto Jimenez
5b40cfa272 Misplaced declaration of UpnpCloseSocket. 2010-10-15 12:17:15 -03:00
Marcelo Roberto Jimenez
fcda28ba75 Remove of unused file. 2010-10-15 11:53:25 -03:00
Marcelo Roberto Jimenez
7cd434225f White spaces and comments. 2010-10-04 17:05:43 -03:00
Marcelo Roberto Jimenez
78e5ba89fa Merge of similar files. 2010-10-04 15:48:45 -03:00
Marcelo Roberto Jimenez
ebb8f209b0 Merge of similar files. 2010-10-04 15:36:11 -03:00
Marcelo Roberto Jimenez
73afd667e1 Fix for bug introduced in the last commit. 2010-10-04 13:24:38 -03:00
Marcelo Roberto Jimenez
cc294a6cf1 Merge similar code. 2010-10-04 13:03:20 -03:00
Marcelo Roberto Jimenez
458a9416c6 Merge of work from 1.8.x. 2010-10-04 12:04:38 -03:00
Marcelo Roberto Jimenez
b9eeb89250 Bumped Doxyfile version. 2010-10-04 11:44:06 -03:00
Marcelo Roberto Jimenez
a6e68b481d Updated THANKS. 2010-10-04 11:33:37 -03:00
Marcelo Roberto Jimenez
a19a896e88 Updated TODO list. 2010-10-04 11:28:37 -03:00
Marcelo Roberto Jimenez
cdee5b7cde UTF-8. 2010-10-04 11:11:33 -03:00
Marcelo Roberto Jimenez
dec78c8ef1 Echo the copy on configure output. 2010-10-04 11:01:28 -03:00
Marcelo Roberto Jimenez
fb62a5d42a Update files for windows compilation. 2010-10-04 10:51:30 -03:00
Marcelo Roberto Jimenez
a9b5081a08 Update build/inc/autoconfig.h and build/inc/upnpconfig.h at configure
time.
2010-10-04 10:47:39 -03:00
Marcelo Roberto Jimenez
3886a697b5 Remove build/inc/config.h. The right file is upnp/src/inc/config.h. 2010-10-04 10:42:32 -03:00
Marcelo Roberto Jimenez
3dab2bd00a Homekeeping for the next release. 2010-10-04 09:58:15 -03:00
Marcelo Roberto Jimenez
95f7a7eeef Whitespace fix on soaplib.h. 2010-10-02 18:57:35 -03:00
Marcelo Roberto Jimenez
ca50c2153e Remove extra soaplib.h. 2010-10-02 18:57:13 -03:00
Fabrice Fontaine
c73d870f46 Adding --disable-notification-reordering option
Adding a configure flag to disable GENA notification reordering as even
with an imillisleep(1), this mechanism consumes too much CPU on embedded
devices when there is a burst of notifications.
2010-10-02 13:44:52 -03:00
Fabrice Fontaine
ab54cb3dc5 Bug fix when there is no service in embedded devices
When a device with embedded devices (like IGD) when created and one of
the embedded devices did not have any service, there was a Segmentation
Fault (see SF Tracker [ 2688125 ]).
2010-09-30 11:51:06 -03:00
Fabrice Fontaine
c33b11d09f Bug fix on burst of GENA notification
When a lot of notifications were generated by a device in a short
period of time then 100% of the CPU was used to reorder those
notifications by pushing back the thread in the job queue. This
mechanism has been modified so now thread sleep 1 ms before being
pushed back into the job queue.

Removing DEFAULT_SCHED_PARAM parameter and use
sched_get_priority_min(DEFAULT_POLICY) instead.
2010-09-28 20:41:28 -03:00
Fabrice Fontaine
4966423d96 Bug fix on M-SEARCH response
Devices must respond to M-SEARCH requests for any supported version and the
response should specify the same version as was contained in the search target.
Previously, the device did not answer if the M-SEARCH request did not
contain the same version number than the version number of the device.
2010-09-22 15:34:45 -03:00
Marcelo Roberto Jimenez
2fb55d3874 White space fix. 2010-09-21 16:49:20 -03:00
Fabrice Fontaine
d2238615e3 Add Content-Language iff Accept-Language
Add Content-Language header in the response if and only if there is an Accept-Language header in the request.
2010-09-21 13:50:29 -03:00
Fabrice Fontaine
2fcbe6df52 Addition of WEB_SERVER_CONTENT_LANGUAGE parameter
This patch adds the WEB_SERVER_CONTENT_LANGUAGE parameter so the user can specify
the language used by the device during Description and Presentation steps of UPnP
through the HTTP CONTENT-LANGUAGE header.
By default, the WEB_SERVER_CONTENT_LANGUAGE is an empty string so no
CONTENT-LANGUAGE is added.
2010-09-21 08:48:40 -03:00
Fabrice Fontaine
467f9987a1 Customize the stack size of the threads used by pupnp through the new THREAD_STACK_SIZE variable
This patch allows a user to customize the stack size of the threads used by
pupnp through the new THREAD_STACK_SIZE variable. This is especially useful
on embedded systems with limited memory where the user can set THREAD_STACK_SIZE
to ITHREAD_STACK_MIN.

However, as this modification can have side effects, I set 0 as the default
value, so threads will continue to use the default stack size of the system
(which varies greatly as stated in
https://computing.llnl.gov/tutorials/pthreads/).
2010-09-18 06:45:56 -03:00
Marcelo Roberto Jimenez
8fbecaee5e Another fix for Changelog. 2010-09-16 08:42:14 -03:00
Fabrice Fontaine
55d581481f Broken IPv6.
IPv6 is currently broken in latest release of branch-1.6.x, so find
a patch attached that correct the issue (small fixes on define,
undef and retVal).
2010-09-16 08:21:41 -03:00
Marcelo Roberto Jimenez
a0b405f902 White spaces. 2010-09-15 06:07:42 -03:00
Marcelo Roberto Jimenez
b37f9ac64a Get rid of evil CLIENTONLY macro. 2010-09-15 05:46:07 -03:00
Marcelo Roberto Jimenez
2dad42679d White spaces. 2010-09-15 05:44:36 -03:00
Chandra Penke
ea00f0f222 Fix win32 compilation errors in visual studio 2010-09-15 05:23:53 -03:00
Marcelo Roberto Jimenez
f3ae1b4116 Added UpnpString_cmp() and UpnpString_casecmp() methods to UpnpString.
UpnpString_set_String() and UpnpString_set_StringN now return error values.
String lenghts are size_t.
(cherry picked from commit 81b28fbb9073b8b3ea5724e5b7c11b29c44f9be4)
2010-09-12 00:35:31 -03:00
David Hoeung
67009170d1 Timeout for TCP connect
Hi,

I've made some modification to the libupnp v1.6.5
I've add a timeout for each TCP connect.

It is very useful when an UPnP device stop working and do not accept
connection for an UPnP action.

Modifications are only located in
upnp/src/genlib/net/http/httpreadwrite.c

For every TCP connection, I set the socket to non-blocking, perform
connect,
check result and wait during a timeout if necessary, then reset the
socket to blocking.

Please see this patch in attached file.

I hope it helps.

Regards,

David Hoeung
Consultant Extia
Orange Labs R&D

----
2010-09-11 00:17:55 -03:00
Warwick Harvey
2b399b1791 Take notice of UPNP_USE_RWLOCK flag.
Updated threadutil to use mutexes instead of read-write locks if
UPNP_USE_RWLOCK is false (0).
2010-09-10 22:43:30 -03:00
Marcelo Roberto Jimenez
0bec9ec1ae Remove some unused code plus some coding style in httpparser.c 2010-09-10 19:46:18 -03:00
Marcelo Roberto Jimenez
25a4bd6d25 2010-09-10 Jean Sigwald <jean.sigwald(at)orange-ftgroup.com>
I discovered a reliable denial-of-service issue on the last stable
release of libupnp (1.6.6) remotely triggerable by any
unauthenticated user. The issue is related with a bad parsing of
malformed XML.
2010-09-10 19:26:10 -03:00
Marcelo Roberto Jimenez
5755ac022f SF Patch Tracker [ 2854711 ] Patch for Solaris10 compilation and usage
Submitted By: zephyrus ( zephyrus00jp )

Patch for Solaris10 compilation and usage.
2010-09-10 19:02:31 -03:00
Marcelo Roberto Jimenez
0158f52ee2 One setp further to stop the CLIENTONLY() mess. 2010-09-10 18:56:36 -03:00
Marcelo Roberto Jimenez
0db4a6beac Fix an UTF-8 issue in README. 2010-09-10 00:47:53 -03:00
Chandra Penke
575e5fc196 SUMMARY: Minor change in comment for SetMaxContentLenght in upnp.h
This is a follow up from issue 6 in tracker id 3056713: calling UpnpSetMaxContentLength() by passing '0' disables the content length checking. This is useful for developing some prototype applications that deal with a lot of XML/SOAP data, and for debugging.

The corresponding c file change is already in the pupnp tree. Copy/pasting the relevant block of code here for clarity:

In upnp/src/genlib/net/http/httpreadwrite.c:

if (g_maxContentLength > 0 && parser->content_length > (unsigned int)g_maxContentLength) {
	*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
	line = __LINE__;
	ret = UPNP_E_OUTOF_BOUNDS;
	goto ExitFunction;
}

This block of code checks only does the bounds check if g_maxContentLength > 0, and it's only place g_maxContentLength is checked.

Attached is a patch against the latest sources.
(cherry picked from commit 7f1e164a5a71515d4afddf70dd17d2e5c0e67ef8)
2010-09-10 00:42:27 -03:00
Marcelo Roberto Jimenez
0e45dd9b8f Fix for coding style and compiler warning message:
src/genlib/miniserver/miniserver.c: In function ‘get_miniserver_sockets’:
src/genlib/miniserver/miniserver.c:592: warning: unused variable ‘actual_port6’
src/genlib/miniserver/miniserver.c:582: warning: unused variable ‘__ss_v6’
2010-09-10 00:32:49 -03:00
Chandra Penke
ae516b6bd3 Add support for conditionally enabling ipv6
(cherry picked from commit 6b0d84fc952350e4e99a5f2e2ba9bd1231a670a2)
2010-09-10 00:32:49 -03:00
Chandra Penke
7137f6e261 Fix for compilation in debug builds.
Ensure internal methods are declared as static since debug builds don't inline.
2010-09-10 00:02:04 -03:00
Marcelo Roberto Jimenez
92b241b560 Fix for UpnpPrintf() in Chandra Penke's last commit.
src/ssdp/ssdp_ctrlpt.c: In function ‘SearchByTarget’:
src/ssdp/ssdp_ctrlpt.c:634: warning: format ‘%s’ expects type ‘char *’, but argument 6 has type ‘int’
2010-09-09 22:52:27 -03:00
Chandra Penke
2b3ab1799b Fix for regression in SSDP code to send/receive messages over UDP
Sending messages over UDP is broken in some Apple OSes
such as OS X and iOS. This might be broken in other OSes to but didn't
verify.

The fix is to modify the socket lenght argument of sendto to use the correct
sockaddr lenght dependng on whether the socket is IPV4 or IPV6.

Also added some error checks and debugging related to the issue
2010-09-09 22:52:26 -03:00
Marcelo Roberto Jimenez
4657e57766 Using UpnpReadHttpGet to download large files causes the application to
crash. This happens when the file being downloaded exceeds the device
memory - entirely possible when transferring video files.
The programmatic cause is that the logic implemented in the function
http_ReadHttpGet (which UpnpReadHttpGet calls) reads the entire file
into memory. The fix modifies the existing logic to discard data after
it's been read; there's no reason to keep it around since the caller
of UpnpReadHttpGet already has a copy of it.

This issue exists in 1.6.6 as well as the latest sources.

Patch submitted by Chandra (inactiveneurons).
2010-09-07 22:15:21 -03:00
Marcelo Roberto Jimenez
21660334e4 In the latest sources, http_RequestAndResponse and other methods that
use connect() are broken. More specifically, connect() in these methods
is returning with an EINVAL. The programatic cause is that the address_len
argument passed to connect() is different in IPV4 vs IPV6 (as described in:
http://www.opengroup.org/onlinepubs/009695399/functions/connect.html).
The current code always uses the IPV6 size. The fix modifies each use of
connect() to use the correct size based on the address family being used.

Patch submitted by Chandra (inactiveneurons).
2010-09-07 21:56:53 -03:00
Marcelo Roberto Jimenez
97af8b6fdb Fix compilation error in upnp/src/gena/gena_ctrlpt.c (this is most
likely an error on all platforms).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:57:56 -03:00
Marcelo Roberto Jimenez
934bd2682f Fix compilation error in upnp/src/inc/ssdplib.h when compiling in OS X
(the netinet/* headers are not available).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:51:38 -03:00
Marcelo Roberto Jimenez
b8e9628140 Fix compilation error in ixml/inc/ixml.h when compiling with an
Objective-C compiler (when cross-compiling for iPhone devices).

Patch submitted by Chandra (inactiveneurons).
2010-09-07 14:47:12 -03:00
Marcelo Roberto Jimenez
b3b7a91a64 White spaces. 2010-09-03 21:51:31 -03:00
Marcelo Roberto Jimenez
ebc941f265 Issue regarding the GENA notifications. A string termination indicator was added
at the end of the notification ("\r\n") in notify_send_and_recv() in
upnp/src/gena/gena_device.c.

Patch by Fabrice Fontaine.
2010-09-03 21:49:49 -03:00
Marcelo Roberto Jimenez
842a6ce5c8 Adding .gitignore. 2010-09-03 21:49:20 -03:00
Marcelo Roberto Jimenez
2d978c32b8 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@581 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:10:50 +00:00
Marcelo Roberto Jimenez
e386dd0d68 The last part of Ronan Menard's patch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@580 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 02:05:34 +00:00
Marcelo Roberto Jimenez
5a2cc884c1 * upnp/src/ssdp/ssdp_device.c: Fix for IPV6 ULA/GUA issues.
* upnp/src/ssdp/ssdp_ctrlpt.c: Fix for IPV6 ULA/GUA issues.
* upnp/src/ssdp/ssdp_server.c: Fix for IPV6 ULA/GUA issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@578 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-22 01:34:35 +00:00
Marcelo Roberto Jimenez
a362d06dff upnp/src/genlib/miniserver/miniserver.c: Fix for IPV6 ULA/GUA issues.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@576 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 22:13:26 +00:00
Marcelo Roberto Jimenez
0e73448ea8 * gena_subscribe(): Fix for IPV6 ULA/GUA issues.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@574 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:53:09 +00:00
Marcelo Roberto Jimenez
a7966b6597 * SOCKET ssdpSock6UlaGua: created variable for later use.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@572 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:40:00 +00:00
Marcelo Roberto Jimenez
2d5c6310a9 * SSDP_IPV6_SITELOCAL: new macro.
Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@569 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:31:55 +00:00
Marcelo Roberto Jimenez
c9bcee536e The scope of the macro NUM_HANDLE is now restricted to upnpapi.c.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@568 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:22:09 +00:00
Marcelo Roberto Jimenez
1605744278 * InitHandleList() has never been implemented, I guess no one has ever
called it, so remove it.
* GetFreeHandle() and FreeHandle() are now static as they should.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@566 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 21:10:50 +00:00
Marcelo Roberto Jimenez
ce0d2833a3 * New internal buffer added to store global/ula IPV6 address.
* Macros to test whether an IPV6 address is global or ula.
* UpnpGetServerUlaGuaIp6Address(): added interface.
* IN6_IS_ADDR_GLOBAL, IN6_IS_ADDR_ULA: new macros.
* gIF_IPV6_ULA_GUA: new buffer.
* UpnpRegisterRootDevice3(): Change to the test of already registered
devices for IPV6.
* UpnpGetIfInfo(): gua/ula issues.

Patch submitted by Ronan Menard.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@564 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-21 20:42:43 +00:00
Marcelo Roberto Jimenez
74db05ff1e English mispelling.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@562 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:54:44 +00:00
Marcelo Roberto Jimenez
9468e0224a libUPnP does support IPV6 now.
Patch submitted by Ronan Menard.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@560 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:48:17 +00:00
Marcelo Roberto Jimenez
cb89781a55 HTTP version equal to 1.0 should failed as required by the UPnP
certification tool. Patch submitted by Ronan Menard.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@558 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-08-19 13:27:50 +00:00
Marcelo Roberto Jimenez
3de0765893 Backport of svn rev 556:
SF Bug Tracker [ 3022490 ] String declaration fix for patch applied in 3007407
	Hello,

	When my patch for tracker ID 3007407 was accepted, the definition of the
	serviceList string was changed from

	#define SERVICELIST_STR "serviceList"

	to

	static const char *SERVICELIST_STR = "serviceList";

	During internal code review of the final patch, it was pointed out that 
	sizeof(SERVICELIST_STR) == 4 since SERVICELIST_STR is now declared as
	a pointer instead of an array.

	If you wish to use a variable instead of a define, I suggest the
	following instead:

	static const char SERVICELIST_STR[] = "serviceList";

	Thanks,
	Chuck Thomason



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@557 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-28 20:40:21 +00:00
Marcelo Roberto Jimenez
ce0e5b664f Backport of svn rev. 554:
Remove excessive 'dnl's from libupnp.m4.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@555 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-26 11:09:49 +00:00
Marcelo Roberto Jimenez
eec36896c3 2010-06-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
Backport of svn revision 552:
	SF Bug Tracker [ 3007407 ] Service traversal issue in AdvertiseAndReply()
	Submitted: Chuck Thomason ( cyt4 ) - 2010-05-26 15:07:39 UTC

	When the UPnP server is started, one alive message is broadcast for each
	service in each device. It appears that libupnp's implementation of the
	alive message generation does not correctly navigate the XML description
	document when locating the services. This can result in the wrong UDN
	being used in the alive message sent for a service.

	In my specific case (see attached XML), the root EchoSTB device contains
	no services, but its embedded MediaServer device contains 2 services.
	When the existing libupnp code traverses the EchoSTB device in the XML,
	it searches the global list of serviceLists within the document instead
	of searching for a serviceList that is its direct child node. The
	ContentDirectory and ConnectionManager services are then announced with
	the UDN of EchoSTB1 (the root device) instead of with the UDN of
	MediaServer, which is actually their parent device.

	I discovered this behavior using libupnp-1.6.6. I have generated a patch
	against branch-1.6.x that corrects the XML navigation such that all
	services are traversed from their parent device, which results in the
	correct UDN being sent in the alive message for each service. I built
	from branch-1.6.x without this patch, tested, and confirmed that the
	issue still exists as I observed it in libupnp-1.6.6. I then built
	from branch-1.6.x with this patch, tested, and confirmed that the
	issue was resolved.

	Thanks,
	Chuck Thomason



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@553 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-06-17 17:07:41 +00:00
Nick Leverton
00cf8052de Add PTHREAD_CFLAGS to Libs: in libupnp.pc, as assumed by acx_pthread.m4
(fixes binutils-gold link failure)


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@551 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-14 13:09:59 +00:00
Marcelo Roberto Jimenez
74b8730f0f SF Bug Tracker [ 2995758 ] libupnp 1.6.6, wrong bind when reuseaddr is 1.
Submitted: viallard anthony ( homer242 )
When trying to use reuseaddr option in miniserver/miniserver.c, there
isn't a affectation of the port chosen (serverAddr.sin_port isn't
receive listen_port variable value).




git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@548 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-05-07 11:07:26 +00:00
Marcelo Roberto Jimenez
1b45bec411 Backport of r544:
Define PROTOTYPES to be one by default in global.h. This affects the
RSA MD5 code.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@546 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 14:59:32 +00:00
Marcelo Roberto Jimenez
21163f491d Comment.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@541 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 12:04:48 +00:00
Marcelo Roberto Jimenez
a54e07bfb2 Code convergence for client_table (ClientSubscription).
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@539 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 08:47:37 +00:00
Marcelo Roberto Jimenez
0dea692199 Allow null pointer deletions in membuffer.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@538 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:47:37 +00:00
Marcelo Roberto Jimenez
dc457414d1 Adding UpnpString.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@537 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-25 00:44:34 +00:00
Nick Leverton
e1d09004eb Subscription auto-renewals copy the renewal time from old subscription.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@533 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-21 12:28:27 +00:00
Marcelo Roberto Jimenez
640fa8b1be Code base convergence.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@530 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-04-01 20:36:30 +00:00
Marcelo Roberto Jimenez
2bcbdffd89 1 - Ported some of IPV6 code to 1.6.7.
2 - Backport of svn revision 527:
* Added API to ithread, created the following functions:
- int ithread_initialize_library(void);
- int ithread_cleanup_library(void);
- int ithread_initialize_thread(void);
- int ithread_cleanup_thread(void);
* SF Bug Tracker [ 2876374 ] Access Violation when compiling with Visual Studio 2008
Submitted: Stulle ( stulleamgym ) - 2009-10-10 19:05

Hi,

I am one of the devs of the MorphXT project and I use this lib in some
other of my projects, too. When I tried to upgrade the lib earlier for one
of my projects I had to realise that something did not work at first and
while most of the things were reasonably ease to be fixed. Now, the last
thing I encountered was not so easy to fix and I am uncertain if my fix is
any good so I'll just post it here and wait for some comments.

The problem was that I got an Access Violation when calling "UpnpInit". It
would call "ithread_rwlock_init(&GlobalHndRWLock, NULL)" which eventually
led to calling "pthread_cond_init" and I got the error notice at
"EnterCriticalSection (&ptw32_cond_list_lock);". It appeared that
"ptw32_cond_list_lock" was NULL. Now, I found two ways to fix this. Firstly
moving the whole block after at least one of the "ThreadPoolInit" calls
will fix the issue. Secondly, you could add:
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
// to get the following working we need this... is it a good patch or
not... I do not know!
pthread_win32_process_attach_np();
#endif
#endif
right before "ithread_rwlock_init(&GlobalHndRWLock, NULL)".

Just so you know, I am using libupnp 1.6.6 and libpthreads 2.8.0 and both
are linked static into the binaries. I am currently using Visual Studio
2008 for development with Windows being the target OS. Any comment at your
end?

Regards, Stulle



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@529 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-31 17:53:16 +00:00
Marcelo Roberto Jimenez
6c8a4dd361 SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp )
This second part covers the issue on linking with -lsocket -lnsl -lrt.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@525 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 14:45:47 +00:00
Marcelo Roberto Jimenez
e9941f7ac8 UTF-8 stuff.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@524 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-27 14:41:25 +00:00
Marcelo Roberto Jimenez
5a465a5cf2 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@523 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-22 09:08:15 +00:00
Marcelo Roberto Jimenez
6aa2419cfd SF Bug Tracker [ 2392166 ] ithread_detach not called for finished worker thread
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24

	Valgrind reports a memory leak due to that the function ithread_detach is
	not called for finished worker threads in ThreadPool.c.

	==21137== 2,176 bytes in 8 blocks are possibly lost in loss record 5 of 5
	==21137== at 0x4C20F3F: calloc (vg_replace_malloc.c:279)
	==21137== by 0x4010F58: _dl_allocate_tls (in /lib/ld-2.6.1.so)
	==21137== by 0x544BA92: pthread_create@@GLIBC_2.2.5 (in
	/lib/libpthread-2.6.1.so)
	==21137== by 0x5F94592: CreateWorker (ThreadPool.c:639)
	==21137== by 0x5F95079: ThreadPoolInit (ThreadPool.c:784)

	I'm using libupnp 1.6.6

	For more info on pthread_detach, see:
	http://gelorakan.wordpress.com/2007/11/26/pthead_create-valgrind-memory-lea
	k-solved/



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@520 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 22:41:49 +00:00
Marcelo Roberto Jimenez
712ed6d2ff SF Bug Tracker [ 2392304 ] Memory leak in SSDP AdvertiseAndReply
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24

	Valgrind reports a memory leak function in AdvertiseAndReply
	(ssdp/ssdp_server.c) in libupnp 1.6.6

	There are continue statements in many places in AdvertiseAndReply. In some
	of those error handling cases the variable nodelist is not free'ed before
	continuing to the next iteration. The next iteration will take care of
	free'ing the nodelist from the previous iteration in most cases, but not
	when breaking out of the for loop after the last element.

	I belive this memory leak can be solved by makeing sure that the rows

	ixmlNodeList_free( nodeList );
	nodeList = NULL;

	are always executed, also in the beginning of the last iteration when we
	found out that there are not more elements.

	==29110== at 0x4C21C16: malloc (vg_replace_malloc.c:149)
	==29110== by 0x5D8DE0E: ixmlNodeList_addToNodeList (nodeList.c:106)
	==29110== by 0x5D8B7E2: ixmlNode_getElementsByTagNameRecursive
	(node.c:1438)
	==29110== by 0x5D8E587: ixmlElement_getElementsByTagName
	(element.c:491)
	==29110== by 0x5B6C0F1: AdvertiseAndReply (ssdp_server.c:201)
	==29110== by 0x5B7AB74: UpnpSendAdvertisement (upnpapi.c:1495)



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@518 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 21:19:13 +00:00
Marcelo Roberto Jimenez
53d5e61b33 Thanks update.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@517 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:53:20 +00:00
Marcelo Roberto Jimenez
324931ca8f Backport of svn revision 514:
libupnp and multi-flows scenario patch
	Submited by Carlo Parata from STMicroelectronics.
Hi Roberto and Nektarios,
after an analysis of the problem of libupnp with a multi-flows scenario, I
noticed that the only cause of the freezed system is the ThreadPool
management. There are not mutex problems. In practise, if all threads in the
thread pool are busy executing jobs, a new worker thread should be created if
a job is scheduled (I inspired to tombupnp library). So I solved the problem
with a little patch in threadutil library that you can find attached in this
e-mail. I hope to have helped you.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@515 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 19:51:18 +00:00
Marcelo Roberto Jimenez
edc0638640 Backport of svn revision 512:
Style compatibilization between two similar constructions addressed in two
separate recent patches.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@513 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 17:07:09 +00:00
Marcelo Roberto Jimenez
e1ea72a5fb Backport of svn revision 510:
SF Patch Tracker [ 2964973 ] install: will not overwrite just-created
	...blah... with...
	Submitted: Nick Leverton ( leveret ) - 2010-03-07 05:18

	Full error:
	/usr/bin/install: will not overwrite just-created
	`/tmp/buildd/libupnp-1.6.6/debian/tmp/usr/share/doc/libupnp3-dev/examples/s
	ample_util.c' with `common/sample_util.c'

	This seems to be from Automake 1.11 which doesn't like having duplicate
	files in a Makefile.am. Patch attached, kindly provided by Stefan Potyra
	for Debian (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543068)

	This fix will be needed for both 1.6.x and 1.8.x branches.




git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@511 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 16:13:59 +00:00
Marcelo Roberto Jimenez
5eb55e0fb2 Backport of svn revision 504:
SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
	Submitted By: Nick Leverton (leveret)
	Fix the order of header inclusion for FreeBSD.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@509 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 15:42:40 +00:00
Marcelo Roberto Jimenez
9226dd833b SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
Submitted By: zephyrus ( zephyrus00jp )
	Obs by Marcelo: The issue with linking with -lsocket -lnsl -lrt is not
	covered in this changeset beacuse I don't have solaris to test. I will
	need some help from zephyrus in this regard. The issue will be addressed
	in a future changeset.

	Compilation for solaris

	I have used gcc3.x and gcc4.x under solaris 10 for x86 / 64 bits.

	A couple of Source file fixes were necessary for successful compilation
	and runtime behavior.

	threadutil/src/ThreadPool.c

	POSIX
	sched_setschduler() returns non-negative value for success.

	Without the fix, UpnpInit() fails immediately.

	upnpp/src/api/upnpai.c

	There is a typo of a macro name "__sun" in one of the
	CPP conditional.
	Without the fix, the compilation aborts due to unknown constant
	in socket ioctl call.

	A few structs and an array is not properly initialized.
	Well, I think it may be safe as is, but when I checked it
	using purify evaluation version, it was reported that
	uninitizlied iszBuffer may cause read of uninitialized memory.
	So play it safe.

	Configure issue.
	This has to be more of a configure magic.
	To link a program successfully using network, we need
	-lsocket and -lnsl library specifications on the link line.
	We also need -lrt for programs that use thread scheduling features.

	The sample program under upnp/sample requires
	-lsocket -lnsl -lrt
	for successful linking.
	I added -lsocket -lnsl -lrt to Makefile.in.
	configure probably needs to take care of these.

	I don't know much about configure, automake, etc., so
	I am just raising a flag here.

	TIA



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@505 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-21 11:47:17 +00:00
Marcelo Roberto Jimenez
25c908c558 SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
stopping at the first lis
	Submitted By: zephyrus ( zephyrus00jp )
	
	Internet Gateway Device description contains nested serviceList (rootdevice
	-> servicelist, subdevice
	and subdevice has the lower-level serviceList, etc..)

	Unfrotunately, the sample code sample_util.c used by tv_device sample,
	etc.
	has a code that looks for only the first top-level serviceList.
	This results in the failure to read all the services of an IGD xml
	description.

	Attached patch modifies this behavior and looks for the service by
	visiting all the serviceList in xml document in turn.

	With the modified patch (ad additional modification), I could
	simulate an IGD device and created a modified control program for that.

	Patch against 1.6.6

	TIA.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@502 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-20 21:32:38 +00:00
Marcelo Roberto Jimenez
16e91b5dcc Backport of svn revision 497:
* SF Patch Tracker [ 2203721 ] timeb.h check obsolete



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@498 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:51:09 +00:00
Marcelo Roberto Jimenez
01d17e5c4b Backport of svn revision 495:
* SF Patch Tracker [ 2970872 ] Update ErrorMessages for latest return
	code list
	Submitted By: Nick Leverton ( leveret )
	
	ErrorMessage[] in upnptools.c has got a bit out of sync, the attached
	patch (generated from grep 'define UPNP_E_') should bring it up to date.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@496 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 23:39:48 +00:00
Marcelo Roberto Jimenez
a1d707ac81 Backport of svn revision 493: Declare a few functions to have proper
(void) argument list.

	* SF Patch Tracker [ 2857611 ] Declare a few functions to have proper
	(void) argument list.
	Submitted By: zephyrus ( zephyrus00jp )
	
	In a publicly installed headers, a few functions are declared without any
	arguments at all, a la "()".
	When I used gcc's -Wimplict and -Wstrict-prototypes to check for the
	mismatch of
	function prototype declarations and their usage in my own program,
	some headers from libupnp-1.6.6 produced warnings.

	They are not strictly bugs, but pretty much annoying. This is 2009, and
	almost all the important compilers
	understand ISO-C.

	So the offending functions are declared as "(void") to show that they have
	no arguments at all.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@494 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-15 15:34:54 +00:00
Marcelo Roberto Jimenez
4ad6ea3545 Backport of svn revision 484:
SF Patch Tracker [ 2546532 ] Missing carriage return between
    	SOAPACTION and User-Agent headers.
    
    	There is something going wrong in soap_ctrlpt.c at line 931 (based on
    	version 1.6.6 release).
    
    	The http_Makemessage call looks as follows:
    
    	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;
    	}
    
    	This will result in the SOAPACTION header to be immediately followed by the
    	User-Agent header, while a cr-lf should separate the two. I propose to fix
    	this by changing the second "s" to "sc" to force the addition of a cr-lf
    	after the SOAPACTION. This looks consistent to the other Makemessage calls.



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@487 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 18:53:12 +00:00
Marcelo Roberto Jimenez
70a0aff4e7 Backport of svn revision 482:
wrong order in parameters corrected


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@486 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2010-03-14 18:38:31 +00:00
Marcelo Roberto Jimenez
aaacf65f41 Do not use C++ like comments. Some compilers don't like it.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@481 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-08-14 12:06:22 +00:00
Marcelo Roberto Jimenez
cd8ce90e19 Backport of svn rev. 479: Fix for application compiler warning: "PRId64" redefined.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@480 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-08-14 12:02:20 +00:00
Marcelo Roberto Jimenez
812d019d12 Backport of ixml from 1.8.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@478 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 05:01:52 +00:00
Marcelo Roberto Jimenez
881b212690 Backport of svn 371: Removing the useless, unused and undocumented function UpnpFree().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@477 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:31:07 +00:00
Marcelo Roberto Jimenez
223c0e8816 Backport of Doxyfile.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@476 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:11:28 +00:00
Marcelo Roberto Jimenez
ceca478180 Backport of most of upnp.h with documentation.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@475 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-27 03:06:21 +00:00
Marcelo Roberto Jimenez
7963e97469 Backport of svn 367: Removing dead code.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@471 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-26 12:24:24 +00:00
Marcelo Roberto Jimenez
0080c080cd Update of win32 files.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@470 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 04:21:11 +00:00
Marcelo Roberto Jimenez
405451e34c Backport of svn 468: Added upnp/m4/libupnp.m4 to the distribution tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@469 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 04:11:17 +00:00
Marcelo Roberto Jimenez
a772b1a754 Backport of svn 403: Bob Ciora's patch for "UpnpCreatePropertySet can leak memory".
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@466 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:42:30 +00:00
Marcelo Roberto Jimenez
ffc4668e0b Backport of 406: Updating Makefile.am for missing files in the "make dist" tarball.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@465 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:35:12 +00:00
Marcelo Roberto Jimenez
56a7f038dc Changelog update for a fixed bug of a missing HandleUnlock() that went in
in one of the latest comitts.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@463 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:25:42 +00:00
Marcelo Roberto Jimenez
3ba4e34662 Added ixmldebug and UpnpGlobal.h to the 1.6.x branch.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@462 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 03:22:35 +00:00
Marcelo Roberto Jimenez
515233ca56 Backport of svn 395 and 434:
395: Bob Ciora's patch for lazy UpnpAcceptSubscription().
434: Fixed a buffer overflow due to a bug in the calculation of the
     CONTENT-TYPE header line size, the length was beeing calculated with
     the wrong string, there was a missing colon.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@461 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-25 02:56:04 +00:00
Marcelo Roberto Jimenez
423808a095 Backport of svn 453: Andre Sodermans (wienerschnitzel) patch for building
libupnp under windows systems with VC8/VC9.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@460 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:40:33 +00:00
Marcelo Roberto Jimenez
f22a69b487 Backport of 457: SF Bug Tracker [ 2026431 ] pupnp does not build on GNU/KfreeBSD.
Submitted By: Nick Leverton - leveret
	Gnu/KFreeBSD is one of the Debian architectures, it includes a FreeBSD
	kernel with GNU userspace (glibc etc). The Gnu/KfreeBSD developers
	provided the attached patch to test the appropriate #define and allow pupnp
	to build in their environment, and asked me to forward it to you.

	Since the test is a simple check for defined(__GLIBC__), this would
	presumably also help with other ports of GNU libc to non-Linux kernels.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@458 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-24 11:30:42 +00:00
Marcelo Roberto Jimenez
bcf5a5c5e0 Backport: Debug code for http_RecvMessage().
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@450 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-10 04:15:36 +00:00
Marcelo Roberto Jimenez
e0c9de0b1d Backport: Added an m4 macro to deal with finding libupnp in the users'
configure script.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@449 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-07-10 04:02:16 +00:00
Marcelo Roberto Jimenez
94e4a3bdda Fix in function SetSeed() in threadutil/src/ThreadPool.c for CYGWIN
compilation. Thanks to Gary Chan.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@355 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-29 15:42:18 +00:00
Marcelo Roberto Jimenez
b7b3bb7d05 Homekeeping for the next release.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@354 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-29 15:38:35 +00:00
Marcelo Roberto Jimenez
f0161c7274 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@351 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-04-26 00:49:39 +00:00
Marcelo Roberto Jimenez
4b40e94b03 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@339 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-25 10:21:08 +00:00
Marcelo Roberto Jimenez
1c9632dcc3 White spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@329 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-03-05 03:55:33 +00:00
Marcelo Roberto Jimenez
cc0c2ffc50 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@327 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-22 04:48:10 +00:00
Marcelo Roberto Jimenez
f812b124d7 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@324 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-10 02:27:45 +00:00
Marcelo Roberto Jimenez
a785465222 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@322 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-08 02:29:26 +00:00
Marcelo Roberto Jimenez
078f3f8faf Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@312 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-02-03 01:36:23 +00:00
Marcelo Roberto Jimenez
1eeaf99b83 Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@306 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2008-01-27 02:13:08 +00:00
Marcelo Roberto Jimenez
f6dd5062fe Merge of trunk into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@284 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-27 02:14:02 +00:00
Marcelo Roberto Jimenez
7d4a610b93 Merge of head into branch-1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@265 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 23:18:38 +00:00
Marcelo Roberto Jimenez
0a074d1989 Merge of trunk into branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@263 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-12-10 22:56:56 +00:00
Marcelo Roberto Jimenez
0475a46680 Merge of current trunk to branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@251 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-11-19 14:15:45 +00:00
Marcelo Roberto Jimenez
2a76749682 Creating branch 1.6.x.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@210 119443c7-1b9e-41f8-b6fc-b9c35fce742c
2007-06-23 14:23:29 +00:00
138 changed files with 35246 additions and 31113 deletions

105
.gitignore vendored Normal file
View File

@ -0,0 +1,105 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# Normal rules
#
.*
*.o
*.o.*
*.a
*.s
*.ko
*.so
*.so.dbg
*.mod.c
*.i
*.lst
*.symtypes
*.order
modules.builtin
*.elf
*.bin
*.gz
*.bz2
*.lzma
*.patch
*.gcno
#
# Top-level generic files
#
/tags
/TAGS
/linux
/vmlinux
/vmlinuz
/System.map
/Module.markers
/Module.symvers
#
# git files that we don't want to ignore even it they are dot-files
#
!.gitignore
!.mailmap
#
# Generated include files
#
include/config
include/linux/version.h
include/generated
# stgit generated dirs
patches-*
# quilt's files
patches
series
# cscope files
cscope.*
ncscope.*
# gnu global files
GPATH
GRTAGS
GSYMS
GTAGS
*.orig
*~
\#*#
*.lo
*.la
Makefile
Makefile.in
aclocal.m4
autoconfig.h
autoconfig.h.in
autom4te.cache/
build-aux/
config.log
config.status
configure
libtool
libupnp.pc
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
stamp-h1
upnp/inc/stamp-h2
upnp/inc/upnpconfig.h
upnp/sample/upnp_tv_combo
upnp/sample/upnp_tv_ctrlpt
upnp/sample/upnp_tv_device
docs/doxygen

1027
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ PROJECT_NAME = libUPnP
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.4.7
PROJECT_NUMBER = 1.6.8
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
@ -91,7 +91,7 @@ ABBREVIATE_BRIEF =
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
ALWAYS_DETAILED_SEC = YES
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
@ -290,7 +290,7 @@ HIDE_IN_BODY_DOCS = NO
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
INTERNAL_DOCS = YES
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
@ -462,7 +462,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ./upnp ./ixml ./threadutil
INPUT = upnp ixml threadutil
# This tag can be used to specify the character encoding of the source files that
# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
@ -995,7 +995,7 @@ ENABLE_PREPROCESSING = YES
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
@ -1029,7 +1029,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED =
PREDEFINED = DEBUG UPNP_HAVE_TOOLS INCLUDE_DEVICE_APIS INCLUDE_CLIENT_APIS EXCLUDE_GENA=0 EXCLUDE_DOM=0
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.

View File

@ -1,7 +1,7 @@
#
# 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
@ -16,6 +16,7 @@ SUBDIRS = \
EXTRA_DIST = \
Doxyfile \
libupnp.pc.in \
LICENSE \
THANKS \
@ -25,9 +26,23 @@ EXTRA_DIST = \
build/libupnp.dsp \
build/libupnp.dsw \
build/inc/autoconfig.h \
build/inc/config.h \
build/inc/upnpconfig.h \
build/msvc/inttypes.h
build/msvc/inttypes.h \
build/msvc/stdint.h \
build/vc8/ixml.vcproj \
build/vc8/libupnp.sln \
build/vc8/libupnp.vcproj \
build/vc8/threadutil.vcproj \
build/vc8/tvcombo.vcproj \
build/vc8/tvctrlpt.vcproj \
build/vc8/tvdevice.vcproj \
build/vc9/ixml.vcproj \
build/vc9/libupnp.sln \
build/vc9/libupnp.vcproj \
build/vc9/threadutil.vcproj \
build/vc9/tvcombo.vcproj \
build/vc9/tvctrlpt.vcproj \
build/vc9/tvdevice.vcproj
# This variable must have 'exec' in its name, in order to be installed

2
README
View File

@ -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.

33
THANKS
View File

@ -6,31 +6,54 @@ suggesting various improvements or submitting actual code.
Here is a list of these people. Help us keep it complete and
exempt of errors.
- Alex (afaucher)
- Andre Sodermans (wienerschnitzel)
- Anthony Viallard (homer242)
- Apostolos Syropoulos
- Arno Willig
- Bob Ciora
- Carlo Parata
- Chandra (inactiveneurons)
- Chaos
- Charles Nepveu (cnepveu)
- Chris Pickel
- Chuck Thomason (cyt4)
- Craig Nelson
- David Blanchet
- David Maass
- Emil Ljungdahl
- Erik Johansson
- Eric Tanguy
- Erwan Velu
- Eugene Christensen
- Fabrice Fontaine
- Fredrik Svensson
- Glen Masgai
- Hartmut Holzgraefe - hholzgra
- Ingo Hofmann
- Jiri Zouhar
- John Dennis
- Jonathan (no_dice)
- Jonathan Casiot (no_dice)
- Josh Carroll
- Keith Brindley
- Leuk_He
- Loigu
- Luke Kim
- Marcelo Roberto Jimenez
- Luke Kim (nereusuj)
- Marcelo Roberto Jimenez (mroberto)
- Markus Strobl
- Nektarios K. Papadopoulos
- Nektarios K. Papadopoulos (npapadop)
- Nicholas Kraft
- Nick Leverton (leveret)
- Oskar Liljeblad
- Michael (Oxy)
- Michael (oxygenic)
- Paul Vixie
- Peter Hartley
- Rene Hexel
- Robert Gingher (robsbox)
- Ronan Menard
- Siva Chandran
- Stéphane Corthésy
- Steve Bresson
- Timothy Redaelli
- Titus Winters

23
TODO
View File

@ -2,28 +2,5 @@
To Be Done
==========
- add FreeBSD patches
( http://sf.net/tracker/index.php?func=detail&aid=1332618&group_id=7189&atid=307189 ?)
- non-regression testing
- replace doc++ by Doxygen for documentation generation
- incorporate public patches and fix reported bugs :
http://sourceforge.net/tracker/?group_id=7189&atid=107189 and
http://sourceforge.net/tracker/?group_id=7189&atid=307189
- RPM packaging (a preliminary one here :
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=176617 )
- make API clean for large files and 64 bits
To Be Decided
=============
- IPV6 support ?

View File

@ -67,9 +67,6 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
@ -82,6 +79,13 @@
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the <ws2tcpip.h> header file. */
/* #undef HAVE_WS2TCPIP_H */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 to prevent compilation of assert() */
#define NDEBUG 1
@ -101,13 +105,13 @@
#define PACKAGE_NAME "libupnp"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libupnp 1.4.7"
#define PACKAGE_STRING "libupnp 1.6.8"
/* 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.7"
#define PACKAGE_VERSION "1.6.8"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@ -116,6 +120,12 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* see upnpconfig.h */
/* #undef UPNP_ENABLE_IPV6 */
/* see upnpconfig.h */
#define UPNP_ENABLE_NOTIFICATION_REORDERING 1
/* see upnpconfig.h */
#define UPNP_HAVE_CLIENT 1
@ -131,20 +141,23 @@
/* see upnpconfig.h */
#define UPNP_HAVE_WEBSERVER 1
/* Do not use pthread_rwlock_t */
#define UPNP_USE_RWLOCK 1
/* see upnpconfig.h */
#define UPNP_VERSION_MAJOR 1
/* see upnpconfig.h */
#define UPNP_VERSION_MINOR 4
#define UPNP_VERSION_MINOR 6
/* see upnpconfig.h */
#define UPNP_VERSION_PATCH 7
#define UPNP_VERSION_PATCH 8
/* see upnpconfig.h */
#define UPNP_VERSION_STRING "1.4.7"
#define UPNP_VERSION_STRING "1.6.8"
/* Version number of package */
#define VERSION "1.4.7"
#define VERSION "1.6.8"
/* File Offset size */
#define _FILE_OFFSET_BITS 64
@ -153,7 +166,7 @@
/* #undef _LARGEFILE_SOURCE */
/* Large files support */
#define _LARGE_FILE_SOURCE
#define _LARGE_FILE_SOURCE /**/
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
@ -164,5 +177,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Substitute for socklen_t */
/* Type for storing the length of struct sockaddr */
/* #undef socklen_t */

View File

@ -1,343 +0,0 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 INTERNAL_CONFIG_H
#define INTERNAL_CONFIG_H
#include "autoconfig.h"
/** @name Compile time configuration options
* The Linux SDK for UPnP Devices contains some compile-time parameters
* that effect the behavior of the SDK. All configuration options are
* located in {\tt src/inc/config.h}.
*/
//@{
/** @name THREAD_IDLE_TIME
* The {\tt THREAD_IDLE_TIME} constant determines when a thread will be
* removed from the thread pool and returned to the operating system. When
* a thread in the thread pool has been idle for this number of milliseconds
* the thread will be released from the thread pool. The default value is
* 5000 milliseconds (5 seconds).
*/
//@{
#define THREAD_IDLE_TIME 5000
//@}
/** @name JOBS_PER_THREAD
* The {\tt JOBS_PER_THREAD} constant determines when a new thread will be
* allocated to the thread pool inside the SDK. The thread pool will
* try and maintain this jobs/thread ratio. When the jobs/thread ratio
* becomes greater than this, then a new thread (up to the max) will be
* allocated to the thread pool. The default ratio is 10 jobs/thread.
*/
//@{
#define JOBS_PER_THREAD 10
//@}
/** @name MIN_THREADS
* The {\tt MIN_THREADS} constant defines the minimum number of threads the
* thread pool inside the SDK will create. The thread pool will
* always have this number of threads. These threads are used
* for both callbacks into applications built on top of the SDK and also
* for making connections to other control points and devices. This number
* includes persistent threads. The default value is two threads.
*/
//@{
#define MIN_THREADS 2
//@}
/** @name MAX_THREADS
* The {\tt MAX_THREADS} constant defines the maximum number of threads the
* thread pool inside the SDK will create. These threads are used
* for both callbacks into applications built on top of the library and also
* for making connections to other control points and devices. It is not
* recommended that this value be below 10, since the threads are
* necessary for correct operation. This value can be increased for greater
* performance in operation at the expense of greater memory overhead. The
* default value is 12.
*/
//@{
#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
* a large amount of data to the control point causing it to crash.
* This can be adjusted dynamically with {\tt UpnpSetMaxContentLength}.
*/
//@{
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
//@}
/** @name NUM_SSDP_COPY
* This configuration parameter determines how many copies of each SSDP
* advertisement and search packets will be sent. By default it will send two
* copies of every packet.
*/
//@{
#define NUM_SSDP_COPY 2
//@}
/** @name SSDP_PAUSE
* This configuration parameter determines the pause between identical SSDP
* advertisement and search packets. The pause is measured in milliseconds
* and defaults to 100.
*/
//@{
#define SSDP_PAUSE 100
//@}
/** @name WEB_SERVER_BUF_SIZE
* This configuration parameter sets the maximum buffer size for the
* webserver. The default value is 1MB.
*/
//@{
#define WEB_SERVER_BUF_SIZE (1024*1024)
//@}
/** @name AUTO_RENEW_TIME
* The {\tt AUTO_RENEW_TIME} is the time, in seconds, before a subscription
* expires that the SDK automatically resubscribes. The default
* value is 10 seconds. Setting this value too low can result in the
* subscription renewal not making it to the device in time, causing the
* subscription to timeout. In order to avoid continually resubscribing
* the minimum subscription time is five seconds more than the auto renew
* time.
*/
//@{
#define AUTO_RENEW_TIME 10
//@}
/** @name CP_MINIMUM_SUBSCRIPTION_TIME
* The {\tt CP_MINIMUM_SUBSCRIPTION_TIME} is the minimum subscription time
* allowed for a control point using the SDK. Subscribing for less than
* this time automatically results in a subscription for this amount. The
* default value is 5 seconds more than the {\tt AUTO_RENEW_TIME}, or 15
* seconds.
*/
//@{
#define CP_MINIMUM_SUBSCRIPTION_TIME (AUTO_RENEW_TIME + 5)
//@}
/** @name MAX_SEARCH_TIME
* The {\tt MAX_SEARCH_TIME} is the maximum time
* allowed for an SSDP search by a control point. Searching for greater than
* this time automatically results in a search for this amount. The default
* value is 80 seconds.
*/
//@{
#define MAX_SEARCH_TIME 80
//@}
/** @name MIN_SEARCH_TIME
* The {\tt MIN_SEARCH_TIME} is the minimumm time
* allowed for an SSDP search by a control point. Searching for less than
* this time automatically results in a search for this amount. The default
* value is 2 seconds.
*/
//@{
#define MIN_SEARCH_TIME 2
//@}
/** @name AUTO_ADVERTISEMENT_TIME
* The {\tt AUTO_ADVERTISEMENT_TIME} is the time, in seconds, before an
* device advertisements expires before a renewed advertisement is sent.
* The default time is 30 seconds.
*/
//@{
#define AUTO_ADVERTISEMENT_TIME 30
//@}
/** @name SSDP_PACKET_DISTRIBUTE
* The {\tt SSDP_PACKET_DISTRIBUTE} enables the SSDP packets to be sent
* at an interval equal to half of the expiration time of SSDP packets
* minus the AUTO_ADVERTISEMENT_TIME. This is used to increase
* the probability of SSDP packets reaching to control points.
* It is recommended that this flag be turned on for embedded wireless
* devices.
*/
//@{
#define SSDP_PACKET_DISTRIBUTE 1
//@}
/** @name Module Exclusion
* Depending on the requirements, the user can selectively discard any of
* the major modules like SOAP, GENA, SSDP or the Internal web server. By
* default everything is included inside the SDK. By setting any of
* the values below to 0, that component will not be included in the final
* SDK.
* \begin{itemize}
* \item {\tt EXCLUDE_SOAP[0,1]}
* \item {\tt EXCLUDE_GENA[0,1]}
* \item {\tt EXCLUDE_SSDP[0,1]}
* \item {\tt EXCLUDE_DOM [0,1]}
* \item {\tt EXCLUDE_MINISERVER[0,1]}
* \item {\tt EXCLUDE_WEB_SERVER[0,1]}
* \item {\tt EXCLUDE_JNI[0,1]}
* \end{itemize}
*
*/
//@{
#define EXCLUDE_SSDP 0
#define EXCLUDE_SOAP 0
#define EXCLUDE_GENA 0
#define EXCLUDE_DOM 0
#define EXCLUDE_MINISERVER 0
#define EXCLUDE_WEB_SERVER 0
#ifdef USE_JNI
# define EXCLUDE_JNI 0
#else
# define EXCLUDE_JNI 1
#endif
//@}
/** @name DEBUG_TARGET
* The user has the option to redirect the library output debug messages
* to either the screen or to a log file. All the output messages with
* debug level 0 will go to {\tt upnp.err} and messages with debug level
* greater than zero will be redirected to {\tt upnp.out}.
*/
//@{
#define DEBUG_TARGET 1
//@}
/** @name Other debugging features
The UPnP SDK contains other features to aid in debugging:
see <upnp/upnpdebug.h>
*/
#define DEBUG_ALL 1
#define DEBUG_SSDP 0
#define DEBUG_SOAP 0
#define DEBUG_GENA 0
#define DEBUG_TPOOL 0
#define DEBUG_MSERV 0
#define DEBUG_DOM 0
#define DEBUG_HTTP 0
#define DEBUG_API 0
//@} // Compile time configuration options
/***************************************************************************
* Do not change, Internal purpose only!!!
***************************************************************************/
//@{
/*
* Set additional defines based on requested configuration
*/
// configure --enable-client
#if UPNP_HAVE_CLIENT
# define INCLUDE_CLIENT_APIS 1
#endif
// configure --enable-device
#if UPNP_HAVE_DEVICE
# define INCLUDE_DEVICE_APIS 1
#endif
// configure --enable-webserver --enable-device
#if UPNP_HAVE_WEBSERVER
# define INTERNAL_WEB_SERVER 1
#endif
#undef EXCLUDE_WEB_SERVER
#undef EXCLUDE_MINISERVER
#ifdef INTERNAL_WEB_SERVER
# define EXCLUDE_WEB_SERVER 0
# define EXCLUDE_MINISERVER 0
#else
# 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
#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
#endif
#ifdef INCLUDE_CLIENT_APIS
# define CLIENTONLY(x) x
#else
# define CLIENTONLY(x)
#endif
//@}
#endif

View File

@ -1,35 +1,35 @@
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
// -*- 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
@ -40,20 +40,20 @@
***************************************************************************/
/** The library version (string) e.g. "1.3.0" */
#define UPNP_VERSION_STRING "1.4.7"
#define UPNP_VERSION_STRING "1.6.8"
/** Major version of the library */
#define UPNP_VERSION_MAJOR 1
/** Minor version of the library */
#define UPNP_VERSION_MINOR 4
#define UPNP_VERSION_MINOR 6
/** Patch version of the library */
#define UPNP_VERSION_PATCH 7
#define UPNP_VERSION_PATCH 8
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
((UPNP_VERSION_MAJOR*100 + UPNP_VERSION_MINOR)*100 + UPNP_VERSION_PATCH)
((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + UPNP_VERSION_PATCH)
@ -91,7 +91,9 @@
* (i.e. configure --enable-tools) : <upnp/upnptools.h> file is available */
#define UPNP_HAVE_TOOLS 1
/** Defined to 1 if the library has been compiled with ipv6 support
* (i.e. configure --enable-ipv6) */
/* #undef UPNP_ENABLE_IPV6 */
#endif // UPNP_CONFIG_H
#endif /* UPNP_CONFIG_H */

View File

@ -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ühren von NMAKE eine Konfiguration angeben
!MESSAGE Sie können beim Ausf?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")
@ -389,10 +389,6 @@ 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

222
build/msvc/stdint.h Normal file
View File

@ -0,0 +1,222 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
#endif
# include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef int intptr_t;
typedef unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

217
build/vc8/ixml.vcproj Normal file
View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="ixml"
ProjectGUID="{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}"
RootNamespace="ixml"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc;..\..\upnp\inc"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
UseOfMFC="0"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc"
PreprocessorDefinitions="WIN32;IXML_INLINE="
RuntimeLibrary="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\ixml\src\attr.c"
>
</File>
<File
RelativePath="..\..\ixml\src\document.c"
>
</File>
<File
RelativePath="..\..\ixml\src\element.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixml.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmldebug.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlmembuf.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlparser.c"
>
</File>
<File
RelativePath="..\..\ixml\src\namedNodeMap.c"
>
</File>
<File
RelativePath="..\..\ixml\src\node.c"
>
</File>
<File
RelativePath="..\..\ixml\src\nodeList.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\ixml\inc\ixml.h"
>
</File>
<File
RelativePath="..\..\ixml\inc\ixmldebug.h"
>
</File>
<File
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
>
</File>
<File
RelativePath="..\..\ixml\src\inc\ixmlparser.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

65
build/vc8/libupnp.sln Normal file
View File

@ -0,0 +1,65 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libupnp", "libupnp.vcproj", "{6227F51A-1498-4C4A-B213-F6FDED605125}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "threadutil", "threadutil.vcproj", "{24884928-0501-4CF2-BC8A-180AFC23B2AF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ixml", "ixml.vcproj", "{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvdevice", "tvdevice.vcproj", "{F592B023-E1F3-4A1E-841E-662DEE497435}"
ProjectSection(ProjectDependencies) = postProject
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
{24884928-0501-4CF2-BC8A-180AFC23B2AF} = {24884928-0501-4CF2-BC8A-180AFC23B2AF}
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427} = {AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvctrlpt", "tvctrlpt.vcproj", "{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}"
ProjectSection(ProjectDependencies) = postProject
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427} = {AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}
{24884928-0501-4CF2-BC8A-180AFC23B2AF} = {24884928-0501-4CF2-BC8A-180AFC23B2AF}
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvcombo", "tvcombo.vcproj", "{B5D74697-F615-4DCB-AA8B-935F6372F01C}"
ProjectSection(ProjectDependencies) = postProject
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
{24884928-0501-4CF2-BC8A-180AFC23B2AF} = {24884928-0501-4CF2-BC8A-180AFC23B2AF}
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427} = {AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.ActiveCfg = Debug|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.Build.0 = Debug|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.ActiveCfg = Release|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.Build.0 = Release|Win32
{24884928-0501-4CF2-BC8A-180AFC23B2AF}.Debug|Win32.ActiveCfg = Debug|Win32
{24884928-0501-4CF2-BC8A-180AFC23B2AF}.Debug|Win32.Build.0 = Debug|Win32
{24884928-0501-4CF2-BC8A-180AFC23B2AF}.Release|Win32.ActiveCfg = Release|Win32
{24884928-0501-4CF2-BC8A-180AFC23B2AF}.Release|Win32.Build.0 = Release|Win32
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}.Debug|Win32.ActiveCfg = Debug|Win32
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}.Debug|Win32.Build.0 = Debug|Win32
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}.Release|Win32.ActiveCfg = Release|Win32
{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}.Release|Win32.Build.0 = Release|Win32
{F592B023-E1F3-4A1E-841E-662DEE497435}.Debug|Win32.ActiveCfg = Debug|Win32
{F592B023-E1F3-4A1E-841E-662DEE497435}.Debug|Win32.Build.0 = Debug|Win32
{F592B023-E1F3-4A1E-841E-662DEE497435}.Release|Win32.ActiveCfg = Release|Win32
{F592B023-E1F3-4A1E-841E-662DEE497435}.Release|Win32.Build.0 = Release|Win32
{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}.Debug|Win32.ActiveCfg = Debug|Win32
{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}.Debug|Win32.Build.0 = Debug|Win32
{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}.Release|Win32.ActiveCfg = Release|Win32
{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}.Release|Win32.Build.0 = Release|Win32
{B5D74697-F615-4DCB-AA8B-935F6372F01C}.Debug|Win32.ActiveCfg = Debug|Win32
{B5D74697-F615-4DCB-AA8B-935F6372F01C}.Debug|Win32.Build.0 = Debug|Win32
{B5D74697-F615-4DCB-AA8B-935F6372F01C}.Release|Win32.ActiveCfg = Release|Win32
{B5D74697-F615-4DCB-AA8B-935F6372F01C}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

650
build/vc8/libupnp.vcproj Normal file
View File

@ -0,0 +1,650 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="libupnp"
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
RootNamespace="libupnp"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/libupnp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\pthreads\include;..\..\ixml\src\inc;..\..\ixml\inc;..\..\threadutil\inc;..\..\upnp\inc;..\..\upnp\src\inc;..\inc;..\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/libupnp.pch"
AssemblerListingLocation="$(OutDir)\"
ObjectFile="$(OutDir)\"
ProgramDataBaseFileName="$(OutDir)\"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1031"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib"
OutputFile="$(OutDir)\libupnp.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/libupnp.pdb"
ImportLibrary=".\Release/libupnp.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/libupnp.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/libupnp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\pthreads\include;..\..\ixml\src\inc;..\..\ixml\inc;..\..\threadutil\inc;..\..\upnp\inc;..\..\upnp\src\inc;..\inc;..\msvc"
PreprocessorDefinitions="DEBUG;WIN32;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile="$(OutDir)\libupnp.pch"
AssemblerListingLocation="$(OutDir)\"
ObjectFile="$(OutDir)\"
ProgramDataBaseFileName="$(OutDir)\"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1031"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib ixml.lib"
OutputFile="$(OutDir)\libupnp.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(OutDir)\..\ixml"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)\libupnp.pdb"
ImportLibrary="$(OutDir)\libupnp.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile="$(OutDir)\libupnp.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="sources"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\..\upnp\src\api\ActionComplete.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\ActionRequest.c"
>
</File>
<File
RelativePath="..\..\ixml\src\attr.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\Discovery.c"
>
</File>
<File
RelativePath="..\..\ixml\src\document.c"
>
</File>
<File
RelativePath="..\..\ixml\src\element.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\Event.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\EventSubscribe.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\FileInfo.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\FreeList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_callback2.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\httpparser.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\httpreadwrite.c"
>
</File>
<File
RelativePath="..\..\upnp\src\inet_pton.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixml.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlmembuf.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlparser.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\LinkedList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\md5.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\membuffer.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\miniserver\miniserver.c"
>
</File>
<File
RelativePath="..\..\ixml\src\namedNodeMap.c"
>
</File>
<File
RelativePath="..\..\ixml\src\node.c"
>
</File>
<File
RelativePath="..\..\ixml\src\nodeList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\parsetools.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\service_table\service_table.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_common.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\sock.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\StateVarComplete.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\StateVarRequest.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\SubscriptionRequest.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\sysdep.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\ThreadPool.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\TimerThread.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\upnp_timeout.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnpapi.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnpdebug.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\UpnpString.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnptools.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\uri\uri.c"
>
</File>
<File
RelativePath="..\..\upnp\src\urlconfig\urlconfig.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\util.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\uuid.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\webserver.c"
>
</File>
<File
RelativePath="..\..\upnp\src\win_dll.c"
>
</File>
</Filter>
<Filter
Name="headers"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\..\upnp\inc\ActionComplete.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\actionrequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\client_table.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\config.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\discovery.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\Event.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\EventSubscribe.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\FileInfo.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena_ctrlpt.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena_device.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\global.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gmtdate.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\http_client.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\httpparser.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\httpreadwrite.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\inet_pton.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\md5.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\membuffer.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\miniserver.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\netall.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\parsetools.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\server.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\service_table.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\soaplib.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\sock.h"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\ssdplib.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\statcodes.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\StateVarComplete.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\statevarrequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\statuscodes.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\strintmap.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\SubscriptionRequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\sysdep.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\unixutil.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnp.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnpapi.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnpdebug.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\UpnpString.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnptools.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\uri.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\urlconfig.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\util.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\utilall.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\uuid.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\webserver.h"
>
</File>
</Filter>
<File
RelativePath="..\..\..\..\libupnp_win32.patch"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

213
build/vc8/threadutil.vcproj Normal file
View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="threadutil"
ProjectGUID="{24884928-0501-4CF2-BC8A-180AFC23B2AF}"
RootNamespace="threadutil"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\threadutil\inc;..\..\upnp\inc;..\..\ixml\inc;..\..\pthreads\include"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="pthreadVC2.lib"
AdditionalLibraryDirectories="..\..\pthreads\lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\threadutil\src\FreeList.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\LinkedList.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\ThreadPool.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\TimerThread.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\threadutil\inc\FreeList.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\ithread.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\LinkedList.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\ThreadPool.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\TimerThread.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

216
build/vc8/tvcombo.vcproj Normal file
View File

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="tvcombo"
ProjectGUID="{B5D74697-F615-4DCB-AA8B-935F6372F01C}"
RootNamespace="tvcombo"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\ixml\inc;..\..\upnp\sample\common;..\inc;..\..\threadutil\inc;..\..\pthreads\include;..\..\upnp\sample\tvcombo;..\..\upnp\sample\tvcombo\linux"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;out.vc8.$(ConfigurationName)\ixml&quot;;&quot;out.vc8.$(ConfigurationName)\threadutil&quot;;&quot;out.vc8.$(ConfigurationName)\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\linux\upnp_tv_combo_main.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_device.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_ctrlpt.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_device.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

208
build/vc8/tvctrlpt.vcproj Normal file
View File

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="tvctrlpt"
ProjectGUID="{BC1557D9-9E84-4BA5-861E-CB04D767FBDC}"
RootNamespace="tvctrlpt"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\ixml\inc;..\..\upnp\sample\common;..\inc;..\..\threadutil\inc;..\..\pthreads\include;..\..\upnp\sample\tvctrlpt;..\..\upnp\sample\tvctrlpt\linux"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;out.vc8.$(ConfigurationName)\ixml&quot;;&quot;out.vc8.$(ConfigurationName)\threadutil&quot;;&quot;out.vc8.$(ConfigurationName)\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\upnp_tv_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\linux\upnp_tv_ctrlpt_main.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\upnp_tv_ctrlpt.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

208
build/vc8/tvdevice.vcproj Normal file
View File

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="tvdevice"
ProjectGUID="{F592B023-E1F3-4A1E-841E-662DEE497435}"
RootNamespace="tvdevice"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\ixml\inc;..\..\upnp\sample\common;..\inc;..\..\threadutil\inc;..\..\pthreads\include;..\..\upnp\sample\tvdevice;..\..\upnp\sample\tvdevice\linux"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;out.vc8.$(ConfigurationName)\ixml&quot;;&quot;out.vc8.$(ConfigurationName)\threadutil&quot;;&quot;out.vc8.$(ConfigurationName)\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
RuntimeLibrary="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\upnp_tv_device.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\linux\upnp_tv_device_main.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\upnp_tv_device.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

216
build/vc9/ixml.vcproj Normal file
View File

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ixml"
ProjectGUID="{9C2C266D-35A3-465F-A297-0E21D54E5C89}"
RootNamespace="ixml"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc;..\..\upnp\inc"
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\ixml\src\attr.c"
>
</File>
<File
RelativePath="..\..\ixml\src\document.c"
>
</File>
<File
RelativePath="..\..\ixml\src\element.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixml.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmldebug.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlmembuf.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlparser.c"
>
</File>
<File
RelativePath="..\..\ixml\src\namedNodeMap.c"
>
</File>
<File
RelativePath="..\..\ixml\src\node.c"
>
</File>
<File
RelativePath="..\..\ixml\src\nodeList.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\ixml\inc\ixml.h"
>
</File>
<File
RelativePath="..\..\ixml\inc\ixmldebug.h"
>
</File>
<File
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
>
</File>
<File
RelativePath="..\..\ixml\src\inc\ixmlparser.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

63
build/vc9/libupnp.sln Normal file
View File

@ -0,0 +1,63 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libupnp", "libupnp.vcproj", "{6227F51A-1498-4C4A-B213-F6FDED605125}"
ProjectSection(ProjectDependencies) = postProject
{9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89}
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ixml", "ixml.vcproj", "{9C2C266D-35A3-465F-A297-0E21D54E5C89}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "threadutil", "threadutil.vcproj", "{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvctrlpt", "tvctrlpt.vcproj", "{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}"
ProjectSection(ProjectDependencies) = postProject
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvdevice", "tvdevice.vcproj", "{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}"
ProjectSection(ProjectDependencies) = postProject
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvcombo", "tvcombo.vcproj", "{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
ProjectSection(ProjectDependencies) = postProject
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.ActiveCfg = Debug|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Debug|Win32.Build.0 = Debug|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.ActiveCfg = Release|Win32
{6227F51A-1498-4C4A-B213-F6FDED605125}.Release|Win32.Build.0 = Release|Win32
{9C2C266D-35A3-465F-A297-0E21D54E5C89}.Debug|Win32.ActiveCfg = Debug|Win32
{9C2C266D-35A3-465F-A297-0E21D54E5C89}.Debug|Win32.Build.0 = Debug|Win32
{9C2C266D-35A3-465F-A297-0E21D54E5C89}.Release|Win32.ActiveCfg = Release|Win32
{9C2C266D-35A3-465F-A297-0E21D54E5C89}.Release|Win32.Build.0 = Release|Win32
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Debug|Win32.ActiveCfg = Debug|Win32
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Debug|Win32.Build.0 = Debug|Win32
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Release|Win32.ActiveCfg = Release|Win32
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}.Release|Win32.Build.0 = Release|Win32
{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Debug|Win32.ActiveCfg = Debug|Win32
{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Debug|Win32.Build.0 = Debug|Win32
{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Release|Win32.ActiveCfg = Release|Win32
{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}.Release|Win32.Build.0 = Release|Win32
{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Debug|Win32.ActiveCfg = Debug|Win32
{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Debug|Win32.Build.0 = Debug|Win32
{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Release|Win32.ActiveCfg = Release|Win32
{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}.Release|Win32.Build.0 = Release|Win32
{6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Debug|Win32.ActiveCfg = Debug|Win32
{6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Debug|Win32.Build.0 = Debug|Win32
{6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Release|Win32.ActiveCfg = Release|Win32
{6365804B-22C6-4D5E-91F3-0C052EB55B4F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

646
build/vc9/libupnp.vcproj Normal file
View File

@ -0,0 +1,646 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="libupnp"
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
RootNamespace="libupnp"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/libupnp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\pthreads\include,..\ixml\src\inc,..\ixml\inc,..\threadutil\inc,..\upnp\inc,..\upnp\src\inc,.\inc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/libupnp.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1031"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib"
OutputFile=".\Release/libupnp.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/libupnp.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release/libupnp.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/libupnp.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/libupnp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\pthreads\include;..\..\ixml\src\inc;..\..\ixml\inc;..\..\threadutil\inc;..\..\upnp\inc;..\..\upnp\src\inc;..\inc;..\msvc"
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile="$(OutDir)\libupnp.pch"
AssemblerListingLocation="$(OutDir)\"
ObjectFile="$(OutDir)\"
ProgramDataBaseFileName="$(OutDir)\"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1031"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib $(TargetDir)..\ixml\ixml.lib"
OutputFile="$(OutDir)\libupnp.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)\libupnp.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)\libupnp.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile="$(OutDir)\libupnp.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="sources"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\..\upnp\src\api\ActionComplete.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\ActionRequest.c"
>
</File>
<File
RelativePath="..\..\ixml\src\attr.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\Discovery.c"
>
</File>
<File
RelativePath="..\..\ixml\src\document.c"
>
</File>
<File
RelativePath="..\..\ixml\src\element.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\Event.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\EventSubscribe.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\FileInfo.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\FreeList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_callback2.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\gena\gena_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\httpparser.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\httpreadwrite.c"
>
</File>
<File
RelativePath="..\..\upnp\src\inet_pton.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixml.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlmembuf.c"
>
</File>
<File
RelativePath="..\..\ixml\src\ixmlparser.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\LinkedList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\md5.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\membuffer.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\miniserver\miniserver.c"
>
</File>
<File
RelativePath="..\..\ixml\src\namedNodeMap.c"
>
</File>
<File
RelativePath="..\..\ixml\src\node.c"
>
</File>
<File
RelativePath="..\..\ixml\src\nodeList.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\parsetools.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\service_table\service_table.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_common.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\soap\soap_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\sock.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.c"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\StateVarComplete.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\StateVarRequest.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\SubscriptionRequest.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\sysdep.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\ThreadPool.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\TimerThread.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\upnp_timeout.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnpapi.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnpdebug.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\UpnpString.c"
>
</File>
<File
RelativePath="..\..\upnp\src\api\upnptools.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\uri\uri.c"
>
</File>
<File
RelativePath="..\..\upnp\src\urlconfig\urlconfig.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\util\util.c"
>
</File>
<File
RelativePath="..\..\upnp\src\uuid\uuid.c"
>
</File>
<File
RelativePath="..\..\upnp\src\genlib\net\http\webserver.c"
>
</File>
<File
RelativePath="..\..\upnp\src\win_dll.c"
>
</File>
</Filter>
<Filter
Name="headers"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\..\upnp\inc\ActionComplete.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\ActionRequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\client_table.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\config.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\Discovery.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\Event.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\EventSubscribe.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\FileInfo.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena_ctrlpt.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gena_device.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\global.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\gmtdate.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\http_client.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\httpparser.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\httpreadwrite.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\inet_pton.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\md5.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\membuffer.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\miniserver.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\netall.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\parsetools.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\server.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\service_table.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\soaplib.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\sock.h"
>
</File>
<File
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\ssdplib.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\statcodes.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\StateVarComplete.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\StateVarRequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\statuscodes.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\strintmap.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\SubscriptionRequest.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\sysdep.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\unixutil.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnp.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\upnpapi.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnpdebug.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\UpnpString.h"
>
</File>
<File
RelativePath="..\..\upnp\inc\upnptools.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\uri.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\urlconfig.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\util.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\utilall.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\uuid.h"
>
</File>
<File
RelativePath="..\..\upnp\src\inc\webserver.h"
>
</File>
</Filter>
<File
RelativePath="..\..\..\..\libupnp_win32.patch"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

216
build/vc9/threadutil.vcproj Normal file
View File

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="threadutil"
ProjectGUID="{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
RootNamespace="threadutil"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="4"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\threadutil\inc;..\..\upnp\inc;..\..\ixml\inc;..\..\pthreads\include"
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="pthreadVC2.lib"
AdditionalLibraryDirectories="..\..\pthreads\lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\threadutil\inc;..\..\upnp\inc;..\..\ixml\inc;..\..\pthreads\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\threadutil\src\FreeList.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\LinkedList.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\ThreadPool.c"
>
</File>
<File
RelativePath="..\..\threadutil\src\TimerThread.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\threadutil\inc\FreeList.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\ithread.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\LinkedList.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\threadpool.h"
>
</File>
<File
RelativePath="..\..\threadutil\inc\TimerThread.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

214
build/vc9/tvcombo.vcproj Normal file
View File

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="tvcombo"
ProjectGUID="{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
RootNamespace="tvcombo"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\upnp\sample\common;..\..\upnp\sample;..\..\ixml\inc;..\..\pthreads\include;..\inc;..\..\threadutil\inc;..\..\upnp\sample\tvcombo"
PreprocessorDefinitions="DEBUG;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib $(TargetDir)..\libupnp\libupnp.lib"
AdditionalLibraryDirectories="&quot;$(TargetDir)..\ixml&quot;;&quot;$(TargetDir)..\threadutil&quot;;&quot;$(TargetDir)..\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\linux\upnp_tv_combo_main.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_device.c"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_ctrlpt.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvcombo\upnp_tv_device.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

204
build/vc9/tvctrlpt.vcproj Normal file
View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="tvctrlpt"
ProjectGUID="{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}"
RootNamespace="sample"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\upnp\sample\common;..\..\ixml\inc;..\inc;..\..\threadutil\inc;..\..\pthreads\include;..\..\upnp\sample\tvctrlpt\linux;..\..\upnp\sample\tvctrlpt"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;.\out.vc9.$(ConfigurationName)\ixml&quot;;&quot;.\out.vc9.$(ConfigurationName)\threadutil&quot;;&quot;.\out.vc9.$(ConfigurationName)\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\upnp_tv_ctrlpt.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\linux\upnp_tv_ctrlpt_main.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvctrlpt\upnp_tv_ctrlpt.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

204
build/vc9/tvdevice.vcproj Normal file
View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="tvdevice"
ProjectGUID="{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}"
RootNamespace="tvdevice"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\upnp\inc;..\..\ixml\inc;..\..\upnp\sample\common;..\inc;..\..\threadutil\inc;..\..\pthreads\include;..\..\upnp\sample\tvdevice;..\..\upnp\sample\tvdevice\linux"
PreprocessorDefinitions="WIN32;DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;.\out.vc9.$(ConfigurationName)\ixml&quot;;&quot;.\out.vc9.$(ConfigurationName)\threadutil&quot;;&quot;.\out.vc9.$(ConfigurationName)\libupnp&quot;"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\upnp_tv_device.c"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\linux\upnp_tv_device_main.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\upnp\sample\common\sample_util.h"
>
</File>
<File
RelativePath="..\..\upnp\sample\tvdevice\upnp_tv_device.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -4,73 +4,203 @@
#
# Process this file with autoconf to produce a configure script.
#
# (C) Copyright 2005-2006 Rémi Turboult <r3mi@users.sourceforge.net>
# (C) Copyright 2005-2007 Rémi Turboult <r3mi@users.sourceforge.net>
#
AC_PREREQ(2.60)
AC_INIT([libupnp], [1.6.0], [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:
# - library code modified: revision++
# - interfaces changed/added/removed: current++ and revision=0
# - interfaces added: age++
# - interfaces removed: age=0
# *please update only once, before a formal release, not for each change*
#
# 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
#
# For release 1.4.6, we had:
#AC_SUBST([LT_VERSION_IXML], [2:3:0])
#AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
#AC_SUBST([LT_VERSION_UPNP], [2:3:0])
#
# "current:revision:age"
#
# - Code has changed in ixml
# revision: 3 -> 4
# - Code has changed in threadutil
# revision: 0 -> 1
# - Code has changed in upnp
# revision: 3 -> 4
# - Interface changed in upnp
# current: 2 -> 3
# revision: 4 -> 0
# - Interface removed in upnp
# age: 0 -> 0
#
# For release 1.6.0, we had:
#AC_SUBST([LT_VERSION_IXML], [2:4:0])
#AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
#AC_SUBST([LT_VERSION_UPNP], [3:0:0])
AC_SUBST([LT_VERSION_IXML], [2:4:0])
AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
AC_SUBST([LT_VERSION_UPNP], [3:0:0])
AC_INIT([libupnp], [1.6.8], [mroberto@users.sourceforge.net])
dnl ############################################################################
dnl # *Independently* of the above libupnp package version, the libtool version
dnl # of the 3 libraries need to be updated whenever there is a change released:
dnl # "current:revision:age" (this is NOT the same as the package version),
dnl # where:
dnl # - library code modified: revision++
dnl # - interfaces changed/added/removed: current++ and revision=0
dnl # - interfaces added: age++
dnl # - interfaces removed: age=0
dnl # *please update only once, before a formal release, not for each change*
dnl #
dnl ############################################################################
dnl # Release 1.4.1:
dnl #AC_SUBST([LT_VERSION_IXML], [2:2:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [2:2:0])
dnl #AC_SUBST([LT_VERSION_UPNP], [2:2:0])
dnl #
dnl ############################################################################
dnl # Release 1.4.6:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in ixml
dnl # revision: 2 -> 3
dnl # - Code has changed in threadutil
dnl # revision: 2 -> 3
dnl # - Interface added in threadutil
dnl # current: 2 -> 3
dnl # revisiion: 3 -> 0
dnl # age: 0 -> 1
dnl # - Code has changed in upnp
dnl # revision: 2 -> 3
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:3:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:0:1])
dnl #AC_SUBST([LT_VERSION_UPNP], [2:3:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.0:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in ixml
dnl # revision: 3 -> 4
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl # - Code has changed in upnp
dnl # revision: 3 -> 4
dnl # - Interface changed in upnp
dnl # current: 2 -> 3
dnl # revision: 4 -> 0
dnl # - Interface removed in upnp
dnl # age: 0 -> 0
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [3:1:1])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:0:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.1:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 1 -> 2
dnl # - Interface added in threadutil
dnl # current: 3 -> 4
dnl # revision: 2 -> 0
dnl # - Interface added in threadutil
dnl # age: 1 -> 2
dnl # - Code has changed in upnp
dnl # revision: 0 -> 1
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:1:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.2:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in upnp
dnl # revision: 1 -> 2
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:0:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.3:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:1:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:2:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.4:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 1 -> 2
dnl # - Code has changed in upnp
dnl # revision: 2 -> 3
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:2:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:3:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.5:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in upnp
dnl # revision: 3 -> 4
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:2:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:4:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.6:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 2 -> 3
dnl # - Code has changed in upnp
dnl # revision: 4 -> 5
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:3:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.7:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in threadutil
dnl # revision: 3 -> 4
dnl # - Code has changed in upnp
dnl # revision: 5 -> 6
dnl # - Interfaces have been changed, added and removed in upnp
dnl # current: 3 -> 4
dnl # revision: 6 -> 0
dnl # - Interfaces removed in upnp:
dnl # age: -> 0
dnl #
dnl #AC_SUBST([LT_VERSION_IXML], [2:4:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
dnl #
dnl # Obs.: 1.6.7 was released with a version error, the correct nubers should
dnl # have been:
dnl #AC_SUBST([LT_VERSION_UPNP], [4:0:0])
dnl #
dnl ############################################################################
dnl # Release 1.6.8:
dnl # "current:revision:age"
dnl #
dnl # - Code has changed in ixml
dnl # revision: 4 -> 5
dnl # - Code has changed in threadutil
dnl # revision: 0 -> 1
dnl # - Code has changed in upnp
dnl # revision: 0 -> 1
dnl #AC_SUBST([LT_VERSION_IXML], [2:5:0])
dnl #AC_SUBST([LT_VERSION_THREADUTIL], [5:1:2])
dnl #AC_SUBST([LT_VERSION_UPNP], [4:1:0])
dnl #
dnl ############################################################################
AC_SUBST([LT_VERSION_IXML], [2:5:0])
AC_SUBST([LT_VERSION_THREADUTIL], [5:1:2])
AC_SUBST([LT_VERSION_UPNP], [4:1:0])
dnl ############################################################################
dnl # Repeating the algorithm to place it closer to the modificatin place:
dnl # - library code modified: revision++
dnl # - interfaces changed/added/removed: current++ and revision=0
dnl # - interfaces added: age++
dnl # - interfaces removed: age=0
dnl # *please update only once, before a formal release, not for each change*
dnl ############################################################################
AC_CONFIG_AUX_DIR(config.aux)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_SRCDIR(upnp/inc/upnp.h)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([upnp/inc/upnp.h])
AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects dist-bzip2])
#
# Get canonical host names in host and host_os
#
@ -95,8 +225,7 @@ AC_REVISION([$Revision: 1.11 $])
upnpmaj=`echo "$PACKAGE_VERSION" | sed 's/\..*//' `
upnpmin=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.// ; s/[^0-9].*$//' `]
upnppatch=[`echo "$PACKAGE_VERSION" | sed 's/^[^.]\.[^.]\.// ; s/[^0-9].*$//' `]
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION",
[see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_STRING], "$PACKAGE_VERSION", [see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_MAJOR], $upnpmaj, [see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_MINOR], $upnpmin, [see upnpconfig.h])
AC_DEFINE_UNQUOTED([UPNP_VERSION_PATCH], $upnppatch, [see upnpconfig.h])
@ -118,7 +247,6 @@ fi
#
# Check for libupnp subsets
#
RT_BOOL_ARG_ENABLE([client], [yes], [control point code (client)])
if test "x$enable_client" = xyes ; then
AC_DEFINE(UPNP_HAVE_CLIENT, 1, [see upnpconfig.h])
@ -148,15 +276,27 @@ if test "x$enable_tools" = xyes ; then
AC_DEFINE(UPNP_HAVE_TOOLS, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([ipv6], [no], [ipv6 support])
if test "x$enable_ipv6" = xyes ; then
AC_DEFINE(UPNP_ENABLE_IPV6, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([notification_reordering], [yes], [GENA notification reordering in gena_device.c])
if test "x$enable_notification_reordering" = xyes ; then
AC_DEFINE(UPNP_ENABLE_NOTIFICATION_REORDERING, 1, [see upnpconfig.h])
fi
RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])
#
# doc installation
# 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(
@ -171,7 +311,9 @@ AS_HELP_STRING(
[],
[with_documentation=no])
#
# 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
@ -205,7 +347,9 @@ freebsd*)
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
:
#:
# Use -O0 in debug so that variables do not get optimized out
AX_CFLAGS_GCC_OPTION([-O0])
else
# add optimise for size
AX_CFLAGS_GCC_OPTION([-Os])
@ -227,9 +371,26 @@ AC_DEFINE([_FILE_OFFSET_BITS], [64], [File Offset size])
#
# Checks for header files
# Are we targetting Win32?
#
AC_MSG_CHECKING([for Win32])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#ifdef WIN32
#error Yup
#endif
],[])], [ac_cv_win32="no"], [ac_cv_win32="yes"])
if test "$ac_cv_win32" = "yes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
#
# Checks for header files (which aren't needed on Win32)
#
AC_HEADER_STDC
if test "$ac_cv_win32" = "no"; then
# libupnp code doesn't use autoconf variables yet,
# so just abort if a header file is not found.
AC_CHECK_HEADERS(
@ -245,20 +406,43 @@ AC_CHECK_HEADERS(
sys/ioctl.h \
sys/socket.h \
sys/time.h \
sys/timeb.h \
syslog.h \
unistd.h \
],
[],
[AC_MSG_ERROR([required header file missing])])
fi
#
# Checks for typedefs, structures, and compiler characteristics
#
AC_C_CONST
AC_TYPE_SIZE_T
TYPE_SOCKLEN_T
# The test for socklen_t was getting it wrong when it exists but is in ws2tcpip.h,
# so we use a new test.
#TYPE_SOCKLEN_T
AC_CHECK_HEADERS([sys/types.h sys/socket.h ws2tcpip.h])
AC_MSG_CHECKING(for socklen_t)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
],[ socklen_t t = 0; return t; ])
],[ac_cv_socklen_t="yes"],[ac_cv_socklen_t="no"])
if test "$ac_cv_socklen_t" = "yes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, using int])
AC_DEFINE(socklen_t, int, [Type for storing the length of struct sockaddr])
fi
#
@ -267,14 +451,50 @@ TYPE_SOCKLEN_T
AC_FUNC_VPRINTF
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
#
# Solaris needs -lsocket -lnsl -lrt
AC_SEARCH_LIBS([bind], [socket])
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([sched_getparam], [rt])
#
# Checks for POSIX Threads
#
echo "--------------------------- pthread stuff -------------------------------------"
ACX_PTHREAD(
[],
[AC_MSG_ERROR([POSIX threads are required to build this program])])
#
# Update environment variables for pthreads
#
CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
#
# Determine if pthread_rwlock_t is available
#
echo "----------------------- pthread_rwlock_t stuff --------------------------------"
AC_MSG_CHECKING([if pthread_rwlock_t is available])
AC_LANG([C])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <pthread.h>],
[pthread_rwlock_t *x;])],
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
AC_MSG_RESULT([yes, supported without any options])],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#define _GNU_SOURCE
#include <pthread.h>],
[pthread_rwlock_t *x;])],
[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
[AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
AC_MSG_ERROR([pthread_rwlock_t not available])])])
echo "-------------------------------------------------------------------------------"
AC_CONFIG_FILES([
@ -292,3 +512,11 @@ AC_CONFIG_FILES([
AC_OUTPUT
#
# Files copied for windows compilation.
#
echo "configure: copying \"autoconfig.h\" to \"build/inc/autoconfig.h\""
cp autoconfig.h build/inc/autoconfig.h
echo "configure: copying \"upnp/inc/upnpconfig.h\" to \"build/inc/upnpconfig.h\""
cp upnp/inc/upnpconfig.h build/inc/upnpconfig.h

View File

@ -39,7 +39,7 @@ EXTRA_DIST = \
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
./html/upnp/UPNP_E_CANCELED-210.html \
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCAPTED-302.html \
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCEPTED-302.html \
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \
@ -295,7 +295,7 @@ if WITH_DOCUMENTATION
./html/upnp/UPNP_E_SOCKET_ERROR-208.html \
./html/upnp/UPNP_E_CANCELED-210.html \
./html/upnp/UPNP_E_SUBSCRIBE_UNACCEPTED-301.html \
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCAPTED-302.html \
./html/upnp/UPNP_E_UNSUBSCRIBE_UNACCEPTED-302.html \
./html/upnp/UPNP_E_NOTIFY_UNACCEPTED-303.html \
./html/upnp/UPNP_E_INVALID_ARGUMENT-501.html \
./html/upnp/UPNP_E_FILE_NOT_FOUND-502.html \

View File

@ -2,7 +2,7 @@
#
# "Makefile.am" for "libupnp/ixml"
#
# (C) Copyright 2005 Rémi Turboult <r3mi@users.sourceforge.net>
# (C) Copyright 2005 Rémi Turboult <r3mi@users.sourceforge.net>
#
SUBDIRS = doc
@ -24,15 +24,23 @@ libixml_la_LDFLAGS = -version-info $(LT_VERSION_IXML) \
-export-symbols-regex '^ixml.*'
libixml_la_SOURCES = \
src/ixml.c src/node.c src/ixmlparser.c \
src/ixmlmembuf.c src/nodeList.c \
src/element.c src/attr.c src/document.c \
src/attr.c \
src/document.c \
src/element.c \
src/inc/ixmlmembuf.h \
src/inc/ixmlparser.h \
src/ixml.c \
src/ixmldebug.c \
src/ixmlparser.c \
src/ixmlmembuf.c \
src/namedNodeMap.c \
src/inc/ixmlmembuf.h src/inc/ixmlparser.h
src/node.c \
src/nodeList.c
upnpincludedir = $(includedir)/upnp
upnpinclude_HEADERS = inc/ixml.h
upnpinclude_HEADERS = \
inc/ixml.h \
inc/ixmldebug.h
check_PROGRAMS = test_document
TESTS = test/test_document.sh
@ -47,4 +55,3 @@ dist-hook:
clean-local:
@if [ -d bin ] ; then rm -rf bin ; fi

File diff suppressed because it is too large Load Diff

67
ixml/inc/ixmldebug.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef IXMLDEBUG_H
#define IXMLDEBUG_H
#include "UpnpGlobal.h"
#include "ixml.h"
/*!
* \file
*
* \brief Auxiliar routines to aid debugging.
*/
/*!
* \brief Prints the debug statement either on the standard output or log file
* along with the information from where this debug statement is coming.
*/
#ifdef DEBUG
void IxmlPrintf(
/*! [in] The file name, usually __FILE__. */
const char *DbgFileName,
/*! [in] The line number, usually __LINE__ or a variable that got the
* __LINE__ at the appropriate place. */
int DbgLineNo,
/*! [in] The function name. */
const char *FunctionName,
/*! [in] Printf like format specification. */
const char* FmtStr,
/*! [in] Printf like Variable number of arguments that will go in the debug
* statement. */
...)
#if (__GNUC__ >= 3)
/* This enables printf like format checking by the compiler */
__attribute__((format (__printf__, 4, 5)))
#endif
;
#else /* DEBUG */
static UPNP_INLINE void IxmlPrintf(
const char* FmtStr,
...) {}
#endif /* DEBUG */
/*!
* \brief Print the node names and values of a XML tree.
*/
#ifdef DEBUG
void printNodes(
/*! [in] The root of the tree to print. */
IXML_Node *tmpRoot,
/*! [in] The depth to print. */
int depth);
#else
static UPNP_INLINE void printNodes(
IXML_Node *tmpRoot,
int depth)
{
}
#endif
#endif /* IXMLDEBUG_H */

View File

@ -1,60 +1,53 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "ixmlparser.h"
/*================================================================
* Function: Attr_init
* Initializes an attribute node
* External function.
*
*=================================================================*/
void
ixmlAttr_init( IN IXML_Attr * attr )
#include <string.h>
void ixmlAttr_init(IN IXML_Attr *attr)
{
if( attr != NULL ) {
memset( attr, 0, sizeof( IXML_Attr ) );
}
if (attr != NULL) {
memset(attr, 0, sizeof (IXML_Attr));
}
}
/*================================================================
* Function: Attr_free
* Frees an attribute node.
* external function.
*
*=================================================================*/
void
ixmlAttr_free( IN IXML_Attr * attr )
void ixmlAttr_free(IN IXML_Attr *attr)
{
if( attr != NULL ) {
ixmlNode_free( ( IXML_Node * ) attr );
}
if (attr != NULL) {
ixmlNode_free((IXML_Node *)attr);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,77 +1,173 @@
///////////////////////////////////////////////////////////////////////////
//
// 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_MEMBUF_H
#define IXML_MEMBUF_H
/*!
* \file
*/
#ifndef _IXML_MEMBUF_H
#define _IXML_MEMBUF_H
#include <stdlib.h>
#include "ixml.h"
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
#ifndef WIN32
#define UPNP_INLINE inline
#endif
#define MEMBUF_DEF_SIZE_INC 20
#include <stdlib.h> /* for size_t */
typedef struct // ixml_membuf
#define MINVAL(a, b) ( (a) < (b) ? (a) : (b) )
#define MAXVAL(a, b) ( (a) > (b) ? (a) : (b) )
#define MEMBUF_DEF_SIZE_INC 20
/*!
* \brief The ixml_membuf type.
*/
typedef struct
{
char *buf;
size_t length;
size_t capacity;
size_t size_inc;
char *buf;
size_t length;
size_t capacity;
size_t size_inc;
} ixml_membuf;
//--------------------------------------------------
//////////////// functions /////////////////////////
//--------------------------------------------------
/*
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
*/
void ixml_membuf_init(INOUT ixml_membuf *m);
void ixml_membuf_destroy(INOUT ixml_membuf *m);
int ixml_membuf_assign(INOUT ixml_membuf *m, IN const void *buf,
IN size_t buf_len );
int ixml_membuf_assign_str(INOUT ixml_membuf *m, IN const char *c_str );
int ixml_membuf_append(INOUT ixml_membuf *m, IN const void *buf);
int ixml_membuf_append_str(INOUT ixml_membuf *m, IN const char *c_str);
int ixml_membuf_insert(INOUT ixml_membuf *m, IN const void* buf,
IN size_t buf_len, int index );
/*!
* \brief ixml_membuf initialization routine.
*/
void ixml_membuf_init(
/*! [in,out] The memory buffer to initializa. */
ixml_membuf *m);
/*!
* \brief ixml_membuf clearing routine.
*
* The internal buffer is deleted and ixml_membuf_init() is called in the end
* to reinitialize the buffer.
*/
void ixml_membuf_destroy(
/*! [in,out] The memory buffer to clear. */
ixml_membuf *m);
/*!
* \brief Copies the contents o a buffer to the designated ixml_membuf.
*
* The previous contents of the ixml_membuf are destroyed.
*
* \return IXML_SUCCESS if successfull, or the error code returned
* by ixml_membuf_set_size().
*
* \sa ixml_membuf_assign_str().
*/
int ixml_membuf_assign(
/*! [in,out] The memory buffer on which to operate. */
ixml_membuf *m,
/*! [in] The input buffer to copy from. */
const void *buf,
/*! [in] The number of bytes to copy from the input buffer. */
size_t buf_len);
/*!
* \brief Copies a \b NULL terminated string to the ixml_buffer.
*
* This is a convenience function that internally uses ixml_membuf_assign().
*
* \return The return value of ixml_membuf_assign().
*
* \sa ixml_membuf_assign().
*/
int ixml_membuf_assign_str(
/*! [in,out] The memory buffer on which to operate. */
ixml_membuf *m,
/*! [in] The input string to copy from. */
const char *c_str);
/*!
* \brief Appends one byte to the designated ixml_membuffer.
*
* This is a convenience function that internally uses ixml_membuf_insert().
*
* \return The return value of ixml_membuf_insert().
*
* \sa ixml_membuf_insert()
*/
int ixml_membuf_append(
/*! [in,out] The memory buffer on which to operate. */
ixml_membuf *m,
/*! [in] The pointer to the byte to append. */
const void *buf);
/*!
* \brief Appends the contents of a \b NULL terminated string to the designated
* ixml_membuf.
*
* This is a convenience function that internally uses ixml_membuf_insert().
*
* \return The return value of ixml_membuf_insert().
*
* \sa ixml_membuf_insert().
*/
int ixml_membuf_append_str(
/*! [in,out] The memory buffer on which to operate. */
ixml_membuf *m,
/*! [in] The input string to copy from. */
const char *c_str);
/*!
* \brief
*
* \return
* \li 0 if successfull.
* \li IXML_INDEX_SIZE_ERR if the index parameter is out of range.
* \li Or the return code of ixml_membuf_set_size()
*
* \sa ixml_membuf_set_size()
*/
int ixml_membuf_insert(
/*! [in,out] The memory buffer on which to operate. */
ixml_membuf *m,
/*! [in] The pointer to the input buffer. */
const void *buf,
/*! [in] The buffer length. */
size_t buf_len,
/*! [in] The point of insertion relative to the beggining of the
* ixml_membuf internal buffer. */
int index);
#endif /* IXML_MEMBUF_H */
#endif // _IXML_MEMBUF_H

View File

@ -1,41 +1,49 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 _IXMLPARSER_H
#define _IXMLPARSER_H
/**************************************************************************
*
* 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 IXMLPARSER_H
#define IXMLPARSER_H
/*!
* \file
*/
#include "ixml.h"
#include "ixmlmembuf.h"
// Parser definitions
/* Parser definitions */
#define QUOT "&quot;"
#define LT "&lt;"
#define GT "&gt;"
@ -44,77 +52,218 @@
#define ESC_HEX "&#x"
#define ESC_DEC "&#"
typedef struct _IXML_NamespaceURI
{
char *nsURI;
char *prefix;
struct _IXML_NamespaceURI *nextNsURI;
char *nsURI;
char *prefix;
struct _IXML_NamespaceURI *nextNsURI;
} IXML_NamespaceURI;
typedef struct _IXML_ElementStack
{
char *element;
char *prefix;
char *namespaceUri;
IXML_NamespaceURI *pNsURI;
struct _IXML_ElementStack *nextElement;
char *element;
char *prefix;
char *namespaceUri;
IXML_NamespaceURI *pNsURI;
struct _IXML_ElementStack *nextElement;
} IXML_ElementStack;
typedef enum
{
eELEMENT,
eATTRIBUTE,
eCONTENT,
eELEMENT,
eATTRIBUTE,
eCONTENT,
} PARSER_STATE;
typedef struct _Parser
{
char *dataBuffer; //data buffer
char *curPtr; //ptr to the token parsed
char *savePtr; //Saves for backup
ixml_membuf lastElem;
ixml_membuf tokenBuf;
IXML_Node *pNeedPrefixNode;
IXML_ElementStack *pCurElement;
IXML_Node *currentNodePtr;
PARSER_STATE state;
BOOL bHasTopLevel;
/*! Data buffer. */
char *dataBuffer;
/*! Pointer to the token parsed. */
char *curPtr;
/*! Saves for backup. */
char *savePtr;
ixml_membuf lastElem;
ixml_membuf tokenBuf;
IXML_Node *pNeedPrefixNode;
IXML_ElementStack *pCurElement;
IXML_Node *currentNodePtr;
PARSER_STATE state;
BOOL bHasTopLevel;
} Parser;
/*!
* \brief Check to see whether name is a valid xml name.
*/
BOOL Parser_isValidXmlName(
/*! [in] The string to be checked. */
const 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);
void Parser_setErrorChar( char c );
/*!
* \brief Sets the error character.
*
* If 'c' is 0 (default), the parser is strict about XML encoding:
* invalid UTF-8 sequences or "&" entities are rejected, and the parsing
* aborts.
*
* If 'c' is not 0, the parser is relaxed: invalid UTF-8 characters
* are replaced by this character, and invalid "&" entities are left
* untranslated. The parsing is then allowed to continue.
*/
void Parser_setErrorChar(
/*! [in] The character to become the error character. */
char c);
void ixmlAttr_free(IXML_Attr *attrNode);
void ixmlAttr_init(IXML_Attr *attrNode);
int ixmlElement_setTagName(IXML_Element *element, const char *tagName);
/*!
* \brief Fees a node contents.
*/
void Parser_freeNodeContent(
/*! [in] The Node to process. */
IXML_Node *IXML_Nodeptr);
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap);
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add);
int Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
void ixmlNode_init(IXML_Node *IXML_Nodeptr);
BOOL ixmlNode_compare(IXML_Node *srcIXML_Node, IXML_Node *destIXML_Node);
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
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, const DOMString qualifiedName);
void ixmlAttr_init(IXML_Attr *attrNode);
void ixmlNodeList_init(IXML_NodeList *nList);
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add);
/*!
* \brief Set the given element's tagName.
*
* \return One of the following:
* \li \b IXML_SUCCESS, if successfull.
* \li \b IXML_FAILED, if element of tagname is \b NULL.
* \li \b IXML_INSUFFICIENT_MEMORY, if there is no memory to allocate the
* buffer for the element's tagname.
*/
int ixmlElement_setTagName(
/*! [in] The element to change the tagname. */
IXML_Element *element,
/*! [in] The new tagName for the element. */
const char *tagName);
#endif // _IXMLPARSER_H
/*!
* \brief Initializes a NamedNodeMap object.
*/
void ixmlNamedNodeMap_init(
/*! [in] The named node map to process. */
IXML_NamedNodeMap *nnMap);
/*!
* \brief Add a node to a NamedNodeMap.
*
* \return IXML_SUCCESS or failure.
*/
int ixmlNamedNodeMap_addToNamedNodeMap(
/* [in] The named node map. */
IXML_NamedNodeMap **nnMap,
/* [in] The node to add. */
IXML_Node *add);
/*!
* \brief Add a node to nodelist.
*/
int ixmlNodeList_addToNodeList(
/*! [in] The pointer to the nodelist. */
IXML_NodeList **nList,
/*! [in] The node to add. */
IXML_Node *add);
/*!
* \brief Intializes a node.
*/
void ixmlNode_init(
/*! [in] The \b Node to iniatialize. */
IN IXML_Node *nodeptr);
/*!
* \brief Compare two nodes to see whether they are the same node.
* Parent, sibling and children node are ignored.
*
* \return
* \li TRUE, the two nodes are the same.
* \li FALSE, the two nodes are not the same.
*/
BOOL ixmlNode_compare(
/*! [in] The first \b Node. */
IXML_Node *srcNode,
/*! [in] The second \b Node. */
IXML_Node *destNode);
/*!
* \brief Returns a nodeList of all descendant Elements with a given tagName,
* in the order in which they are encountered in a traversal of this element
* tree.
*/
void ixmlNode_getElementsByTagName(
/*! [in] The \b Node tree. */
IXML_Node *n,
/*! [in] The tag name to match. */
const char *tagname,
/*! [out] The output \b NodeList. */
IXML_NodeList **list);
/*!
* \brief Returns a nodeList of all the descendant Elements with a given local
* name and namespace URI in the order in which they are encountered in a
* preorder traversal of this Elememt tree.
*/
void ixmlNode_getElementsByTagNameNS(
/*! [in] The \b Element tree. */
IXML_Node *n,
/*! [in] The name space to match. */
const char *namespaceURI,
/*! [in] The local name to match. */
const char *localName,
/*! [out] The output \b NodeList. */
IXML_NodeList **list);
/*!
* \brief
*
* \return
*/
int ixmlNode_setNodeName(
/*! [in] The \b Node. */
IXML_Node *node,
/*! [in] . */
const DOMString qualifiedName);
/*!
* \brief
*
* \return
*/
int ixmlNode_setNodeProperties(
/*! [in] . */
IXML_Node *destNode,
/*! [in] . */
IXML_Node *src);
/*!
* \brief Initializes a nodelist
*/
void ixmlNodeList_init(
/*! [in,out] The \b NodeList to initialize. */
IXML_NodeList *nList);
#endif /* IXMLPARSER_H */

View File

@ -1,531 +1,469 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
**************************************************************************/
/*!
* \file
*/
#include "ixmldebug.h"
#include "ixmlmembuf.h"
#include "ixmlparser.h"
/*================================================================
* copy_with_escape
*
*
*=================================================================*/
static void
copy_with_escape( INOUT ixml_membuf * buf,
IN const char *p )
#include <stdlib.h> /* for free() */
#include <string.h>
/*!
* \brief Appends a string to a buffer, substituting some characters by escape
* sequences.
*/
static void copy_with_escape(
/*! [in,out] The input/output buffer. */
ixml_membuf *buf,
/*! [in] The string to copy from. */
const char *p)
{
int i;
int plen;
if( p == NULL )
return;
plen = strlen( p );
for( i = 0; i < plen; i++ ) {
switch ( p[i] ) {
case '<':
ixml_membuf_append_str( buf, "&lt;" );
break;
case '>':
ixml_membuf_append_str( buf, "&gt;" );
break;
case '&':
ixml_membuf_append_str( buf, "&amp;" );
break;
case '\'':
ixml_membuf_append_str( buf, "&apos;" );
break;
case '\"':
ixml_membuf_append_str( buf, "&quot;" );
break;
default:
ixml_membuf_append( buf, &p[i] );
}
}
}
/*================================================================
* ixmlPrintDomTreeRecursive
* It is a recursive function to print all the node in a tree.
* Internal to parser only.
*
*=================================================================*/
void
ixmlPrintDomTreeRecursive( IN IXML_Node * nodeptr,
IN ixml_membuf * buf )
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL,
*sibling = NULL;
if( nodeptr != NULL ) {
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
nodeValue = ixmlNode_getNodeValue( nodeptr );
switch ( ixmlNode_getNodeType( nodeptr ) ) {
case eTEXT_NODE:
copy_with_escape( buf, nodeValue );
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, " " );
copy_with_escape( buf, nodeValue );
ixml_membuf_append_str( buf, "?>\n" );
break;
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive( ixmlNode_getFirstChild
( nodeptr ), buf );
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str( buf, nodeName );
ixml_membuf_append_str( buf, "=\"" );
copy_with_escape( buf, nodeValue );
ixml_membuf_append_str( buf, "\"" );
if( nodeptr->nextSibling != NULL ) {
ixml_membuf_append_str( buf, " " );
ixmlPrintDomTreeRecursive( nodeptr->nextSibling, buf );
}
break;
case eELEMENT_NODE:
ixml_membuf_append_str( buf, "<" );
ixml_membuf_append_str( buf, nodeName );
if( nodeptr->firstAttr != NULL ) {
ixml_membuf_append_str( buf, " " );
ixmlPrintDomTreeRecursive( nodeptr->firstAttr, buf );
}
child = ixmlNode_getFirstChild( nodeptr );
if( ( child != NULL )
&& ( ixmlNode_getNodeType( child ) ==
eELEMENT_NODE ) ) {
ixml_membuf_append_str( buf, ">\r\n" );
} else {
ixml_membuf_append_str( buf, ">" );
}
// output the children
ixmlPrintDomTreeRecursive( ixmlNode_getFirstChild
( nodeptr ), buf );
// Done with children. Output the end tag.
ixml_membuf_append_str( buf, "</" );
ixml_membuf_append_str( buf, nodeName );
sibling = ixmlNode_getNextSibling( nodeptr );
if( sibling != NULL
&& ixmlNode_getNodeType( sibling ) == eTEXT_NODE ) {
ixml_membuf_append_str( buf, ">" );
} else {
ixml_membuf_append_str( buf, ">\r\n" );
}
ixmlPrintDomTreeRecursive( ixmlNode_getNextSibling
( nodeptr ), buf );
break;
default:
break;
}
}
}
/*================================================================
* ixmlPrintDomTree
* Print a DOM tree.
* Element, and Attribute nodes are handled differently.
* We don't want to print the Element and Attribute nodes' sibling.
* External function.
*
*=================================================================*/
void
ixmlPrintDomTree( IN IXML_Node * nodeptr,
IN ixml_membuf * buf )
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL;
if( ( nodeptr == NULL ) || ( buf == NULL ) ) {
return;
}
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
nodeValue = ixmlNode_getNodeValue( nodeptr );
switch ( ixmlNode_getNodeType( nodeptr ) ) {
case eTEXT_NODE:
case eCDATA_SECTION_NODE:
case ePROCESSING_INSTRUCTION_NODE:
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive( nodeptr, buf );
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str( buf, nodeName );
ixml_membuf_append_str( buf, "=\"" );
copy_with_escape( buf, nodeValue );
ixml_membuf_append_str( buf, "\"" );
break;
case eELEMENT_NODE:
ixml_membuf_append_str( buf, "<" );
ixml_membuf_append_str( buf, nodeName );
if( nodeptr->firstAttr != NULL ) {
ixml_membuf_append_str( buf, " " );
ixmlPrintDomTreeRecursive( nodeptr->firstAttr, buf );
}
child = ixmlNode_getFirstChild( nodeptr );
if( ( child != NULL )
&& ( ixmlNode_getNodeType( child ) == eELEMENT_NODE ) ) {
ixml_membuf_append_str( buf, ">\r\n" );
} else {
ixml_membuf_append_str( buf, ">" );
}
// output the children
ixmlPrintDomTreeRecursive( ixmlNode_getFirstChild( nodeptr ),
buf );
// Done with children. Output the end tag.
ixml_membuf_append_str( buf, "</" );
ixml_membuf_append_str( buf, nodeName );
ixml_membuf_append_str( buf, ">\r\n" );
break;
default:
break;
}
}
/*================================================================
* ixmlDomTreetoString
* Converts a DOM tree into a text string
* Element, and Attribute nodes are handled differently.
* We don't want to print the Element and Attribute nodes' sibling.
* External function.
*
*=================================================================*/
void
ixmlDomTreetoString( IN IXML_Node * nodeptr,
IN ixml_membuf * buf )
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL;
if( ( nodeptr == NULL ) || ( buf == NULL ) ) {
return;
}
nodeName = ( const char * )ixmlNode_getNodeName( nodeptr );
nodeValue = ixmlNode_getNodeValue( nodeptr );
switch ( ixmlNode_getNodeType( nodeptr ) ) {
case eTEXT_NODE:
case eCDATA_SECTION_NODE:
case ePROCESSING_INSTRUCTION_NODE:
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive( nodeptr, buf );
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str( buf, nodeName );
ixml_membuf_append_str( buf, "=\"" );
copy_with_escape( buf, nodeValue );
ixml_membuf_append_str( buf, "\"" );
break;
case eELEMENT_NODE:
ixml_membuf_append_str( buf, "<" );
ixml_membuf_append_str( buf, nodeName );
if( nodeptr->firstAttr != NULL ) {
ixml_membuf_append_str( buf, " " );
ixmlPrintDomTreeRecursive( nodeptr->firstAttr, buf );
}
child = ixmlNode_getFirstChild( nodeptr );
if( ( child != NULL )
&& ( ixmlNode_getNodeType( child ) == eELEMENT_NODE ) ) {
ixml_membuf_append_str( buf, ">" );
} else {
ixml_membuf_append_str( buf, ">" );
}
// output the children
ixmlPrintDomTreeRecursive( ixmlNode_getFirstChild( nodeptr ),
buf );
// Done with children. Output the end tag.
ixml_membuf_append_str( buf, "</" );
ixml_membuf_append_str( buf, nodeName );
ixml_membuf_append_str( buf, ">" );
break;
default:
break;
}
}
/*================================================================
* ixmlLoadDocumentEx
* Parses the given file, and returns the DOM tree from it.
* External function.
*
*=================================================================*/
int
ixmlLoadDocumentEx( IN const char *xmlFile,
IXML_Document ** doc )
{
if( ( xmlFile == NULL ) || ( doc == NULL ) ) {
return IXML_INVALID_PARAMETER;
}
return Parser_LoadDocument( doc, xmlFile, TRUE );
}
/*================================================================
* ixmlLoadDocument
* Parses the given file, and returns the DOM tree from it.
* External function.
*
*=================================================================*/
IXML_Document *
ixmlLoadDocument( IN const char *xmlFile )
{
IXML_Document *doc = NULL;
ixmlLoadDocumentEx( xmlFile, &doc );
return doc;
}
/*================================================================
* ixmlPrintDocument
* Prints entire document, prepending XML prolog first.
* Puts lots of white spaces.
* External function.
*
*=================================================================*/
DOMString
ixmlPrintDocument(IXML_Document *doc)
{
IXML_Node* rootNode = ( IXML_Node * )doc;
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if( rootNode == NULL ) {
return NULL;
}
ixml_membuf_init( buf );
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );
ixmlPrintDomTree( rootNode, buf );
return buf->buf;
}
/*================================================================
* ixmlPrintNode
* Print DOM tree under node. Puts lots of white spaces
* External function.
*
*=================================================================*/
DOMString
ixmlPrintNode( IN IXML_Node * node )
{
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if( node == NULL ) {
return NULL;
}
ixml_membuf_init( buf );
ixmlPrintDomTree( node, buf );
return buf->buf;
}
/*================================================================
* ixmlDocumenttoString
* converts DOM tree under node to text string,
* prepending XML prolog first.
* External function.
*
*=================================================================*/
DOMString
ixmlDocumenttoString(IXML_Document *doc)
{
IXML_Node* rootNode = ( IXML_Node * )doc;
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if( rootNode == NULL ) {
return NULL;
}
ixml_membuf_init( buf );
ixml_membuf_append_str( buf, "<?xml version=\"1.0\"?>\r\n" );
ixmlDomTreetoString( rootNode, buf );
return buf->buf;
}
/*================================================================
* ixmlNodetoString
* converts DOM tree under node to text string
* External function.
*
*=================================================================*/
DOMString
ixmlNodetoString( IN IXML_Node * node )
{
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if( node == NULL ) {
return NULL;
}
ixml_membuf_init( buf );
ixmlDomTreetoString( node, buf );
return buf->buf;
}
/*================================================================
* ixmlRelaxParser
* Makes the XML parser more tolerant to malformed text.
* External function.
*
*=================================================================*/
void
ixmlRelaxParser(char errorChar)
{
Parser_setErrorChar( errorChar );
int i;
int plen;
if (p == NULL) {
return;
}
plen = strlen( p );
for (i = 0; i < plen; i++) {
switch (p[i]) {
case '<':
ixml_membuf_append_str(buf, "&lt;");
break;
case '>':
ixml_membuf_append_str(buf, "&gt;");
break;
case '&':
ixml_membuf_append_str(buf, "&amp;");
break;
case '\'':
ixml_membuf_append_str(buf, "&apos;");
break;
case '\"':
ixml_membuf_append_str(buf, "&quot;");
break;
default:
ixml_membuf_append(buf, &p[i]);
break;
}
}
}
/*================================================================
* ixmlParseBufferEx
* Parse xml file stored in buffer.
* External function.
*
*=================================================================*/
int
ixmlParseBufferEx( IN const char *buffer,
IXML_Document ** retDoc )
/*!
* \brief Recursive function to print all the node in a tree.
* Internal to parser only.
*/
static void ixmlPrintDomTreeRecursive(
/*! [in] \todo documentation. */
IXML_Node *nodeptr,
/*! [in] \todo documentation. */
ixml_membuf *buf)
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL,
*sibling = NULL;
if( ( buffer == NULL ) || ( retDoc == NULL ) ) {
return IXML_INVALID_PARAMETER;
}
if (nodeptr != NULL) {
nodeName = (const char *)ixmlNode_getNodeName(nodeptr);
nodeValue = ixmlNode_getNodeValue(nodeptr);
switch (ixmlNode_getNodeType(nodeptr)) {
case eTEXT_NODE:
copy_with_escape(buf, nodeValue);
break;
if( buffer[0] == '\0' ) {
return IXML_INVALID_PARAMETER;
}
case eCDATA_SECTION_NODE:
ixml_membuf_append_str(buf, "<![CDATA[");
ixml_membuf_append_str(buf, nodeValue);
ixml_membuf_append_str(buf, "]]>");
break;
return Parser_LoadDocument( retDoc, buffer, FALSE );
case ePROCESSING_INSTRUCTION_NODE:
ixml_membuf_append_str(buf, "<?");
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, " ");
copy_with_escape(buf, nodeValue);
ixml_membuf_append_str(buf, "?>\n");
break;
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive(
ixmlNode_getFirstChild(nodeptr), buf);
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, "=\"");
copy_with_escape(buf, nodeValue);
ixml_membuf_append_str(buf, "\"");
if (nodeptr->nextSibling != NULL) {
ixml_membuf_append_str(buf, " ");
ixmlPrintDomTreeRecursive(nodeptr->nextSibling, buf);
}
break;
case eELEMENT_NODE:
ixml_membuf_append_str(buf, "<");
ixml_membuf_append_str(buf, nodeName);
if (nodeptr->firstAttr != NULL) {
ixml_membuf_append_str(buf, " ");
ixmlPrintDomTreeRecursive(nodeptr->firstAttr, buf);
}
child = ixmlNode_getFirstChild(nodeptr);
if (child != NULL &&
ixmlNode_getNodeType(child) == eELEMENT_NODE) {
ixml_membuf_append_str(buf, ">\r\n");
} else {
ixml_membuf_append_str(buf, ">");
}
// output the children
ixmlPrintDomTreeRecursive(
ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag.
ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName);
sibling = ixmlNode_getNextSibling(nodeptr);
if (sibling != NULL &&
ixmlNode_getNodeType(sibling) == eTEXT_NODE) {
ixml_membuf_append_str( buf, ">" );
} else {
ixml_membuf_append_str( buf, ">\r\n" );
}
ixmlPrintDomTreeRecursive(
ixmlNode_getNextSibling(nodeptr), buf);
break;
default:
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
ixmlNode_getNodeType(nodeptr));
break;
}
}
}
/*================================================================
* ixmlParseBuffer
* Parse xml file stored in buffer.
* External function.
*
*=================================================================*/
IXML_Document *
ixmlParseBuffer( IN const char *buffer )
{
IXML_Document *doc = NULL;
ixmlParseBufferEx( buffer, &doc );
return doc;
/*!
* \brief Print a DOM tree.
*
* Element, and Attribute nodes are handled differently. We don't want to print
* the Element and Attribute nodes' sibling.
*/
static void ixmlPrintDomTree(
/*! [in] \todo documentation. */
IXML_Node *nodeptr,
/*! [in] \todo documentation. */
ixml_membuf *buf)
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL;
if (nodeptr == NULL || buf == NULL) {
return;
}
nodeName = (const char *)ixmlNode_getNodeName(nodeptr);
nodeValue = ixmlNode_getNodeValue(nodeptr);
switch (ixmlNode_getNodeType(nodeptr)) {
case eTEXT_NODE:
case eCDATA_SECTION_NODE:
case ePROCESSING_INSTRUCTION_NODE:
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive(nodeptr, buf);
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, "=\"");
copy_with_escape(buf, nodeValue);
ixml_membuf_append_str(buf, "\"");
break;
case eELEMENT_NODE:
ixml_membuf_append_str(buf, "<");
ixml_membuf_append_str(buf, nodeName);
if (nodeptr->firstAttr != NULL) {
ixml_membuf_append_str(buf, " ");
ixmlPrintDomTreeRecursive(nodeptr->firstAttr, buf);
}
child = ixmlNode_getFirstChild(nodeptr);
if (child != NULL &&
ixmlNode_getNodeType(child) == eELEMENT_NODE) {
ixml_membuf_append_str(buf, ">\r\n");
} else {
ixml_membuf_append_str(buf, ">");
}
// output the children
ixmlPrintDomTreeRecursive(
ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag.
ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, ">\r\n");
break;
default:
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTree",
"Warning, unknown node type %d\n",
ixmlNode_getNodeType(nodeptr));
break;
}
}
/*================================================================
* ixmlCloneDOMString
* Clones a DOM String.
* External function.
*
*=================================================================*/
DOMString
ixmlCloneDOMString( IN const DOMString src )
{
if( src == NULL ) {
return NULL;
}
return ( strdup( src ) );
/*!
* \brief Converts a DOM tree into a text string.
*
* Element, and Attribute nodes are handled differently. We don't want to print
* the Element and Attribute nodes' sibling.
*/
static void ixmlDomTreetoString(
/*! [in] \todo documentation. */
IXML_Node *nodeptr,
/*! [in] \todo documentation. */
ixml_membuf *buf)
{
const char *nodeName = NULL;
const char *nodeValue = NULL;
IXML_Node *child = NULL;
if (nodeptr == NULL || buf == NULL) {
return;
}
nodeName = (const char *)ixmlNode_getNodeName(nodeptr);
nodeValue = ixmlNode_getNodeValue(nodeptr);
switch (ixmlNode_getNodeType(nodeptr)) {
case eTEXT_NODE:
case eCDATA_SECTION_NODE:
case ePROCESSING_INSTRUCTION_NODE:
case eDOCUMENT_NODE:
ixmlPrintDomTreeRecursive(nodeptr, buf);
break;
case eATTRIBUTE_NODE:
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, "=\"");
copy_with_escape(buf, nodeValue );
ixml_membuf_append_str(buf, "\"");
break;
case eELEMENT_NODE:
ixml_membuf_append_str(buf, "<");
ixml_membuf_append_str(buf, nodeName);
if (nodeptr->firstAttr != NULL) {
ixml_membuf_append_str(buf, " ");
ixmlPrintDomTreeRecursive(nodeptr->firstAttr, buf);
}
child = ixmlNode_getFirstChild(nodeptr);
if (child != NULL &&
ixmlNode_getNodeType(child) == eELEMENT_NODE) {
ixml_membuf_append_str(buf, ">");
} else {
ixml_membuf_append_str(buf, ">");
}
// output the children
ixmlPrintDomTreeRecursive(ixmlNode_getFirstChild(nodeptr), buf);
// Done with children. Output the end tag.
ixml_membuf_append_str(buf, "</");
ixml_membuf_append_str(buf, nodeName);
ixml_membuf_append_str(buf, ">");
break;
default:
IxmlPrintf(__FILE__, __LINE__, "ixmlPrintDomTreeRecursive",
"Warning, unknown node type %d\n",
ixmlNode_getNodeType(nodeptr));
break;
}
}
/*================================================================
* ixmlFreeDOMString
* Frees a DOM String.
* External function.
*
*=================================================================*/
void
ixmlFreeDOMString( IN DOMString buf )
int ixmlLoadDocumentEx(const char *xmlFile, IXML_Document **doc)
{
if( buf != NULL ) {
free( buf );
}
if (xmlFile == NULL || doc == NULL) {
return IXML_INVALID_PARAMETER;
}
return Parser_LoadDocument(doc, xmlFile, TRUE);
}
IXML_Document *ixmlLoadDocument(const char *xmlFile)
{
IXML_Document *doc = NULL;
ixmlLoadDocumentEx(xmlFile, &doc);
return doc;
}
DOMString ixmlPrintDocument(IXML_Document *doc)
{
IXML_Node* rootNode = (IXML_Node *)doc;
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if(rootNode == NULL) {
return NULL;
}
ixml_membuf_init(buf);
ixml_membuf_append_str(buf, "<?xml version=\"1.0\"?>\r\n");
ixmlPrintDomTree(rootNode, buf);
return buf->buf;
}
DOMString ixmlPrintNode(IXML_Node *node)
{
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if (node == NULL) {
return NULL;
}
ixml_membuf_init(buf);
ixmlPrintDomTree(node, buf);
return buf->buf;
}
DOMString ixmlDocumenttoString(IXML_Document *doc)
{
IXML_Node* rootNode = (IXML_Node *)doc;
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if(rootNode == NULL) {
return NULL;
}
ixml_membuf_init(buf);
ixml_membuf_append_str(buf, "<?xml version=\"1.0\"?>\r\n");
ixmlDomTreetoString(rootNode, buf);
return buf->buf;
}
DOMString ixmlNodetoString(IXML_Node *node)
{
ixml_membuf memBuf;
ixml_membuf *buf = &memBuf;
if (node == NULL) {
return NULL;
}
ixml_membuf_init(buf);
ixmlDomTreetoString(node, buf);
return buf->buf;
}
void ixmlRelaxParser(char errorChar)
{
Parser_setErrorChar(errorChar);
}
int ixmlParseBufferEx(const char *buffer, IXML_Document **retDoc)
{
if (buffer == NULL || retDoc == NULL) {
return IXML_INVALID_PARAMETER;
}
if (buffer[0] == '\0') {
return IXML_INVALID_PARAMETER;
}
return Parser_LoadDocument(retDoc, buffer, FALSE);
}
IXML_Document *ixmlParseBuffer(const char *buffer)
{
IXML_Document *doc = NULL;
ixmlParseBufferEx(buffer, &doc);
return doc;
}
DOMString ixmlCloneDOMString(const DOMString src)
{
if (src == NULL) {
return NULL;
}
return strdup(src);
}
void ixmlFreeDOMString(DOMString buf)
{
if (buf != NULL) {
free(buf);
}
}

70
ixml/src/ixmldebug.c Normal file
View File

@ -0,0 +1,70 @@
/*!
* \file
*/
#include "autoconfig.h"
#include "ixmldebug.h"
#include <stdarg.h>
#include <stdio.h>
#ifdef DEBUG
void IxmlPrintf(
const char *DbgFileName,
int DbgLineNo,
const char *FunctionName,
const char *FmtStr,
...)
{
va_list ArgList;
FILE *fp = stdout;
fprintf(fp, "(%s::%s), line %d", DbgFileName, FunctionName, DbgLineNo);
if (FmtStr) {
fprintf(fp, ": ");
va_start(ArgList, FmtStr);
vfprintf(fp, FmtStr, ArgList);
fflush(fp);
va_end(ArgList);
} else {
fprintf(fp, "\n");
}
}
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
IXML_Node *ChildNode1;
unsigned short NodeType;
const DOMString NodeValue;
const DOMString NodeName;
NodeList1 = ixmlNode_getChildNodes(tmpRoot);
for (i = 0; i < 100; ++i) {
ChildNode1 = ixmlNodeList_item(NodeList1, i);
if (ChildNode1 == NULL) {
break;
}
printNodes(ChildNode1, depth+1);
NodeType = ixmlNode_getNodeType(ChildNode1);
NodeValue = ixmlNode_getNodeValue(ChildNode1);
NodeName = ixmlNode_getNodeName(ChildNode1);
IxmlPrintf(__FILE__, __LINE__, "printNodes",
"DEPTH-%2d-IXML_Node Type %d, "
"IXML_Node Name: %s, IXML_Node Value: %s\n",
depth, NodeType, NodeName, NodeValue);
}
}
#endif

View File

@ -1,236 +1,218 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
**************************************************************************/
/*!
* \file
*/
#include "ixmlmembuf.h"
#include "ixml.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "ixmlmembuf.h"
#include "ixml.h"
/*================================================================
* ixml_membuf_set_size
*
* Increases or decreases buffer cap so that at least
* 'new_length' bytes can be stored
*
* On error, m's fields do not change.
*
* returns:
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
*
*=================================================================*/
static int
ixml_membuf_set_size( INOUT ixml_membuf * m,
IN size_t new_length )
/*!
* \brief Increases or decreases buffer capacity so that at least 'new_length'
* bytes can be stored.
*
* On error, m's fields do not change.
*
* \return
* \li UPNP_E_SUCCESS
* \li UPNP_E_OUTOF_MEMORY
*/
static int ixml_membuf_set_size(
/*! [in,out] The memory buffer. */
INOUT ixml_membuf *m,
/*! [in] The new lenght. */
IN size_t new_length)
{
size_t diff;
size_t alloc_len;
char *temp_buf;
size_t diff;
size_t alloc_len;
char *temp_buf;
if( new_length >= m->length ) // increase length
{
// need more mem?
if( new_length <= m->capacity ) {
return 0; // have enough mem; done
}
if (new_length >= m->length) {
/* increase length */
/* need more mem? */
if (new_length <= m->capacity) {
/* have enough mem; done */
return 0;
}
diff = new_length - m->length;
alloc_len = MAXVAL( m->size_inc, diff ) + m->capacity;
} else // decrease length
{
assert( new_length <= m->length );
diff = new_length - m->length;
alloc_len = MAXVAL(m->size_inc, diff) + m->capacity;
} else {
// decrease length
assert(new_length <= m->length);
// if diff is 0..m->size_inc, don't free
if( ( m->capacity - new_length ) <= m->size_inc ) {
return 0;
}
// if diff is 0..m->size_inc, don't free
if ((m->capacity - new_length) <= m->size_inc) {
return 0;
}
alloc_len = new_length + m->size_inc;
}
alloc_len = new_length + m->size_inc;
}
assert(alloc_len >= new_length);
assert( alloc_len >= new_length );
temp_buf = realloc(m->buf, alloc_len + 1);
if (temp_buf == NULL) {
/* try smaller size */
alloc_len = new_length;
temp_buf = realloc(m->buf, alloc_len + 1);
if (temp_buf == NULL) {
return IXML_INSUFFICIENT_MEMORY;
}
}
/* save */
m->buf = temp_buf;
m->capacity = alloc_len;
temp_buf = realloc( m->buf, alloc_len + 1 );
if( temp_buf == NULL ) {
// try smaller size
alloc_len = new_length;
temp_buf = realloc( m->buf, alloc_len + 1 );
if( temp_buf == NULL ) {
return IXML_INSUFFICIENT_MEMORY;
}
}
// save
m->buf = temp_buf;
m->capacity = alloc_len;
return 0;
return 0;
}
/*================================================================
* membuffer_init
*
*
*=================================================================*/
void
ixml_membuf_init( INOUT ixml_membuf * m )
{
assert( m != NULL );
m->size_inc = MEMBUF_DEF_SIZE_INC;
m->buf = NULL;
m->length = 0;
m->capacity = 0;
void ixml_membuf_init(ixml_membuf *m)
{
assert(m != NULL);
m->size_inc = MEMBUF_DEF_SIZE_INC;
m->buf = NULL;
m->length = 0;
m->capacity = 0;
}
/*================================================================
* membuffer_destroy
*
*
*=================================================================*/
void
ixml_membuf_destroy( INOUT ixml_membuf * m )
{
if( m == NULL ) {
return;
}
free( m->buf );
ixml_membuf_init( m );
void ixml_membuf_destroy(ixml_membuf *m)
{
if (m == NULL) {
return;
}
free(m->buf);
ixml_membuf_init(m);
}
/*================================================================
* ixml_membuf_assign
*
*
*=================================================================*/
int
ixml_membuf_assign( INOUT ixml_membuf * m,
IN const void *buf,
IN size_t buf_len )
int ixml_membuf_assign(
ixml_membuf *m,
const void *buf,
size_t buf_len)
{
int return_code;
int return_code;
assert( m != NULL );
assert(m != NULL);
// set value to null
if( buf == NULL ) {
ixml_membuf_destroy( m );
return IXML_SUCCESS;
}
// alloc mem
return_code = ixml_membuf_set_size( m, buf_len );
if( return_code != 0 ) {
return return_code;
}
// copy
memcpy( m->buf, buf, buf_len );
m->buf[buf_len] = 0; // null-terminate
// set value to null
if (buf == NULL) {
ixml_membuf_destroy(m);
return IXML_SUCCESS;
}
// alloc mem
return_code = ixml_membuf_set_size(m, buf_len);
if (return_code != 0) {
return return_code;
}
m->length = buf_len;
// copy
memcpy(m->buf, buf, buf_len);
return IXML_SUCCESS;
// null-terminate
m->buf[buf_len] = 0;
m->length = buf_len;
return IXML_SUCCESS;
}
/*================================================================
* ixml_membuf_assign_str
*
*
*=================================================================*/
int
ixml_membuf_assign_str( INOUT ixml_membuf * m,
IN const char *c_str )
int ixml_membuf_assign_str(
ixml_membuf *m,
const char *c_str)
{
return ixml_membuf_assign( m, c_str, strlen( c_str ) );
return ixml_membuf_assign(m, c_str, strlen(c_str));
}
/*================================================================
* ixml_membuf_append
*
*
*=================================================================*/
int
ixml_membuf_append( INOUT ixml_membuf * m,
IN const void *buf )
{
assert( m != NULL );
return ixml_membuf_insert( m, buf, 1, m->length );
int ixml_membuf_append(
INOUT ixml_membuf *m,
IN const void *buf)
{
assert(m != NULL);
return ixml_membuf_insert(m, buf, 1, m->length);
}
/*================================================================
* ixml_membuf_append_str
*
*
*=================================================================*/
int
ixml_membuf_append_str( INOUT ixml_membuf * m,
IN const char *c_str )
int ixml_membuf_append_str(
INOUT ixml_membuf *m,
IN const char *c_str)
{
return ixml_membuf_insert( m, c_str, strlen( c_str ), m->length );
return ixml_membuf_insert(m, c_str, strlen(c_str), m->length);
}
/*================================================================
* ixml_membuf_insert
*
*
*=================================================================*/
int
ixml_membuf_insert( INOUT ixml_membuf * m,
IN const void *buf,
IN size_t buf_len,
int index )
int ixml_membuf_insert(
INOUT ixml_membuf *m,
IN const void *buf,
IN size_t buf_len,
int index)
{
int return_code;
int return_code = 0;
assert( m != NULL );
assert(m != NULL);
if( index < 0 || index > ( int )m->length )
return IXML_INDEX_SIZE_ERR;
if (index < 0 || index > (int)m->length) {
return IXML_INDEX_SIZE_ERR;
}
if( buf == NULL || buf_len == 0 ) {
return 0;
}
// alloc mem
return_code = ixml_membuf_set_size( m, m->length + buf_len );
if( return_code != 0 ) {
return return_code;
}
// insert data
// move data to right of insertion point
memmove( m->buf + index + buf_len, m->buf + index, m->length - index );
memcpy( m->buf + index, buf, buf_len );
m->length += buf_len;
m->buf[m->length] = 0; // null-terminate
if (buf == NULL || buf_len == 0) {
return 0;
}
/* alloc mem */
return_code = ixml_membuf_set_size(m, m->length + buf_len);
if (return_code != 0) {
return return_code;
}
/* insert data */
/* move data to right of insertion point */
memmove(m->buf + index + buf_len, m->buf + index, m->length - index);
memcpy(m->buf + index, buf, buf_len);
m->length += buf_len;
/* Null terminate */
m->buf[m->length] = 0;
return 0;
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,242 +1,195 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
**************************************************************************/
/*!
* \file
*/
#include "ixmlparser.h"
/*================================================================
* NamedNodeMap_getItemNumber
* return the item number of a item in NamedNodeMap.
* Internal to parser only.
* Parameters:
* name: the name of the item to find
*
*=================================================================*/
unsigned long
ixmlNamedNodeMap_getItemNumber( IN IXML_NamedNodeMap * nnMap,
IN const char *name )
#include <assert.h>
#include <stdlib.h> /* for free(), malloc() */
#include <string.h>
/*!
* \brief Return the item number of a item in NamedNodeMap.
*/
static unsigned long ixmlNamedNodeMap_getItemNumber(
/*! [in] The named node map to process. */
IN IXML_NamedNodeMap *nnMap,
/*! [in] The name of the item to find. */
IN const char *name)
{
IXML_Node *tempNode;
unsigned long returnItemNo = 0;
IXML_Node *tempNode;
unsigned long returnItemNo = 0;
assert( nnMap != NULL && name != NULL );
if( ( nnMap == NULL ) || ( name == NULL ) ) {
return IXML_INVALID_ITEM_NUMBER;
}
assert(nnMap != NULL && name != NULL);
if (nnMap == NULL || name == NULL) {
return IXML_INVALID_ITEM_NUMBER;
}
tempNode = nnMap->nodeItem;
while( tempNode != NULL ) {
if( strcmp( name, tempNode->nodeName ) == 0 ) {
return returnItemNo;
}
tempNode = nnMap->nodeItem;
while (tempNode != NULL) {
if (strcmp(name, tempNode->nodeName) == 0) {
return returnItemNo;
}
tempNode = tempNode->nextSibling;
returnItemNo++;
}
tempNode = tempNode->nextSibling;
returnItemNo++;
}
return IXML_INVALID_ITEM_NUMBER;
return IXML_INVALID_ITEM_NUMBER;
}
/*================================================================
* NamedNodeMap_init
* Initializes a NamedNodeMap object.
* External function.
*
*=================================================================*/
void
ixmlNamedNodeMap_init( IN IXML_NamedNodeMap * nnMap )
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
{
assert( nnMap != NULL );
memset( nnMap, 0, sizeof( IXML_NamedNodeMap ) );
assert(nnMap != NULL);
memset(nnMap, 0, sizeof (IXML_NamedNodeMap));
}
/*================================================================
* NamedNodeMap_getNamedItem
* Retrieves a node specified by name.
* External function.
*
* Parameter:
* name: type nodeName of a node to retrieve.
*
* Return Value:
* A Node with the specified nodeName, or null if it
* does not identify any node in this map.
*
*=================================================================*/
IXML_Node *
ixmlNamedNodeMap_getNamedItem( IN IXML_NamedNodeMap * nnMap,
IN const char *name )
IXML_Node *ixmlNamedNodeMap_getNamedItem(
IXML_NamedNodeMap *nnMap,
const DOMString name)
{
long index;
long index;
if( ( nnMap == NULL ) || ( name == NULL ) ) {
return NULL;
}
if (nnMap == NULL || name == NULL) {
return NULL;
}
index = ixmlNamedNodeMap_getItemNumber( nnMap, name );
if( index == IXML_INVALID_ITEM_NUMBER ) {
return NULL;
} else {
return ( ixmlNamedNodeMap_item( nnMap, ( unsigned long )index ) );
}
index = ixmlNamedNodeMap_getItemNumber(nnMap, name);
if (index == IXML_INVALID_ITEM_NUMBER) {
return NULL;
} else {
return ixmlNamedNodeMap_item(nnMap, (unsigned long)index);
}
}
/*================================================================
* NamedNodeMap_item
* Returns the indexth item in the map. If index is greater than or
* equal to the number of nodes in this map, this returns null.
* External function.
*
* Parameter:
* index: index into this map.
*
* Return Value:
* The node at the indexth position in the map, or null if that is
* not a valid index.
*
*=================================================================*/
IXML_Node *
ixmlNamedNodeMap_item( IN IXML_NamedNodeMap * nnMap,
IN unsigned long index )
IXML_Node *ixmlNamedNodeMap_item(
IN IXML_NamedNodeMap *nnMap,
IN unsigned long index )
{
IXML_Node *tempNode;
unsigned int i;
IXML_Node *tempNode;
unsigned int i;
if( nnMap == NULL ) {
return NULL;
}
if (nnMap == NULL) {
return NULL;
}
if( index > ixmlNamedNodeMap_getLength( nnMap ) - 1 ) {
return NULL;
}
if (index > ixmlNamedNodeMap_getLength(nnMap) - 1) {
return NULL;
}
tempNode = nnMap->nodeItem;
for( i = 0; i < index && tempNode != NULL; ++i ) {
tempNode = tempNode->nextSibling;
}
tempNode = nnMap->nodeItem;
for (i = 0; i < index && tempNode != NULL; ++i) {
tempNode = tempNode->nextSibling;
}
return tempNode;
return tempNode;
}
/*================================================================
* NamedNodeMap_getLength
* Return the number of Nodes in this map.
* External function.
*
* Parameters:
*
*=================================================================*/
unsigned long
ixmlNamedNodeMap_getLength( IN IXML_NamedNodeMap * nnMap )
{
IXML_Node *tempNode;
unsigned long length = 0;
if( nnMap != NULL ) {
tempNode = nnMap->nodeItem;
for( length = 0; tempNode != NULL; ++length ) {
tempNode = tempNode->nextSibling;
}
}
return length;
unsigned long ixmlNamedNodeMap_getLength(IXML_NamedNodeMap *nnMap)
{
IXML_Node *tempNode;
unsigned long length = 0;
if (nnMap != NULL) {
tempNode = nnMap->nodeItem;
for (length = 0; tempNode != NULL; ++length) {
tempNode = tempNode->nextSibling;
}
}
return length;
}
/*================================================================
* ixmlNamedNodeMap_free
* frees a NamedNodeMap.
* External function.
*
*=================================================================*/
void
ixmlNamedNodeMap_free( IXML_NamedNodeMap * nnMap )
{
IXML_NamedNodeMap *pNext;
while( nnMap != NULL ) {
pNext = nnMap->next;
free( nnMap );
nnMap = pNext;
}
void ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap)
{
IXML_NamedNodeMap *pNext;
while (nnMap != NULL) {
pNext = nnMap->next;
free(nnMap);
nnMap = pNext;
}
}
/*================================================================
* NamedNodeMap_addToNamedNodeMap
* add a node to a NamedNodeMap.
* Internal to parser only.
* Parameters:
* add: the node to add into NamedNodeMap.
* Return:
* IXML_SUCCESS or failure.
*
*=================================================================*/
int
ixmlNamedNodeMap_addToNamedNodeMap( IN IXML_NamedNodeMap ** nnMap,
IN IXML_Node * add )
int ixmlNamedNodeMap_addToNamedNodeMap(
IXML_NamedNodeMap **nnMap,
IXML_Node *add)
{
IXML_NamedNodeMap *traverse = NULL,
*p = NULL;
IXML_NamedNodeMap *newItem = NULL;
IXML_NamedNodeMap *traverse = NULL;
IXML_NamedNodeMap *p = NULL;
IXML_NamedNodeMap *newItem = NULL;
if( add == NULL ) {
return IXML_SUCCESS;
}
if(add == NULL) {
return IXML_SUCCESS;
}
if( *nnMap == NULL ) // nodelist is empty
{
*nnMap =
( IXML_NamedNodeMap * ) malloc( sizeof( IXML_NamedNodeMap ) );
if( *nnMap == NULL ) {
return IXML_INSUFFICIENT_MEMORY;
}
ixmlNamedNodeMap_init( *nnMap );
}
if (*nnMap == NULL) {
// nodelist is empty
*nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
if (*nnMap == NULL) {
return IXML_INSUFFICIENT_MEMORY;
}
ixmlNamedNodeMap_init(*nnMap);
}
if ((*nnMap)->nodeItem == NULL) {
(*nnMap)->nodeItem = add;
} else {
traverse = *nnMap;
p = traverse;
while (traverse != NULL) {
p = traverse;
traverse = traverse->next;
}
newItem = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
if (newItem == NULL) {
return IXML_INSUFFICIENT_MEMORY;
}
p->next = newItem;
newItem->nodeItem = add;
newItem->next = NULL;
}
if( ( *nnMap )->nodeItem == NULL ) {
( *nnMap )->nodeItem = add;
} else {
traverse = *nnMap;
p = traverse;
while( traverse != NULL ) {
p = traverse;
traverse = traverse->next;
}
newItem =
( IXML_NamedNodeMap * ) malloc( sizeof( IXML_NamedNodeMap ) );
if( newItem == NULL ) {
return IXML_INSUFFICIENT_MEMORY;
}
p->next = newItem;
newItem->nodeItem = add;
newItem->next = NULL;
}
return IXML_SUCCESS;
return IXML_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,176 +1,152 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/*!
* \file
*/
#include "ixmlparser.h"
/*================================================================
* ixmlNodeList_init
* initializes a nodelist
* External function.
*
*=================================================================*/
void
ixmlNodeList_init( IXML_NodeList * nList )
#include <assert.h>
#include <string.h>
void ixmlNodeList_init(IXML_NodeList *nList)
{
assert( nList != NULL );
memset( nList, 0, sizeof( IXML_NodeList ) );
assert(nList != NULL);
memset(nList, 0, sizeof (IXML_NodeList));
}
/*================================================================
* ixmlNodeList_item
* Returns the indexth item in the collection. If index is greater
* than or equal to the number of nodes in the list, this returns
* null.
* External function.
*
*=================================================================*/
IXML_Node *
ixmlNodeList_item( IXML_NodeList * nList,
unsigned long index )
IXML_Node *ixmlNodeList_item(
IXML_NodeList *nList,
unsigned long index)
{
IXML_NodeList *next;
unsigned int i;
IXML_NodeList *next;
unsigned int i;
// if the list ptr is NULL
if( nList == NULL ) {
return NULL;
}
// if index is more than list length
if( index > ixmlNodeList_length( nList ) - 1 ) {
return NULL;
}
// if the list ptr is NULL
if (nList == NULL) {
return NULL;
}
// if index is more than list length
if (index > ixmlNodeList_length(nList) - 1) {
return NULL;
}
next = nList;
for( i = 0; i < index && next != NULL; ++i ) {
next = next->next;
}
next = nList;
for (i = 0; i < index && next != NULL; ++i) {
next = next->next;
}
if( next == NULL ) return NULL;
return next->nodeItem;
if (next == NULL) {
return NULL;
}
return next->nodeItem;
}
/*================================================================
* ixmlNodeList_addToNodeList
* Add a node to nodelist
* Internal to parser only.
*
*=================================================================*/
int
ixmlNodeList_addToNodeList( IN IXML_NodeList ** nList,
IN IXML_Node * add )
int ixmlNodeList_addToNodeList(
IXML_NodeList **nList,
IXML_Node *add)
{
IXML_NodeList *traverse,
*p = NULL;
IXML_NodeList *newListItem;
IXML_NodeList *traverse = NULL;
IXML_NodeList *p = NULL;
IXML_NodeList *newListItem;
assert( add != NULL );
assert(add != NULL);
if( add == NULL ) {
return IXML_FAILED;
}
if (add == NULL) {
return IXML_FAILED;
}
if( *nList == NULL ) // nodelist is empty
{
*nList = ( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
if( *nList == NULL ) {
return IXML_INSUFFICIENT_MEMORY;
}
if (*nList == NULL) {
// nodelist is empty
*nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
if (*nList == NULL) {
return IXML_INSUFFICIENT_MEMORY;
}
ixmlNodeList_init( *nList );
}
ixmlNodeList_init(*nList);
}
if( ( *nList )->nodeItem == NULL ) {
( *nList )->nodeItem = add;
} else {
traverse = *nList;
while( traverse != NULL ) {
p = traverse;
traverse = traverse->next;
}
if ((*nList)->nodeItem == NULL) {
(*nList)->nodeItem = add;
} else {
traverse = *nList;
while (traverse != NULL) {
p = traverse;
traverse = traverse->next;
}
newListItem =
( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
if( newListItem == NULL ) {
return IXML_INSUFFICIENT_MEMORY;
}
p->next = newListItem;
newListItem->nodeItem = add;
newListItem->next = NULL;
}
newListItem = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
if (newListItem == NULL) {
return IXML_INSUFFICIENT_MEMORY;
}
p->next = newListItem;
newListItem->nodeItem = add;
newListItem->next = NULL;
}
return IXML_SUCCESS;
return IXML_SUCCESS;
}
/*================================================================
* ixmlNodeList_length
* Returns the number of nodes in the list. The range of valid
* child node indices is 0 to length-1 inclusive.
* External function.
*
*=================================================================*/
unsigned long
ixmlNodeList_length( IN IXML_NodeList * nList )
unsigned long ixmlNodeList_length(IXML_NodeList *nList)
{
IXML_NodeList *list;
unsigned long length = 0;
IXML_NodeList *list;
unsigned long length = 0;
list = nList;
while( list != NULL ) {
++length;
list = list->next;
}
list = nList;
while (list != NULL) {
++length;
list = list->next;
}
return length;
return length;
}
/*================================================================
* ixmlNodeList_free
* frees a nodeList
* External function
*
*=================================================================*/
void
ixmlNodeList_free( IN IXML_NodeList * nList )
void ixmlNodeList_free(IXML_NodeList *nList)
{
IXML_NodeList *next;
while( nList != NULL ) {
next = nList->next;
free( nList );
nList = next;
}
IXML_NodeList *next;
while (nList != NULL) {
next = nList->next;
free(nList);
nList = next;
}
}

0
ixml/test/test_document.sh Normal file → Executable file
View File

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: libupnp
Description: Linux SDK for UPnP Devices
Version: @VERSION@
Libs: @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml
Libs: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml
Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp

View File

@ -1,4 +1,4 @@
Version: 1.4.2
Version: 1.6.8
Summary: Universal Plug and Play (UPnP) SDK
Name: libupnp
Release: 1%{?dist}
@ -77,6 +77,12 @@ make install DESTDIR=$RPM_BUILD_ROOT
rm -rf %{buildroot}
%changelog
* Mon Nov 19 2007 Marcelo Jimenez <mroberto@users.sourceforge.net> - 1.6.2-1
- Update to version 1.6.2
* 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

View File

@ -41,7 +41,7 @@ AC_DEFUN([RT_BOOL_ARG_ENABLE],[
)])
test "x$enable_[$1]" != [x]m4_if([$2],[yes],[no],[yes]) dnl
&& enable_[]Name=[$2]
AC_MSG_RESULT($enable_[]Name)dnl
AC_MSG_RESULT($enable_[]Name)
AM_CONDITIONAL([ENABLE_]NAME, test x"$enable_[]Name" = xyes)
dnl
m4_popdef([NAME])dnl

View File

@ -6,7 +6,6 @@
#
AM_CPPFLAGS = -I$(srcdir)/inc -I$(srcdir)/src/inc
AM_CFLAGS = $(PTHREAD_CFLAGS)
if ENABLE_DEBUG
AM_CPPFLAGS += -DDEBUG -DSTATS
@ -21,12 +20,11 @@ libthreadutil_la_LDFLAGS = -version-info $(LT_VERSION_THREADUTIL)
libthreadutil_la_SOURCES = \
src/FreeList.c src/LinkedList.c \
src/ThreadPool.c src/TimerThread.c \
src/iasnprintf.c
src/ThreadPool.c src/TimerThread.c
upnpincludedir = $(includedir)/upnp
upnpinclude_HEADERS = \
inc/FreeList.h inc/LinkedList.h \
inc/ThreadPool.h inc/TimerThread.h \
inc/iasnprintf.h inc/ithread.h
inc/ithread.h

View File

@ -29,14 +29,24 @@
*
******************************************************************************/
#ifndef FREE_LIST_H
#define FREE_LIST_H
/*!
* \file
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "ithread.h"
#include <errno.h>
/****************************************************************************

View File

@ -29,21 +29,32 @@
*
******************************************************************************/
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
/*!
* \file
*/
#include "FreeList.h"
#ifdef __cplusplus
extern "C" {
#endif
#define EOUTOFMEM (-7 & 1<<29)
#define FREELISTSIZE 100
#define LIST_SUCCESS 1
#define LIST_FAIL 0
/****************************************************************************
* Name: free_routine
*
@ -52,6 +63,7 @@ extern "C" {
*****************************************************************************/
typedef void (*free_function)(void *arg);
/****************************************************************************
* Name: cmp_routine
*
@ -61,6 +73,7 @@ typedef void (*free_function)(void *arg);
*****************************************************************************/
typedef int (*cmp_routine)(void *itemA,void *itemB);
/****************************************************************************
* Name: ListNode
*
@ -75,6 +88,7 @@ typedef struct LISTNODE
void *item;
} ListNode;
/****************************************************************************
* Name: LinkedList
*
@ -104,6 +118,7 @@ typedef struct LINKEDLIST
cmp_routine cmp_func; /* compare function to use */
} LinkedList;
/****************************************************************************
* Function: ListInit
*
@ -119,6 +134,7 @@ typedef struct LINKEDLIST
*****************************************************************************/
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
/****************************************************************************
* Function: ListAddHead
*
@ -135,6 +151,7 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
*****************************************************************************/
ListNode *ListAddHead(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddTail
*
@ -151,6 +168,7 @@ ListNode *ListAddHead(LinkedList *list, void *item);
*****************************************************************************/
ListNode *ListAddTail(LinkedList *list, void *item);
/****************************************************************************
* Function: ListAddAfter
*
@ -205,6 +223,7 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
*****************************************************************************/
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
/****************************************************************************
* Function: ListDestroy
*
@ -240,6 +259,7 @@ int ListDestroy(LinkedList *list, int freeItem);
*****************************************************************************/
ListNode* ListHead(LinkedList *list);
/****************************************************************************
* Function: ListTail
*
@ -256,6 +276,7 @@ ListNode* ListHead(LinkedList *list);
*****************************************************************************/
ListNode* ListTail(LinkedList *list);
/****************************************************************************
* Function: ListNext
*
@ -272,6 +293,7 @@ ListNode* ListTail(LinkedList *list);
*****************************************************************************/
ListNode* ListNext(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListPrev
*
@ -288,6 +310,7 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListPrev(LinkedList *list, ListNode * node);
/****************************************************************************
* Function: ListFind
*
@ -307,6 +330,7 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
*****************************************************************************/
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
/****************************************************************************
* Function: ListSize
*

View File

@ -29,70 +29,134 @@
*
******************************************************************************/
#ifndef THREADPOOL_H
#define THREADPOOL_H
/*!
* \file
*/
#include "FreeList.h"
#include "ithread.h"
#include "LinkedList.h"
#include "UpnpInet.h"
#include "UpnpGlobal.h" /* for UPNP_INLINE, EXPORT_SPEC */
#include <errno.h>
#ifdef WIN32
#include <time.h>
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz);
#else /* WIN32 */
#include <sys/param.h>
#include <sys/time.h> /* for gettimeofday() */
#if defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
#include <sys/resource.h> /* for setpriority() */
#endif
#endif
#ifdef __cplusplus
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;
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_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
#define STATS 1 /* always include stats because code change is minimal */
typedef enum duration {
SHORT_TERM,
PERSISTENT
} Duration;
/* Statistics */
#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */
#undef STATS
#endif
typedef enum priority {
LOW_PRIORITY,
MED_PRIORITY,
HIGH_PRIORITY
} ThreadPriority;
/*! default priority used by TPJobInit */
#define DEFAULT_PRIORITY MED_PRIORITY
/*! default minimum used by TPAttrInit */
#define DEFAULT_MIN_THREADS 1
/*! default max used by TPAttrInit */
#define DEFAULT_MAX_THREADS 10
/*! default stack size used by TPAttrInit */
#define DEFAULT_STACK_SIZE 0
/*! default jobs per thread used by TPAttrInit */
#define DEFAULT_JOBS_PER_THREAD 10
/*! default starvation time used by TPAttrInit */
#define DEFAULT_STARVATION_TIME 500
/*! default idle time used by TPAttrInit */
#define DEFAULT_IDLE_TIME 10 * 1000
/*! default free routine used TPJobInit */
#define DEFAULT_FREE_ROUTINE NULL
/*! default max jobs used TPAttrInit */
#define DEFAULT_MAX_JOBS_TOTAL 100
/*!
* \brief Statistics.
*
* Always include stats because code change is minimal.
*/
#define STATS 1
#ifdef STATS
#define STATSONLY(x) x
#else
#define STATSONLY(x)
#endif
#ifdef _DEBUG
#define DEBUG 1
#endif
#include "LinkedList.h"
#include <sys/timeb.h>
#include "FreeList.h"
#include "ithread.h"
#include <errno.h>
#include <sys/timeb.h>
#define EXPORT
typedef int PolicyType;
#define DEFAULT_POLICY SCHED_OTHER
#define DEFAULT_SCHED_PARAM 0 /* default priority */
/****************************************************************************
* Name: free_routine
@ -102,6 +166,7 @@ typedef int PolicyType;
*****************************************************************************/
typedef void (*free_routine)(void *arg);
/****************************************************************************
* Name: ThreadPoolAttr
*
@ -111,28 +176,35 @@ typedef void (*free_routine)(void *arg);
*****************************************************************************/
typedef struct THREADPOOLATTR
{
int minThreads; /* minThreads, ThreadPool will always maintain at least
this many threads */
/* minThreads, ThreadPool will always maintain at least this many threads */
int minThreads;
int maxThreads; /* maxThreads, ThreadPool will never have more than this
number of threads */
/* maxThreads, ThreadPool will never have more than this number of threads */
int maxThreads;
int maxIdleTime; /* maxIdleTime (in milliseconds)
this is the maximum time a thread will remain idle
before dying */
/* stackSize (in bytes), this is the minimum stack size allocated for each
* thread */
size_t stackSize;
int jobsPerThread; /* jobs per thread to maintain */
/* maxIdleTime (in milliseconds) this is the maximum time a thread will
* remain idle before dying */
int maxIdleTime;
int maxJobsTotal; /* maximum number of jobs that can be queued totally. */
/* jobs per thread to maintain */
int jobsPerThread;
int starvationTime; /* the time a low priority or med priority
job waits before getting bumped
up a priority (in milliseconds) */
/* maximum number of jobs that can be queued totally. */
int maxJobsTotal;
PolicyType schedPolicy; /* scheduling policy to use */
/* the time a low priority or med priority job waits before getting bumped
* up a priority (in milliseconds) */
int starvationTime;
/* scheduling policy to use */
PolicyType schedPolicy;
} ThreadPoolAttr;
/****************************************************************************
* Name: ThreadPool
*
@ -141,94 +213,80 @@ typedef struct THREADPOOLATTR
*****************************************************************************/
typedef struct THREADPOOLJOB
{
start_routine func;
void *arg;
free_routine free_func;
struct timeb requestTime;
int priority;
int jobId;
start_routine func;
void *arg;
free_routine free_func;
struct timeval requestTime;
int priority;
int jobId;
} ThreadPoolJob;
/****************************************************************************
* Name: ThreadPoolStats
*
* Description:
* Structure to hold statistics
*****************************************************************************/
#ifdef STATS
typedef struct TPOOLSTATS
{
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
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;
/****************************************************************************
* Name: ThreadPool
/*!
* \brief A thread pool similar to the thread pool in the UPnP SDK.
*
* Description:
* A thread pool similar to the thread pool in the UPnP SDK.
* Allows jobs to be scheduled for running by threads in a
* thread pool. The thread pool is initialized with a
* minimum and maximum thread number as well as a
* max idle time
* and a jobs per thread ratio. If a worker thread waits the whole
* max idle time without receiving a job and the thread pool
* currently has more threads running than the minimum
* then the worker thread will exit. If when
* scheduling a job the current job to thread ratio
* becomes greater than the set ratio and the thread pool currently has
* less than the maximum threads then a new thread will
* be created.
*
*****************************************************************************/
* Allows jobs to be scheduled for running by threads in a
* thread pool. The thread pool is initialized with a
* minimum and maximum thread number as well as a max idle time
* and a jobs per thread ratio. If a worker thread waits the whole
* max idle time without receiving a job and the thread pool
* currently has more threads running than the minimum
* then the worker thread will exit. If when
* scheduling a job the current job to thread ratio
* becomes greater than the set ratio and the thread pool currently has
* less than the maximum threads then a new thread will
* be created.
*/
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 */
ThreadPoolAttr attr; /* thread pool attributes */
#ifdef STATS
/* statistics */
ThreadPoolStats stats;
#endif
} 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 busyThreads; /* number of threads that are currently executing jobs */
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 */
/* statistics */
ThreadPoolStats stats;
} ThreadPool;
/****************************************************************************
@ -267,8 +325,8 @@ typedef struct THREADPOOL
* INVALID_POLICY if schedPolicy can't be set
* EMAXTHREADS if minimum threads is greater than maximum threads
*****************************************************************************/
int ThreadPoolInit(ThreadPool *tp,
ThreadPoolAttr *attr);
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
/****************************************************************************
* Function: ThreadPoolAddPersistent
@ -290,9 +348,8 @@ int ThreadPoolInit(ThreadPool *tp,
* EOUTOFMEM not enough memory to add job.
* EMAXTHREADS not enough threads to add persistent job.
*****************************************************************************/
int ThreadPoolAddPersistent (ThreadPool*tp,
ThreadPoolJob *job,
int *jobId);
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
/****************************************************************************
* Function: ThreadPoolGetAttr
@ -307,8 +364,9 @@ int ThreadPoolAddPersistent (ThreadPool*tp,
* 0 on success, nonzero on failure
* Always returns 0.
*****************************************************************************/
int ThreadPoolGetAttr(ThreadPool *tp,
ThreadPoolAttr *out);
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
/****************************************************************************
* Function: ThreadPoolSetAttr
*
@ -322,8 +380,8 @@ int ThreadPoolGetAttr(ThreadPool *tp,
* 0 on success, nonzero on failure
* Returns INVALID_POLICY if policy can not be set.
*****************************************************************************/
int ThreadPoolSetAttr(ThreadPool *tp,
ThreadPoolAttr *attr);
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
/****************************************************************************
* Function: ThreadPoolAdd
@ -342,9 +400,8 @@ int ThreadPoolSetAttr(ThreadPool *tp,
* 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to add job.
*****************************************************************************/
int ThreadPoolAdd (ThreadPool*tp,
ThreadPoolJob *job,
int *jobId);
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
/****************************************************************************
* Function: ThreadPoolRemove
@ -361,8 +418,7 @@ int ThreadPoolAdd (ThreadPool*tp,
* 0 on success, nonzero on failure.
* INVALID_JOB_ID if job not found.
*****************************************************************************/
int ThreadPoolRemove(ThreadPool *tp,
int jobId, ThreadPoolJob *out);
int ThreadPoolRemove(ThreadPool *tp, int jobId, ThreadPoolJob *out);
@ -399,6 +455,7 @@ int ThreadPoolShutdown(ThreadPool *tp);
*****************************************************************************/
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
/****************************************************************************
* Function: TPJobSetPriority
*
@ -412,6 +469,7 @@ int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
*****************************************************************************/
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
/****************************************************************************
* Function: TPJobSetFreeFunction
*
@ -439,6 +497,7 @@ int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
*****************************************************************************/
int TPAttrInit(ThreadPoolAttr *attr);
/****************************************************************************
* Function: TPAttrSetMaxThreads
*
@ -452,6 +511,7 @@ int TPAttrInit(ThreadPoolAttr *attr);
*****************************************************************************/
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
/****************************************************************************
* Function: TPAttrSetMinThreads
*
@ -465,6 +525,21 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
*****************************************************************************/
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
/****************************************************************************
* Function: TPAttrSetStackSize
*
* Description:
* Sets the stack size for the thread pool attributes.
* Parameters:
* attr - must be valid thread pool attributes.
* stackSize - value to set
* Returns:
* Always returns 0.
*****************************************************************************/
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize);
/****************************************************************************
* Function: TPAttrSetIdleTime
*
@ -477,6 +552,7 @@ int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
*****************************************************************************/
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
/****************************************************************************
* Function: TPAttrSetJobsPerThread
*
@ -490,6 +566,7 @@ int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
*****************************************************************************/
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
/****************************************************************************
* Function: TPAttrSetStarvationTime
*
@ -503,6 +580,7 @@ int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
*****************************************************************************/
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
/****************************************************************************
* Function: TPAttrSetSchedPolicy
*
@ -530,6 +608,7 @@ int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
*****************************************************************************/
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
/****************************************************************************
* Function: ThreadPoolGetStats
*
@ -544,14 +623,20 @@ int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
* Always returns 0.
*****************************************************************************/
#ifdef STATS
EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);
EXPORT_SPEC int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);
EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);
EXPORT_SPEC void ThreadPoolPrintStats(ThreadPoolStats *stats);
#else
static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {}
static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {}
#endif
#ifdef __cplusplus
}
#endif
#endif /* ThreadPool */
#endif /* THREADPOOL_H */

View File

@ -29,160 +29,139 @@
*
******************************************************************************/
#ifndef TIMERTHREAD_H
#define TIMERTHREAD_H
/*!
* \file
*/
#include "FreeList.h"
#include "ithread.h"
#include "LinkedList.h"
#include "FreeList.h"
#include "ThreadPool.h"
#ifdef __cplusplus
extern "C" {
#endif
#define INVALID_EVENT_ID (-10 & 1<<29)
/* 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;
/****************************************************************************
* Name: TimerThread
*
* Description:
* A timer thread similar to the one in the Upnp SDK that allows
* the scheduling of a job to run at a specified time in the future
* Because the timer thread uses the thread pool there is no
* gurantee of timing, only approximate timing.
* Uses ThreadPool, Mutex, Condition, Thread
*
*
*****************************************************************************/
/*!
* A timer thread similar to the one in the Upnp SDK that allows
* the scheduling of a job to run at a specified time in the future.
*
* Because the timer thread uses the thread pool there is no
* gurantee of timing, only approximate timing.
*
* Uses ThreadPool, Mutex, Condition, Thread.
*/
typedef struct TIMERTHREAD
{
ithread_mutex_t mutex;
ithread_cond_t condition;
int lastEventId;
LinkedList eventQ;
int shutdown;
FreeList freeEvents;
ThreadPool *tp;
ithread_mutex_t mutex;
ithread_cond_t condition;
int lastEventId;
LinkedList eventQ;
int shutdown;
FreeList freeEvents;
ThreadPool *tp;
} TimerThread;
/****************************************************************************
* Name: TimerEvent
*
* Description:
*
* Struct to contain information for a timer event.
* Internal to the TimerThread
*
*****************************************************************************/
/*!
* Struct to contain information for a timer event.
*
* Internal to the 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;
ThreadPoolJob job;
/*! [in] Absolute time for event in seconds since Jan 1, 1970. */
time_t eventTime;
/*! [in] Long term or short term job. */
Duration persistent;
int id;
} TimerEvent;
/************************************************************************
* Function: TimerThreadInit
*
* Description:
* Initializes and starts timer thread.
/*!
* \brief Initializes and starts timer thread.
*
* Parameters:
* timer - valid timer thread pointer.
* tp - valid thread pool to use. Must be
* started. Must be valid for lifetime
* of timer. Timer must be shutdown
* BEFORE thread pool.
* Return:
* 0 on success, nonzero on failure
* Returns error from ThreadPoolAddPersistent on failure.
*
************************************************************************/
int TimerThreadInit(TimerThread *timer,
ThreadPool *tp);
* \return 0 on success, nonzero on failure. Returns error from
* ThreadPoolAddPersistent on failure.
*/
int TimerThreadInit(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Valid thread pool to use. Must be started. Must be valid for
* lifetime of timer. Timer must be shutdown BEFORE thread pool. */
ThreadPool *tp);
/************************************************************************
* Function: TimerThreadSchedule
*
* Description:
* Schedules an event to run at a specified time.
/*!
* \brief Schedules an event to run at a specified time.
*
* Parameters:
* timer - valid timer thread pointer.
* time_t - time of event.
* either in absolute seconds,
* or relative seconds in the future.
* timeoutType - either ABS_SEC, or REL_SEC.
* if REL_SEC, then the event
* will be scheduled at the
* current time + REL_SEC.
* job-> valid Thread pool job with following fields
* func - function to schedule
* arg - argument to function
* priority - priority of job.
*
* id - id of timer event. (out, can be null)
* Return:
* 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to schedule job.
*
************************************************************************/
int TimerThreadSchedule(TimerThread* timer,
time_t time,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
int *id);
* \return 0 on success, nonzero on failure, EOUTOFMEM if not enough memory
* to schedule job.
*/
int TimerThreadSchedule(
/*! [in] Valid timer thread pointer. */
TimerThread* timer,
/*! [in] time of event. Either in absolute seconds, or relative
* seconds in the future. */
time_t time,
/*! [in] either ABS_SEC, or REL_SEC. If REL_SEC, then the event
* will be scheduled at the current time + REL_SEC. */
TimeoutType type,
/*! [in] Valid Thread pool job with following fields. */
ThreadPoolJob *job,
/*! [in] . */
Duration duration,
/*! [in] Id of timer event. (out, can be null). */
int *id);
/************************************************************************
* Function: TimerThreadRemove
*
* Description:
* Removes an event from the timer Q.
* Events can only be removed
* before they have been placed in the
* thread pool.
*
* Parameters:
* timer - valid timer thread pointer.
* id - id of event to remove.
* ThreadPoolJob *out - space for thread pool job.
* Return:
* 0 on success,
* INVALID_EVENT_ID on failure
*
************************************************************************/
int TimerThreadRemove(TimerThread *timer,
int id,
ThreadPoolJob *out);
/************************************************************************
* Function: TimerThreadShutdown
*
* Description:
* Shutdown the timer thread
* Events scheduled in the future will NOT be run.
* Timer thread should be shutdown BEFORE it's associated
* thread pool.
* Returns:
* returns 0 if succesfull,
* nonzero otherwise.
* Always returns 0.
***********************************************************************/
int TimerThreadShutdown(TimerThread *timer);
/*!
* \brief Removes an event from the timer Q.
*
* Events can only be removed before they have been placed in the thread pool.
*
* \return 0 on success, INVALID_EVENT_ID on failure.
*/
int TimerThreadRemove(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Id of event to remove. */
int id,
/*! [in] Space for thread pool job. */
ThreadPoolJob *out);
/*!
* \brief Shutdown the timer thread.
*
* Events scheduled in the future will NOT be run.
*
* Timer thread should be shutdown BEFORE it's associated thread pool.
*
* \return 0 if succesfull, nonzero otherwise. Always returns 0.
*/
int TimerThreadShutdown(
/*! [in] Valid timer thread pointer. */
TimerThread *timer);
#ifdef __cplusplus
}

View File

@ -1,66 +0,0 @@
/*******************************************************************************
*
* 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>
#define EXPORT
#ifdef __cplusplus
extern "C" {
#endif
/**
* Allocates enough memory for the
* Formatted string, up to max
* specified.
* With max set to -1, allocates
* as much size as needed.
* Memory must be freed using free.
*/
EXPORT int iasnprintf(char **ret,
int incr,
int max,
const char * fmt, ...)
#ifndef SPARC_SOLARIS
#if (__GNUC__ >= 3)
__attribute__((format (__printf__, 4, 5)));
#else
;
#endif
EXPORT void iasnprintfFree(char *);
#else
;
#endif
#ifdef __cplusplus
}
#endif

View File

@ -29,144 +29,288 @@
*
******************************************************************************/
#ifndef ITHREADH
#define ITHREADH
#ifndef ITHREAD_H
#define ITHREAD_H
/*!
* \file
*/
#if !defined(WIN32)
#include <sys/param.h>
#endif
#include "UpnpGlobal.h" /* For UPNP_INLINE, EXPORT_SPEC */
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h>
#ifndef WIN32
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#ifdef __FreeBSD__
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#if defined(BSD)
#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
/* 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 /* PTHREAD_MUTEX_RECURSIVE */
#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 /* PTHREAD_MUTEX_RECURSIVE */
#define ITHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
#define ITHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
#define ITHREAD_CANCELED PTHREAD_CANCELED
/***************************************************************************
* Name: ithread_t
*
* Description:
* Thread handle.
* typedef to pthread_t.
* Internal Use Only.
***************************************************************************/
typedef pthread_t ithread_t;
/****************************************************************************
* Name: ithread_attr_t
*
* Description:
* Thread attribute.
* typedef to pthread_attr_t
* Internal Use Only
***************************************************************************/
typedef pthread_attr_t ithread_attr_t;
#define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
/****************************************************************************
* Name: start_routine
*
* Description:
* Thread start routine
* Internal Use Only.
***************************************************************************/
typedef void * (*start_routine) (void *arg);
/***************************************************************************
* Name: ithread_t
*
* Description:
* Thread handle.
* typedef to pthread_t.
* Internal Use Only.
***************************************************************************/
typedef pthread_t ithread_t;
/****************************************************************************
* Name: ithread_cond_t
*
* Description:
* condition variable.
* typedef to pthread_cond_t
* Internal Use Only.
***************************************************************************/
typedef pthread_cond_t ithread_cond_t;
/****************************************************************************
* Name: ithread_attr_t
*
* Description:
* Thread attribute.
* typedef to pthread_attr_t
* Internal Use Only
***************************************************************************/
typedef pthread_attr_t ithread_attr_t;
/****************************************************************************
* Name: ithread_mutexattr_t
*
* Description:
* Mutex attribute.
* typedef to pthread_mutexattr_t
* Internal Use Only
***************************************************************************/
typedef pthread_mutexattr_t ithread_mutexattr_t;
/****************************************************************************
* Name: start_routine
*
* Description:
* Thread start routine
* Internal Use Only.
***************************************************************************/
typedef void *(*start_routine)(void *arg);
/****************************************************************************
* Name: ithread_mutex_t
*
* Description:
* Mutex.
* typedef to pthread_mutex_t
* Internal Use Only.
***************************************************************************/
typedef pthread_mutex_t ithread_mutex_t;
/****************************************************************************
* Name: ithread_condattr_t
*
* Description:
* Condition attribute.
* typedef to pthread_condattr_t
* NOT USED
* Internal Use Only
***************************************************************************/
typedef pthread_condattr_t ithread_condattr_t;
/****************************************************************************
* Function: ithread_mutexattr_init
*
* Description:
* Initializes a mutex attribute variable.
* Used to set the type of the mutex.
* Parameters:
* ithread_mutexattr_init * attr (must be valid non NULL pointer to
* pthread_mutexattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_mutexattr_init
***************************************************************************/
/****************************************************************************
* Name: ithread_cond_t
*
* Description:
* condition variable.
* typedef to pthread_cond_t
* Internal Use Only.
***************************************************************************/
typedef pthread_cond_t ithread_cond_t;
/****************************************************************************
* Name: ithread_mutexattr_t
*
* Description:
* Mutex attribute.
* typedef to pthread_mutexattr_t
* Internal Use Only
***************************************************************************/
typedef pthread_mutexattr_t ithread_mutexattr_t;
/****************************************************************************
* Name: ithread_mutex_t
*
* Description:
* Mutex.
* typedef to pthread_mutex_t
* Internal Use Only.
***************************************************************************/
typedef pthread_mutex_t ithread_mutex_t;
/****************************************************************************
* Name: ithread_condattr_t
*
* Description:
* Condition attribute.
* typedef to pthread_condattr_t
* NOT USED
* Internal Use Only
***************************************************************************/
typedef pthread_condattr_t ithread_condattr_t;
/****************************************************************************
* Name: ithread_rwlockattr_t
*
* Description:
* Mutex attribute.
* typedef to pthread_rwlockattr_t
* Internal Use Only
***************************************************************************/
#if UPNP_USE_RWLOCK
typedef pthread_rwlockattr_t ithread_rwlockattr_t;
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Name: ithread_rwlock_t
*
* Description:
* Condition attribute.
* typedef to pthread_rwlock_t
* Internal Use Only
***************************************************************************/
#if UPNP_USE_RWLOCK
typedef pthread_rwlock_t ithread_rwlock_t;
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_initialize_library
*
* Description:
* Initializes the library. Does nothing in all implementations, except
* when statically linked for WIN32.
* Parameters:
* none.
* Returns:
* 0 on success, Nonzero on failure.
***************************************************************************/
static UPNP_INLINE int ithread_initialize_library(void) {
int ret = 0;
#if defined(WIN32) && defined(PTW32_STATIC_LIB)
ret = !pthread_win32_process_attach_np();
#endif
return ret;
}
/****************************************************************************
* Function: ithread_cleanup_library
*
* Description:
* Clean up library resources. Does nothing in all implementations, except
* when statically linked for WIN32.
* Parameters:
* none.
* Returns:
* 0 on success, Nonzero on failure.
***************************************************************************/
static UPNP_INLINE int ithread_cleanup_library(void) {
int ret = 0;
#if defined(WIN32) && defined(PTW32_STATIC_LIB)
ret = !pthread_win32_process_detach_np();
#endif
return ret;
}
/****************************************************************************
* Function: ithread_initialize_thread
*
* Description:
* Initializes the thread. Does nothing in all implementations, except
* when statically linked for WIN32.
* Parameters:
* none.
* Returns:
* 0 on success, Nonzero on failure.
***************************************************************************/
static UPNP_INLINE int ithread_initialize_thread(void) {
int ret = 0;
#if defined(WIN32) && defined(PTW32_STATIC_LIB)
ret = !pthread_win32_thread_attach_np();
#endif
return ret;
}
/****************************************************************************
* Function: ithread_cleanup_thread
*
* Description:
* Clean up thread resources. Does nothing in all implementations, except
* when statically linked for WIN32.
* Parameters:
* none.
* Returns:
* 0 on success, Nonzero on failure.
***************************************************************************/
static UPNP_INLINE int ithread_cleanup_thread(void) {
int ret = 0;
#if defined(WIN32) && defined(PTW32_STATIC_LIB)
ret = !pthread_win32_thread_detach_np();
#endif
return ret;
}
/****************************************************************************
* Function: ithread_mutexattr_init
*
* Description:
* Initializes a mutex attribute variable.
* Used to set the type of the mutex.
* Parameters:
* ithread_mutexattr_init * attr (must be valid non NULL pointer to
* pthread_mutexattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_mutexattr_init
***************************************************************************/
#define ithread_mutexattr_init pthread_mutexattr_init
/****************************************************************************
* Function: ithread_mutexattr_destroy
*
* Description:
* Releases any resources held by the mutex attribute.
* Currently there are no resources associated with the attribute
* Parameters:
* ithread_mutexattr_t * attr (must be valid non NULL pointer to
* pthread_mutexattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_mutexattr_destroy
***************************************************************************/
/****************************************************************************
* Function: ithread_mutexattr_destroy
*
* Description:
* Releases any resources held by the mutex attribute.
* Currently there are no resources associated with the attribute
* Parameters:
* ithread_mutexattr_t * attr (must be valid non NULL pointer to
* pthread_mutexattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_mutexattr_destroy
***************************************************************************/
#define ithread_mutexattr_destroy pthread_mutexattr_destroy
@ -180,7 +324,7 @@ extern "C" {
* ITHREAD_MUTEX_ERRORCHECK_NP
*
* Parameters:
* ithread_mutexattr_t * mutex (must be valid non NULL pointer to
* ithread_mutexattr_t * attr (must be valid non NULL pointer to
* ithread_mutexattr_t)
* int kind (one of ITHREAD_MUTEX_FAST_NP or ITHREAD_MUTEX_RECURSIVE_NP
* or ITHREAD_MUTEX_ERRORCHECK_NP)
@ -190,9 +334,9 @@ extern "C" {
* See man page for pthread_mutexattr_setkind_np
*****************************************************************************/
#ifdef PTHREAD_MUTEX_RECURSIVE
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
#define ithread_mutexattr_setkind_np pthread_mutexattr_settype
#else
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np
#endif
/****************************************************************************
@ -205,7 +349,7 @@ extern "C" {
* ITHREAD_MUTEX_ERRORCHECK_NP
*
* Parameters:
* ithread_mutexattr_t * mutex (must be valid non NULL pointer to
* ithread_mutexattr_t * attr (must be valid non NULL pointer to
* pthread_mutexattr_t)
* int *kind (one of ITHREAD_MUTEX_FAST_NP or ITHREAD_MUTEX_RECURSIVE_NP
* or ITHREAD_MUTEX_ERRORCHECK_NP)
@ -215,9 +359,9 @@ extern "C" {
* See man page for pthread_mutexattr_getkind_np
*****************************************************************************/
#ifdef PTHREAD_MUTEX_RECURSIVE
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
#else
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np
#endif
@ -237,7 +381,8 @@ extern "C" {
* See man page for pthread_mutex_init
*****************************************************************************/
#define ithread_mutex_init pthread_mutex_init
/****************************************************************************
* Function: ithread_mutex_lock
*
@ -291,7 +436,188 @@ extern "C" {
*****************************************************************************/
#define ithread_mutex_destroy pthread_mutex_destroy
/****************************************************************************
* Function: ithread_rwlockattr_init
*
* Description:
* Initializes a rwlock attribute variable to default values.
* Parameters:
* const ithread_rwlockattr_init *attr (must be valid non NULL pointer to
* pthread_rwlockattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlockattr_init
***************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_init pthread_rwlockattr_init
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlockattr_destroy
*
* Description:
* Releases any resources held by the rwlock attribute.
* Parameters:
* ithread_rwlockattr_t *attr (must be valid non NULL pointer to
* pthread_rwlockattr_t)
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlockattr_destroy
***************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlockatttr_setpshared
*
* Description:
* Sets the rwlock type in the attribute.
* Valid types are: ITHREAD_PROCESS_PRIVATE
* ITHREAD_PROCESS_SHARED
*
* Parameters:
* ithread_rwlockattr_t * attr (must be valid non NULL pointer to
* ithread_rwlockattr_t)
* int kind (one of ITHREAD_PROCESS_PRIVATE or ITHREAD_PROCESS_SHARED)
*
* Returns:
* 0 on success. Nonzero on failure.
* Returns EINVAL if the kind is not supported.
* See man page for pthread_rwlockattr_setkind_np
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlockatttr_getpshared
*
* Description:
* Gets the rwlock type in the attribute.
* Valid types are: ITHREAD_PROCESS_PRIVATE
* ITHREAD_PROCESS_SHARED
*
* Parameters:
* ithread_rwlockattr_t * attr (must be valid non NULL pointer to
* pthread_rwlockattr_t)
* int *kind (one of ITHREAD_PROCESS_PRIVATE or ITHREAD_PROCESS_SHARED)
*
* Returns:
* 0 on success. Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlockatttr_getpshared
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_init
*
* Description:
* Initializes rwlock.
* Must be called before use.
*
* Parameters:
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
* const ithread_rwlockattr_t *rwlock_attr
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlock_init
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_init pthread_rwlock_init
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_rdlock
*
* Description:
* Locks rwlock for reading.
* Parameters:
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
* rwlock must be initialized.
*
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlock_rdlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_rdlock pthread_rwlock_rdlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_wrlock
*
* Description:
* Locks rwlock for writting.
* Parameters:
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
* rwlock must be initialized.
*
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlock_wrlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_wrlock pthread_rwlock_wrlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_unlock
*
* Description:
* Unlocks rwlock.
*
* Parameters:
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
* rwlock must be initialized.
*
* Returns:
* 0 on success, Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlock_unlock
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_unlock pthread_rwlock_unlock
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_rwlock_destroy
*
* Description:
* Releases any resources held by the rwlock.
* rwlock can no longer be used after this call.
* rwlock is only destroyed when there are no longer any threads waiting on it.
* rwlock cannot be destroyed if it is locked.
* Parameters:
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
* rwlock must be initialized.
* Returns:
* 0 on success. Nonzero on failure.
* Always returns 0.
* See man page for pthread_rwlock_destroy
*****************************************************************************/
#if UPNP_USE_RWLOCK
#define ithread_rwlock_destroy pthread_rwlock_destroy
#endif /* UPNP_USE_RWLOCK */
/****************************************************************************
* Function: ithread_cond_init
*
@ -299,8 +625,8 @@ extern "C" {
* Initializes condition variable.
* Must be called before use.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to pthread_cond_t)
* const ithread_condattr_t * cond_attr (ignored)
* ithread_cond_t *cond (must be valid non NULL pointer to pthread_cond_t)
* const ithread_condattr_t *cond_attr (ignored)
* Returns:
* 0 on success, Nonzero on failure.
* See man page for pthread_cond_init
@ -308,7 +634,6 @@ extern "C" {
#define ithread_cond_init pthread_cond_init
/****************************************************************************
* Function: ithread_cond_signal
*
@ -316,7 +641,7 @@ extern "C" {
* Wakes up exactly one thread waiting on condition.
* Associated mutex MUST be locked by thread before entering this call.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to
* ithread_cond_t *cond (must be valid non NULL pointer to
* ithread_cond_t)
* cond must be initialized
* Returns:
@ -333,7 +658,7 @@ extern "C" {
* Wakes up all threads waiting on condition.
* Associated mutex MUST be locked by thread before entering this call.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to
* ithread_cond_t *cond (must be valid non NULL pointer to
* ithread_cond_t)
* cond must be initialized
* Returns:
@ -351,7 +676,7 @@ extern "C" {
* Associated mutex MUST be locked by thread before entering this call.
* Mutex is reacquired when call returns.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to
* ithread_cond_t *cond (must be valid non NULL pointer to
* ithread_cond_t)
* cond must be initialized
* ithread_mutex_t *mutex (must be valid non NULL pointer to
@ -367,23 +692,19 @@ extern "C" {
/****************************************************************************
* Function: pthread_cond_timedwait
*
* Description:
* Atomically releases the associated mutex and waits on the condition.
* If the condition is not signaled in the specified time
* than the
* call times out and returns.
* Associated mutex MUST be locked by thread before entering
* this call.
* Mutex is reacquired when call returns.
* Description:
* Atomically releases the associated mutex and waits on the
* condition.
* If the condition is not signaled in the specified time than the
* call times out and returns.
* Associated mutex MUST be locked by thread before entering this call.
* Mutex is reacquired when call returns.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to
* ithread_cond_t)
* cond must be initialized
* ithread_mutex_t *mutex (must be valid non NULL pointer to
* ithread_mutex_t)
* Mutex must be locked.
* const struct timespec *abstime (absolute time, measured
* from Jan 1, 1970)
* ithread_cond_t *cond (must be valid non NULL pointer to ithread_cond_t)
* cond must be initialized
* ithread_mutex_t *mutex (must be valid non NULL pointer to ithread_mutex_t)
* Mutex must be locked.
* const struct timespec *abstime (absolute time, measured from Jan 1, 1970)
* Returns:
* 0 on success. ETIMEDOUT on timeout. Nonzero on failure.
* See man page for pthread_cond_timedwait
@ -399,7 +720,7 @@ extern "C" {
* Releases any resources held by the condition variable.
* Condition variable can no longer be used after this call.
* Parameters:
* ithread_cond_t * cond (must be valid non NULL pointer to
* ithread_cond_t *cond (must be valid non NULL pointer to
* ithread_cond_t)
* cond must be initialized.
* Returns:
@ -408,6 +729,49 @@ extern "C" {
***************************************************************************/
#define ithread_cond_destroy pthread_cond_destroy
/****************************************************************************
* Function: ithread_attr_init
*
* Description:
* Initialises thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_init
***************************************************************************/
#define ithread_attr_init pthread_attr_init
/****************************************************************************
* Function: ithread_attr_destroy
*
* Description:
* Destroys thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_destroy
***************************************************************************/
#define ithread_attr_destroy pthread_attr_destroy
/****************************************************************************
* Function: ithread_attr_setstacksize
*
* Description:
* Sets stack size of a thread attribute object.
* Parameters:
* ithread_attr_t *attr (must be valid non NULL pointer to
* ithread_attr_t)
* size_t stacksize (value of stacksize must be greater than
* ITHREAD_STACK_MIN and lower than system-imposed limits
* Returns:
* 0 on success. Nonzero on failure.
* See man page for pthread_attr_setstacksize
***************************************************************************/
#define ithread_attr_setstacksize pthread_attr_setstacksize
/****************************************************************************
* Function: ithread_create
@ -417,7 +781,7 @@ extern "C" {
* and argument.
* Parameters:
* ithread_t * thread (must be valid non NULL pointer to pthread_t)
* ithread_attr_t *attr, IGNORED
* ithread_attr_t *attr
* void * (start_routine) (void *arg) (start routine)
* void * arg - argument.
* Returns:
@ -455,6 +819,7 @@ extern "C" {
***************************************************************************/
#define ithread_exit pthread_exit
/****************************************************************************
* Function: ithread_get_current_thread_id
*
@ -478,6 +843,7 @@ extern "C" {
***************************************************************************/
#define ithread_self pthread_self
/****************************************************************************
* Function: ithread_detach
*
@ -491,6 +857,7 @@ extern "C" {
***************************************************************************/
#define ithread_detach pthread_detach
/****************************************************************************
* Function: ithread_join
*
@ -510,7 +877,6 @@ extern "C" {
#define ithread_join pthread_join
/****************************************************************************
* Function: isleep
*
@ -524,7 +890,12 @@ extern "C" {
* 0 on success, Nonzero on failure.
* See man page for sleep (man 3 sleep)
*****************************************************************************/
#define isleep sleep
#ifdef WIN32
#define isleep(x) Sleep((x)*1000)
#else
#define isleep sleep
#endif
/****************************************************************************
* Function: isleep
@ -539,21 +910,10 @@ extern "C" {
* 0 on success, Nonzero on failure.
* See man page for sleep (man 3 sleep)
*****************************************************************************/
#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
#define imillisleep Sleep
#else
#define EXPORT_SPEC
#define imillisleep(x) usleep(1000*x)
#endif
@ -562,9 +922,11 @@ extern "C" {
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ITHREADH */
#endif /* ITHREAD_H */

View File

@ -1,43 +1,55 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "LinkedList.h"
#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306)
#include <stdlib.h>
#ifdef WIN32
/* Do not #include <sys/param.h> */
#else
#include <malloc.h>
#include <sys/param.h>
#endif
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <assert.h>
static int
freeListNode( ListNode * node,
LinkedList * list )
@ -532,3 +544,4 @@ ListSize( LinkedList * list )
return list->size;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,69 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/*!
* \file
*/
#include "TimerThread.h"
#include <assert.h>
/****************************************************************************
* Function: FreeTimerEvent
*
* Description:
* Deallocates a dynamically allocated TimerEvent.
* Parameters:
* TimerEvent *event - must be allocated with CreateTimerEvent
*****************************************************************************/
static void
FreeTimerEvent( TimerThread * timer,
TimerEvent * event )
/*!
* \brief Deallocates a dynamically allocated TimerEvent.
*/
static void FreeTimerEvent(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] Must be allocated with CreateTimerEvent*/
TimerEvent *event)
{
assert(timer != NULL);
assert( timer != NULL );
FreeListFree( &timer->freeEvents, event );
FreeListFree(&timer->freeEvents, event);
}
/****************************************************************************
* Function: TimerThreadWorker
/*!
* \brief Implements timer thread.
*
* Description:
* Implements timer thread.
* Waits for next event to occur and schedules
* associated job into threadpool.
* Internal Only.
* Parameters:
* void * arg -> is cast to TimerThread *
*****************************************************************************/
static void *
TimerThreadWorker( void *arg )
* Waits for next event to occur and schedules associated job into threadpool.
*/
static void *TimerThreadWorker(
/*! [in] arg is cast to (TimerThread *). */
void *arg)
{
TimerThread *timer = ( TimerThread * ) arg;
ListNode *head = NULL;
@ -81,19 +82,14 @@ TimerThreadWorker( void *arg )
while( 1 )
{
//mutex should always be locked at top of loop
//Check for shutdown
if( timer->shutdown )
{
timer->shutdown = 0;
ithread_cond_signal( &timer->condition );
ithread_mutex_unlock( &timer->mutex );
return NULL;
}
nextEvent = NULL;
@ -102,7 +98,6 @@ TimerThreadWorker( void *arg )
if( timer->eventQ.size > 0 )
{
head = ListHead( &timer->eventQ );
nextEvent = ( TimerEvent * ) head->item;
nextEventTime = nextEvent->eventTime;
}
@ -110,54 +105,42 @@ TimerThreadWorker( void *arg )
currentTime = time( NULL );
//If time has elapsed, schedule job
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
{
if( nextEvent->persistent ) {
ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
&tempId );
} else {
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
}
ListDelNode( &timer->eventQ, head, 0 );
FreeTimerEvent( timer, nextEvent );
continue;
}
if( nextEvent != NULL ) {
timeToWait.tv_nsec = 0;
timeToWait.tv_sec = nextEvent->eventTime;
ithread_cond_timedwait( &timer->condition, &timer->mutex,
&timeToWait );
} else {
ithread_cond_wait( &timer->condition, &timer->mutex );
}
}
}
/****************************************************************************
* Function: CalculateEventTime
/*!
* \brief Calculates the appropriate timeout in absolute seconds
* since Jan 1, 1970.
*
* Description:
* Calculates the appropriate timeout in absolute seconds since
* Jan 1, 1970
* Internal Only.
* Parameters:
* time_t *timeout - timeout
*
*****************************************************************************/
static int
CalculateEventTime( time_t * timeout,
TimeoutType type )
* \return
*/
static int CalculateEventTime(
/*! [in] Timeout. */
time_t *timeout,
/*! [in] Timeout type. */
TimeoutType type)
{
time_t now;
@ -175,29 +158,22 @@ CalculateEventTime( time_t * timeout,
}
/****************************************************************************
* Function: CreateTimerEvent
/*!
* \brief Creates a Timer Event. (Dynamically allocated).
*
* Description:
* Creates a Timer Event. (Dynamically allocated)
* Internal to timer thread.
* Parameters:
* func - thread function to run.
* arg - argument to function.
* priority - priority of job.
* eventTime - the absoule time of the event
* in seconds from Jan, 1970
* id - id of job
*
* Returns:
* TimerEvent * on success, NULL on failure.
****************************************************************************/
static TimerEvent *
CreateTimerEvent( TimerThread * timer,
ThreadPoolJob * job,
Duration persistent,
time_t eventTime,
int id )
* \return (TimerEvent *) on success, NULL on failure.
*/
static TimerEvent *CreateTimerEvent(
/*! [in] Valid timer thread pointer. */
TimerThread *timer,
/*! [in] . */
ThreadPoolJob *job,
/*! [in] . */
Duration persistent,
/*! [in] The absoule time of the event in seconds from Jan, 1970. */
time_t eventTime,
/*! [in] Id of job. */
int id)
{
TimerEvent *temp = NULL;
@ -215,25 +191,8 @@ CreateTimerEvent( TimerThread * timer,
return temp;
}
/************************************************************************
* Function: TimerThreadInit
*
* Description:
* Initializes and starts timer thread.
*
* Parameters:
* timer - valid timer thread pointer.
* tp - valid thread pool to use. Must be
* started. Must be valid for lifetime
* of timer. Timer must be shutdown
* BEFORE thread pool.
* Return:
* 0 on success, nonzero on failure
* Returns error from ThreadPoolAddPersistent if failure.
************************************************************************/
int
TimerThreadInit( TimerThread * timer,
ThreadPool * tp )
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
{
int rc = 0;
@ -290,37 +249,14 @@ TimerThreadInit( TimerThread * timer,
}
/************************************************************************
* Function: TimerThreadSchedule
*
* Description:
* Schedules an event to run at a specified time.
*
* Parameters:
* timer - valid timer thread pointer.
* time_t - time of event.
* either in absolute seconds,
* or relative seconds in the future.
* timeoutType - either ABS_SEC, or REL_SEC.
* if REL_SEC, then the event
* will be scheduled at the
* current time + REL_SEC.
*
* func - function to schedule
* arg - argument to function
* priority - priority of job.
* id - id of timer event. (out)
* Return:
* 0 on success, nonzero on failure
* EOUTOFMEM if not enough memory to schedule job
************************************************************************/
int
TimerThreadSchedule( TimerThread * timer,
time_t timeout,
TimeoutType type,
ThreadPoolJob * job,
Duration duration,
int *id )
int TimerThreadSchedule(
TimerThread *timer,
time_t timeout,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
int *id)
{
int rc = EOUTOFMEM;
@ -394,28 +330,11 @@ TimerThreadSchedule( TimerThread * timer,
return rc;
}
/************************************************************************
* Function: TimerThreadRemove
*
* Description:
* Removes an event from the timer Q.
* Events can only be removed
* before they have been placed in the
* thread pool.
*
* Parameters:
* timer - valid timer thread pointer.
* id - id of event to remove.
* out - space for returned job (Can be NULL)
* Return:
* 0 on success.
* INVALID_EVENT_ID on error.
*
************************************************************************/
int
TimerThreadRemove( TimerThread * timer,
int id,
ThreadPoolJob * out )
int TimerThreadRemove(
TimerThread *timer,
int id,
ThreadPoolJob *out)
{
int rc = INVALID_EVENT_ID;
ListNode *tempNode = NULL;
@ -450,21 +369,8 @@ TimerThreadRemove( TimerThread * timer,
return rc;
}
/************************************************************************
* Function: TimerThreadShutdown
*
* Description:
* Shutdown the timer thread
* Events scheduled in the future will NOT be run.
* Timer thread should be shutdown BEFORE it's associated
* thread pool.
* Returns:
* returns 0 if succesfull,
* nonzero otherwise.
* Always returns 0.
***********************************************************************/
int
TimerThreadShutdown( TimerThread * timer )
int TimerThreadShutdown(TimerThread *timer)
{
ListNode *tempNode2 = NULL;
ListNode *tempNode = NULL;
@ -517,3 +423,4 @@ TimerThreadShutdown( TimerThread * timer )
return 0;
}

View File

@ -1,153 +0,0 @@
///////////////////////////////////////////////////////////////////////////
//
// 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>
#include <assert.h>
#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <stdio.h>
#include "iasnprintf.h"
#ifndef NULL
#define NULL 0
#endif
#ifdef WIN32
#define vsnprintf _vsnprintf
#endif
/**
* Allocates enough memory for the
* Formatted string, up to max
* specified.
* With max set to -1, it allocates as
* much size as needed.
* Memory must be freed using free.
*/
int
iasnprintf( char **ret,
int incr,
int max,
const char *fmt,
... )
{
int size = incr;
int retc = 0;
va_list ap;
char *temp = NULL;
assert( ret );
assert( fmt );
( *ret ) = ( char * )malloc( incr );
if( ( *ret ) == NULL ) return -1;
while( 1 ) {
va_start( ap, fmt );
retc = vsnprintf( ( *ret ), size, fmt, ap );
va_end( ap );
if( retc < 0 ) {
//size not big enough
//and vsnprintf does NOT return the
//necessary number of bytes
if( ( max != -1 ) && ( size == max ) ) //max reached
{
break;
}
incr *= 2; //increase increment
//increase size and try again
if( ( max != -1 ) && ( ( size + incr ) > max ) ) {
incr = ( max - size );
}
temp = ( char * )realloc( ( *ret ), size + incr );
if( temp == NULL ) {
break;
}
size += incr;
( *ret ) = temp;
} else {
if( ( retc + 1 ) > size ) {
//size not big enough
//and vsnprintf
//returns the necessary
//number of bytes
if( ( max != -1 ) && ( retc + 1 > max ) ) {
retc = -1;
break;
}
temp = ( char * )realloc( ( *ret ), retc + 1 );
if( temp == NULL ) {
retc = -1;
break;
}
size = retc + 1;
( *ret ) = temp; //size increased try again
} else if( ( retc + 1 ) < size ) {
//size is bigger than needed
//try and reallocate smaller
temp = ( char * )realloc( ( *ret ), retc + 1 );
if( temp != NULL ) {
( *ret ) = temp;
}
break;
} else //size is just right, exit
{
break;
}
}
}
if( retc < 0 ) {
free( ( *ret ) );
( *ret ) = NULL;
}
return retc;
}
void
iasnprintfFree( char *fChar )
{
free( fChar );
fChar = NULL;
}

View File

@ -1,7 +1,7 @@
#
# "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 . sample
@ -11,10 +11,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/threadutil/inc \
-I$(top_srcdir)/ixml/inc
AM_CFLAGS = $(PTHREAD_CFLAGS)
AM_LDFLAGS = $(PTHREAD_LIBS)
LDADD = \
libupnp.la \
$(top_builddir)/threadutil/libthreadutil.la \
@ -23,8 +19,11 @@ LDADD = \
upnpincludedir = $(includedir)/upnp
upnpinclude_HEADERS = \
inc/UpnpString.h \
inc/upnp.h \
inc/upnpdebug.h
inc/upnpdebug.h \
inc/UpnpGlobal.h \
inc/UpnpInet.h
nodist_upnpinclude_HEADERS = inc/upnpconfig.h
if ENABLE_TOOLS
@ -50,7 +49,6 @@ libupnp_la_SOURCES = \
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 \
@ -69,13 +67,13 @@ libupnp_la_SOURCES = \
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/VirtualDir.h \
src/inc/webserver.h
# ssdp
@ -114,10 +112,14 @@ libupnp_la_SOURCES += \
src/gena/gena_callback2.c
# api
libupnp_la_SOURCES += src/api/upnpapi.c
libupnp_la_SOURCES += \
src/api/UpnpString.c \
src/api/upnpapi.c
if ENABLE_TOOLS
libupnp_la_SOURCES += src/api/upnptools.c
endif
if ENABLE_DEBUG
libupnp_la_SOURCES += src/api/upnpdebug.c
endif
@ -134,6 +136,12 @@ libupnp_la_SOURCES += \
libupnp_la_SOURCES += src/urlconfig/urlconfig.c
# inet_pton (needed on Win32, compiles to nothing elsewhere)
libupnp_la_SOURCES += \
src/inet_pton.c \
src/inc/inet_pton.h
# check / distcheck tests
check_PROGRAMS = test_init
TESTS = test_init
@ -142,8 +150,7 @@ test_init_SOURCES = test/test_init.c
EXTRA_DIST = \
LICENSE \
src/inc/inet_pton.h \
src/inet_pton.c \
m4/libupnp.m4 \
src/win_dll.c

120
upnp/inc/UpnpGlobal.h Normal file
View File

@ -0,0 +1,120 @@
#ifndef UPNPGLOBAL_H
#define UPNPGLOBAL_H
/*!
* \file
*
* \brief Defines constants that for some reason are not defined on some systems.
*/
#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
#ifdef WIN32
/*
* EXPORT_SPEC
*/
#ifdef UPNP_STATIC_LIB
#define EXPORT_SPEC
#else /* 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 /* LIBUPNP_EXPORTS */
#define EXPORT_SPEC __declspec(dllimport)
#endif /* LIBUPNP_EXPORTS */
#endif /* UPNP_STATIC_LIB */
/*
* UPNP_INLINE
* PRId64
* PRIzu
*/
#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 /* UPNP_USE_MSVCPP */
#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,
#warning please someone provide a proper fix here
#define PRId64 "I64d"
#define PRIzu "zu"
#endif /* UPNP_USE_BCBPP */
#ifdef __GNUC__
#define UPNP_INLINE inline
/* Note with PRIzu that in the case of Mingw32, it's the MS C
* runtime printf which ends up getting called, not the glibc
* printf, so it genuinely doesn't have "zu"
*/
#define PRIzu "lu"
#endif /* __GNUC__ */
#else
/*!
* \brief Export functions on WIN32 DLLs.
*
* Every funtion that belongs to the library API must use this
* definition upon declaration or it will not be exported on WIN32
* DLLs.
*/
#define EXPORT_SPEC
/*!
* \brief Declares an inline function.
*
* Surprisingly, there are some compilers that do not understand the
* inline keyword. This definition makes the use of this keyword
* portable to these systems.
*/
#define UPNP_INLINE inline
/*!
* \brief Supply the PRId64 printf() macro.
*
* MSVC still does not know about this.
*/
/* #define PRId64 PRId64 */
/*!
* \brief Supply the PRIzu printf() macro.
*
* This macro was invented so that we can live a little longer with
* MSVC lack of C99. "z" is the correct printf() size specifier for
* the size_t type.
*/
#define PRIzu "zu"
#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*/
#endif /* UPNPGLOBAL_H */

38
upnp/inc/UpnpInet.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef UPNPINET_H
#define UPNPINET_H
/*!
* \file
*
* \brief Provides a platform independent way to include TCP/IP types and functions.
*/
#ifdef WIN32
#include <iphlpapi.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#define UpnpCloseSocket closesocket
#else
#include <sys/param.h>
#if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__)
#include <ifaddrs.h>
/* Do not move or remove the include below for "sys/socket"!
* Will break FreeBSD builds. */
#include <sys/socket.h>
#endif
#include <netinet/in.h>
#include <unistd.h> /* for close(). Do not include in WIN32. */
#define SOCKET int
#define INVALID_SOCKET ((SOCKET)(-1))
#define UpnpCloseSocket close
#endif
#endif /* UPNPINET_H */

171
upnp/inc/UpnpString.h Normal file
View File

@ -0,0 +1,171 @@
#ifndef STRING_H
#define STRING_H
/*!
* \defgroup UpnpString The UpnpString Class
*
* \brief Implements string operations in the UPnP library.
*
* \author Marcelo Roberto Jimenez
*
* \version 1.0
*
* @{
*
* \file
*
* \brief UpnpString object declarartion.
*/
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include <stdlib.h> /* for size_t */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*!
* \brief Type of the string objects inside libupnp.
*/
typedef struct s_UpnpString UpnpString;
/*!
* \brief Constructor.
*
* \return A pointer to a new allocated object.
*/
EXPORT_SPEC UpnpString *UpnpString_new();
/*!
* \brief Destructor.
*/
EXPORT_SPEC void UpnpString_delete(
/*! [in] The \em \b this pointer. */
UpnpString *p);
/*!
* \brief Copy Constructor.
*
* \return A pointer to a new allocated copy of the original object.
*/
EXPORT_SPEC UpnpString *UpnpString_dup(
/*! [in] The \em \b this pointer. */
const UpnpString *p);
/*!
* \brief Assignment operator.
*/
EXPORT_SPEC void UpnpString_assign(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] The \em \b that pointer. */
const UpnpString *q);
/*!
* \brief Returns the length of the string.
*
* \return The length of the string.
* */
EXPORT_SPEC size_t UpnpString_get_Length(
/*! [in] The \em \b this pointer. */
const UpnpString *p);
/*!
* \brief Truncates the string to the specified lenght, or does nothing
* if the current lenght is less than or equal to the requested length.
* */
EXPORT_SPEC void UpnpString_set_Length(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] The requested length. */
size_t n);
/*!
* \brief Returns the pointer to char.
*
* \return The pointer to char.
*/
EXPORT_SPEC const char *UpnpString_get_String(
/*! [in] The \em \b this pointer. */
const UpnpString *p);
/*!
* \brief Sets the string from a pointer to char.
*/
EXPORT_SPEC int UpnpString_set_String(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] (char *) to copy from. */
const char *s);
/*!
* \brief Sets the string from a pointer to char using a maximum of N chars.
*/
EXPORT_SPEC int UpnpString_set_StringN(
/*! [in] The \em \b this pointer. */
UpnpString *p,
/*! [in] (char *) to copy from. */
const char *s,
/*! Maximum number of chars to copy.*/
size_t n);
/*!
* \brief Clears the string, sets its size to zero.
*/
EXPORT_SPEC void UpnpString_clear(
/*! [in] The \em \b this pointer. */
UpnpString *p);
/*!
* \brief Compares two strings for equality. Case matters.
*
* \return The result of strcmp().
*/
EXPORT_SPEC int UpnpString_cmp(
/*! [in] The \em \b the first string. */
UpnpString *p,
/*! [in] The \em \b the second string. */
UpnpString *q);
/*!
* \brief Compares two strings for equality. Case does not matter.
*
* \return The result of strcasecmp().
*/
EXPORT_SPEC int UpnpString_casecmp(
/*! [in] The \em \b the first string. */
UpnpString *p,
/*! [in] The \em \b the second string. */
UpnpString *q);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* @} UpnpString The UpnpString API */
#endif /* STRING_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* -*- 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
@ -52,7 +52,7 @@
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
((UPNP_VERSION_MAJOR*100 + UPNP_VERSION_MINOR)*100 + UPNP_VERSION_PATCH)
((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + UPNP_VERSION_PATCH)
@ -90,6 +90,9 @@
* (i.e. configure --enable-tools) : <upnp/upnptools.h> file is available */
#undef UPNP_HAVE_TOOLS
/** Defined to 1 if the library has been compiled with ipv6 support
* (i.e. configure --enable-ipv6) */
#undef UPNP_ENABLE_IPV6
#endif /* UPNP_CONFIG_H */

View File

@ -7,12 +7,12 @@
* 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,
* - 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,
* - 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
* - 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.
*
@ -33,25 +33,34 @@
#ifndef UPNP_DEBUG_H
#define UPNP_DEBUG_H
#include "upnp.h"
/*!
* \file
*/
#include "ThreadPool.h"
#include "upnpconfig.h"
#include "UpnpGlobal.h" /* for UPNP_INLINE */
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @name Other debugging features
The UPnP SDK contains other features to aid in debugging.
/** \name Other debugging features
*
* The UPnP SDK contains other features to aid in debugging.
*/
/*@{*/
/*! @{ */
/** @name Upnp_LogLevel
/** \name Upnp_LogLevel
* The user has the option to select 4 different types of debugging levels,
* see {\tt UpnpSetLogLevel}.
* see \c UpnpSetLogLevel.
* The critical level will show only those messages
* which can halt the normal processing of the library, like memory
* allocation errors. The remaining three levels are just for debugging
@ -60,14 +69,11 @@ extern "C" {
* Info Level displays the other important operational information
* regarding the working of the library. If the user selects All,
* then the library displays all the debugging information that it has.
* \begin{itemize}
* \item {\tt UPNP_CRITICAL [0]}
* \item {\tt UPNP_PACKET [1]}
* \item {\tt UPNP_INFO [2]}
* \item {\tt UPNP_ALL [3]}
* \end{itemize}
* \li \c UPNP_CRITICAL [0]
* \li \c UPNP_PACKET [1]
* \li \c UPNP_INFO [2]
* \li \c UPNP_ALL [3]
*/
typedef enum Upnp_Module {
SSDP,
SOAP,
@ -79,91 +85,69 @@ typedef enum Upnp_Module {
HTTP
} Dbg_Module;
/*! @{ */
/*@{*/
typedef enum Upnp_LogLevel_e {
UPNP_CRITICAL,
UPNP_PACKET,
UPNP_INFO,
UPNP_ALL
} Upnp_LogLevel;
/*! @} */
/*@}*/
/**
* Default log level : see {\tt Upnp_LogLevel}
* Default log level : see \c Upnp_LogLevel
*/
#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
/***************************************************************************
* Function : UpnpInitLog
/*!
* \brief Initialize the log files.
*
* Parameters: void
*
* Description:
* This functions initializes the log files
*
* Returns: int
* -1 : If fails
* UPNP_E_SUCCESS : if success
***************************************************************************/
* \return -1 if fails or UPNP_E_SUCCESS if succeeds.
*/
#ifdef DEBUG
int UpnpInitLog();
int UpnpInitLog(void);
#else
static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; }
static UPNP_INLINE int UpnpInitLog(void)
{
return UPNP_E_SUCCESS;
}
#endif
/***************************************************************************
* Function : UpnpSetLogLevel
*
* Parameters: Upnp_LogLevel log_level
*
* Description:
* This functions set the log level (see {\tt Upnp_LogLevel}
* Returns: void
***************************************************************************/
/*!
* \brief Set the log level (see \c Upnp_LogLevel).
*/
#ifdef DEBUG
void UpnpSetLogLevel(Upnp_LogLevel log_level);
void UpnpSetLogLevel(
/*! [in] Log level. */
Upnp_LogLevel log_level);
#else
static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
#endif
/***************************************************************************
* Function : UpnpCloseLog
*
* Parameters: void
*
* Description:
* This functions closes the log files
* Returns: void
***************************************************************************/
/*!
* \brief Closes the log files.
*/
#ifdef DEBUG
void UpnpCloseLog();
void UpnpCloseLog(void);
#else
static UPNP_INLINE void UpnpCloseLog() {}
static UPNP_INLINE void UpnpCloseLog(void) {}
#endif
/***************************************************************************
* Function : UpnpSetLogFileNames
*
* Parameters:
* IN const char* ErrFileName: name of the error file
* IN const char *InfoFileName: name of the information file
* IN int size: Size of the buffer
* IN int starLength: This parameter provides the width of the banner
*
* Description:
* This functions takes the buffer and writes the buffer in the file as
* per the requested banner
* Returns: void
***************************************************************************/
/*!
* \brief Set the name for error and information files, respectively.
*/
#ifdef DEBUG
void UpnpSetLogFileNames(
/*! [in] Name of the error file. */
const char *ErrFileName,
/*! [in] Name of the information file. */
const char *InfoFileName);
#else
static UPNP_INLINE void UpnpSetLogFileNames(
@ -172,24 +156,20 @@ static UPNP_INLINE void UpnpSetLogFileNames(
#endif
/***************************************************************************
* Function : UpnpGetDebugFile
*
* 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 function checks if the module is turned on for debug
* and returns the file descriptor corresponding to the debug level
* Returns: FILE *
* NULL : if the module is turn off for debug
* else returns the right file descriptor
***************************************************************************/
/*!
* \brief Check if the module is turned on for debug and returns the file
* descriptor corresponding to the debug level
*
* \return NULL if the module is turn off for debug otheriwse returns the
* right file descriptor.
*/
#ifdef DEBUG
FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module);
FILE *UpnpGetDebugFile(
/*! [in] The level of the debug logging. It will decide whether debug
* statement will go to standard output, or any of the log files. */
Upnp_LogLevel level,
/*! [in] debug will go in the name of this module. */
Dbg_Module module);
#else
static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
{
@ -198,96 +178,98 @@ static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module
#endif
/***************************************************************************
* 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.
/*!
* \brief Returns true if debug output should be done in this module.
*
* Returns: int
***************************************************************************/
* \return Nonzero value if true, zero if false.
*/
#ifdef DEBUG
int DebugAtThisLevel(
IN Upnp_LogLevel DLevel,
IN Dbg_Module Module);
/*! [in] The level of the debug logging. It will decide whether debug
* statement will go to standard output, or any of the log files. */
Upnp_LogLevel DLevel,
/*! [in] Debug will go in the name of this module. */
Dbg_Module Module);
#else
static UPNP_INLINE int DebugAtThisLevel(
IN Upnp_LogLevel DLevel,
IN Dbg_Module Module) { return 0; }
Upnp_LogLevel DLevel,
Dbg_Module Module)
{
return 0;
}
#endif
/***************************************************************************
* Function : UpnpPrintf
*
* 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
* IN char *DbgFileName: Name of the file from where debug statement is
* coming
* IN int DbgLineNo : Line number of the file from where debug statement
* is coming
* IN char * FmtStr, ...: Variable number of arguments that will go
* in the debug statement
*
* Description:
* This functions prints the debug statement either on the startdard
* output or log file along with the information from where this
* debug statement is coming
* Returns: void
***************************************************************************/
/*!
* \brief Prints the debug statement either on the standard output or log file
* along with the information from where this debug statement is coming.
*/
#ifdef DEBUG
void UpnpPrintf(
/*! [in] The level of the debug logging. It will decide whether debug
* statement will go to standard output, or any of the log files. */
Upnp_LogLevel DLevel,
/*! [in] debug will go in the name of this module. */
Dbg_Module Module,
/*! [in] Name of the file from where debug statement is coming. */
const char* DbgFileName,
/*! [in] Line number of the file from where debug statement is coming. */
int DbgLineNo,
/*! [in] Printf like format specification. */
const char* FmtStr,
/*! [in] Printf like Variable number of arguments that will go in the debug
* statement. */
...)
#if (__GNUC__ >= 3)
/* This enables printf like format checking by the compiler */
__attribute__((format (__printf__, 5, 6)))
#endif
;
#else
#else /* DEBUG */
static UPNP_INLINE void UpnpPrintf(
Upnp_LogLevel DLevel,
Dbg_Module Module,
const char* DbgFileName,
int DbgLineNo,
const char* FmtStr,
...) {}
...)
{
}
#endif /* DEBUG */
/*!
* \brief Writes the file name and file number from where debug statement is
* coming to the log file.
*/
#ifdef DEBUG
void UpnpDisplayFileAndLine(
/*! [in] File descriptor where line number and file name will be written. */
FILE *fd,
/*! [in] Name of the file. */
const char *DbgFileName,
/*! [in] Line number of the file. */
int DbgLineNo);
#else
static UPNP_INLINE void UpnpDisplayFileAndLine(
FILE *fd,
const char *DbgFileName,
int DbgLineNo) {}
#endif
/***************************************************************************
* Function : UpnpDisplayBanner
*
* Parameters:
* IN FILE *fd: file descriptor where the banner will be written
* IN char **lines: The buffer that will be written
* IN int size: Size of the buffer
* IN int starLength: This parameter provides the width of the banner
*
* Description:
* This functions takes the buffer and writes the buffer in the file as
* per the requested banner
* Returns: void
***************************************************************************/
/*!
* \brief Writes the buffer in the file as per the requested banner
*/
#ifdef DEBUG
void UpnpDisplayBanner(
/*! [in] file descriptor where the banner will be written. */
FILE *fd,
/*! [in] The buffer that will be written. */
const char **lines,
/*! [in] Size of the buffer. */
size_t size,
/*! [in] This parameter provides the width of the banner. */
int starlength);
#else
static UPNP_INLINE void UpnpDisplayBanner(
@ -298,33 +280,31 @@ static UPNP_INLINE void UpnpDisplayBanner(
#endif
/***************************************************************************
* Function : UpnpDisplayFileAndLine
*
* Parameters:
* IN FILE *fd: File descriptor where line number and file name will be
* written
* IN char *DbgFileName: Name of the file
* IN int DbgLineNo : Line number of the file
*
* Description:
* This function writes the file name and file number from where
* debug statement is coming to the log file
* Returns: void
***************************************************************************/
/*!
* \brief Prints thread pool statistics.
*/
#ifdef DEBUG
void UpnpDisplayFileAndLine(
FILE *fd,
void PrintThreadPoolStats(
/*! [in] The thread pool. */
ThreadPool *tp,
/*! [in] The file name that called this function, use the macro __FILE__. */
const char *DbgFileName,
int DbgLineNo);
/*! [in] The line number that the function was called, use the macro __LINE__. */
int DbgLineNo,
/*! [in] The message. */
const char *msg);
#else
static UPNP_INLINE void UpnpDisplayFileAndLine(
FILE *fd,
static UPNP_INLINE void PrintThreadPoolStats(
ThreadPool *tp,
const char *DbgFileName,
int DbgLineNo) {}
int DbgLineNo,
const char *msg)
{
}
#endif
/*! @} */
/*@}*/
#ifdef __cplusplus
}

View File

@ -29,201 +29,237 @@
*
******************************************************************************/
/** @name Optional Tool APIs
* The Linux SDK for UPnP Devices contains some additional, optional
* utility APIs that can be helpful in writing applications using the
* SDK. These additional APIs can be compiled out in order to save code
* size in the SDK. Refer to the README for details.
*/
/*! @{ */
#ifndef UPNP_TOOLS_H
#define UPNP_TOOLS_H
#include "upnp.h"
/*!
* \file
*
* \defgroup UPnPTools Optional Tool API
*
* \brief Additional, optional utility API that can be helpful in writing
* applications.
*
* This additional API can be compiled out in order to save code size in the
* library. Refer to the file README for details.
*
* @{
*/
#include "ixml.h" /* for IXML_Document */
/* Function declarations only if tools compiled into the library */
#if UPNP_HAVE_TOOLS
#ifdef __cplusplus
extern "C" {
#endif
/** {\bf UpnpResolveURL} combines a base URL and a relative URL into
* a single absolute URL. The memory for {\bf AbsURL} needs to be
* allocated by the caller and must be large enough to hold the
* {\bf BaseURL} and {\bf RelURL} combined.
/*!
* \brief Converts an SDK error code into a string error message suitable for
* display. The memory returned from this function should NOT be freed.
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: {\bf RelURL} is {\tt NULL}.
* \item {\tt UPNP_E_INVALID_URL}: The {\bf BaseURL} / {\bf RelURL}
* \return An ASCII text string representation of the error message associated
* with the error code or the string "Unknown error code"
*/
EXPORT_SPEC const char *UpnpGetErrorMessage(
/*! [in] The SDK error code to convert. */
int errorcode);
/*!
* \brief Combines a base URL and a relative URL into a single absolute URL.
*
* The memory for \b AbsURL needs to be allocated by the caller and must
* be large enough to hold the \b BaseURL and \b RelURL combined.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: \b RelURL is <tt>NULL</tt>.
* \li <tt>UPNP_E_INVALID_URL</tt>: The \b BaseURL / \b RelURL
* combination does not form a valid URL.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
* \end{itemize}
*/
EXPORT_SPEC int UpnpResolveURL(
IN const char * BaseURL, /** The base URL to combine. */
IN const char * RelURL, /** The relative URL to {\bf BaseURL}. */
OUT char * AbsURL /** A pointer to a buffer to store the
absolute URL. */
);
/*! [in] The base URL to combine. */
const char *BaseURL,
/*! [in] The relative URL to \b BaseURL. */
const char *RelURL,
/*! [out] A pointer to a buffer to store the absolute URL. */
char *AbsURL);
/** {\bf UpnpMakeAction} creates an action request packet based on its input
* parameters (status variable name and value pair). Any number of input
* parameters can be passed to this function but every input variable name
* should have a matching value argument.
*
* @return [IXML_Document*] The action node of {\bf Upnp_Document} type or
* {\tt NULL} if the operation failed.
*/
EXPORT_SPEC IXML_Document* UpnpMakeAction(
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN int NumArg, /** Number of argument pairs to be passed. */
IN const char * Arg, /** Status variable name and value pair. */
IN ... /* Other status variable name and value pairs. */
);
/** {\bf UpnpAddToAction} creates an action request packet based on its input
* parameters (status variable name and value pair). This API is specially
* suitable inside a loop to add any number input parameters into an existing
* action. If no action document exists in the beginning then a
* {\bf Upnp_Document} variable initialized with {\tt NULL} should be passed
* as a parameter.
/*!
* \brief Creates an action request packet based on its input parameters
* (status variable name and value pair).
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
* Any number of input parameters can be passed to this function but every
* input variable name should have a matching value argument.
*
* It is a wrapper function that calls makeAction() function to create the
* action request.
*
* \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
* operation failed.
*/
EXPORT_SPEC IXML_Document *UpnpMakeAction(
/*! [in] Name of the action request or response. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] Number of argument pairs to be passed. */
int NumArg,
/*! [in] pointer to the first argument. */
const char *Arg,
/*! [in] Argument list. */
...);
/*!
* \brief Ceates an action response packet based on its output parameters
* (status variable name and value pair).
*
* Any number of input parameters can be passed to this function but every
* output variable name should have a matching value argument.
*
* It is a wrapper function that calls makeAction() function to create the
* action request.
*
* \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
* operation failed.
*/
EXPORT_SPEC IXML_Document *UpnpMakeActionResponse(
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type.. */
const char *ServType,
/*! [in] The number of argument pairs passed. */
int NumArg,
/*! [in] The status variable name and value pair. */
const char *Arg,
/*! [in] Other status variable name and value pairs. */
...);
/*!
* \brief Adds the argument in the action request.
*
* This API is specially suitable inside a loop to add any number input
* parameters into an existing action. If no action document exists in the
* beginning then a <b>Upnp_Document variable initialized with <tt>NULL</tt></b>
* should be passed as a parameter.
*
* It is a wrapper function that calls addToAction() function to add the
* argument in the action request.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToAction(
IN OUT IXML_Document ** ActionDoc,
/** A pointer to store the action
document node. */
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] A pointer to store the action document node. */
IXML_Document **ActionDoc,
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpMakeActionResponse} creates an action response packet based
* on its output parameters (status variable name and value pair). Any
* number of input parameters can be passed to this function but every output
* variable name should have a matching value argument.
*
* @return [IXML_Document*] The action node of {\bf Upnp_Document} type or
* {\tt NULL} if the operation failed.
*/
EXPORT_SPEC IXML_Document* UpnpMakeActionResponse(
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN int NumArg, /** The number of argument pairs passed. */
IN const char * Arg, /** The status variable name and value pair. */
IN ... /* Other status variable name and value pairs. */
);
/** {\bf UpnpAddToActionResponse} creates an action response
* packet based on its output parameters (status variable name
* and value pair). This API is especially suitable inside
* a loop to add any number of input parameters into an existing action
* response. If no action document exists in the beginning, a
* {\bf Upnp_Document} variable initialized with {\tt NULL} should be passed
* as a parameter.
/*!
* \brief Creates an action response packet based on its output parameters
* (status variable name and value pair).
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
* This API is especially suitable inside a loop to add any number of input
* parameters into an existing action response. If no action document exists
* in the beginning, a \b Upnp_Document variable initialized with <tt>NULL</tt>
* should be passed as a parameter.
*
* It is a wrapper function that calls addToAction() function to add the
* argument in the action request.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToActionResponse(
IN OUT IXML_Document ** ActionResponse,
/** Pointer to a document to
store the action document
node. */
IN const char * ActionName, /** The action name. */
IN const char * ServType, /** The service type. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] Pointer to a document to store the action document node. */
IXML_Document **ActionResponse,
/*! [in] The action name. */
const char *ActionName,
/*! [in] The service type. */
const char *ServType,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpAddToPropertySet} can be used when an application needs to
* transfer the status of many variables at once. It can be used
* (inside a loop) to add some extra status variables into an existing
* property set. If the application does not already have a property
* set document, the application should create a variable initialized
* with {\tt NULL} and pass that as the first parameter.
*
* @return [int] An integer representing one of the following:
* \begin{itemize}
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
* are invalid.
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
* complete this operation.
* \end{itemize}
/*!
* \brief Creates a property set message packet.
*
* Any number of input parameters can be passed to this function but every
* input variable name should have a matching value input argument.
*
* \return <tt>NULL</tt> on failure, or the property-set document node.
*/
EXPORT_SPEC IXML_Document *UpnpCreatePropertySet(
/*! [in] The number of argument pairs passed. */
int NumArg,
/*! [in] The status variable name and value pair. */
const char *Arg,
/*! [in] Variable sized list with the rest of the parameters. */
...);
/*!
* \brief Can be used when an application needs to transfer the status of many
* variables at once.
*
* It can be used (inside a loop) to add some extra status variables into an
* existing property set. If the application does not already have a property
* set document, the application should create a variable initialized with
* <tt>NULL</tt> and pass that as the first parameter.
*
* \return An integer representing one of the following:
* \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
* \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
* \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
* complete this operation.
*/
EXPORT_SPEC int UpnpAddToPropertySet(
IN OUT IXML_Document **PropSet,
/** A pointer to the document containing
the property set document node. */
IN const char * ArgName, /** The status variable name. */
IN const char * ArgVal /** The status variable value. */
);
/*! [in,out] A pointer to the document containing the property set document node. */
IXML_Document **PropSet,
/*! [in] The status variable name. */
const char *ArgName,
/*! [in] The status variable value. */
const char *ArgVal);
/** {\bf UpnpCreatePropertySet} creates a property set
* message packet. Any number of input parameters can be passed
* to this function but every input variable name should have
* a matching value input argument.
*
* @return [IXML_Document*] {\tt NULL} on failure, or the property-set
* document node.
*
*/
EXPORT_SPEC IXML_Document* UpnpCreatePropertySet(
IN int NumArg, /** The number of argument pairs passed. */
IN const char* Arg, /** The status variable name and value pair. */
IN ...
);
/** {\bf UpnpGetErrorMessage} converts an SDK error code into a
* string error message suitable for display. The memory returned
* from this function should NOT be freed.
*
* @return [char*] An ASCII text string representation of the error message
* associated with the error code.
*/
EXPORT_SPEC const char * UpnpGetErrorMessage(
int errorcode /** The SDK error code to convert. */
);
/*! @} */
#ifdef __cplusplus
}
#endif
/*! @} */
#endif /* UPNP_HAVE_TOOLS */
#endif /* UPNP_TOOLS_H */

97
upnp/m4/libupnp.m4 Normal file
View File

@ -0,0 +1,97 @@
# -*- Autoconf -*-
# This file is part of the aMule project.
# This file is part of the libupnp library project.
#
# Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
dnl --------------------------------------------------------------------------
dnl LIBUPNP_CHECK([VERSION = 1.6.6], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl
dnl Check for the libupnp library
dnl --------------------------------------------------------------------------
dnl
dnl This macro sets these variables:
dnl - LIBUPNP_VERSION
dnl Something like "1.6.7"
dnl - LIBUPNP_CPPFLAGS
dnl Flags to be added to CPPFLAGS
dnl - LIBUPNP_CFLAGS
dnl Flags to be added to CFLAGS
dnl - LIBUPNP_LDFLAGS
dnl Flags to be added to LDFLAGS
dnl - LIBUPNP_LIBS
dnl Library to be added to LIBS
dnl
dnl The LIBUPNP_CPPFLAGS, LIBUPNP_CFLAGS, LIBUPNP_LDFLAGS and LIBUPNP_LIBS variables are also substituted.
dnl
AC_DEFUN([LIBUPNP_CHECK],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
m4_define([MIN_LIBUPNP_VERSION], [m4_ifval([$1], [$1], [1.6.6])])dnl
dnl Test for --with-libupnp-prefix
AC_ARG_WITH(
[libupnp-prefix],
[AS_HELP_STRING(
[--with-libupnp-prefix=PREFIX],
[UPnP library location])],
[export PKG_CONFIG_PATH=$withval/lib/pkgconfig])
dnl Check for libupnp >= MIN_LIBUPNP_VERSION
AS_IF([test $cross_compiling = no], [
AC_MSG_CHECKING([for libupnp version >= MIN_LIBUPNP_VERSION])
AS_IF([test -n "$PKG_CONFIG"], [
AS_IF([$PKG_CONFIG libupnp --exists], [
LIBUPNP_VERSION=`$PKG_CONFIG libupnp --modversion`
AS_IF([$PKG_CONFIG libupnp --atleast-version=MIN_LIBUPNP_VERSION], [
result=yes
resultstr=" (version $LIBUPNP_VERSION)"
LIBUPNP_CPPFLAGS=`$PKG_CONFIG libupnp --cflags-only-I`
LIBUPNP_CFLAGS=`$PKG_CONFIG libupnp --cflags-only-other`
LIBUPNP_LDFLAGS=`$PKG_CONFIG libupnp --libs-only-L`
LIBUPNP_LIBS=`$PKG_CONFIG libupnp --libs-only-other`
LIBUPNP_LIBS="$LIBUPNP_LIBS `$PKG_CONFIG libupnp --libs-only-l`"
], [
result=no
resultstr=" (version $LIBUPNP_VERSION is not new enough)"
])
], [
result=no
resultstr=" (try to use --with-libupnp-prefix=PREFIX)"
])
], [
result=no
resultstr=" (pkg-config not found)"
])
AC_MSG_RESULT([$result$resultstr])
libupnp_error="libupnp >= MIN_LIBUPNP_VERSION not found$resultstr"
], [
dnl Currently cross-compilation with libupnp is not supported.
result=no
libupnp_error="cross compiling"
])
dnl Execute the right action.
AS_IF([test ${result:-no} = yes], [$2], [$3])
dnl Exported symbols
AC_SUBST([LIBUPNP_CPPFLAGS])dnl
AC_SUBST([LIBUPNP_CFLAGS])dnl
AC_SUBST([LIBUPNP_LDFLAGS])dnl
AC_SUBST([LIBUPNP_LIBS])dnl
m4_undefine([MIN_LIBUPNP_VERSION])dnl
])

View File

@ -9,10 +9,6 @@ AM_CPPFLAGS = \
-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 \
@ -73,8 +69,9 @@ upnp_tv_combo_SOURCES = \
if WITH_DOCUMENTATION
examplesdir = $(docdir)/examples
examples_DATA = \
$(upnp_tv_ctrlpt_SOURCES) \
$(upnp_tv_device_SOURCES)
$(sort \
$(upnp_tv_ctrlpt_SOURCES) \
$(upnp_tv_device_SOURCES))
endif

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,63 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 SAMPLE_UTIL_H
#define SAMPLE_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#include "ithread.h"
#include "ixml.h" /* for IXML_Document, IXML_Element */
#include "upnp.h" /* for Upnp_EventType */
#include "upnptools.h"
#include <stdlib.h>
#include <string.h>
#include "upnptools.h"
#include "ithread.h"
#include "ixml.h"
//mutex to control displaying of events
extern ithread_mutex_t display_mutex ;
/* mutex to control displaying of events */
extern ithread_mutex_t display_mutex;
typedef enum {
STATE_UPDATE = 0,
DEVICE_ADDED =1,
DEVICE_REMOVED=2,
GET_VAR_COMPLETE=3
DEVICE_ADDED = 1,
DEVICE_REMOVED = 2,
GET_VAR_COMPLETE = 3
} eventType;
@ -68,7 +74,7 @@ typedef enum {
* node -- The DOM node from which to extract the value
*
********************************************************************************/
char * SampleUtil_GetElementValue(IN IXML_Element *element);
char *SampleUtil_GetElementValue(IN IXML_Element *element);
/********************************************************************************
* SampleUtil_GetFirstServiceList
@ -85,7 +91,7 @@ char * SampleUtil_GetElementValue(IN IXML_Element *element);
*
********************************************************************************/
IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document * doc);
IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document *doc);
/********************************************************************************
@ -100,7 +106,7 @@ IXML_NodeList *SampleUtil_GetFirstServiceList(IN IXML_Document * doc);
* item -- The item to search for
*
********************************************************************************/
char * SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *item);
char *SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *item);
@ -116,7 +122,7 @@ char * SampleUtil_GetFirstDocumentItem(IN IXML_Document *doc, IN const char *ite
* item -- The item to search for
*
********************************************************************************/
char * SampleUtil_GetFirstElementItem(IN IXML_Element *element, IN const char *item);
char *SampleUtil_GetFirstElementItem(IN IXML_Element *element, IN const char *item);
/********************************************************************************
* SampleUtil_PrintEventType
@ -162,9 +168,13 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType,
* controlURL -- OUT -- The control URL for the service
*
********************************************************************************/
int SampleUtil_FindAndParseService (IN IXML_Document *DescDoc, IN char* location,
IN char *serviceType, OUT char **serviceId,
OUT char **eventURL, OUT char **controlURL);
int SampleUtil_FindAndParseService (
IN IXML_Document *DescDoc,
IN const char* location,
IN char *serviceType,
OUT char **serviceId,
OUT char **eventURL,
OUT char **controlURL);
/********************************************************************************
@ -196,8 +206,11 @@ extern print_string gPrintFun;
* const char * UDN
* int newDevice
********************************************************************************/
typedef void (*state_update)( const char *varName, const char *varValue, const char *UDN,
eventType type);
typedef void (*state_update)(
const char *varName,
const char *varValue,
const char *UDN,
eventType type);
//global state update function used by smaple util
extern state_update gStateUpdateFun;
@ -224,7 +237,7 @@ int SampleUtil_Initialize(print_string print_function);
* Parameters:
*
********************************************************************************/
int SampleUtil_Finish(void);
int SampleUtil_Finish();
/********************************************************************************
* SampleUtil_Print
@ -238,7 +251,7 @@ int SampleUtil_Finish(void);
* . . . - variable number of args. (see printf)
*
********************************************************************************/
int SampleUtil_Print( char *fmt, ... );
int SampleUtil_Print(char *fmt, ...);
/********************************************************************************
* SampleUtil_RegisterUpdateFunction
@ -248,7 +261,7 @@ int SampleUtil_Print( char *fmt, ... );
* Parameters:
*
********************************************************************************/
int SampleUtil_RegisterUpdateFunction( state_update update_function );
int SampleUtil_RegisterUpdateFunction(state_update update_function);
/********************************************************************************
* SampleUtil_StateUpdate
@ -258,11 +271,22 @@ int SampleUtil_RegisterUpdateFunction( state_update update_function );
* Parameters:
*
********************************************************************************/
void SampleUtil_StateUpdate( const char *varName, const char *varValue, const char *UDN,
eventType type);
void SampleUtil_StateUpdate(
const char *varName,
const char *varValue,
const char *UDN,
eventType type);
#ifdef __cplusplus
};
#endif /* __cplusplus */
#ifdef WIN32
#define snprintf _snprintf
#define strcasecmp stricmp
#endif
#endif /* UPNPSDK_UTIL_H */
#endif /* SAMPLE_UTIL_H */

View File

@ -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 "sample_util.h"
@ -130,7 +130,8 @@ TvCtrlPointPrintLongHelp( void )
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( "devices, described in the tvdevicedesc.xml description document." );
SampleUtil_Print( "It also registers itself as a tv device." );
SampleUtil_Print( "" );
SampleUtil_Print( "Commands:" );
SampleUtil_Print( " Help" );
@ -449,17 +450,18 @@ device_main( int argc, char **argv )
port = ( unsigned short )portTemp;
return TvDeviceStart(
ip_address, port, desc_doc_name, web_dir_path, linux_print );
return TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path, linux_print );
}
int
main( int argc, char **argv )
int main( int argc, char **argv )
{
int rc;
ithread_t cmdloop_thread;
#ifdef WIN32
#else
int sig;
sigset_t sigs_to_catch;
#endif
int code;
device_main(argc, argv);
@ -468,11 +470,12 @@ main( int argc, char **argv )
SampleUtil_Print( "Error starting UPnP TV Control Point" );
return rc;
}
// start a command loop thread
code =
ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop,
NULL );
/* start a command loop thread */
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
#ifdef WIN32
ithread_join(cmdloop_thread, NULL);
#else
/*
Catch Ctrl-C and properly shutdown
*/
@ -480,10 +483,9 @@ main( int argc, char **argv )
sigaddset( &sigs_to_catch, SIGINT );
sigwait( &sigs_to_catch, &sig );
SampleUtil_Print( "Shutting down on signal %d...", sig );
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
#endif
TvDeviceStop();
rc = TvCtrlPointStop();
return rc;
}

View File

@ -1,37 +1,42 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "upnp_tv_ctrlpt.h"
/*
#include "upnp.h"
/*!
Mutex for protecting the global device list
in a multi-threaded, asynchronous environment.
All functions should lock this mutex before reading
@ -48,7 +53,7 @@ char *TvServiceType[] = {
};
char *TvServiceName[] = { "Control", "Picture" };
/*
/*!
Global arrays for storing variable names and counts for
TvControl and TvPicture services
*/
@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
char TvVarCount[TV_SERVICE_SERVCOUNT] =
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
/*
/*!
Timeout to request during subscriptions
*/
int default_timeout = 1801;
/*
/*!
The first node in the global device list, or NULL if empty
*/
struct TvDeviceNode *GlobalDeviceList = NULL;
@ -138,11 +143,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
* UDN -- The Unique Device Name for the device to remove
*
********************************************************************************/
int
TvCtrlPointRemoveDevice( char *UDN )
int TvCtrlPointRemoveDevice(const char *UDN)
{
struct TvDeviceNode *curdevnode,
*prevdevnode;
struct TvDeviceNode *curdevnode;
struct TvDeviceNode *prevdevnode;
ithread_mutex_lock( &DeviceListMutex );
@ -224,7 +228,7 @@ TvCtrlPointRefresh( void )
{
int rc;
TvCtrlPointRemoveAll( );
TvCtrlPointRemoveAll();
/*
Search for all devices of type tvdevice version 1,
@ -539,7 +543,7 @@ TvCtrlPointGetDevice( int devnum,
*
********************************************************************************/
int
TvCtrlPointPrintList( )
TvCtrlPointPrintList()
{
struct TvDeviceNode *tmpdevnode;
int i = 0;
@ -668,8 +672,8 @@ TvCtrlPointPrintDevice( int devnum )
*
********************************************************************************/
void
TvCtrlPointAddDevice( IXML_Document * DescDoc,
char *location,
TvCtrlPointAddDevice( IXML_Document *DescDoc,
const char *location,
int expires )
{
char *deviceType = NULL;
@ -682,20 +686,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
int TimeOut[TV_SERVICE_SERVCOUNT] =
{ default_timeout, default_timeout };
int TimeOut[TV_SERVICE_SERVCOUNT] = {
default_timeout,
default_timeout };
struct TvDeviceNode *deviceNode;
struct TvDeviceNode *tmpdevnode;
int ret = 1;
int found = 0;
int service,
var;
int service;
int var;
ithread_mutex_lock( &DeviceListMutex );
/*
Read key elements from description document
*/
/* Read key elements from description document */
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
friendlyName =
@ -703,9 +706,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
ret =
UpnpResolveURL( ( baseURL ? baseURL : location ), relURL,
presURL );
ret = UpnpResolveURL(
( baseURL ? baseURL : location ), relURL, presURL);
if( UPNP_E_SUCCESS != ret )
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
@ -939,34 +941,36 @@ TvStateUpdate( char *UDN,
* changes -- The DOM document representing the changes
*
********************************************************************************/
void
TvCtrlPointHandleEvent( Upnp_SID sid,
int evntkey,
IXML_Document * changes )
void TvCtrlPointHandleEvent(
const char *sid,
int evntkey,
IXML_Document *changes)
{
struct TvDeviceNode *tmpdevnode;
int service;
struct TvDeviceNode *tmpdevnode;
int service;
ithread_mutex_lock( &DeviceListMutex );
ithread_mutex_lock(&DeviceListMutex);
tmpdevnode = GlobalDeviceList;
while( tmpdevnode ) {
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
0 ) {
SampleUtil_Print( "Received Tv %s Event: %d for SID %s",
TvServiceName[service], evntkey, sid );
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
changes,
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
break;
}
}
tmpdevnode = tmpdevnode->next;
}
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
( char ** )&tmpdevnode->device.
TvService[service].VariableStrVal );
break;
}
}
tmpdevnode = tmpdevnode->next;
}
ithread_mutex_unlock( &DeviceListMutex );
ithread_mutex_unlock(&DeviceListMutex);
}
/********************************************************************************
@ -983,10 +987,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid,
* timeout -- The new timeout for the subscription
*
********************************************************************************/
void
TvCtrlPointHandleSubscribeUpdate( char *eventURL,
Upnp_SID sid,
int timeout )
void TvCtrlPointHandleSubscribeUpdate(
const char *eventURL,
const Upnp_SID sid,
int timeout)
{
struct TvDeviceNode *tmpdevnode;
int service;
@ -1014,10 +1018,10 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL,
ithread_mutex_unlock( &DeviceListMutex );
}
void
TvCtrlPointHandleGetVar( char *controlURL,
char *varName,
DOMString varValue )
void TvCtrlPointHandleGetVar(
const char *controlURL,
const char *varName,
const DOMString varValue)
{
struct TvDeviceNode *tmpdevnode;
@ -1026,14 +1030,11 @@ TvCtrlPointHandleGetVar( char *controlURL,
ithread_mutex_lock( &DeviceListMutex );
tmpdevnode = GlobalDeviceList;
while( tmpdevnode ) {
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
if( strcmp
( tmpdevnode->device.TvService[service].ControlURL,
controlURL ) == 0 ) {
SampleUtil_StateUpdate( varName, varValue,
tmpdevnode->device.UDN,
GET_VAR_COMPLETE );
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
SampleUtil_StateUpdate(
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
break;
}
}
@ -1057,186 +1058,137 @@ TvCtrlPointHandleGetVar( char *controlURL,
* Cookie -- Optional data specified during callback registration
*
********************************************************************************/
int
TvCtrlPointCallbackEventHandler( Upnp_EventType EventType,
void *Event,
void *Cookie )
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
SampleUtil_PrintEvent( EventType, Event );
/*int errCode = 0;*/
switch ( EventType ) {
/*
SSDP Stuff
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
{
struct Upnp_Discovery *d_event =
( struct Upnp_Discovery * )Event;
IXML_Document *DescDoc = NULL;
int ret;
SampleUtil_PrintEvent(EventType, Event);
switch ( EventType ) {
/* SSDP Stuff */
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
IXML_Document *DescDoc = NULL;
int ret;
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error in Discovery Callback -- %d",
d_event->ErrCode );
}
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", d_event->ErrCode);
}
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
d_event->Location, ret);
} else {
TvCtrlPointAddDevice(
DescDoc, d_event->Location, d_event->Expires);
}
if (DescDoc) {
ixmlDocument_free(DescDoc);
}
TvCtrlPointPrintList();
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
if( ( ret =
UpnpDownloadXmlDoc( d_event->Location,
&DescDoc ) ) !=
UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error obtaining device description from %s -- error = %d",
d_event->Location, ret );
} else {
TvCtrlPointAddDevice( DescDoc, d_event->Location,
d_event->Expires );
}
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if( DescDoc )
ixmlDocument_free( DescDoc );
if (a_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d", a_event->ErrCode);
}
/* No need for any processing here, just print out results.
* Service state table updates are handled by events. */
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
TvCtrlPointPrintList( );
break;
}
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
} else {
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/*
Nothing to do here...
*/
break;
TvCtrlPointHandleEvent(
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
{
struct Upnp_Discovery *d_event =
( struct Upnp_Discovery * )Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Discovery ByeBye Callback -- %d",
d_event->ErrCode );
}
ret = UpnpSubscribe(
ctrlpt_handle,
es_event->PublisherUrl,
&TimeOut,
newSID);
if (ret == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
}
break;
}
/* ignore these cases, since this is not a device */
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
case UPNP_CONTROL_ACTION_REQUEST:
break;
}
SampleUtil_Print( "Received ByeBye for Device: %s",
d_event->DeviceId );
TvCtrlPointRemoveDevice( d_event->DeviceId );
SampleUtil_Print( "After byebye:" );
TvCtrlPointPrintList( );
break;
}
/*
SOAP Stuff
*/
case UPNP_CONTROL_ACTION_COMPLETE:
{
struct Upnp_Action_Complete *a_event =
( struct Upnp_Action_Complete * )Event;
if( a_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Action Complete Callback -- %d",
a_event->ErrCode );
}
/*
No need for any processing here, just print out results. Service state
table updates are handled by events.
*/
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE:
{
struct Upnp_State_Var_Complete *sv_event =
( struct Upnp_State_Var_Complete * )Event;
if( sv_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Get Var Complete Callback -- %d",
sv_event->ErrCode );
} else {
TvCtrlPointHandleGetVar( sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal );
}
break;
}
/*
GENA Stuff
*/
case UPNP_EVENT_RECEIVED:
{
struct Upnp_Event *e_event = ( struct Upnp_Event * )Event;
TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey,
e_event->ChangedVariables );
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE:
{
struct Upnp_Event_Subscribe *es_event =
( struct Upnp_Event_Subscribe * )Event;
if( es_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Event Subscribe Callback -- %d",
es_event->ErrCode );
} else {
TvCtrlPointHandleSubscribeUpdate( es_event->
PublisherUrl,
es_event->Sid,
es_event->TimeOut );
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED:
{
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
struct Upnp_Event_Subscribe *es_event =
( struct Upnp_Event_Subscribe * )Event;
ret =
UpnpSubscribe( ctrlpt_handle, es_event->PublisherUrl,
&TimeOut, newSID );
if( ret == UPNP_E_SUCCESS ) {
SampleUtil_Print( "Subscribed to EventURL with SID=%s",
newSID );
TvCtrlPointHandleSubscribeUpdate( es_event->
PublisherUrl, newSID,
TimeOut );
} else {
SampleUtil_Print
( "Error Subscribing to EventURL -- %d", ret );
}
break;
}
/*
ignore these cases, since this is not a device
*/
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
case UPNP_CONTROL_ACTION_REQUEST:
break;
}
return 0;
return 0;
}
/********************************************************************************
@ -1320,12 +1272,12 @@ TvCtrlPointVerifyTimeouts( int incr )
* None
*
********************************************************************************/
void *
TvCtrlPointTimerLoop( void *args )
static int TvCtrlPointTimerLoopRun = 1;
void *TvCtrlPointTimerLoop(void *args)
{
int incr = 30; // how often to verify the timeouts, in seconds
while( 1 ) {
while (TvCtrlPointTimerLoopRun) {
isleep( incr );
TvCtrlPointVerifyTimeouts( incr );
}
@ -1348,62 +1300,74 @@ TvCtrlPointTimerLoop( void *args )
* TV_SUCCESS if everything went well, else TV_ERROR
*
********************************************************************************/
int
TvCtrlPointStart( print_string printFunctionPtr,
state_update updateFunctionPtr )
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
{
ithread_t timer_thread;
int rc;
short int port = 0;
char *ip_address = NULL;
ithread_t timer_thread;
int rc;
unsigned short port = 0;
char *ip_address = NULL;
SampleUtil_Initialize( printFunctionPtr );
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
SampleUtil_Initialize(printFunctionPtr);
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
ithread_mutex_init( &DeviceListMutex, 0 );
ithread_mutex_init(&DeviceListMutex, 0);
SampleUtil_Print( "Intializing UPnP with ipaddress=%s port=%d",
ip_address, port );
rc = UpnpInit( ip_address, port );
if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
//UpnpFinish( );
//return TV_ERROR;
}
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
if( NULL == ip_address )
ip_address = UpnpGetServerIpAddress( );
if( 0 == port )
port = UpnpGetServerPort( );
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
/*
UpnpFinish();
return TV_ERROR;
*/
}
if (!ip_address) {
ip_address = UpnpGetServerIpAddress();
}
if (!port) {
port = UpnpGetServerPort();
}
SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port );
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
SampleUtil_Print( "Registering Control Point" );
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle );
if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish( );
return TV_ERROR;
}
SampleUtil_Print("Registering Control Point");
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle);
if (rc != UPNP_E_SUCCESS) {
SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish();
SampleUtil_Print( "Control Point Registered" );
return TV_ERROR;
}
TvCtrlPointRefresh( );
SampleUtil_Print("Control Point Registered");
// start a timer thread
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
TvCtrlPointRefresh();
return TV_SUCCESS;
/* start a timer thread */
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
ithread_detach(timer_thread);
return TV_SUCCESS;
}
int
TvCtrlPointStop( void )
int TvCtrlPointStop(void)
{
TvCtrlPointRemoveAll( );
UpnpUnRegisterClient( ctrlpt_handle );
UpnpFinish( );
SampleUtil_Finish( );
TvCtrlPointTimerLoopRun = 0;
TvCtrlPointRemoveAll();
UpnpUnRegisterClient( ctrlpt_handle );
UpnpFinish();
SampleUtil_Finish();
return TV_SUCCESS;
return TV_SUCCESS;
}

View File

@ -1,53 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// 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_TV_CTRLPT_H
#define UPNP_TV_CTRLPT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "sample_util.h"
#include "ithread.h"
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include "upnp.h"
#include "UpnpString.h"
#include "upnptools.h"
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "upnp.h"
#include "upnptools.h"
#include "sample_util.h"
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0
@ -66,12 +79,12 @@ extern "C" {
#define TV_MAX_VAL_LEN 5
#define TV_SUCCESS 0
#define TV_ERROR (-1)
#define TV_WARNING 1
#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
#define TV_MAXVARS TV_PICTURE_VARCOUNT
extern char TvDeviceType[];
extern char *TvServiceType[];
@ -108,11 +121,11 @@ 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 );
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll(void);
int TvCtrlPointRefresh(void);
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
@ -136,20 +149,20 @@ int TvCtrlPointGetContrast(int);
int TvCtrlPointGetBrightness(int);
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
int TvCtrlPointPrintList( void );
int TvCtrlPointPrintList(void);
int TvCtrlPointPrintDevice(int);
void TvCtrlPointAddDevice (IXML_Document *, char *, int);
void TvCtrlPointHandleGetVar(char *,char *,DOMString);
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
void TvStateUpdate(char*,int, IXML_Document * , char **);
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
void TvCtrlPointHandleEvent(const char *, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const 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 );
void TvCtrlPointPrintCommands(void);
void* TvCtrlPointCommandLoop(void *);
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
int TvCtrlPointStop(void);
int TvCtrlPointProcessCommand(char *cmdline);
#ifdef __cplusplus
};

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// 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_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"
#include "ithread.h"
#include "upnp.h"
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
//Color constants
#define MAX_COLOR 10
#define MIN_COLOR 1
@ -146,8 +161,7 @@ extern char *TvServiceType[];
*
*****************************************************************************/
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
char **errorString);
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
/* Structure for storing Tv Service
identifiers and state table */
@ -191,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
* struct TvService *out - service containing action table to set.
*
*****************************************************************************/
int SetActionTable(int serviceType, struct TvService * out);
int SetActionTable(int serviceType, struct TvService *out);
/******************************************************************************
* TvDeviceStateTableInit
@ -311,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDevicePowerOff
@ -327,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetChannel
@ -345,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseChannel
@ -361,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseChannel
*
@ -376,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetVolume
*
@ -393,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseVolume
@ -409,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
* 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);
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@ -426,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
//Picture Service Actions
@ -447,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@ -463,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
* 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);
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseColor
@ -478,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* 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);
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetTint
@ -496,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseTint
@ -512,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseTint
@ -528,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/*****************************************************************************
* TvDeviceSetContrast
@ -546,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
****************************************************************************/
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseContrast
@ -563,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseContrast
*
@ -578,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetBrightness
@ -593,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* brightness -- The brightness value to change to.
*
*****************************************************************************/
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseBrightness
@ -609,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseBrightness
@ -624,12 +619,11 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
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();
int TvDeviceStop(void);
#ifdef __cplusplus
}

View File

@ -1,37 +1,40 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 <stdio.h>
#include "sample_util.h"
#include "upnp_tv_ctrlpt.h"
#include <stdio.h>
#include <string.h>
/*
@ -124,108 +127,72 @@ TvCtrlPointPrintLongHelp( void )
SampleUtil_Print( "* TV Control Point Help Info *" );
SampleUtil_Print( "******************************" );
SampleUtil_Print( "" );
SampleUtil_Print
( "This sample control point application automatically searches" );
SampleUtil_Print
( "for and subscribes to the services of television device emulator" );
SampleUtil_Print
( "devices, described in the tvdevicedesc.xml description document." );
SampleUtil_Print( "This sample control point application automatically searches" );
SampleUtil_Print( "for and subscribes to the services of television device emulator" );
SampleUtil_Print( "devices, described in the tvdevicedesc.xml description document." );
SampleUtil_Print( "" );
SampleUtil_Print( "Commands:" );
SampleUtil_Print( " Help" );
SampleUtil_Print( " Print this help info." );
SampleUtil_Print( " ListDev" );
SampleUtil_Print
( " Print the current list of TV Device Emulators that this" );
SampleUtil_Print
( " control point is aware of. Each device is preceded by a" );
SampleUtil_Print
( " device number which corresponds to the devnum argument of" );
SampleUtil_Print( " Print the current list of TV Device Emulators that this" );
SampleUtil_Print( " control point is aware of. Each device is preceded by a" );
SampleUtil_Print( " device number which corresponds to the devnum argument of" );
SampleUtil_Print( " commands listed below." );
SampleUtil_Print( " Refresh" );
SampleUtil_Print
( " Delete all of the devices from the device list and issue new" );
SampleUtil_Print
( " search request to rebuild the list from scratch." );
SampleUtil_Print( " Delete all of the devices from the device list and issue new" );
SampleUtil_Print( " search request to rebuild the list from scratch." );
SampleUtil_Print( " PrintDev <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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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( " 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." );
@ -242,7 +209,7 @@ TvCtrlPointPrintLongHelp( void )
*
********************************************************************************/
void
TvCtrlPointPrintCommands( )
TvCtrlPointPrintCommands()
{
int i;
int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands );
@ -321,11 +288,11 @@ TvCtrlPointProcessCommand( char *cmdline )
switch ( cmdnum ) {
case PRTHELP:
TvCtrlPointPrintShortHelp( );
TvCtrlPointPrintShortHelp();
break;
case PRTFULLHELP:
TvCtrlPointPrintLongHelp( );
TvCtrlPointPrintLongHelp();
break;
case POWON:
@ -411,15 +378,15 @@ TvCtrlPointProcessCommand( char *cmdline )
break;
case LSTDEV:
TvCtrlPointPrintList( );
TvCtrlPointPrintList();
break;
case REFRESH:
TvCtrlPointRefresh( );
TvCtrlPointRefresh();
break;
case EXITCMD:
rc = TvCtrlPointStop( );
rc = TvCtrlPointStop();
exit( rc );
break;
@ -434,26 +401,29 @@ TvCtrlPointProcessCommand( char *cmdline )
return TV_SUCCESS;
}
int
main( int argc,
char **argv )
int main( int argc, char **argv )
{
int rc;
ithread_t cmdloop_thread;
#ifdef WIN32
#else
int sig;
sigset_t sigs_to_catch;
#endif
int code;
rc = TvCtrlPointStart( linux_print, NULL );
if( rc != TV_SUCCESS ) {
SampleUtil_Print( "Error starting UPnP TV Control Point" );
exit( rc );
return rc;
}
// start a command loop thread
code =
ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop,
NULL );
/* start a command loop thread */
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
#ifdef WIN32
ithread_join(cmdloop_thread, NULL);
#else
/*
Catch Ctrl-C and properly shutdown
*/
@ -461,7 +431,11 @@ main( int argc,
sigaddset( &sigs_to_catch, SIGINT );
sigwait( &sigs_to_catch, &sig );
SampleUtil_Print( "Shutting down on signal %d...", sig );
rc = TvCtrlPointStop( );
exit( rc );
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
#endif
rc = TvCtrlPointStop();
return rc;
}

View File

@ -1,37 +1,42 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "upnp_tv_ctrlpt.h"
/*
#include "upnp.h"
/*!
Mutex for protecting the global device list
in a multi-threaded, asynchronous environment.
All functions should lock this mutex before reading
@ -48,7 +53,7 @@ char *TvServiceType[] = {
};
char *TvServiceName[] = { "Control", "Picture" };
/*
/*!
Global arrays for storing variable names and counts for
TvControl and TvPicture services
*/
@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
char TvVarCount[TV_SERVICE_SERVCOUNT] =
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
/*
/*!
Timeout to request during subscriptions
*/
int default_timeout = 1801;
/*
/*!
The first node in the global device list, or NULL if empty
*/
struct TvDeviceNode *GlobalDeviceList = NULL;
@ -138,11 +143,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
* UDN -- The Unique Device Name for the device to remove
*
********************************************************************************/
int
TvCtrlPointRemoveDevice( char *UDN )
int TvCtrlPointRemoveDevice(const char *UDN)
{
struct TvDeviceNode *curdevnode,
*prevdevnode;
struct TvDeviceNode *curdevnode;
struct TvDeviceNode *prevdevnode;
ithread_mutex_lock( &DeviceListMutex );
@ -224,7 +228,7 @@ TvCtrlPointRefresh( void )
{
int rc;
TvCtrlPointRemoveAll( );
TvCtrlPointRemoveAll();
/*
Search for all devices of type tvdevice version 1,
@ -539,7 +543,7 @@ TvCtrlPointGetDevice( int devnum,
*
********************************************************************************/
int
TvCtrlPointPrintList( )
TvCtrlPointPrintList()
{
struct TvDeviceNode *tmpdevnode;
int i = 0;
@ -668,8 +672,8 @@ TvCtrlPointPrintDevice( int devnum )
*
********************************************************************************/
void
TvCtrlPointAddDevice( IXML_Document * DescDoc,
char *location,
TvCtrlPointAddDevice( IXML_Document *DescDoc,
const char *location,
int expires )
{
char *deviceType = NULL;
@ -682,20 +686,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
int TimeOut[TV_SERVICE_SERVCOUNT] =
{ default_timeout, default_timeout };
int TimeOut[TV_SERVICE_SERVCOUNT] = {
default_timeout,
default_timeout };
struct TvDeviceNode *deviceNode;
struct TvDeviceNode *tmpdevnode;
int ret = 1;
int found = 0;
int service,
var;
int service;
int var;
ithread_mutex_lock( &DeviceListMutex );
/*
Read key elements from description document
*/
/* Read key elements from description document */
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
friendlyName =
@ -703,9 +706,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
ret =
UpnpResolveURL( ( baseURL ? baseURL : location ), relURL,
presURL );
ret = UpnpResolveURL(
( baseURL ? baseURL : location ), relURL, presURL);
if( UPNP_E_SUCCESS != ret )
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
@ -939,34 +941,36 @@ TvStateUpdate( char *UDN,
* changes -- The DOM document representing the changes
*
********************************************************************************/
void
TvCtrlPointHandleEvent( Upnp_SID sid,
int evntkey,
IXML_Document * changes )
void TvCtrlPointHandleEvent(
const char *sid,
int evntkey,
IXML_Document *changes)
{
struct TvDeviceNode *tmpdevnode;
int service;
struct TvDeviceNode *tmpdevnode;
int service;
ithread_mutex_lock( &DeviceListMutex );
ithread_mutex_lock(&DeviceListMutex);
tmpdevnode = GlobalDeviceList;
while( tmpdevnode ) {
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
0 ) {
SampleUtil_Print( "Received Tv %s Event: %d for SID %s",
TvServiceName[service], evntkey, sid );
tmpdevnode = GlobalDeviceList;
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
if (strcmp(tmpdevnode->device.TvService[service].SID, sid) == 0) {
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
TvServiceName[service],
evntkey,
sid);
TvStateUpdate(
tmpdevnode->device.UDN,
service,
changes,
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
break;
}
}
tmpdevnode = tmpdevnode->next;
}
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
( char ** )&tmpdevnode->device.
TvService[service].VariableStrVal );
break;
}
}
tmpdevnode = tmpdevnode->next;
}
ithread_mutex_unlock( &DeviceListMutex );
ithread_mutex_unlock(&DeviceListMutex);
}
/********************************************************************************
@ -983,10 +987,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid,
* timeout -- The new timeout for the subscription
*
********************************************************************************/
void
TvCtrlPointHandleSubscribeUpdate( char *eventURL,
Upnp_SID sid,
int timeout )
void TvCtrlPointHandleSubscribeUpdate(
const char *eventURL,
const Upnp_SID sid,
int timeout)
{
struct TvDeviceNode *tmpdevnode;
int service;
@ -1014,10 +1018,10 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL,
ithread_mutex_unlock( &DeviceListMutex );
}
void
TvCtrlPointHandleGetVar( char *controlURL,
char *varName,
DOMString varValue )
void TvCtrlPointHandleGetVar(
const char *controlURL,
const char *varName,
const DOMString varValue)
{
struct TvDeviceNode *tmpdevnode;
@ -1026,14 +1030,11 @@ TvCtrlPointHandleGetVar( char *controlURL,
ithread_mutex_lock( &DeviceListMutex );
tmpdevnode = GlobalDeviceList;
while( tmpdevnode ) {
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
if( strcmp
( tmpdevnode->device.TvService[service].ControlURL,
controlURL ) == 0 ) {
SampleUtil_StateUpdate( varName, varValue,
tmpdevnode->device.UDN,
GET_VAR_COMPLETE );
while (tmpdevnode) {
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
SampleUtil_StateUpdate(
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
break;
}
}
@ -1057,186 +1058,137 @@ TvCtrlPointHandleGetVar( char *controlURL,
* Cookie -- Optional data specified during callback registration
*
********************************************************************************/
int
TvCtrlPointCallbackEventHandler( Upnp_EventType EventType,
void *Event,
void *Cookie )
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
{
SampleUtil_PrintEvent( EventType, Event );
/*int errCode = 0;*/
switch ( EventType ) {
/*
SSDP Stuff
*/
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT:
{
struct Upnp_Discovery *d_event =
( struct Upnp_Discovery * )Event;
IXML_Document *DescDoc = NULL;
int ret;
SampleUtil_PrintEvent(EventType, Event);
switch ( EventType ) {
/* SSDP Stuff */
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
case UPNP_DISCOVERY_SEARCH_RESULT: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
IXML_Document *DescDoc = NULL;
int ret;
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print( "Error in Discovery Callback -- %d",
d_event->ErrCode );
}
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery Callback -- %d", d_event->ErrCode);
}
ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
if (ret != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error obtaining device description from %s -- error = %d",
d_event->Location, ret);
} else {
TvCtrlPointAddDevice(
DescDoc, d_event->Location, d_event->Expires);
}
if (DescDoc) {
ixmlDocument_free(DescDoc);
}
TvCtrlPointPrintList();
break;
}
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/* Nothing to do here... */
break;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
if( ( ret =
UpnpDownloadXmlDoc( d_event->Location,
&DescDoc ) ) !=
UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error obtaining device description from %s -- error = %d",
d_event->Location, ret );
} else {
TvCtrlPointAddDevice( DescDoc, d_event->Location,
d_event->Expires );
}
if (d_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Discovery ByeBye Callback -- %d", d_event->ErrCode);
}
SampleUtil_Print("Received ByeBye for Device: %s", d_event->DeviceId);
TvCtrlPointRemoveDevice(d_event->DeviceId);
SampleUtil_Print("After byebye:");
TvCtrlPointPrintList();
break;
}
/* SOAP Stuff */
case UPNP_CONTROL_ACTION_COMPLETE: {
struct Upnp_Action_Complete *a_event = (struct Upnp_Action_Complete *)Event;
if( DescDoc )
ixmlDocument_free( DescDoc );
if (a_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Action Complete Callback -- %d", a_event->ErrCode);
}
/* No need for any processing here, just print out results.
* Service state table updates are handled by events. */
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE: {
struct Upnp_State_Var_Complete *sv_event = (struct Upnp_State_Var_Complete *)Event;
TvCtrlPointPrintList( );
break;
}
if (sv_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Get Var Complete Callback -- %d", sv_event->ErrCode);
} else {
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal);
}
break;
}
/* GENA Stuff */
case UPNP_EVENT_RECEIVED: {
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
/*
Nothing to do here...
*/
break;
TvCtrlPointHandleEvent(
e_event->Sid,
e_event->EventKey,
e_event->ChangedVariables);
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
{
struct Upnp_Discovery *d_event =
( struct Upnp_Discovery * )Event;
if (es_event->ErrCode != UPNP_E_SUCCESS) {
SampleUtil_Print(
"Error in Event Subscribe Callback -- %d", es_event->ErrCode);
} else {
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
es_event->Sid,
es_event->TimeOut);
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
struct Upnp_Event_Subscribe *es_event = (struct Upnp_Event_Subscribe *)Event;
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Discovery ByeBye Callback -- %d",
d_event->ErrCode );
}
ret = UpnpSubscribe(
ctrlpt_handle,
es_event->PublisherUrl,
&TimeOut,
newSID);
if (ret == UPNP_E_SUCCESS) {
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
TvCtrlPointHandleSubscribeUpdate(
es_event->PublisherUrl,
newSID,
TimeOut);
} else {
SampleUtil_Print("Error Subscribing to EventURL -- %d", ret);
}
break;
}
/* ignore these cases, since this is not a device */
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
case UPNP_CONTROL_ACTION_REQUEST:
break;
}
SampleUtil_Print( "Received ByeBye for Device: %s",
d_event->DeviceId );
TvCtrlPointRemoveDevice( d_event->DeviceId );
SampleUtil_Print( "After byebye:" );
TvCtrlPointPrintList( );
break;
}
/*
SOAP Stuff
*/
case UPNP_CONTROL_ACTION_COMPLETE:
{
struct Upnp_Action_Complete *a_event =
( struct Upnp_Action_Complete * )Event;
if( a_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Action Complete Callback -- %d",
a_event->ErrCode );
}
/*
No need for any processing here, just print out results. Service state
table updates are handled by events.
*/
break;
}
case UPNP_CONTROL_GET_VAR_COMPLETE:
{
struct Upnp_State_Var_Complete *sv_event =
( struct Upnp_State_Var_Complete * )Event;
if( sv_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Get Var Complete Callback -- %d",
sv_event->ErrCode );
} else {
TvCtrlPointHandleGetVar( sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal );
}
break;
}
/*
GENA Stuff
*/
case UPNP_EVENT_RECEIVED:
{
struct Upnp_Event *e_event = ( struct Upnp_Event * )Event;
TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey,
e_event->ChangedVariables );
break;
}
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
case UPNP_EVENT_RENEWAL_COMPLETE:
{
struct Upnp_Event_Subscribe *es_event =
( struct Upnp_Event_Subscribe * )Event;
if( es_event->ErrCode != UPNP_E_SUCCESS ) {
SampleUtil_Print
( "Error in Event Subscribe Callback -- %d",
es_event->ErrCode );
} else {
TvCtrlPointHandleSubscribeUpdate( es_event->
PublisherUrl,
es_event->Sid,
es_event->TimeOut );
}
break;
}
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED:
{
int TimeOut = default_timeout;
Upnp_SID newSID;
int ret;
struct Upnp_Event_Subscribe *es_event =
( struct Upnp_Event_Subscribe * )Event;
ret =
UpnpSubscribe( ctrlpt_handle, es_event->PublisherUrl,
&TimeOut, newSID );
if( ret == UPNP_E_SUCCESS ) {
SampleUtil_Print( "Subscribed to EventURL with SID=%s",
newSID );
TvCtrlPointHandleSubscribeUpdate( es_event->
PublisherUrl, newSID,
TimeOut );
} else {
SampleUtil_Print
( "Error Subscribing to EventURL -- %d", ret );
}
break;
}
/*
ignore these cases, since this is not a device
*/
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
case UPNP_CONTROL_GET_VAR_REQUEST:
case UPNP_CONTROL_ACTION_REQUEST:
break;
}
return 0;
return 0;
}
/********************************************************************************
@ -1320,12 +1272,12 @@ TvCtrlPointVerifyTimeouts( int incr )
* None
*
********************************************************************************/
void *
TvCtrlPointTimerLoop( void *args )
static int TvCtrlPointTimerLoopRun = 1;
void *TvCtrlPointTimerLoop(void *args)
{
int incr = 30; // how often to verify the timeouts, in seconds
while( 1 ) {
while (TvCtrlPointTimerLoopRun) {
isleep( incr );
TvCtrlPointVerifyTimeouts( incr );
}
@ -1348,62 +1300,72 @@ TvCtrlPointTimerLoop( void *args )
* TV_SUCCESS if everything went well, else TV_ERROR
*
********************************************************************************/
int
TvCtrlPointStart( print_string printFunctionPtr,
state_update updateFunctionPtr )
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
{
ithread_t timer_thread;
int rc;
short int port = 0;
char *ip_address = NULL;
ithread_t timer_thread;
int rc;
unsigned short port = 0;
char *ip_address = NULL;
SampleUtil_Initialize( printFunctionPtr );
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
SampleUtil_Initialize(printFunctionPtr);
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
ithread_mutex_init( &DeviceListMutex, 0 );
ithread_mutex_init(&DeviceListMutex, 0);
SampleUtil_Print( "Intializing UPnP with ipaddress=%s port=%d",
ip_address, port );
rc = UpnpInit( ip_address, port );
if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
UpnpFinish( );
return TV_ERROR;
}
SampleUtil_Print(
"Initializing UPnP Sdk with\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
if( NULL == ip_address )
ip_address = UpnpGetServerIpAddress( );
if( 0 == port )
port = UpnpGetServerPort( );
rc = UpnpInit(ip_address, port);
if (rc != UPNP_E_SUCCESS) {
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
UpnpFinish();
return TV_ERROR;
}
if (!ip_address) {
ip_address = UpnpGetServerIpAddress();
}
if (!port) {
port = UpnpGetServerPort();
}
SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port );
SampleUtil_Print(
"UPnP Initialized\n"
"\tipaddress = %s port = %u\n",
ip_address ? ip_address : "{NULL}",
port);
SampleUtil_Print( "Registering Control Point" );
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle );
if( UPNP_E_SUCCESS != rc ) {
SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish( );
return TV_ERROR;
}
SampleUtil_Print("Registering Control Point");
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
&ctrlpt_handle, &ctrlpt_handle);
if (rc != UPNP_E_SUCCESS) {
SampleUtil_Print( "Error registering CP: %d", rc );
UpnpFinish();
SampleUtil_Print( "Control Point Registered" );
return TV_ERROR;
}
TvCtrlPointRefresh( );
SampleUtil_Print("Control Point Registered");
// start a timer thread
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
TvCtrlPointRefresh();
return TV_SUCCESS;
/* start a timer thread */
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
ithread_detach(timer_thread);
return TV_SUCCESS;
}
int
TvCtrlPointStop( void )
int TvCtrlPointStop(void)
{
TvCtrlPointRemoveAll( );
UpnpUnRegisterClient( ctrlpt_handle );
UpnpFinish( );
SampleUtil_Finish( );
TvCtrlPointTimerLoopRun = 0;
TvCtrlPointRemoveAll();
UpnpUnRegisterClient( ctrlpt_handle );
UpnpFinish();
SampleUtil_Finish();
return TV_SUCCESS;
return TV_SUCCESS;
}

View File

@ -1,53 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// 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_TV_CTRLPT_H
#define UPNP_TV_CTRLPT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "sample_util.h"
#include "ithread.h"
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include "upnp.h"
#include "UpnpString.h"
#include "upnptools.h"
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "upnp.h"
#include "upnptools.h"
#include "sample_util.h"
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
#define TV_SERVICE_SERVCOUNT 2
#define TV_SERVICE_CONTROL 0
@ -66,12 +79,12 @@ extern "C" {
#define TV_MAX_VAL_LEN 5
#define TV_SUCCESS 0
#define TV_ERROR (-1)
#define TV_WARNING 1
#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
#define TV_MAXVARS TV_PICTURE_VARCOUNT
extern char TvDeviceType[];
extern char *TvServiceType[];
@ -108,11 +121,11 @@ 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 );
void TvCtrlPointPrintHelp(void);
int TvCtrlPointDeleteNode(struct TvDeviceNode *);
int TvCtrlPointRemoveDevice(const char *);
int TvCtrlPointRemoveAll(void);
int TvCtrlPointRefresh(void);
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
@ -136,20 +149,20 @@ int TvCtrlPointGetContrast(int);
int TvCtrlPointGetBrightness(int);
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
int TvCtrlPointPrintList( void );
int TvCtrlPointPrintList(void);
int TvCtrlPointPrintDevice(int);
void TvCtrlPointAddDevice (IXML_Document *, char *, int);
void TvCtrlPointHandleGetVar(char *,char *,DOMString);
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
void TvStateUpdate(char*,int, IXML_Document * , char **);
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
void TvCtrlPointHandleEvent(const char *, int, IXML_Document *);
void TvCtrlPointHandleSubscribeUpdate(const char *, const 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 );
void TvCtrlPointPrintCommands(void);
void* TvCtrlPointCommandLoop(void *);
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr);
int TvCtrlPointStop(void);
int TvCtrlPointProcessCommand(char *cmdline);
#ifdef __cplusplus
};

View File

@ -1,38 +1,42 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 <stdio.h>
#include "sample_util.h"
#include "upnp_tv_device.h"
#include <stdio.h>
/******************************************************************************
* linux_print
*
@ -82,7 +86,7 @@ TvDeviceCommandLoop( void *args )
if( strcasecmp( cmd, "exit" ) == 0 ) {
SampleUtil_Print( "Shutting down...\n" );
TvDeviceStop( );
TvDeviceStop();
exit( 0 );
} else {
SampleUtil_Print( "\n Unknown command: %s\n\n", cmd );
@ -117,26 +121,27 @@ TvDeviceCommandLoop( void *args )
*
*
*****************************************************************************/
int
main( IN int argc,
IN char **argv )
int main( IN int argc, IN char **argv )
{
unsigned int portTemp = 0;
char *ip_address = NULL,
*desc_doc_name = NULL,
*web_dir_path = NULL;
int rc;
ithread_t cmdloop_thread;
int code;
unsigned int port = 0;
#ifdef WIN32
#else
int sig;
sigset_t sigs_to_catch;
#endif
int code;
unsigned int port = 0;
int i = 0;
SampleUtil_Initialize( linux_print );
//Parse options
// Parse options
for( i = 1; i < argc; i++ ) {
if( strcmp( argv[i], "-ip" ) == 0 ) {
ip_address = argv[++i];
@ -163,21 +168,20 @@ main( IN int argc,
( "\tweb_dir_path: Filesystem path where web files "
"related to the device are stored\n" );
SampleUtil_Print( "\t\te.g.: /upnp/sample/tvdevice/web\n" );
exit( 1 );
return 1;
}
}
port = ( unsigned short )portTemp;
TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path,
linux_print );
TvDeviceStart( ip_address, port, desc_doc_name, web_dir_path, linux_print );
/*
start a command loop thread
*/
code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop,
NULL );
/* start a command loop thread */
code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, NULL );
#ifdef WIN32
ithread_join(cmdloop_thread, NULL);
#else
/*
Catch Ctrl-C and properly shutdown
*/
@ -186,6 +190,9 @@ main( IN int argc,
sigwait( &sigs_to_catch, &sig );
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
TvDeviceStop( );
exit( 0 );
#endif
rc = TvDeviceStop();
return rc;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// 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_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"
#include "ithread.h"
#include "upnp.h"
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
/* Do not #include <unistd.h> */
#else
#include <unistd.h>
#endif
//Color constants
#define MAX_COLOR 10
#define MIN_COLOR 1
@ -146,8 +161,7 @@ extern char *TvServiceType[];
*
*****************************************************************************/
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
char **errorString);
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
/* Structure for storing Tv Service
identifiers and state table */
@ -191,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
* struct TvService *out - service containing action table to set.
*
*****************************************************************************/
int SetActionTable(int serviceType, struct TvService * out);
int SetActionTable(int serviceType, struct TvService *out);
/******************************************************************************
* TvDeviceStateTableInit
@ -311,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDevicePowerOff
@ -327,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetChannel
@ -345,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseChannel
@ -361,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseChannel
*
@ -376,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetVolume
*
@ -393,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseVolume
@ -409,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
* 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);
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@ -426,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
OUT char **errorString);
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
//Picture Service Actions
@ -447,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
@ -463,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
* 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);
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseColor
@ -478,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* 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);
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetTint
@ -496,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseTint
@ -512,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseTint
@ -528,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/*****************************************************************************
* TvDeviceSetContrast
@ -546,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
****************************************************************************/
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseContrast
@ -563,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseContrast
*
@ -578,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceSetBrightness
@ -593,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
* brightness -- The brightness value to change to.
*
*****************************************************************************/
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceIncreaseBrightness
@ -609,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
/******************************************************************************
* TvDeviceDecreaseBrightness
@ -624,12 +619,11 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
* char **errorString - errorString (in case action was unsuccessful)
*
*****************************************************************************/
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
OUT char **errorString);
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();
int TvDeviceStop(void);
#ifdef __cplusplus
}

205
upnp/src/api/UpnpString.c Normal file
View File

@ -0,0 +1,205 @@
/*!
* \addtogroup UpnpString
*
* Due to its heavy use, this class is coded for efficiency, not for beauty.
* Do not use this as example to other classes. Please take a look at any
* other one.
*
* \todo Always alloc a minimum size like 64 bytes or so and when shrinking
* do not perform a new memory allocation.
*
* @{
*
* \file
*
* \brief UpnpString object implementation.
*/
#include "config.h"
#include "UpnpString.h"
#include <stdlib.h> /* for calloc(), free() */
#include <string.h> /* for strlen(), strdup() */
#ifdef WIN32
#define strcasecmp stricmp
#else
/* Other systems have strncasecmp */
#endif
/* strndup() is a GNU extension. Other systems must fix it with elif's. */
#ifdef __GNUC__
extern char *strndup(__const char *__string, size_t __n);
#endif
/*!
* \brief Internal implementation of the class UpnpString.
*
* \internal
*/
struct SUpnpString
{
/*! \brief Length of the string. */
int m_length;
/*! \brief Pointer to a dynamically allocated area that holds the NULL
* terminated string. */
char *m_string;
};
UpnpString *UpnpString_new()
{
// All bytes are zero, and so is the length of the string.
struct SUpnpString *p = calloc(1, sizeof (struct SUpnpString));
if (p == NULL) {
goto error_handler1;
}
#if 0
p->m_length = 0;
#endif
// This byte is zero, calloc does initialize it.
p->m_string = calloc(1, 1);
if (p->m_string == NULL) {
goto error_handler2;
}
return (UpnpString *)p;
//free(p->m_string);
error_handler2:
free(p);
error_handler1:
return NULL;
}
void UpnpString_delete(UpnpString *p)
{
struct SUpnpString *q = (struct SUpnpString *)p;
if (!q) return;
q->m_length = 0;
free(q->m_string);
q->m_string = NULL;
free(p);
}
UpnpString *UpnpString_dup(const UpnpString *p)
{
struct SUpnpString *q = calloc(1, sizeof (struct SUpnpString));
if (q == NULL) {
goto error_handler1;
}
q->m_length = ((struct SUpnpString *)p)->m_length;
q->m_string = strdup(((struct SUpnpString *)p)->m_string);
if (q->m_string == NULL) {
goto error_handler2;
}
return (UpnpString *)q;
//free(q->m_string);
error_handler2:
free(q);
error_handler1:
return NULL;
}
void UpnpString_assign(UpnpString *p, const UpnpString *q)
{
if (p != q) {
UpnpString_set_String(p, UpnpString_get_String(q));
}
}
size_t UpnpString_get_Length(const UpnpString *p)
{
return ((struct SUpnpString *)p)->m_length;
}
void UpnpString_set_Length(UpnpString *p, size_t n)
{
if (((struct SUpnpString *)p)->m_length > n) {
((struct SUpnpString *)p)->m_length = n;
/* No need to realloc now, will do later when needed. */
((struct SUpnpString *)p)->m_string[n] = 0;
}
}
const char *UpnpString_get_String(const UpnpString *p)
{
return ((struct SUpnpString *)p)->m_string;
}
int UpnpString_set_String(UpnpString *p, const char *s)
{
char *q = strdup(s);
if (!q) goto error_handler1;
free(((struct SUpnpString *)p)->m_string);
((struct SUpnpString *)p)->m_length = strlen(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
}
int UpnpString_set_StringN(UpnpString *p, const char *s, size_t n)
{
char *q = strndup(s, n);
if (!q) goto error_handler1;
free(((struct SUpnpString *)p)->m_string);
((struct SUpnpString *)p)->m_length = strlen(q);
((struct SUpnpString *)p)->m_string = q;
error_handler1:
return q != NULL;
}
void UpnpString_clear(UpnpString *p)
{
((struct SUpnpString *)p)->m_length = 0;
/* No need to realloc now, will do later when needed. */
((struct SUpnpString *)p)->m_string[0] = 0;
}
int UpnpString_cmp(UpnpString *p, UpnpString *q)
{
const char *cp = UpnpString_get_String(p);
const char *cq = UpnpString_get_String(q);
return strcmp(cp, cq);
}
int UpnpString_casecmp(UpnpString *p, UpnpString *q)
{
const char *cp = UpnpString_get_String(p);
const char *cq = UpnpString_get_String(q);
return strcasecmp(cp, cq);
}
/* @} UpnpString */

File diff suppressed because it is too large Load Diff

View File

@ -1,177 +1,121 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "config.h"
#include "ithread.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include "ithread.h"
#include "upnp.h"
#include <stdarg.h>
#include <string.h>
//Mutex to synchronize all the log file opeartions in the debug mode
/*! Mutex to synchronize all the log file opeartions in the debug mode */
static ithread_mutex_t GlobalDebugMutex;
// Global log level
/*! Global log level */
static Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL;
//File handle for the error log file
/*! File handle for the error log file */
static FILE *ErrFileHnd = NULL;
//File handle for the information log file
/*! File handle for the information log file */
static FILE *InfoFileHnd = NULL;
//Name of the error file
/*! Name of the error file */
static const char *errFileName = "IUpnpErrFile.txt";
//Name of the info file
/*! Name of the info file */
static const char *infoFileName = "IUpnpInfoFile.txt";
#ifdef DEBUG
/***************************************************************************
* Function : UpnpSetLogFileNames
*
* Parameters:
* IN const char* ErrFileName: name of the error file
* IN const char *InfoFileName: name of the information file
* IN int size: Size of the buffer
* IN int starLength: This parameter provides the width of the banner
*
* Description:
* This functions takes the buffer and writes the buffer in the file as
* per the requested banner
* Returns: void
***************************************************************************/
void
UpnpSetLogFileNames ( IN const char *ErrFileName,
IN const char *InfoFileName )
int UpnpInitLog(void)
{
if( ErrFileName ) {
errFileName = ErrFileName;
}
if( InfoFileName ) {
infoFileName = InfoFileName;
}
ithread_mutex_init(&GlobalDebugMutex, NULL);
if(DEBUG_TARGET == 1) {
if((ErrFileHnd = fopen( errFileName, "a")) == NULL) {
return -1;
}
if((InfoFileHnd = fopen( infoFileName, "a")) == NULL) {
return -1;
}
}
return UPNP_E_SUCCESS;
}
/***************************************************************************
* Function : UpnpInitLog
*
* Parameters: void
*
* Description:
* This functions initializes the log files
*
* Returns: int
* -1 : If fails
* UPNP_E_SUCCESS : if success
***************************************************************************/
int
UpnpInitLog()
{
ithread_mutex_init( &GlobalDebugMutex, NULL );
if( DEBUG_TARGET == 1 ) {
if( ( ErrFileHnd = fopen( errFileName, "a" ) ) == NULL )
return -1;
if( ( InfoFileHnd = fopen( infoFileName, "a" ) ) == NULL )
return -1;
}
return UPNP_E_SUCCESS;
}
/***************************************************************************
* Function : UpnpSetLogLevel
*
* Parameters: Upnp_LogLevel log_level
*
* Description:
* This functions set the log level (see {\tt Upnp_LogLevel}
* Returns: void
***************************************************************************/
void
UpnpSetLogLevel (Upnp_LogLevel log_level)
void UpnpSetLogLevel(Upnp_LogLevel log_level)
{
g_log_level = log_level;
}
/***************************************************************************
* Function : UpnpCloseLog
*
* Parameters: void
*
* Description:
* This functions closes the log files
* Returns: void
***************************************************************************/
void
UpnpCloseLog()
void UpnpCloseLog(void)
{
if( DEBUG_TARGET == 1 ) {
fflush( ErrFileHnd );
fflush( InfoFileHnd );
fclose( ErrFileHnd );
fclose( InfoFileHnd );
}
ithread_mutex_destroy( &GlobalDebugMutex );
if (DEBUG_TARGET == 1) {
fflush(ErrFileHnd);
fflush(InfoFileHnd);
fclose(ErrFileHnd);
fclose(InfoFileHnd);
}
ithread_mutex_destroy(&GlobalDebugMutex);
}
void UpnpSetLogFileNames(
const char *ErrFileName,
const char *InfoFileName)
{
if (ErrFileName) {
errFileName = ErrFileName;
}
if (InfoFileName) {
infoFileName = InfoFileName;
}
}
/***************************************************************************
* 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)
Upnp_LogLevel DLevel,
Dbg_Module Module)
{
int ret = DLevel <= g_log_level;
ret &=
@ -186,38 +130,15 @@ int DebugAtThisLevel(
return ret;
}
#endif
/***************************************************************************
* Function : UpnpPrintf
*
* 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
* IN char *DbgFileName: Name of the file from where debug statement is
* coming
* IN int DbgLineNo : Line number of the file from where debug statement
* is coming
* IN char * FmtStr, ...: Variable number of arguments that will go
* in the debug statement
*
* Description:
* This functions prints the debug statement either on the startdard
* output or log file along with the information from where this debug
* statement is coming
* Returns: void
***************************************************************************/
#ifdef DEBUG
void UpnpPrintf(
IN Upnp_LogLevel DLevel,
IN Dbg_Module Module,
IN const char *DbgFileName,
IN int DbgLineNo,
IN const char *FmtStr,
... )
Upnp_LogLevel DLevel,
Dbg_Module Module,
const char *DbgFileName,
int DbgLineNo,
const char *FmtStr,
...)
{
va_list ArgList;
@ -228,7 +149,7 @@ void UpnpPrintf(
ithread_mutex_lock(&GlobalDebugMutex);
va_start(ArgList, FmtStr);
if (!DEBUG_TARGET) {
if( DbgFileName ) {
if (DbgFileName) {
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
}
vfprintf(stdout, FmtStr, ArgList);
@ -249,27 +170,9 @@ void UpnpPrintf(
va_end(ArgList);
ithread_mutex_unlock(&GlobalDebugMutex);
}
#endif
/***************************************************************************
* Function : UpnpGetDebugFile
*
* 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 function checks if the module is turned on for debug
* and returns the file descriptor corresponding to the debug level
* Returns: FILE *
* NULL : if the module is turn off for debug
* else returns the right file descriptor
***************************************************************************/
#ifdef DEBUG
FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
{
FILE *ret;
@ -287,65 +190,51 @@ FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
return ret;
}
#endif
/***************************************************************************
* Function : UpnpDisplayFileAndLine
*
* Parameters:
* IN FILE *fd: File descriptor where line number and file name will be
* written
* IN char *DbgFileName: Name of the file
* IN int DbgLineNo : Line number of the file
*
* Description:
* This function writes the file name and file number from where
* debug statement is coming to the log file
* Returns: void
***************************************************************************/
#ifdef DEBUG
void UpnpDisplayFileAndLine(
IN FILE * fd,
IN const char *DbgFileName,
IN int DbgLineNo)
FILE *fd,
const char *DbgFileName,
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;
#define NLINES 2
#define MAX_LINE_SIZE 512
#define NUMBER_OF_STARS 80
const char *lines[NLINES];
char buf[NLINES][MAX_LINE_SIZE];
int i;
/* Initialize the pointer array */
for (i = 0; i < NLINES; i++) {
lines[i] = buf[i];
}
UpnpDisplayBanner(fd, lines, 2, starlength);
/* Put the debug lines in the buffer */
sprintf(buf[0], "DEBUG - THREAD ID: 0x%lX",
#ifdef WIN32
(unsigned long int)ithread_self().p
#else
(unsigned long int)ithread_self()
#endif
);
if (DbgFileName) {
sprintf(buf[1],
"FILE: %s, LINE: %d",
DbgFileName,
DbgLineNo);
}
/* Show the lines centered */
UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS);
fflush(fd);
}
#endif
/***************************************************************************
* Function : UpnpDisplayBanner
*
* Parameters:
* IN FILE *fd: file descriptor where the banner will be written
* IN char **lines: The buffer that will be written
* IN int size: Size of the buffer
* IN int starLength: This parameter provides the width of the banner
*
* Description:
* This functions takes the buffer and writes the buffer in the file as
* per the requested banner
* Returns: void
***************************************************************************/
#ifdef DEBUG
void UpnpDisplayBanner(
IN FILE * fd,
IN const char **lines,
IN size_t size,
IN int starLength)
FILE * fd,
const char **lines,
size_t size,
int starLength)
{
int leftMarginLength = starLength / 2 + 1;
int rightMarginLength = starLength / 2 + 1;
@ -386,12 +275,54 @@ void UpnpDisplayBanner(
rightMargin[rightMarginLength] = 0;
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
}
fprintf( fd, "%s\n\n", stars );
fprintf(fd, "%s\n\n", stars);
free( currentLine );
free( stars );
free( rightMargin );
free( leftMargin );
free(currentLine);
free(stars);
free(rightMargin);
free(leftMargin);
}
#endif
void PrintThreadPoolStats(
ThreadPool *tp,
const char *DbgFileName,
int DbgLineNo,
const char *msg)
{
ThreadPoolStats stats;
ThreadPoolGetStats(tp, &stats);
UpnpPrintf(UPNP_INFO, API, DbgFileName, DbgLineNo,
"%s\n"
"High Jobs pending: %d\n"
"Med Jobs Pending: %d\n"
"Low Jobs Pending: %d\n"
"Average wait in High Q in milliseconds: %lf\n"
"Average wait in Med Q in milliseconds: %lf\n"
"Average wait in Low Q in milliseconds: %lf\n"
"Max Threads Used: %d\n"
"Worker Threads: %d\n"
"Persistent Threads: %d\n"
"Idle Threads: %d\n"
"Total Threads: %d\n"
"Total Work Time: %lf\n"
"Total Idle Time: %lf\n",
msg,
stats.currentJobsHQ,
stats.currentJobsMQ,
stats.currentJobsLQ,
stats.avgWaitHQ,
stats.avgWaitMQ,
stats.avgWaitLQ,
stats.maxThreads,
stats.workerThreads,
stats.persistentThreads,
stats.idleThreads,
stats.totalThreads,
stats.totalWorkTime,
stats.totalIdleTime);
}
#endif /* DEBUG */

View File

@ -1,584 +1,475 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 "config.h"
/*!
* \file
*/
#if EXCLUDE_DOM == 0
#include <stdarg.h>
#include "upnp.h"
#include "upnptools.h"
#include "uri.h"
#include <stdarg.h>
#include <stdio.h>
/*! Maximum action header buffer length. */
#define HEADER_LENGTH 2000
//Structure to maintain a error code and string associated with the
// error code
/*!
* \brief Structure to maintain a error code and string associated with the
* error code.
*/
struct ErrorString {
int rc; /* error code */
const char *rcError; /* error description */
/*! Error code. */
int rc;
/*! Error description. */
const char *rcError;
};
//Intializing the array of error structures.
struct ErrorString ErrorMessages[] = { {UPNP_E_SUCCESS, "UPNP_E_SUCCESS"},
{UPNP_E_INVALID_HANDLE, "UPNP_E_INVALID_HANDLE"},
{UPNP_E_INVALID_PARAM, "UPNP_E_INVALID_PARAM"},
{UPNP_E_OUTOF_HANDLE, "UPNP_E_OUTOF_HANDLE"},
{UPNP_E_OUTOF_CONTEXT, "UPNP_E_OUTOF_CONTEXT"},
{UPNP_E_OUTOF_MEMORY, "UPNP_E_OUTOF_MEMOR"},
{UPNP_E_INIT, "UPNP_E_INIT"},
{UPNP_E_BUFFER_TOO_SMALL, "UPNP_E_BUFFER_TOO_SMALL"},
{UPNP_E_INVALID_DESC, "UPNP_E_INVALID_DESC"},
{UPNP_E_INVALID_URL, "UPNP_E_INVALID_URL"},
{UPNP_E_INVALID_SID, "UPNP_E_INVALID_SID"},
{UPNP_E_INVALID_DEVICE, "UPNP_E_INVALID_DEVICE"},
{UPNP_E_INVALID_SERVICE, "UPNP_E_INVALID_SERVICE"},
{UPNP_E_BAD_RESPONSE, "UPNP_E_BAD_RESPONSE"},
{UPNP_E_BAD_REQUEST, "UPNP_E_BAD_REQUEST"},
{UPNP_E_INVALID_ACTION, "UPNP_E_INVALID_ACTION"},
{UPNP_E_FINISH, "UPNP_E_FINISH"},
{UPNP_E_INIT_FAILED, "UPNP_E_INIT_FAILED"},
{UPNP_E_BAD_HTTPMSG, "UPNP_E_BAD_HTTPMSG"},
{UPNP_E_NETWORK_ERROR, "UPNP_E_NETWORK_ERROR"},
{UPNP_E_SOCKET_WRITE, "UPNP_E_SOCKET_WRITE"},
{UPNP_E_SOCKET_READ, "UPNP_E_SOCKET_READ"},
{UPNP_E_SOCKET_BIND, "UPNP_E_SOCKET_BIND"},
{UPNP_E_SOCKET_CONNECT, "UPNP_E_SOCKET_CONNECT"},
{UPNP_E_OUTOF_SOCKET, "UPNP_E_OUTOF_SOCKET"},
{UPNP_E_LISTEN, "UPNP_E_LISTEN"},
{UPNP_E_EVENT_PROTOCOL, "UPNP_E_EVENT_PROTOCOL"},
{UPNP_E_SUBSCRIBE_UNACCEPTED, "UPNP_E_SUBSCRIBE_UNACCEPTED"},
{UPNP_E_UNSUBSCRIBE_UNACCEPTED, "UPNP_E_UNSUBSCRIBE_UNACCEPTED"},
{UPNP_E_NOTIFY_UNACCEPTED, "UPNP_E_NOTIFY_UNACCEPTED"},
{UPNP_E_INTERNAL_ERROR, "UPNP_E_INTERNAL_ERROR"},
{UPNP_E_INVALID_ARGUMENT, "UPNP_E_INVALID_ARGUMENT"},
{UPNP_E_OUTOF_BOUNDS, "UPNP_E_OUTOF_BOUNDS"}
/*!
* \brief Array of error structures.
*/
struct ErrorString ErrorMessages[] = {
{UPNP_E_SUCCESS, "UPNP_E_SUCCESS"},
{UPNP_E_INVALID_HANDLE, "UPNP_E_INVALID_HANDLE"},
{UPNP_E_INVALID_PARAM, "UPNP_E_INVALID_PARAM"},
{UPNP_E_OUTOF_HANDLE, "UPNP_E_OUTOF_HANDLE"},
{UPNP_E_OUTOF_CONTEXT, "UPNP_E_OUTOF_CONTEXT"},
{UPNP_E_OUTOF_MEMORY, "UPNP_E_OUTOF_MEMORY"},
{UPNP_E_INIT, "UPNP_E_INIT"},
{UPNP_E_BUFFER_TOO_SMALL, "UPNP_E_BUFFER_TOO_SMALL"},
{UPNP_E_INVALID_DESC, "UPNP_E_INVALID_DESC"},
{UPNP_E_INVALID_URL, "UPNP_E_INVALID_URL"},
{UPNP_E_INVALID_SID, "UPNP_E_INVALID_SID"},
{UPNP_E_INVALID_DEVICE, "UPNP_E_INVALID_DEVICE"},
{UPNP_E_INVALID_SERVICE, "UPNP_E_INVALID_SERVICE"},
{UPNP_E_BAD_RESPONSE, "UPNP_E_BAD_RESPONSE"},
{UPNP_E_BAD_REQUEST, "UPNP_E_BAD_REQUEST"},
{UPNP_E_INVALID_ACTION, "UPNP_E_INVALID_ACTION"},
{UPNP_E_FINISH, "UPNP_E_FINISH"},
{UPNP_E_INIT_FAILED, "UPNP_E_INIT_FAILED"},
{UPNP_E_URL_TOO_BIG, "UPNP_E_URL_TOO_BIG"},
{UPNP_E_BAD_HTTPMSG, "UPNP_E_BAD_HTTPMSG"},
{UPNP_E_ALREADY_REGISTERED, "UPNP_E_ALREADY_REGISTERED"},
{UPNP_E_INVALID_INTERFACE, "UPNP_E_INVALID_INTERFACE"},
{UPNP_E_NETWORK_ERROR, "UPNP_E_NETWORK_ERROR"},
{UPNP_E_SOCKET_WRITE, "UPNP_E_SOCKET_WRITE"},
{UPNP_E_SOCKET_READ, "UPNP_E_SOCKET_READ"},
{UPNP_E_SOCKET_BIND, "UPNP_E_SOCKET_BIND"},
{UPNP_E_SOCKET_CONNECT, "UPNP_E_SOCKET_CONNECT"},
{UPNP_E_OUTOF_SOCKET, "UPNP_E_OUTOF_SOCKET"},
{UPNP_E_LISTEN, "UPNP_E_LISTEN"},
{UPNP_E_TIMEDOUT, "UPNP_E_TIMEDOUT"},
{UPNP_E_SOCKET_ERROR, "UPNP_E_SOCKET_ERROR"},
{UPNP_E_FILE_WRITE_ERROR, "UPNP_E_FILE_WRITE_ERROR"},
{UPNP_E_CANCELED, "UPNP_E_CANCELED"},
{UPNP_E_EVENT_PROTOCOL, "UPNP_E_EVENT_PROTOCOL"},
{UPNP_E_SUBSCRIBE_UNACCEPTED, "UPNP_E_SUBSCRIBE_UNACCEPTED"},
{UPNP_E_UNSUBSCRIBE_UNACCEPTED, "UPNP_E_UNSUBSCRIBE_UNACCEPTED"},
{UPNP_E_NOTIFY_UNACCEPTED, "UPNP_E_NOTIFY_UNACCEPTED"},
{UPNP_E_INVALID_ARGUMENT, "UPNP_E_INVALID_ARGUMENT"},
{UPNP_E_FILE_NOT_FOUND, "UPNP_E_FILE_NOT_FOUND"},
{UPNP_E_FILE_READ_ERROR, "UPNP_E_FILE_READ_ERROR"},
{UPNP_E_EXT_NOT_XML, "UPNP_E_EXT_NOT_XML"},
{UPNP_E_NO_WEB_SERVER, "UPNP_E_NO_WEB_SERVER"},
{UPNP_E_OUTOF_BOUNDS, "UPNP_E_OUTOF_BOUNDS"},
{UPNP_E_NOT_FOUND, "UPNP_E_NOT_FOUND"},
{UPNP_E_INTERNAL_ERROR, "UPNP_E_INTERNAL_ERROR"},
};
/************************************************************************
* Function : UpnpGetErrorMessage
*
* Parameters:
* IN int rc: error code
*
* Description:
* This functions returns the error string mapped to the error code
* Returns: const char *
* return either the right string or "Unknown Error"
***************************************************************************/
const char *
UpnpGetErrorMessage( IN int rc )
const char *UpnpGetErrorMessage(int rc)
{
int i;
int i;
for( i = 0; i < sizeof( ErrorMessages ) / sizeof( ErrorMessages[0] );
i++ ) {
if( rc == ErrorMessages[i].rc )
return ErrorMessages[i].rcError;
}
return "Unknown Error";
for (i = 0; i < sizeof (ErrorMessages) / sizeof (ErrorMessages[0]); ++i) {
if (rc == ErrorMessages[i].rc) {
return ErrorMessages[i].rcError;
}
}
return "Unknown error code";
}
/************************************************************************
* Function : UpnpResolveURL
*
* Parameters:
* IN char * BaseURL: Base URL string
* IN char * RelURL: relative URL string
* OUT char * AbsURL: Absolute URL string
* Description:
* This functions concatinates the base URL and relative URL to generate
* the absolute URL
* Returns: int
* return either UPNP_E_SUCCESS or appropriate error
***************************************************************************/
int
UpnpResolveURL( IN const char *BaseURL,
IN const char *RelURL,
OUT char *AbsURL )
/*!
* \todo There is some unnecessary allocation and deallocation going on here
* because of the way resolve_rel_url() was originally written and used. In the
* future it would be nice to clean this up.
*/
int UpnpResolveURL(
const char *BaseURL,
const char *RelURL,
char *AbsURL)
{
// There is some unnecessary allocation and
// deallocation going on here because of the way
// resolve_rel_url was originally written and used
// in the future it would be nice to clean this up
int ret = UPNP_E_SUCCESS;
char *tempRel = NULL;
char *tempRel;
if (RelURL == NULL) {
ret = UPNP_E_INVALID_PARAM;
goto ExitFunction;
}
if( RelURL == NULL )
return UPNP_E_INVALID_PARAM;
tempRel = NULL;
tempRel = resolve_rel_url((char*) BaseURL, (char*) RelURL );
if( tempRel ) {
strcpy( AbsURL, tempRel );
free( tempRel );
} else {
return UPNP_E_INVALID_URL;
}
return UPNP_E_SUCCESS;
tempRel = resolve_rel_url((char *)BaseURL, (char *)RelURL);
if (tempRel) {
strcpy(AbsURL, tempRel);
free(tempRel);
} else {
ret = UPNP_E_INVALID_URL;
}
ExitFunction:
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : addToAction
*
* Parameters:
* IN int response: flag to tell if the ActionDoc is for response
* or request
* INOUT IXML_Document **ActionDoc: request or response document
* IN char *ActionName: Name of the action request or response
* IN char *ServType: Service type
* IN char * ArgName: Name of the argument
* IN char * ArgValue: Value of the argument
*
* Description:
* This function adds the argument in the action request or response.
* This function creates the action request or response if it is a first
* argument else it will add the argument in the document
*
* Returns: int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
***************************************************************************/
static int
addToAction( IN int response,
INOUT IXML_Document ** ActionDoc,
IN const char *ActionName,
IN const char *ServType,
IN const char *ArgName,
IN const char *ArgValue )
/*!
* \brief Adds the argument in the action request or response.
*
* This function creates the action request or response if it is a first
* argument, otherwise it will add the argument in the document.
*
* \returns UPNP_E_SUCCESS if successful, otherwise the appropriate error.
*/
static int addToAction(
/*! [in] flag to tell if the ActionDoc is for response or request. */
int response,
/*! [in,out] Request or response document. */
IXML_Document **ActionDoc,
/*! [in] Name of the action request or response. */
const char *ActionName,
/*! [in] Service type. */
const char *ServType,
/*! [in] Name of the argument. */
const char *ArgName,
/*! [in] Value of the argument. */
const char *ArgValue)
{
char *ActBuff = NULL;
IXML_Node *node = NULL;
IXML_Element *Ele = NULL;
IXML_Node *Txt = NULL;
int rc = 0;
char *ActBuff = NULL;
IXML_Node *node = NULL;
IXML_Element *Ele = NULL;
IXML_Node *Txt = NULL;
int rc = 0;
if( ActionName == NULL || ServType == NULL ) {
return UPNP_E_INVALID_PARAM;
}
if (ActionName == NULL || ServType == NULL) {
return UPNP_E_INVALID_PARAM;
}
if( *ActionDoc == NULL ) {
ActBuff = ( char * )malloc( HEADER_LENGTH );
if( ActBuff == NULL ) {
return UPNP_E_OUTOF_MEMORY;
}
if (*ActionDoc == NULL) {
ActBuff = (char *)malloc(HEADER_LENGTH);
if (ActBuff == NULL) {
return UPNP_E_OUTOF_MEMORY;
}
if( response ) {
sprintf( ActBuff,
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
ActionName, ServType, ActionName );
} else {
sprintf( ActBuff,
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
ActionName, ServType, ActionName );
}
if (response) {
sprintf(ActBuff,
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
ActionName, ServType, ActionName);
} else {
sprintf(ActBuff,
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
ActionName, ServType, ActionName);
}
rc = ixmlParseBufferEx( ActBuff, ActionDoc );
free( ActBuff );
if( rc != IXML_SUCCESS ) {
if( rc == IXML_INSUFFICIENT_MEMORY ) {
return UPNP_E_OUTOF_MEMORY;
} else {
return UPNP_E_INVALID_DESC;
}
}
}
rc = ixmlParseBufferEx(ActBuff, ActionDoc);
free(ActBuff);
if (rc != IXML_SUCCESS) {
if (rc == IXML_INSUFFICIENT_MEMORY) {
return UPNP_E_OUTOF_MEMORY;
} else {
return UPNP_E_INVALID_DESC;
}
}
}
if( ArgName != NULL /*&& ArgValue != NULL */ ) {
node = ixmlNode_getFirstChild( ( IXML_Node * ) * ActionDoc );
Ele = ixmlDocument_createElement( *ActionDoc, ArgName );
if( ArgValue ) {
Txt = ixmlDocument_createTextNode( *ActionDoc, ArgValue );
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
}
if (ArgName != NULL /*&& ArgValue != NULL */) {
node = ixmlNode_getFirstChild((IXML_Node *)*ActionDoc);
Ele = ixmlDocument_createElement(*ActionDoc, ArgName);
if(ArgValue) {
Txt = ixmlDocument_createTextNode(*ActionDoc, ArgValue);
ixmlNode_appendChild((IXML_Node *)Ele, Txt);
}
ixmlNode_appendChild(node, (IXML_Node *)Ele);
}
ixmlNode_appendChild( node, ( IXML_Node * ) Ele );
}
return UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : makeAction
*
* Parameters:
* IN int response: flag to tell if the ActionDoc is for response
* or request
* IN char * ActionName: Name of the action request or response
* IN char * ServType: Service type
* IN int NumArg :Number of arguments in the action request or response
* IN char * Arg : pointer to the first argument
* IN va_list ArgList: Argument list
*
* Description:
* This function creates the action request or response from the argument
* list.
* Returns: IXML_Document *
* returns action request or response document if successful
* else returns NULL
***************************************************************************/
static IXML_Document *
makeAction( IN int response,
IN const char *ActionName,
IN const char *ServType,
IN int NumArg,
IN const char *Arg,
IN va_list ArgList )
/*!
* \brief Creates the action request or response from the argument list.
*
* \return Action request or response document if successful, otherwise
* returns NULL
*/
static IXML_Document *makeAction(
/*! [in] flag to tell if the ActionDoc is for response or request. */
int response,
/*! [in] Name of the action request or response. */
const char *ActionName,
/*! [in] Service type. */
const char *ServType,
/*! [in] Number of arguments in the action request or response. */
int NumArg,
/*! [in] pointer to the first argument. */
const char *Arg,
/*! [in] Argument list. */
va_list ArgList)
{
const char *ArgName;
const char *ArgValue;
char *ActBuff;
int Idx = 0;
IXML_Document *ActionDoc;
IXML_Node *node;
IXML_Element *Ele;
IXML_Node *Txt = NULL;
const char *ArgName;
const char *ArgValue;
char *ActBuff;
int Idx = 0;
IXML_Document *ActionDoc;
IXML_Node *node;
IXML_Element *Ele;
IXML_Node *Txt = NULL;
if( ActionName == NULL || ServType == NULL ) {
return NULL;
}
if (ActionName == NULL || ServType == NULL) {
return NULL;
}
ActBuff = ( char * )malloc( HEADER_LENGTH );
if( ActBuff == NULL ) {
return NULL;
}
ActBuff = (char *)malloc(HEADER_LENGTH);
if (ActBuff == NULL) {
return NULL;
}
if( response ) {
sprintf( ActBuff,
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
ActionName, ServType, ActionName );
} else {
sprintf( ActBuff,
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
ActionName, ServType, ActionName );
}
if (response) {
sprintf(ActBuff,
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
ActionName, ServType, ActionName);
} else {
sprintf(ActBuff,
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
ActionName, ServType, ActionName);
}
if (ixmlParseBufferEx(ActBuff, &ActionDoc) != IXML_SUCCESS) {
free(ActBuff);
return NULL;
}
if( ixmlParseBufferEx( ActBuff, &ActionDoc ) != IXML_SUCCESS ) {
free( ActBuff );
return NULL;
}
free(ActBuff);
if(ActionDoc == NULL) {
return NULL;
}
free( ActBuff );
if (NumArg > 0) {
//va_start(ArgList, Arg);
ArgName = Arg;
for ( ; ; ) {
ArgValue = va_arg(ArgList, const char *);
if (ArgName != NULL) {
node = ixmlNode_getFirstChild((IXML_Node *)ActionDoc);
Ele = ixmlDocument_createElement(ActionDoc, ArgName);
if (ArgValue) {
Txt = ixmlDocument_createTextNode(ActionDoc, ArgValue);
ixmlNode_appendChild((IXML_Node *)Ele, Txt);
}
ixmlNode_appendChild(node, (IXML_Node *)Ele);
}
if (++Idx < NumArg) {
ArgName = va_arg(ArgList, const char *);
} else {
break;
}
}
//va_end(ArgList);
}
if( ActionDoc == NULL ) {
return NULL;
}
if( NumArg > 0 ) {
//va_start(ArgList, Arg);
ArgName = Arg;
for ( ; ; ) {
ArgValue = va_arg( ArgList, const char * );
if( ArgName != NULL ) {
node = ixmlNode_getFirstChild( ( IXML_Node * ) ActionDoc );
Ele = ixmlDocument_createElement( ActionDoc, ArgName );
if( ArgValue ) {
Txt =
ixmlDocument_createTextNode( ActionDoc, ArgValue );
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
}
ixmlNode_appendChild( node, ( IXML_Node * ) Ele );
}
if (++Idx < NumArg) {
ArgName = va_arg( ArgList, const char * );
} else {
break;
}
}
//va_end(ArgList);
}
return ActionDoc;
return ActionDoc;
}
/************************************************************************
* Function : UpnpMakeAction
*
* Parameters:
* IN char * ActionName: Name of the action request or response
* IN char * ServType: Service type
* IN int NumArg :Number of arguments in the action request or response
* IN char * Arg : pointer to the first argument
* IN ... : variable argument list
* IN va_list ArgList: Argument list
*
* Description:
* This function creates the action request from the argument
* list. Its a wrapper function that calls makeAction function to create
* the action request.
*
* Returns: IXML_Document *
* returns action request document if successful
* else returns NULL
***************************************************************************/
IXML_Document *
UpnpMakeAction( const char *ActionName,
const char *ServType,
int NumArg,
const char *Arg,
... )
IXML_Document *UpnpMakeAction(
const char *ActionName,
const char *ServType,
int NumArg,
const char *Arg,
...)
{
va_list ArgList;
IXML_Document *out = NULL;
va_list ArgList;
IXML_Document *out = NULL;
va_start( ArgList, Arg );
out = makeAction( 0, ActionName, ServType, NumArg, Arg, ArgList );
va_end( ArgList );
va_start(ArgList, Arg);
out = makeAction(0, ActionName, ServType, NumArg, Arg, ArgList);
va_end(ArgList);
return out;
return out;
}
/************************************************************************
* Function : UpnpMakeActionResponse
*
* Parameters:
* IN char * ActionName: Name of the action request or response
* IN char * ServType: Service type
* IN int NumArg :Number of arguments in the action request or response
* IN char * Arg : pointer to the first argument
* IN ... : variable argument list
* IN va_list ArgList: Argument list
*
* Description:
* This function creates the action response from the argument
* list. Its a wrapper function that calls makeAction function to create
* the action response.
*
* Returns: IXML_Document *
* returns action response document if successful
* else returns NULL
***************************************************************************/
IXML_Document *
UpnpMakeActionResponse( const char *ActionName,
const char *ServType,
int NumArg,
const char *Arg,
... )
IXML_Document *UpnpMakeActionResponse(
const char *ActionName,
const char *ServType,
int NumArg,
const char *Arg,
...)
{
va_list ArgList;
IXML_Document *out = NULL;
va_list ArgList;
IXML_Document *out = NULL;
va_start( ArgList, Arg );
out = makeAction( 1, ActionName, ServType, NumArg, Arg, ArgList );
va_end( ArgList );
va_start(ArgList, Arg);
out = makeAction(1, ActionName, ServType, NumArg, Arg, ArgList);
va_end(ArgList);
return out;
return out;
}
/************************************************************************
* Function : UpnpAddToActionResponse
*
* Parameters:
* INOUT IXML_Document **ActionResponse: action response document
* IN char * ActionName: Name of the action request or response
* IN char * ServType: Service type
* IN int ArgName :Name of argument to be added in the action response
* IN char * ArgValue : value of the argument
*
* Description:
* This function adds the argument in the action response. Its a wrapper
* function that calls addToAction function to add the argument in the
* action response.
*
* Returns: int
* returns UPNP_E_SUCCESS if successful
* else returns appropriate error
***************************************************************************/
int
UpnpAddToActionResponse( INOUT IXML_Document ** ActionResponse,
IN const char *ActionName,
IN const char *ServType,
IN const char *ArgName,
IN const char *ArgValue )
int UpnpAddToAction(
IXML_Document **ActionDoc,
const char *ActionName,
const char *ServType,
const char *ArgName,
const char *ArgValue)
{
return addToAction( 1, ActionResponse, ActionName, ServType, ArgName,
ArgValue );
return addToAction(0, ActionDoc, ActionName, ServType, ArgName, ArgValue);
}
/************************************************************************
* Function : UpnpAddToAction
*
* Parameters:
* INOUT IXML_Document **ActionDoc: action request document
* IN char * ActionName: Name of the action request or response
* IN char * ServType: Service type
* IN int ArgName :Name of argument to be added in the action response
* IN char * ArgValue : value of the argument
*
* Description:
* This function adds the argument in the action request. Its a wrapper
* function that calls addToAction function to add the argument in the
* action request.
*
* Returns: int
* returns UPNP_E_SUCCESS if successful
* else returns appropriate error
***************************************************************************/
int
UpnpAddToAction( IXML_Document ** ActionDoc,
const char *ActionName,
const char *ServType,
const char *ArgName,
const char *ArgValue )
{
return addToAction( 0, ActionDoc, ActionName, ServType, ArgName,
ArgValue );
int UpnpAddToActionResponse(
IXML_Document **ActionResponse,
const char *ActionName,
const char *ServType,
const char *ArgName,
const char *ArgValue)
{
return addToAction(1, ActionResponse, ActionName, ServType, ArgName, ArgValue);
}
/************************************************************************
* Function : UpnpAddToPropertySet
*
* Parameters:
* INOUT IXML_Document **PropSet: propertyset document
* IN char *ArgName: Name of the argument
* IN char *ArgValue: value of the argument
*
* Description:
* This function adds the argument in the propertyset node
*
* Returns: int
* returns UPNP_E_SUCCESS if successful else returns appropriate error
***************************************************************************/
int
UpnpAddToPropertySet( INOUT IXML_Document ** PropSet,
IN const char *ArgName,
IN const char *ArgValue )
IXML_Document *UpnpCreatePropertySet(
int NumArg,
const char *Arg,
...)
{
va_list ArgList;
int Idx = 0;
char BlankDoc[] =
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"
"</e:propertyset>";
const char *ArgName,
*ArgValue;
IXML_Node *node;
IXML_Element *Ele;
IXML_Element *Ele1;
IXML_Node *Txt;
IXML_Document *PropSet;
char BlankDoc[] = "<e:propertyset xmlns:e=\"urn:schemas"
"-upnp-org:event-1-0\"></e:propertyset>";
IXML_Node *node;
IXML_Element *Ele;
IXML_Element *Ele1;
IXML_Node *Txt;
int rc;
if(ixmlParseBufferEx(BlankDoc, &PropSet) != IXML_SUCCESS) {
return NULL;
}
if( ArgName == NULL ) {
return UPNP_E_INVALID_PARAM;
}
if (NumArg < 1) {
return PropSet;
}
if( *PropSet == NULL ) {
rc = ixmlParseBufferEx( BlankDoc, PropSet );
if( rc != IXML_SUCCESS ) {
return UPNP_E_OUTOF_MEMORY;
}
}
va_start(ArgList, Arg);
ArgName = Arg;
while (Idx++ != NumArg) {
ArgValue = va_arg(ArgList, const char *);
if (ArgName != NULL /*&& ArgValue != NULL */) {
node = ixmlNode_getFirstChild((IXML_Node *)PropSet);
Ele1 = ixmlDocument_createElement(PropSet, "e:property");
Ele = ixmlDocument_createElement(PropSet, ArgName);
if (ArgValue) {
Txt = ixmlDocument_createTextNode(PropSet, ArgValue);
ixmlNode_appendChild((IXML_Node *)Ele, Txt);
}
ixmlNode_appendChild((IXML_Node *)Ele1, (IXML_Node *)Ele);
ixmlNode_appendChild( node, (IXML_Node *)Ele1);
}
ArgName = va_arg(ArgList, const char *);
}
va_end(ArgList);
node = ixmlNode_getFirstChild( ( IXML_Node * ) * PropSet );
Ele1 = ixmlDocument_createElement( *PropSet, "e:property" );
Ele = ixmlDocument_createElement( *PropSet, ArgName );
if( ArgValue ) {
Txt = ixmlDocument_createTextNode( *PropSet, ArgValue );
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
}
ixmlNode_appendChild( ( IXML_Node * ) Ele1, ( IXML_Node * ) Ele );
ixmlNode_appendChild( node, ( IXML_Node * ) Ele1 );
return UPNP_E_SUCCESS;
return PropSet;
}
/************************************************************************
* Function : UpnpCreatePropertySet
*
* Parameters:
* IN int NumArg: Number of argument that will go in the propertyset node
* IN char * Args: argument strings
*
* Description:
* This function creates a propertyset node and put all the input
* parameters in the node as elements
*
* Returns: IXML_Document *
* returns the document containing propertyset node.
***************************************************************************/
IXML_Document *
UpnpCreatePropertySet( IN int NumArg,
IN const char *Arg,
... )
int UpnpAddToPropertySet(
IXML_Document **PropSet,
const char *ArgName,
const char *ArgValue)
{
va_list ArgList;
int Idx = 0;
char BlankDoc[] = "<e:propertyset xmlns:e=\"urn:schemas-"
"upnp-org:event-1-0\"></e:propertyset>";
const char *ArgName,
*ArgValue;
IXML_Node *node;
IXML_Element *Ele;
IXML_Element *Ele1;
IXML_Node *Txt;
IXML_Document *PropSet;
char BlankDoc[] =
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"
"</e:propertyset>";
IXML_Node *node;
IXML_Element *Ele;
IXML_Element *Ele1;
IXML_Node *Txt;
int rc;
if( ixmlParseBufferEx( BlankDoc, &PropSet ) != IXML_SUCCESS ) {
return NULL;
}
if (ArgName == NULL) {
return UPNP_E_INVALID_PARAM;
}
if( NumArg < 1 ) {
return NULL;
}
if (*PropSet == NULL) {
rc = ixmlParseBufferEx(BlankDoc, PropSet);
if (rc != IXML_SUCCESS) {
return UPNP_E_OUTOF_MEMORY;
}
}
va_start( ArgList, Arg );
ArgName = Arg;
node = ixmlNode_getFirstChild((IXML_Node *)*PropSet);
while( Idx++ != NumArg ) {
ArgValue = va_arg( ArgList, const char * );
Ele1 = ixmlDocument_createElement(*PropSet, "e:property");
Ele = ixmlDocument_createElement(*PropSet, ArgName);
if( ArgName != NULL /*&& ArgValue != NULL */ ) {
node = ixmlNode_getFirstChild( ( IXML_Node * ) PropSet );
Ele1 = ixmlDocument_createElement( PropSet, "e:property" );
Ele = ixmlDocument_createElement( PropSet, ArgName );
if( ArgValue ) {
Txt = ixmlDocument_createTextNode( PropSet, ArgValue );
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
}
if (ArgValue) {
Txt = ixmlDocument_createTextNode(*PropSet, ArgValue);
ixmlNode_appendChild((IXML_Node *)Ele, Txt);
}
ixmlNode_appendChild( ( IXML_Node * ) Ele1,
( IXML_Node * ) Ele );
ixmlNode_appendChild( node, ( IXML_Node * ) Ele1 );
}
ixmlNode_appendChild((IXML_Node *)Ele1, (IXML_Node *)Ele);
ixmlNode_appendChild(node, (IXML_Node *)Ele1);
ArgName = va_arg( ArgList, const char * );
}
va_end( ArgList );
return PropSet;
return UPNP_E_SUCCESS;
}
#endif
#endif /* EXCLUDE_DOM == 0 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,209 +1,329 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file defines the functions for clients. It defines
* functions for adding and removing clients to and from the client table,
* adding and accessing subscription and other attributes pertaining to the
* client
************************************************************************/
* Purpose: This file defines the functions for clients. It defines
* functions for adding and removing clients to and from the client table,
* adding and accessing subscription and other attributes pertaining to the
* client
************************************************************************/
#include "config.h"
#include "client_table.h"
/************************************************************************
* Function : copy_client_subscription
*
* Parameters :
* client_subscription * in ; - source client subscription
* client_subscription * out ; - destination client subscription
*
* Description : Make a copy of the client subscription data
*
* Return : int ;
* UPNP_E_OUTOF_MEMORY - On Failure to allocate memory
* HTTP_SUCCESS - On Success
*
* Note :
************************************************************************/
CLIENTONLY( int copy_client_subscription( client_subscription * in,
client_subscription * out ) {
int len = strlen( in->ActualSID ) + 1;
int len1 = strlen( in->EventURL ) + 1;
memcpy( out->sid, in->sid, SID_SIZE );
out->sid[SID_SIZE] = 0;
out->ActualSID = ( char * )malloc( len );
if( out->ActualSID == NULL )
return UPNP_E_OUTOF_MEMORY;
out->EventURL = ( char * )malloc( len1 );
if( out->EventURL == NULL ) {
free(out->ActualSID);
return UPNP_E_OUTOF_MEMORY;
}
memcpy( out->ActualSID, in->ActualSID, len );
memcpy( out->EventURL, in->EventURL, len1 );
//copies do not get RenewEvent Ids or next
out->RenewEventId = -1; out->next = NULL; return HTTP_SUCCESS;}
/************************************************************************
* Function : free_client_subscription
*
* Parameters :
* client_subscription * sub ; - Client subscription to be freed
*
* Description : Free memory allocated for client subscription data.
* Remove timer thread associated with this subscription event.
*
* Return : void ;
*
* Note :
************************************************************************/
void free_client_subscription( client_subscription * sub ) {
upnp_timeout * event; ThreadPoolJob tempJob; if( sub ) {
if( sub->ActualSID )
free( sub->ActualSID ); if( sub->EventURL )
free( sub->EventURL ); if( sub->RenewEventId != -1 ) //do not remove timer event of copy
//invalid timer event id
{
if( TimerThreadRemove
( &gTimerThread, sub->RenewEventId, &tempJob ) == 0 ) {
event = ( upnp_timeout * ) tempJob.arg;
free_upnp_timeout( event );}
}
#ifdef INCLUDE_CLIENT_APIS
sub->RenewEventId = -1;}
}
/************************************************************************
* Function : freeClientSubList
*
* Parameters :
* client_subscription * list ; Client subscription
*
* Description : Free the client subscription table.
*
* Return : void ;
*
* Note :
************************************************************************/
void freeClientSubList( client_subscription * list ) {
client_subscription * next; while( list ) {
free_client_subscription( list );
next = list->next; free( list ); list = next;}
}
#include <stdlib.h> // for calloc(), free()
/************************************************************************
* Function : RemoveClientSubClientSID
*
* Parameters :
* client_subscription **head ; Head of the subscription list
* const Upnp_SID sid ; Subscription ID to be mactched
*
* Description : Remove the client subscription matching the
* subscritpion id represented by the const Upnp_SID sid parameter
* from the table and update the table.
*
* Return : void ;
*
* Note :
************************************************************************/
void RemoveClientSubClientSID( client_subscription ** head,
const Upnp_SID sid ) {
client_subscription * finger = ( *head );
client_subscription * previous = NULL; while( finger ) {
if( !( strcmp( sid, finger->sid ) ) ) {
if( previous )
previous->next = finger->next;
else
( *head ) = finger->next;
finger->next = NULL;
freeClientSubList( finger ); finger = NULL;}
else
{
previous = finger; finger = finger->next;}
}
}
/************************************************************************
* Function : GetClientSubClientSID
*
* Parameters :
* client_subscription *head ; Head of the subscription list
* const Upnp_SID sid ; Subscription ID to be matched
*
* Description : Return the client subscription from the client table
* that matches const Upnp_SID sid subscrition id value.
*
* Return : client_subscription * ; The matching subscription
*
* Note :
************************************************************************/
client_subscription *
GetClientSubClientSID( client_subscription * head,
const Upnp_SID sid ) {
client_subscription * next = head; while( next ) {
if( !strcmp( next->sid, sid ) )
break;
else
{
next = next->next;}
}
return next;}
struct SClientSubscription {
int m_renewEventId;
UpnpString *m_SID;
UpnpString *m_actualSID;
UpnpString *m_eventURL;
struct SClientSubscription *m_next;
};
/************************************************************************
* Function : GetClientSubActualSID
*
* Parameters :
* client_subscription *head ; Head of the subscription list
* token * sid ; Subscription ID to be matched
*
* Description : Returns the client subscription from the client
* subscription table that has the matching token * sid buffer
* value.
*
* Return : client_subscription * ; The matching subscription
*
* Note :
************************************************************************/
client_subscription *
GetClientSubActualSID( client_subscription * head,
token * sid ) {
client_subscription * next = head; while( next ) {
if( !memcmp( next->ActualSID, sid->buff, sid->size ) )
break;
else
{
next = next->next;}
}
return next;}
/** Constructor */
ClientSubscription *UpnpClientSubscription_new()
{
struct SClientSubscription *p = calloc(1, sizeof (struct SClientSubscription));
#if 0
p->renewEventId = 0;
#endif
p->m_SID = UpnpString_new();
p->m_actualSID = UpnpString_new();
p->m_eventURL = UpnpString_new();
p->m_next = NULL;
return (ClientSubscription *)p;
}
/** Destructor */
void UpnpClientSubscription_delete(ClientSubscription *p)
{
struct SClientSubscription *q = (struct SClientSubscription *)p;
if (!q) return;
q->m_renewEventId = 0;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
UpnpString_delete(q->m_actualSID);
q->m_actualSID = NULL;
UpnpString_delete(q->m_eventURL);
q->m_eventURL = NULL;
q->m_next = NULL;
free(p);
}
/** Copy Constructor */
ClientSubscription *UpnpClientSubscription_dup(const ClientSubscription *p)
{
ClientSubscription *q = UpnpClientSubscription_new();
UpnpClientSubscription_assign(q, p);
return q;
}
/** Assignment operator */
void UpnpClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
{
if (q != p) {
// Do not copy RenewEventId
((struct SClientSubscription *)q)->m_renewEventId = -1;
UpnpClientSubscription_set_SID(q, UpnpClientSubscription_get_SID(p));
UpnpClientSubscription_set_ActualSID(q, UpnpClientSubscription_get_ActualSID(p));
UpnpClientSubscription_set_EventURL(q, UpnpClientSubscription_get_EventURL(p));
// Do not copy m_next
((struct SClientSubscription *)q)->m_next = NULL;
}
}
int UpnpClientSubscription_get_RenewEventId(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_renewEventId;
}
void UpnpClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
{
((struct SClientSubscription *)p)->m_renewEventId = n;
}
const UpnpString *UpnpClientSubscription_get_SID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_SID;
}
const char *UpnpClientSubscription_get_SID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_SID(p));
}
void UpnpClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_SID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
((struct SClientSubscription *)p)->m_SID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_SID, s);
}
const UpnpString *UpnpClientSubscription_get_ActualSID(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_actualSID;
}
const char *UpnpClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_ActualSID(p));
}
void UpnpClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
((struct SClientSubscription *)p)->m_actualSID = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_actualSID, s);
}
const UpnpString *UpnpClientSubscription_get_EventURL(const ClientSubscription *p)
{
return ((struct SClientSubscription *)p)->m_eventURL;
}
const char *UpnpClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
{
return UpnpString_get_String(UpnpClientSubscription_get_EventURL(p));
}
void UpnpClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
}
void UpnpClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s)
{
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
((struct SClientSubscription *)p)->m_eventURL = UpnpString_new();
UpnpString_set_String(((struct SClientSubscription *)p)->m_eventURL, s);
}
ClientSubscription *UpnpClientSubscription_get_Next(const ClientSubscription *p)
{
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
}
void UpnpClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
{
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
}
void free_client_subscription(ClientSubscription *sub)
{
upnp_timeout *event;
ThreadPoolJob tempJob;
if (sub) {
int renewEventId = UpnpClientSubscription_get_RenewEventId(sub);
UpnpClientSubscription_strcpy_ActualSID(sub, "");
UpnpClientSubscription_strcpy_EventURL(sub, "");
if (renewEventId != -1) {
// do not remove timer event of copy
// invalid timer event id
if (TimerThreadRemove(&gTimerThread, renewEventId, &tempJob) == 0) {
event = (upnp_timeout *)tempJob.arg;
free_upnp_timeout(event);
}
}
UpnpClientSubscription_set_RenewEventId(sub, -1);
}
}
void freeClientSubList(ClientSubscription *list)
{
ClientSubscription *next;
while (list) {
free_client_subscription(list);
next = UpnpClientSubscription_get_Next(list);
UpnpClientSubscription_delete(list);
list = next;
}
}
void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
{
ClientSubscription *finger = *head;
ClientSubscription *previous = NULL;
int found = 0;
while (finger) {
found = !strcmp(
UpnpString_get_String(sid),
UpnpClientSubscription_get_SID_cstr(finger));
if (found) {
if (previous) {
UpnpClientSubscription_set_Next(previous,
UpnpClientSubscription_get_Next(finger));
} else {
*head = UpnpClientSubscription_get_Next(finger);
}
UpnpClientSubscription_set_Next(finger, NULL);
freeClientSubList(finger);
finger = NULL;
} else {
previous = finger;
finger = UpnpClientSubscription_get_Next(finger);
}
}
}
ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpString *sid)
{
ClientSubscription *next = head;
int found = 0;
while (next) {
found = !strcmp(
UpnpClientSubscription_get_SID_cstr(next),
UpnpString_get_String(sid));
if(found) {
break;
} else {
next = UpnpClientSubscription_get_Next(next);
}
}
return next;
}
ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
{
ClientSubscription *next = head;
while (next) {
if (!memcmp(
UpnpClientSubscription_get_ActualSID_cstr(next),
sid->buff, sid->size)) {
break;
} else {
next = UpnpClientSubscription_get_Next(next);
}
}
return next;
}
#endif /* INCLUDE_CLIENT_APIS */
)

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +1,65 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/*
* \file
*
* \brief Contains functions for scanner and parser for http messages.
*/
/************************************************************************
* Purpose: This file contains functions for scanner and parser for http
* messages.
************************************************************************/
#define _GNU_SOURCE // For strcasestr() in string.h
#include "config.h"
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
#include "strintmap.h"
#include "httpparser.h"
#include "statcodes.h"
#include "unixutil.h"
#include "upnpdebug.h"
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/* entity positions */
// entity positions
#define NUM_HTTP_METHODS 9
static str_int_entry Http_Method_Table[NUM_HTTP_METHODS] = {
@ -59,7 +72,6 @@ static str_int_entry Http_Method_Table[NUM_HTTP_METHODS] = {
{"SUBSCRIBE", HTTPMETHOD_SUBSCRIBE},
{"UNSUBSCRIBE", HTTPMETHOD_UNSUBSCRIBE},
{"POST", SOAPMETHOD_POST},
};
#define NUM_HTTP_HEADER_NAMES 33
@ -100,9 +112,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
};
/***********************************************************************/
/************* scanner *************/
/***********************************************************************/
#define TOKCHAR_CR 0xD
@ -121,13 +131,11 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
*
* Note :
************************************************************************/
static UPNP_INLINE void
scanner_init( OUT scanner_t * scanner,
IN membuffer * bufptr )
static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufptr)
{
scanner->cursor = 0;
scanner->msg = bufptr;
scanner->entire_msg_loaded = FALSE;
scanner->cursor = 0;
scanner->msg = bufptr;
scanner->entire_msg_loaded = FALSE;
}
/************************************************************************
@ -142,10 +150,9 @@ scanner_init( OUT scanner_t * scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_separator_char( IN char c )
static UPNP_INLINE xboolean is_separator_char(IN char c)
{
return strchr( " \t()<>@,;:\\\"/[]?={}", c ) != NULL;
return strchr(" \t()<>@,;:\\\"/[]?={}", c) != NULL;
}
/************************************************************************
@ -160,10 +167,9 @@ is_separator_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_identifier_char( IN char c )
static UPNP_INLINE xboolean is_identifier_char(IN char c)
{
return ( c >= 32 && c <= 126 ) && !is_separator_char( c );
return c >= 32 && c <= 126 && !is_separator_char(c);
}
/************************************************************************
@ -178,10 +184,9 @@ is_identifier_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_control_char( IN char c )
static UPNP_INLINE xboolean is_control_char(IN char c)
{
return ( ( c >= 0 && c <= 31 ) || ( c == 127 ) );
return (c >= 0 && c <= 31) || c == 127;
}
/************************************************************************
@ -196,8 +201,7 @@ is_control_char( IN char c )
*
* Note :
************************************************************************/
static UPNP_INLINE xboolean
is_qdtext_char( IN char cc )
static UPNP_INLINE xboolean is_qdtext_char(IN char cc)
{
unsigned char c = ( unsigned char )cc;
@ -231,10 +235,10 @@ is_qdtext_char( IN char cc )
*
* Note :
************************************************************************/
static parse_status_t
scanner_get_token( INOUT scanner_t * scanner,
OUT memptr * token,
OUT token_type_t * tok_type )
static parse_status_t scanner_get_token(
INOUT scanner_t *scanner,
OUT memptr *token,
OUT token_type_t *tok_type)
{
char *cursor;
char *null_terminator; // point to null-terminator in buffer
@ -375,52 +379,11 @@ scanner_get_token( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE char *
scanner_get_str( IN scanner_t * scanner )
static UPNP_INLINE char *scanner_get_str(IN scanner_t * scanner)
{
return scanner->msg->buf + scanner->cursor;
return scanner->msg->buf + scanner->cursor;
}
/************************************************************************
* Function : scanner_pushback
*
* 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
*
* Return : void ;
*
* Note :
************************************************************************/
#warning The only use of the function 'scanner_pushback()' in the code is commented out.
#warning 'scanner_pushback()' is a candidate for removal.
static UPNP_INLINE void
scanner_pushback( INOUT scanner_t * scanner,
IN size_t pushback_bytes )
{
scanner->cursor -= pushback_bytes;
}
/***********************************************************************/
/************* end of scanner **************/
/***********************************************************************/
/***********************************************************************/
/************* parser **************/
/***********************************************************************/
/***********************************************************************/
/************* http_message_t **************/
/***********************************************************************/
/************************************************************************
* Function : httpmsg_compare
@ -435,15 +398,14 @@ scanner_pushback( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static int
httpmsg_compare( void *param1,
void *param2 )
static int httpmsg_compare(void *param1, void *param2)
{
assert( param1 != NULL );
assert( param2 != NULL );
return ( ( http_header_t * ) param1 )->name_id ==
( ( http_header_t * ) param2 )->name_id;
return
((http_header_t *)param1)->name_id ==
((http_header_t *)param2)->name_id;
}
/************************************************************************
@ -458,8 +420,7 @@ httpmsg_compare( void *param1,
*
* Note :
************************************************************************/
static void
httpheader_free( void *msg )
static void httpheader_free(void *msg)
{
http_header_t *hdr = ( http_header_t * ) msg;
@ -480,8 +441,7 @@ httpheader_free( void *msg )
*
* Note :
************************************************************************/
void
httpmsg_init( INOUT http_message_t * msg )
void httpmsg_init(INOUT http_message_t *msg)
{
msg->initialized = 1;
msg->entity.buf = NULL;
@ -503,8 +463,7 @@ httpmsg_init( INOUT http_message_t * msg )
*
* Note :
************************************************************************/
void
httpmsg_destroy( INOUT http_message_t * msg )
void httpmsg_destroy( INOUT http_message_t * msg )
{
assert( msg != NULL );
@ -532,9 +491,9 @@ httpmsg_destroy( INOUT http_message_t * msg )
*
* Note :
************************************************************************/
http_header_t *
httpmsg_find_hdr_str( IN http_message_t * msg,
IN const char *header_name )
http_header_t *httpmsg_find_hdr_str(
IN http_message_t *msg,
IN const char *header_name)
{
http_header_t *header;
@ -569,27 +528,21 @@ httpmsg_find_hdr_str( IN http_message_t * msg,
*
* Note :
************************************************************************/
http_header_t *
httpmsg_find_hdr( IN http_message_t * msg,
IN int header_name_id,
OUT memptr * value )
http_header_t *httpmsg_find_hdr(
IN http_message_t *msg,
IN int header_name_id,
OUT memptr *value)
{
http_header_t header; // temp header for searching
ListNode *node;
http_header_t *data;
header.name_id = header_name_id;
node = ListFind( &msg->headers, NULL, &header );
if( node == NULL ) {
return NULL;
}
data = ( http_header_t * ) node->item;
if( value != NULL ) {
value->buf = data->value.buf;
value->length = data->value.length;
@ -598,12 +551,6 @@ httpmsg_find_hdr( IN http_message_t * msg,
return data;
}
/***********************************************************************/
/************* http_parser_t **************/
/***********************************************************************/
/************************************************************************
* Function : skip_blank_lines
*
@ -616,26 +563,23 @@ httpmsg_find_hdr( IN http_message_t * msg,
*
* Note :
************************************************************************/
static UPNP_INLINE int
skip_blank_lines( INOUT scanner_t * scanner )
static UPNP_INLINE int skip_blank_lines(INOUT scanner_t *scanner)
{
memptr token;
token_type_t tok_type;
parse_status_t status;
memptr token;
token_type_t tok_type;
parse_status_t status;
// skip ws, crlf
do {
status = scanner_get_token( scanner, &token, &tok_type );
} while( status == PARSE_OK &&
( tok_type == TT_WHITESPACE || tok_type == TT_CRLF ) );
/* skip ws, crlf */
do {
status = scanner_get_token(scanner, &token, &tok_type);
} while (status == PARSE_OK &&
(tok_type == TT_WHITESPACE || tok_type == TT_CRLF));
if (status == PARSE_OK) {
/* pushback a non-whitespace token */
scanner->cursor -= token.length;
}
if( status == PARSE_OK ) {
// pushback a non-whitespace token
scanner->cursor -= token.length;
//scanner_pushback( scanner, token.length );
}
return status;
return status;
}
/************************************************************************
@ -653,8 +597,7 @@ skip_blank_lines( INOUT scanner_t * scanner )
*
* Note :
************************************************************************/
static UPNP_INLINE int
skip_lws( INOUT scanner_t * scanner )
static UPNP_INLINE int skip_lws(INOUT scanner_t *scanner)
{
memptr token;
token_type_t tok_type;
@ -708,9 +651,9 @@ skip_lws( INOUT scanner_t * scanner )
*
* Note :
************************************************************************/
static UPNP_INLINE parse_status_t
match_non_ws_string( INOUT scanner_t * scanner,
OUT memptr * str )
static UPNP_INLINE parse_status_t match_non_ws_string(
INOUT scanner_t *scanner,
OUT memptr *str)
{
memptr token;
token_type_t tok_type;
@ -774,9 +717,9 @@ match_non_ws_string( INOUT scanner_t * scanner,
*
* Note :
************************************************************************/
static UPNP_INLINE parse_status_t
match_raw_value( INOUT scanner_t * scanner,
OUT memptr * raw_value )
static UPNP_INLINE parse_status_t match_raw_value(
INOUT scanner_t * scanner,
OUT memptr *raw_value)
{
memptr token;
token_type_t tok_type;
@ -865,10 +808,10 @@ match_raw_value( INOUT scanner_t * scanner,
* PARSE_FAILURE -- bad input
* PARSE_INCOMPLETE
************************************************************************/
static UPNP_INLINE int
match_int( INOUT scanner_t * scanner,
IN int base,
OUT int *value )
static UPNP_INLINE int match_int(
INOUT scanner_t *scanner,
IN int base,
OUT int *value)
{
memptr token;
token_type_t tok_type;
@ -952,31 +895,6 @@ read_until_crlf( INOUT scanner_t * scanner,
return status;
}
/************************************************************************
* Function: skip_to_end_of_header
*
* Parameters:
* INOUT scanner_t* scanner ; Scanner Object
*
* Description: Skip to end of header
*
* Returns:
* PARSE_OK
* PARSE_FAILURE
* PARSE_INCOMPLETE
************************************************************************/
#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code.
#warning 'skip_to_end_of_header()' is a candidate for removal.
static UPNP_INLINE int
skip_to_end_of_header( INOUT scanner_t * scanner )
{
memptr dummy_raw_value;
parse_status_t status;
status = match_raw_value( scanner, &dummy_raw_value );
return status;
}
/************************************************************************
* Function: match_char
*
@ -1522,7 +1440,9 @@ parser_parse_responseline( INOUT http_parser_t * parser )
if( num_scanned != 3 ||
hmsg->major_version < 0 ||
hmsg->minor_version < 0 || hmsg->status_code < 0 ) {
/* HTTP version equals to 1.0 should fail as required by the
* UPnP certification tool */
hmsg->minor_version < 1 || hmsg->status_code < 0 ) {
// bad response line
return PARSE_FAILURE;
}
@ -1729,140 +1649,6 @@ parser_parse_headers( INOUT http_parser_t * parser )
}
////////////////////////////////////////////////////////////////////////
#ifdef HIGHLY_UNLIKELY
// **************
static parse_status_t
parser_parse_headers_old( INOUT http_parser_t * parser )
{
parse_status_t status;
memptr token;
memptr hdr_value;
token_type_t tok_type;
scanner_t *scanner = &parser->scanner;
size_t save_pos;
http_header_t *header;
int header_id;
int ret = 0;
int index;
http_header_t *orig_header;
char save_char;
int ret2,
ret3;
assert( parser->position == POS_HEADERS ||
parser->ent_position == ENTREAD_CHUNKY_HEADERS );
while( TRUE ) {
save_pos = scanner->cursor;
//
// check end of headers
//
status = scanner_get_token( scanner, &token, &tok_type );
if( status != PARSE_OK ) {
return status;
}
if( tok_type == TT_CRLF ) {
// end of headers
parser->position = POS_ENTITY; // read entity next
return PARSE_OK;
}
//
// not end; read header
//
if( tok_type != TT_IDENTIFIER ) {
return PARSE_FAILURE; // didn't see header name
}
status = match( scanner, " : %R%c", &hdr_value );
if( status != PARSE_OK ) {
// pushback tokens; useful only on INCOMPLETE error
scanner->cursor = save_pos;
return status;
}
//
// add header
//
// find header
index = map_str_to_int( token.buf, token.length, Http_Header_Names,
NUM_HTTP_HEADER_NAMES, FALSE );
if( index != -1 ) {
header_id = Http_Header_Names[index].id;
orig_header =
httpmsg_find_hdr( &parser->msg, header_id, NULL );
} else {
header_id = HDR_UNKNOWN;
save_char = token.buf[token.length];
token.buf[token.length] = '\0';
orig_header = httpmsg_find_hdr_str( &parser->msg, token.buf );
token.buf[token.length] = save_char; // restore
}
if( orig_header == NULL ) {
//
// add new header
//
header = ( http_header_t * ) malloc( sizeof( http_header_t ) );
if( header == NULL ) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
membuffer_init( &header->multi_hdr_buf );
header->name = token;
header->value = hdr_value;
header->name_id = header_id;
ret = dlist_append( &parser->msg.headers, header );
if( ret == UPNP_E_OUTOF_MEMORY ) {
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
} else if( hdr_value.length > 0 ) {
//
// append value to existing header
//
if( orig_header->multi_hdr_buf.buf == NULL ) {
// store in buffer
ret = membuffer_append( &orig_header->multi_hdr_buf,
orig_header->value.buf,
orig_header->value.length );
}
// append space
ret2 =
membuffer_append( &orig_header->multi_hdr_buf, ", ", 2 );
// append continuation of header value
ret3 = membuffer_append( &orig_header->multi_hdr_buf,
hdr_value.buf, hdr_value.length );
if( ret == UPNP_E_OUTOF_MEMORY ||
ret2 == UPNP_E_OUTOF_MEMORY ||
ret3 == UPNP_E_OUTOF_MEMORY ) {
// not enuf mem
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
return PARSE_FAILURE;
}
// header value points to allocated buf
orig_header->value.buf = orig_header->multi_hdr_buf.buf;
orig_header->value.length = orig_header->multi_hdr_buf.length;
}
} // end while
}
#endif
// ******************************
/************************************************************************
* Function: parser_parse_entity_using_clen
*
@ -1884,9 +1670,9 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
assert( parser->ent_position == ENTREAD_USING_CLEN );
// determine entity (i.e. body) length so far
//entity_length = parser->msg.msg.length - parser->entity_start_position;
parser->msg.entity.length =
parser->msg.msg.length - parser->entity_start_position;
parser->msg.msg.length - parser->entity_start_position +
parser->msg.entity_offset;
if( parser->msg.entity.length < parser->content_length ) {
// more data to be read
@ -1894,7 +1680,8 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser )
} else {
if( parser->msg.entity.length > parser->content_length ) {
// silently discard extra data
parser->msg.msg.buf[parser->entity_start_position +
parser->msg.msg.buf[parser->entity_start_position -
parser->msg.entity_offset +
parser->content_length] = '\0';
}
// save entity length
@ -2279,6 +2066,7 @@ parser_response_init( OUT http_parser_t * parser,
parser_init( parser );
parser->msg.is_request = FALSE;
parser->msg.request_method = request_method;
parser->msg.entity_offset = 0;
parser->position = POS_RESPONSE_LINE;
}
@ -2374,10 +2162,6 @@ parser_append( INOUT http_parser_t * parser,
return parser_parse( parser );
}
/************************************************************************
********** end of parser ***********
************************************************************************/
/************************************************************************
* Function: raw_to_int
*
@ -2390,9 +2174,7 @@ parser_append( INOUT http_parser_t * parser,
* Returns:
* int
************************************************************************/
int
raw_to_int( IN memptr * raw_value,
IN int base )
int raw_to_int(IN memptr *raw_value, IN int base)
{
long num;
char *end_ptr;
@ -2429,9 +2211,7 @@ raw_to_int( IN memptr * raw_value,
* Returns:
* int - index at which the substring is found.
************************************************************************/
int
raw_find_str( IN memptr *raw_value,
IN const char *str )
int raw_find_str(IN memptr *raw_value, IN const char *str)
{
char c;
char *ptr;
@ -2474,8 +2254,7 @@ raw_find_str( IN memptr *raw_value,
* Returns:
* const char* ptr - Ptr to the HTTP Method
************************************************************************/
const char *
method_to_str( IN http_method_t method )
const char *method_to_str(IN http_method_t method)
{
int index;
@ -2486,26 +2265,15 @@ method_to_str( IN http_method_t method )
return index == -1 ? NULL : Http_Method_Table[index].name;
}
/************************************************************************
* Function: print_http_headers
*
* Parameters:
* http_message_t* hmsg ; HTTP Message object
*
* Description:
*
* Returns:
* void
************************************************************************/
#ifdef DEBUG
void
print_http_headers( http_message_t * hmsg )
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
/* print start line */
if( hmsg->is_request ) {
printf( "method = %d, version = %d.%d, url = %.*s\n",
hmsg->method, hmsg->major_version, hmsg->minor_version,
@ -2516,19 +2284,19 @@ print_http_headers( http_message_t * hmsg )
(int)hmsg->status_msg.length, hmsg->status_msg.buf);
}
// print headers
/* 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;
/* 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
#endif /* DEBUG */

File diff suppressed because it is too large Load Diff

View File

@ -176,7 +176,7 @@ http_get_code_text( int statusCode )
int table_num;
if( !gInitialized ) {
init_tables( );
init_tables();
}
if( statusCode < 100 && statusCode >= 600 ) {

File diff suppressed because it is too large Load Diff

View File

@ -1,334 +1,214 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
**************************************************************************/
/************************************************************************
* Purpose: This file implements the sockets functionality
************************************************************************/
/*!
* \file
*
* \brief Implements the sockets functionality.
*/
#include "config.h"
#include "sock.h"
#include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */
#include "upnp.h"
#include <assert.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include "sock.h"
#include "upnp.h"
#ifndef WIN32
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#else
#include <winsock2.h>
#endif
#include "unixutil.h"
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#define MSG_NOSIGNAL 0
#endif
/************************************************************************
* Function : sock_init
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN int sockfd ; Socket Descriptor
*
* Description : Assign the passed in socket descriptor to socket
* descriptor in the SOCKINFO structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
*
* Note :
************************************************************************/
int
sock_init( OUT SOCKINFO * info,
IN int sockfd )
int sock_init(OUT SOCKINFO *info, IN SOCKET sockfd)
{
assert( info );
assert(info);
memset( info, 0, sizeof( SOCKINFO ) );
memset(info, 0, sizeof(SOCKINFO));
info->socket = sockfd;
info->socket = sockfd;
return UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : sock_init_with_ip
*
* Parameters :
* OUT SOCKINFO* info ; Socket Information Object
* IN int sockfd ; Socket Descriptor
* IN struct in_addr foreign_ip_addr ; Remote IP Address
* IN unsigned short foreign_ip_port ; Remote Port number
*
* Description : Calls the sock_init function and assigns the passed in
* IP address and port to the IP address and port in the SOCKINFO
* structure.
*
* Return : int;
* UPNP_E_SUCCESS
* UPNP_E_OUTOF_MEMORY
* UPNP_E_SOCKET_ERROR
*
* Note :
************************************************************************/
int
sock_init_with_ip( OUT SOCKINFO * info,
IN int sockfd,
IN struct in_addr foreign_ip_addr,
IN unsigned short foreign_ip_port )
int sock_init_with_ip(OUT SOCKINFO *info, IN SOCKET sockfd,
IN struct sockaddr *foreign_sockaddr)
{
int ret;
int ret;
ret = sock_init( info, sockfd );
if( ret != UPNP_E_SUCCESS ) {
return ret;
}
ret = sock_init(info, sockfd);
if (ret != UPNP_E_SUCCESS) {
return ret;
}
info->foreign_ip_addr = foreign_ip_addr;
info->foreign_ip_port = foreign_ip_port;
memcpy(&info->foreign_sockaddr, foreign_sockaddr,
sizeof(info->foreign_sockaddr));
return UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
}
/************************************************************************
* Function : sock_destroy
*
* Parameters :
* INOUT SOCKINFO* info ; Socket Information Object
* int ShutdownMethod ; How to shutdown the socket. Used by
* sockets's shutdown()
*
* Description : Shutsdown the socket using the ShutdownMethod to
* indicate whether sends and receives on the socket will be
* dis-allowed. After shutting down the socket, closesocket is called
* to release system resources used by the socket calls.
*
* Return : int;
* UPNP_E_SOCKET_ERROR on failure
* UPNP_E_SUCCESS on success
*
* Note :
************************************************************************/
int
sock_destroy( INOUT SOCKINFO * info,
int ShutdownMethod )
int sock_destroy(INOUT SOCKINFO *info, int ShutdownMethod)
{
shutdown( info->socket, ShutdownMethod );
if( UpnpCloseSocket( info->socket ) == -1 ) {
return UPNP_E_SOCKET_ERROR;
}
int ret = UPNP_E_SUCCESS;
return UPNP_E_SUCCESS;
if (info->socket != -1) {
shutdown(info->socket, ShutdownMethod);
if (sock_close(info->socket) == -1) {
ret = UPNP_E_SOCKET_ERROR;
}
info->socket = -1;
}
return ret;
}
/************************************************************************
* Function : sock_read_write
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* OUT char* buffer ; Buffer to get data to or send data from
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
* IN xboolean bRead ; Boolean value specifying read or write option
*
* Description : Receives or sends data. Also returns the time taken
* to receive or send data.
*
* Return :int ;
* numBytes - On Success, no of bytes received or sent
* UPNP_E_TIMEDOUT - Timeout
* UPNP_E_SOCKET_ERROR - Error on socket calls
*
* Note :
************************************************************************/
static int
sock_read_write( IN SOCKINFO * info,
OUT char *buffer,
IN size_t bufsize,
IN int *timeoutSecs,
IN xboolean bRead )
/*!
* \brief Receives or sends data. Also returns the time taken to receive or
* send data.
*
* \return
* \li \c numBytes - On Success, no of bytes received or sent or
* \li \c UPNP_E_TIMEDOUT - Timeout
* \li \c UPNP_E_SOCKET_ERROR - Error on socket calls
*/
static int sock_read_write(
/*! Socket Information Object. */
IN SOCKINFO *info,
/*! Buffer to get data to or send data from. */
OUT char *buffer,
/*! Size of the buffer. */
IN size_t bufsize,
/*! timeout value. */
IN int *timeoutSecs,
/*! Boolean value specifying read or write option. */
IN xboolean bRead)
{
int retCode;
fd_set readSet;
fd_set writeSet;
struct timeval timeout;
int numBytes;
time_t start_time = time( NULL );
int sockfd = info->socket;
long bytes_sent = 0,
byte_left = 0,
num_written;
if( *timeoutSecs < 0 ) {
return UPNP_E_TIMEDOUT;
}
FD_ZERO( &readSet );
FD_ZERO( &writeSet );
if( bRead ) {
FD_SET( ( unsigned )sockfd, &readSet );
} else {
FD_SET( ( unsigned )sockfd, &writeSet );
}
timeout.tv_sec = *timeoutSecs;
timeout.tv_usec = 0;
while( TRUE ) {
if( *timeoutSecs == 0 ) {
retCode =
select( sockfd + 1, &readSet, &writeSet, NULL, NULL );
} else {
retCode =
select( sockfd + 1, &readSet, &writeSet, NULL, &timeout );
}
if( retCode == 0 ) {
return UPNP_E_TIMEDOUT;
}
if( retCode == -1 ) {
if( errno == EINTR )
continue;
return UPNP_E_SOCKET_ERROR; // error
} else {
break; // read or write
}
}
int retCode;
fd_set readSet;
fd_set writeSet;
struct timeval timeout;
int numBytes;
time_t start_time = time(NULL);
SOCKET sockfd = info->socket;
long bytes_sent = 0, byte_left = 0, num_written;
if (*timeoutSecs < 0) {
return UPNP_E_TIMEDOUT;
}
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
if (bRead) {
FD_SET(sockfd, &readSet);
} else {
FD_SET(sockfd, &writeSet);
}
timeout.tv_sec = *timeoutSecs;
timeout.tv_usec = 0;
while (TRUE) {
if (*timeoutSecs == 0) {
retCode = select(sockfd + 1, &readSet, &writeSet,
NULL, NULL);
} else {
retCode = select(sockfd + 1, &readSet, &writeSet,
NULL, &timeout);
}
if (retCode == 0) {
return UPNP_E_TIMEDOUT;
}
if (retCode == -1) {
if (errno == EINTR)
continue;
return UPNP_E_SOCKET_ERROR;
} else {
/* read or write. */
break;
}
}
#ifdef SO_NOSIGPIPE
{
int old;
int set = 1;
socklen_t olen = sizeof(old);
getsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, &olen);
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
{
int old;
int set = 1;
socklen_t olen = sizeof(old);
getsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, &olen);
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
#endif
if( bRead ) {
// read data
numBytes = recv( sockfd, buffer, bufsize,MSG_NOSIGNAL);
} else {
byte_left = bufsize;
bytes_sent = 0;
while( byte_left > 0 ) {
// write data
num_written =
send( sockfd, buffer + bytes_sent, byte_left,
MSG_DONTROUTE|MSG_NOSIGNAL);
if( num_written == -1 ) {
if (bRead) {
/* read data. */
numBytes = recv(sockfd, buffer, bufsize, MSG_NOSIGNAL);
} else {
byte_left = bufsize;
bytes_sent = 0;
while (byte_left > 0) {
/* write data. */
num_written = send(sockfd,
buffer + bytes_sent, byte_left,
MSG_DONTROUTE | MSG_NOSIGNAL);
if (num_written == -1) {
#ifdef SO_NOSIGPIPE
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
setsockopt(sockfd, SOL_SOCKET,
SO_NOSIGPIPE, &old, olen);
#endif
return num_written;
}
byte_left = byte_left - num_written;
bytes_sent += num_written;
}
numBytes = bytes_sent;
}
return num_written;
}
byte_left = byte_left - num_written;
bytes_sent += num_written;
}
numBytes = bytes_sent;
}
#ifdef SO_NOSIGPIPE
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
}
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &old, olen);
}
#endif
if (numBytes < 0) {
return UPNP_E_SOCKET_ERROR;
}
/* subtract time used for reading/writing. */
if (*timeoutSecs != 0) {
*timeoutSecs -= time(NULL) - start_time;
}
if( numBytes < 0 ) {
return UPNP_E_SOCKET_ERROR;
}
// subtract time used for reading/writing
if( *timeoutSecs != 0 ) {
*timeoutSecs -= time( NULL ) - start_time;
}
return numBytes;
return numBytes;
}
/************************************************************************
* Function : sock_read
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* OUT char* buffer ; Buffer to get data to
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Calls sock_read_write() for reading data on the
* socket
*
* Return : int;
* Values returned by sock_read_write()
*
* Note :
************************************************************************/
int
sock_read( IN SOCKINFO * info,
OUT char *buffer,
IN size_t bufsize,
INOUT int *timeoutSecs )
int sock_read(IN SOCKINFO *info, OUT char *buffer, IN size_t bufsize,
INOUT int *timeoutSecs)
{
return sock_read_write( info, buffer, bufsize, timeoutSecs, TRUE );
return sock_read_write(info, buffer, bufsize, timeoutSecs, TRUE);
}
/************************************************************************
* Function : sock_write
*
* Parameters :
* IN SOCKINFO *info ; Socket Information Object
* IN char* buffer ; Buffer to send data from
* IN size_t bufsize ; Size of the buffer
* IN int *timeoutSecs ; timeout value
*
* Description : Calls sock_read_write() for writing data on the
* socket
*
* Return : int;
* sock_read_write()
*
* Note :
************************************************************************/
int
sock_write( IN SOCKINFO * info,
IN char *buffer,
IN size_t bufsize,
INOUT int *timeoutSecs )
int sock_write(IN SOCKINFO *info, IN char *buffer, IN size_t bufsize,
INOUT int *timeoutSecs)
{
return sock_read_write( info, buffer, bufsize, timeoutSecs, FALSE );
return sock_read_write(info, buffer, bufsize, timeoutSecs, FALSE);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,34 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file defines the functions for services. It defines
@ -116,25 +117,8 @@ RemoveSubscriptionSID( Upnp_SID sid,
}
/************************************************************************
* Function : GetSubscriptionSID
*
* Parameters :
* Upnp_SID sid ; subscription ID
* service_info * service ; service object providing the list of
* subscriptions
*
* Description : Return the subscription from the service table
* that matches const Upnp_SID sid value.
*
* Return : subscription * - Pointer to the matching subscription
* node;
*
* Note :
************************************************************************/
subscription *
GetSubscriptionSID( Upnp_SID sid,
service_info * service )
subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
{
subscription *next = service->subscriptionList;
subscription *previous = NULL;
@ -169,31 +153,15 @@ GetSubscriptionSID( Upnp_SID sid,
}
/************************************************************************
* Function : GetNextSubscription
*
* Parameters :
* service_info * service ; service object providing the list of
* subscriptions
* subscription *current ; current subscription object
*
* Description : Get current and valid subscription from the service
* table.
*
* Return : subscription * - Pointer to the next subscription node;
*
* Note :
************************************************************************/
subscription *
GetNextSubscription( service_info * service,
subscription * current )
subscription *GetNextSubscription(service_info *service, subscription *current)
{
time_t current_time;
subscription *next = NULL;
subscription *previous = NULL;
int notDone = 1;
//get the current_time
// get the current_time
time( &current_time );
while( ( notDone ) && ( current ) ) {
previous = current;
@ -218,52 +186,26 @@ GetNextSubscription( service_info * service,
return next;
}
/************************************************************************
* Function : GetFirstSubscription
*
* Parameters :
* service_info *service ; service object providing the list of
* subscriptions
*
* Description : Gets pointer to the first subscription node in the
* service table.
*
* Return : subscription * - pointer to the first subscription node ;
*
* Note :
************************************************************************/
subscription *
GetFirstSubscription( service_info * service )
{
subscription temp;
subscription *next = NULL;
temp.next = service->subscriptionList;
next = GetNextSubscription( service, &temp );
service->subscriptionList = temp.next;
// service->subscriptionList=next;
return next;
subscription *GetFirstSubscription(service_info *service)
{
subscription temp;
subscription *next = NULL;
temp.next = service->subscriptionList;
next = GetNextSubscription(service, &temp);
service->subscriptionList = temp.next;
// service->subscriptionList = next;
return next;
}
/************************************************************************
* Function : freeSubscription
*
* Parameters :
* subscription * sub ; subscription to be freed
*
* Description : Free's the memory allocated for storing the URL of
* the subscription.
*
* Return : void ;
*
* Note :
************************************************************************/
void
freeSubscription( subscription * sub )
void freeSubscription(subscription *sub)
{
if( sub ) {
free_URL_list( &sub->DeliveryURLs );
}
if (sub) {
free_URL_list(&sub->DeliveryURLs);
}
}
/************************************************************************
@ -929,8 +871,10 @@ getServiceList( IXML_Node * node,
( *end ) = current;
return head;
} else
} else {
( *end ) = NULL;
return NULL;
}
}
@ -976,7 +920,8 @@ getAllServiceList( IXML_Node * node,
if( head ) {
end->next =
getServiceList( currentDevice, &next_end, URLBase );
end = next_end;
if ( next_end )
end = next_end;
} else
head = getServiceList( currentDevice, &end, URLBase );

View File

@ -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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file contains functions that operate on memory and
@ -491,6 +491,8 @@ membuffer_delete( INOUT membuffer * m,
assert( m != NULL );
if (!m) return;
if( m->length == 0 ) {
return;
}

View File

@ -1,65 +1,59 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/*!
* \file
*
* \brief Contains a function for freeing the memory associated with a upnp
* time out event.
*/
/************************************************************************
* Purpose: This file contains a function for freeing the memory associated
* wuth a upnp time out event.
************************************************************************/
#include "config.h"
#include "upnp_timeout.h"
#include <stdlib.h>
/************************************************************************
* Function : free_upnp_timeout
*
* Parameters :
* upnp_timeout *event ; Event which needs to be freed
*
* Description : Free memory associated with event and memory for any
* sub-elements
*
* Return : void ;
*
* Note :
************************************************************************/
void
free_upnp_timeout( upnp_timeout * event )
#include <stdlib.h> /* for free() */
void free_upnp_timeout(upnp_timeout *event)
{
if( event ) {
if( event->Event )
free( event->Event );
free( event );
}
if (event) {
if (event->Event) {
free(event->Event);
}
free(event);
}
}

View File

@ -1,43 +1,48 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file contains functions for copying strings based on
* different options.
************************************************************************/
#include "config.h"
#include "upnp.h"
#include "util.h"
#include <string.h>
/************************************************************************
* Function : linecopy
*

Some files were not shown because too many files have changed in this diff Show More