Compare commits
269 Commits
release-1.
...
last_svn_t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a15e0c99d7 | ||
|
|
93a3016df1 | ||
|
|
36d6a34f5d | ||
|
|
9763158d69 | ||
|
|
2963919081 | ||
|
|
9f7936781e | ||
|
|
bc724a8073 | ||
|
|
7ff1d56906 | ||
|
|
2150bdc5b6 | ||
|
|
5bb3621626 | ||
|
|
b895fce678 | ||
|
|
bc551a1ab3 | ||
|
|
a13d09176f | ||
|
|
03c858af51 | ||
|
|
b2e38b2fca | ||
|
|
fab22807c0 | ||
|
|
338b22b754 | ||
|
|
11524cc218 | ||
|
|
54727b2a9e | ||
|
|
71ec18a3a9 | ||
|
|
99758f2dff | ||
|
|
3772ad4595 | ||
|
|
d33ad5c03e | ||
|
|
ad9bcc9100 | ||
|
|
da5cf568e6 | ||
|
|
7f1be91e76 | ||
|
|
01039a1d9a | ||
|
|
472cc5a993 | ||
|
|
a627df4d10 | ||
|
|
8f852b1ee9 | ||
|
|
59ec1fd641 | ||
|
|
3fb182aa95 | ||
|
|
9c440e2cbf | ||
|
|
c434f275ef | ||
|
|
35392132af | ||
|
|
5eccaf4b64 | ||
|
|
c6558b04d5 | ||
|
|
bf169e434c | ||
|
|
b26fe55772 | ||
|
|
1e6c3331ed | ||
|
|
c7806de98c | ||
|
|
c56ab5613e | ||
|
|
f6a30b842c | ||
|
|
cbbbb14e21 | ||
|
|
0c578f7962 | ||
|
|
500eb1df8f | ||
|
|
8eac74ee50 | ||
|
|
b80e888ae2 | ||
|
|
82a3114379 | ||
|
|
218d4bf5dd | ||
|
|
6b0272d66b | ||
|
|
aca89457ae | ||
|
|
b77fead68a | ||
|
|
da3ce95628 | ||
|
|
44cb915b1b | ||
|
|
bb55b1ed9c | ||
|
|
5c61b05ee9 | ||
|
|
285f6a2a72 | ||
|
|
cd01b538a9 | ||
|
|
34b5a5ce90 | ||
|
|
78f5e5004f | ||
|
|
54ab392bbd | ||
|
|
13a771367d | ||
|
|
7847d15171 | ||
|
|
8ab8265fd2 | ||
|
|
443cc8ea37 | ||
|
|
cd6d5822fb | ||
|
|
c9484d4f20 | ||
|
|
8180a54f41 | ||
|
|
1548c9044d | ||
|
|
943483e8b7 | ||
|
|
d991fbe26c | ||
|
|
6baedbab55 | ||
|
|
7d1e026c0c | ||
|
|
f00392e678 | ||
|
|
654363468a | ||
|
|
b0f782f9c2 | ||
|
|
cb6dfa2824 | ||
|
|
40b43458f1 | ||
|
|
3182593c01 | ||
|
|
c89f83497e | ||
|
|
46bc551a48 | ||
|
|
087e675c94 | ||
|
|
11a4ce7359 | ||
|
|
a6ba868e58 | ||
|
|
9f96b04831 | ||
|
|
219871b1dc | ||
|
|
a583e0a60e | ||
|
|
3906d8c2c7 | ||
|
|
4578ff8452 | ||
|
|
8e03b34739 | ||
|
|
5c008e3634 | ||
|
|
7f4bac9727 | ||
|
|
f00752efbd | ||
|
|
b78f27dd3e | ||
|
|
9e3b03e229 | ||
|
|
3d7b653426 | ||
|
|
0f2463f739 | ||
|
|
680db7c78d | ||
|
|
a9064dc0ca | ||
|
|
9ca32e0eb4 | ||
|
|
aa63ef88f1 | ||
|
|
08a4da2876 | ||
|
|
93ff2d7361 | ||
|
|
37ecd99305 | ||
|
|
9fc2c364fa | ||
|
|
7a796b264e | ||
|
|
517965c946 | ||
|
|
767eac1050 | ||
|
|
ad8a223998 | ||
|
|
00e047f3c8 | ||
|
|
0ea80ee482 | ||
|
|
23260a7df1 | ||
|
|
2a4701328c | ||
|
|
0e7e47d5bd | ||
|
|
e83ccbe4d0 | ||
|
|
ef0835d038 | ||
|
|
3d78996c40 | ||
|
|
92f4a78ffa | ||
|
|
6fb2655086 | ||
|
|
441cf2e471 | ||
|
|
eb66b253e2 | ||
|
|
c1ac15fccc | ||
|
|
ecb06fa24f | ||
|
|
1175a0cadb | ||
|
|
1401fce206 | ||
|
|
bbb4478c81 | ||
|
|
b4b4ee982f | ||
|
|
a8521c09cf | ||
|
|
d0d4a0631a | ||
|
|
494518b14b | ||
|
|
724700be0d | ||
|
|
bad7c80e5e | ||
|
|
ddb2f2c478 | ||
|
|
4beacd4c2d | ||
|
|
0e51ee5b61 | ||
|
|
7cf161ad22 | ||
|
|
2e85c471ca | ||
|
|
35db3e9bba | ||
|
|
98e2b2b3af | ||
|
|
494613c23b | ||
|
|
0eba550da0 | ||
|
|
90f52baa61 | ||
|
|
094cedc807 | ||
|
|
9a98f25b95 | ||
|
|
e90e549cbb | ||
|
|
efb6812b3e | ||
|
|
263e616403 | ||
|
|
b503c89f78 | ||
|
|
c60ab8eeac | ||
|
|
d8fce6e0fe | ||
|
|
e56a9d68a3 | ||
|
|
4e6102d1c2 | ||
|
|
9e54783740 | ||
|
|
164dce7fc2 | ||
|
|
537a9a4d93 | ||
|
|
9326b73d06 | ||
|
|
0fb20847a7 | ||
|
|
6b7dc5d340 | ||
|
|
a86a127f44 | ||
|
|
7acfd52f6b | ||
|
|
be2fa49891 | ||
|
|
d2c34a15de | ||
|
|
98a45e17b5 | ||
|
|
2e4a96f034 | ||
|
|
4f2075b7c9 | ||
|
|
7206e80127 | ||
|
|
5e742f04e3 | ||
|
|
0fc29c3d99 | ||
|
|
2c094ee8ea | ||
|
|
a4a7dda7ef | ||
|
|
a732d1a62e | ||
|
|
f18abdb52d | ||
|
|
85024d9576 | ||
|
|
8d21e60a2f | ||
|
|
84cb69fc2d | ||
|
|
0a173ca0c3 | ||
|
|
39e77f6d25 | ||
|
|
e599661068 | ||
|
|
3846fcc9ba | ||
|
|
0b39b2ad6c | ||
|
|
a91534042e | ||
|
|
04f80795c2 | ||
|
|
6223b7521f | ||
|
|
04b2ccca92 | ||
|
|
13bcc67f14 | ||
|
|
156ee82358 | ||
|
|
6d426a5d2e | ||
|
|
59784a134c | ||
|
|
2683d884ce | ||
|
|
d2d2081230 | ||
|
|
37558fb793 | ||
|
|
fa84a12d61 | ||
|
|
5bc8cae4ea | ||
|
|
c28942f6fe | ||
|
|
cc5ebd5b78 | ||
|
|
d264810747 | ||
|
|
77f1cff5d5 | ||
|
|
c24997917a | ||
|
|
332064ce09 | ||
|
|
93d2b99446 | ||
|
|
bcfedbc45e | ||
|
|
7b4dfce3dc | ||
|
|
87eff01a43 | ||
|
|
757caf9284 | ||
|
|
3b38c5fe68 | ||
|
|
1ab5221db5 | ||
|
|
f94b090c80 | ||
|
|
5756f589d7 | ||
|
|
ad479caddf | ||
|
|
16c883932a | ||
|
|
1457bf5937 | ||
|
|
ff3c4ae623 | ||
|
|
4e23dd9c1b | ||
|
|
3fe9ccb9ae | ||
|
|
4a6014c6f6 | ||
|
|
3f4be1ef7b | ||
|
|
868d0f0a03 | ||
|
|
b66f2646c3 | ||
|
|
34e18c2444 | ||
|
|
0ea632f699 | ||
|
|
e156038d5c | ||
|
|
9bfac585af | ||
|
|
8faf828b50 | ||
|
|
44b8ee0b3a | ||
|
|
66ed0d8f69 | ||
|
|
be3a6c6825 | ||
|
|
6cbd7f0159 | ||
|
|
c7c493c043 | ||
|
|
c2f8e8789a | ||
|
|
76457d0187 | ||
|
|
9f5d49f9fd | ||
|
|
cad4d05cd7 | ||
|
|
26b8968e0c | ||
|
|
d2eaa23b59 | ||
|
|
b8aec74782 | ||
|
|
851cfbc4db | ||
|
|
f42bbb6dc2 | ||
|
|
bd6027c3d1 | ||
|
|
e3865bf6b6 | ||
|
|
27af41e562 | ||
|
|
1f05f5d6cc | ||
|
|
43b9760840 | ||
|
|
0103424b91 | ||
|
|
13a1fff7a1 | ||
|
|
c9463545a8 | ||
|
|
de1d7e81a3 | ||
|
|
f87dbf8115 | ||
|
|
83ee32afb7 | ||
|
|
4f960c4e34 | ||
|
|
c85537df11 | ||
|
|
20905cb7a7 | ||
|
|
5b744169d5 | ||
|
|
c69e16b347 | ||
|
|
cb7e6b7472 | ||
|
|
fd80e5a8ff | ||
|
|
b29de32110 | ||
|
|
6455ac6eea | ||
|
|
f7bb1f9582 | ||
|
|
0728ab3b25 | ||
|
|
cb9ee8254c | ||
|
|
f08fdac9b6 | ||
|
|
0db035cc7b | ||
|
|
da11e52924 | ||
|
|
bc7b0c9d4d | ||
|
|
b2757d9d55 | ||
|
|
7967a0cd45 | ||
|
|
67b51187b9 | ||
|
|
491f5ffef6 |
780
ChangeLog
780
ChangeLog
@@ -1,3 +1,721 @@
|
|||||||
|
*******************************************************************************
|
||||||
|
Version 1.8.0
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-08-22 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* upnp/src/api/Discovery.c: Fix a serious bug and memory leak in
|
||||||
|
UpnpDiscovery_strcpy_DeviceType(). Thanks to David Blanchet for the
|
||||||
|
patch.
|
||||||
|
|
||||||
|
2010-04-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
Separation of the ClientSubscription object.
|
||||||
|
|
||||||
|
2010-04-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
Protect the object destructors agains null pointers on deletion, which
|
||||||
|
should be something valid.
|
||||||
|
|
||||||
|
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
SF Patch Tracker [ 2987390 ] upnp_debug vs. ixml_debug
|
||||||
|
Thanks for the load of updates, I'm still assimilating them ! Could I make
|
||||||
|
a suggestion though? The addition of printNodes(IXML_Node) to upnpdebug a
|
||||||
|
dds a new dependency on ixml.h for anything using upnpdebug.h. I'm making
|
||||||
|
quite a bit of use of upnpdebug in porting things to version 1.8.0, and I'd
|
||||||
|
prefer it if printNodes could be added to ixmldebug.h instead. I'm attach
|
||||||
|
ing a patch, what do you think ?
|
||||||
|
|
||||||
|
Nick
|
||||||
|
|
||||||
|
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Forward port of svn revision 505:
|
||||||
|
SF Patch Tracker [ 2836704 ] Patch for Solaris10 compilation and usage.
|
||||||
|
Submitted By: zephyrus ( zephyrus00jp )
|
||||||
|
|
||||||
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
|
||||||
|
Submitted By: Nick Leverton (leveret)
|
||||||
|
Fix the order of header inclusion for FreeBSD.
|
||||||
|
|
||||||
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Forward port of svn revision 502:
|
||||||
|
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.
|
||||||
|
|
||||||
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2973319 ] Problem in commit 499
|
||||||
|
Submitted By: Nick Leverton (leveret)
|
||||||
|
Afraid that this doesn't compile, it seems retval should be retVal in two
|
||||||
|
places.
|
||||||
|
|
||||||
|
2010-03-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fix for the ithread_mutex_unlock() logic in UpnpInit().
|
||||||
|
Thanks for Nicholas Kraft.
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2962606 ] Autorenewal errors: invalid SID,
|
||||||
|
too-short renewal interval
|
||||||
|
Submitted By: Nick Leverton (leveret)
|
||||||
|
|
||||||
|
Auto-renewals send an invalid SID due to a missing UpnpString_get_String
|
||||||
|
call. They also send a renewal interval of 0 instead of copying it from
|
||||||
|
the original subscription.
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2964685 ] patch for avoiding inet_ntoa (1.8.0)
|
||||||
|
Submitted By: Nick Leverton (leveret)
|
||||||
|
|
||||||
|
Seems like SF's tracker won't let me add a patch to someone else's issue ?!
|
||||||
|
This refers to https://sourceforge.net/support/tracker.php?aid=2724578
|
||||||
|
|
||||||
|
The calls to inet_ntoa are in getlocalhostname(), which is called from
|
||||||
|
UpnpInit when it is returning the bound IP address.
|
||||||
|
UpnpInit/getlocalhostname hasn't been updated to IPv6, I presume this is
|
||||||
|
deliberate so that it doesn't start returning IPv6 addresses and
|
||||||
|
overwriting the caller's IPv4-sized allocation.
|
||||||
|
|
||||||
|
The attached patch just updates getlocalhostname to use inet_ntop instead
|
||||||
|
of inet_ntoa, and also documents the fact that UpnpInit is IPv4 only whilst
|
||||||
|
UpnpInnit2 is both IPv4 and IPv6.
|
||||||
|
|
||||||
|
A fuller solution might be to change UpnpInit to use some variant on
|
||||||
|
UpnpGetIfInfo. UpnpInit could still be left as IPv4 only if desired -
|
||||||
|
perhaps UpnpGetIfInfo could take an option for the desired address family.
|
||||||
|
getlocalhostname and its own copy of the interface scanning code would then
|
||||||
|
be redundant. I don't have IPv6 capability here though so I'm reluctant to
|
||||||
|
change the IPv6 code, as I have no way to test it.
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2724578 ] patch for avoiding memory leaks when
|
||||||
|
add devices
|
||||||
|
|
||||||
|
each time a device been added, UpnpInit() is called, on exit, UpnpFinish()
|
||||||
|
is called, but the memories allocated by ThreadPoolInit() may lost because
|
||||||
|
there's no code to call ThreadPoolShutdown() to release the memories. And
|
||||||
|
inet_ntoa() is not thread safe, so in my patch, I substitute inet_ntoa()
|
||||||
|
with inet_ntop().
|
||||||
|
|
||||||
|
2010-03-14 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2964687 ] Add new string based accessors to upnp
|
||||||
|
object API
|
||||||
|
|
||||||
|
As per email to pupnp-devel, this is the patch to add the _strget_
|
||||||
|
accessors for string-like objects in the interface.
|
||||||
|
|
||||||
|
Will add a further patch shortly to udpate the sample programs.
|
||||||
|
|
||||||
|
2008-06-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Nicholas Kraft's patch to fix some IPv6 copy/paste issues. He
|
||||||
|
reported to be getting infinite loops with the svn code.
|
||||||
|
|
||||||
|
2008-06-13 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Bug Tracker [ 1984541 ]
|
||||||
|
ixmlDocumenttoString does not render the namespace tag.
|
||||||
|
Submitted By: Beliveau - belivo
|
||||||
|
|
||||||
|
Undoing the patch that fixed this problem. In fact, there was no
|
||||||
|
problem and the patch was wrong.
|
||||||
|
|
||||||
|
2008-06-11 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Ingo Hofmann's patch for "Content-Type in Subscription responses".
|
||||||
|
Adds charset="utf-8" attribute to the CONTENT-TYPE header line.
|
||||||
|
|
||||||
|
Hi,
|
||||||
|
|
||||||
|
I have found an inconsistency regarding the text/xml content-type
|
||||||
|
returned by libupnp. It looks like only subscription responses send
|
||||||
|
"text/xml" where all other messages contain "text/xml; charset="utf-8"".
|
||||||
|
Since I'm working on an DLNA device the latter behaviour is mandatory.
|
||||||
|
I changed the according lines in gena_device.c (see attached patch).
|
||||||
|
I'm not sure if it would be ok for other device to have the charset
|
||||||
|
field but it would help me a lot :)
|
||||||
|
|
||||||
|
Best regards,
|
||||||
|
Ingo
|
||||||
|
|
||||||
|
2008-06-04 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Bug Tracker [ 1984541 ]
|
||||||
|
ixmlDocumenttoString does not render the namespace tag.
|
||||||
|
Submitted By: Beliveau - belivo
|
||||||
|
|
||||||
|
The problem occurs when converting a xml document using
|
||||||
|
ixmlDocumenttoString containing a namespace tag created with
|
||||||
|
ixmlDocument_createElementNS. The namespace tag doesn't get rendered.
|
||||||
|
|
||||||
|
example: The following code fragment prints:
|
||||||
|
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<root></root>
|
||||||
|
|
||||||
|
instead of:
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<root xmlns="urn:schemas-upnp-org:device-1-0"></root>
|
||||||
|
|
||||||
|
Code:
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <upnp/ixml.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
IXML_Document* wDoc = ixmlDocument_createDocument();
|
||||||
|
IXML_Element* wRoot = ixmlDocument_createElementNS(wDoc,
|
||||||
|
"urn:schemas-upnp-org:device-1-0", "root");
|
||||||
|
ixmlNode_appendChild((IXML_Node *)wDoc,(IXML_Node *)wRoot);
|
||||||
|
DOMString wString = ixmlDocumenttoString(wDoc);
|
||||||
|
printf(wString);
|
||||||
|
free(wString);
|
||||||
|
ixmlDocument_free(wDoc);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
The problem was in the printing routine, not in the library data
|
||||||
|
structure.
|
||||||
|
|
||||||
|
2008-05-31 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Charles Nepveu's suggestion of not allocating a thread for
|
||||||
|
MiniServer when it is not compiled.
|
||||||
|
|
||||||
|
2008-05-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Ported Peter Hartley's patch to compile with mingw.
|
||||||
|
|
||||||
|
2008-05-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Added some debug capability to ixml.
|
||||||
|
|
||||||
|
2008-05-02 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Merged Charles Nepveu's IPv6 work. libupnp now is IPv6 enabled.
|
||||||
|
|
||||||
|
2008-02-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Breaking API so that we now hide internal data structures.
|
||||||
|
|
||||||
|
2008-02-06 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Rewrote Peter Hartley's patch to include a new extra header field in
|
||||||
|
FileInfo.
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.6.7
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* The last part of Ronan Menard's patch.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* upnp/src/genlib/miniserver/miniserver.c: Fix for IPV6 ULA/GUA issues.
|
||||||
|
|
||||||
|
Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* gena_subscribe(): Fix for IPV6 ULA/GUA issues.
|
||||||
|
|
||||||
|
Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SOCKET ssdpSock6UlaGua: created variable for later use.
|
||||||
|
|
||||||
|
Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SSDP_IPV6_SITELOCAL: new macro.
|
||||||
|
|
||||||
|
Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* The scope of the macro NUM_HANDLE is now restricted to upnpapi.c.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-08-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-08-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* libUPnP does support IPV6 now.
|
||||||
|
|
||||||
|
Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-08-19 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* HTTP version equal to 1.0 should fail as required by the UPnP
|
||||||
|
certification tool. Patch submitted by Ronan Menard.
|
||||||
|
|
||||||
|
2010-06-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
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
|
||||||
|
|
||||||
|
2010-06-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
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
|
||||||
|
|
||||||
|
2010-05-07 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
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).
|
||||||
|
|
||||||
|
2010-04-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
Define PROTOTYPES to be one by default in global.h. This affects the
|
||||||
|
RSA MD5 code.
|
||||||
|
|
||||||
|
2010-03-27 Nick Leverton <nick@leverton.org>
|
||||||
|
Subscription auto-renewals copy the renewal time from old subscription.
|
||||||
|
|
||||||
|
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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
|
||||||
|
|
||||||
|
2010-03-27 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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/
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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)
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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
|
||||||
|
|
||||||
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2203721 ] timeb.h check obsolete
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-15 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2010-03-14 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2009-03-06 Oxygenic <oxygenic(at)users.sourceforge.net>
|
||||||
|
* parameter problem fixed in soap_request_and_response(), 2nd call to
|
||||||
|
http_RequestAndResponse() was wrong (thanks to Kim Kyungsan)
|
||||||
|
|
||||||
|
2008-07-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Added upnp/m4/libupnp.m4 to the distribution tarball.
|
||||||
|
|
||||||
|
2008-07-25 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fixed a missing HandleUnlock() in upnp/src/gena/gena_device.c.
|
||||||
|
|
||||||
|
2008-07-24 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2008-07-16 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Andre Sodermans (wienerschnitzel) patch for building libupnp under
|
||||||
|
windows systems with VC9. This one fixes a missing include.
|
||||||
|
|
||||||
|
2008-06-30 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Added an m4 macro to deal with finding libupnp in the users'
|
||||||
|
configure script.
|
||||||
|
|
||||||
|
2008-06-11 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2008-06-02 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Bug Tracker [ 1942285 ]
|
||||||
|
UpnpCreatePropertySet can leak memory.
|
||||||
|
Submitted By: Bob Ciora - bobciora
|
||||||
|
|
||||||
|
In file upnp/src/api/upnptools.c, function UpnpCreatePropertySet can leak
|
||||||
|
memory if no additional arguments are passed. This is because of the
|
||||||
|
'return' statement at (or near) line 554.
|
||||||
|
|
||||||
|
The prior call to ixmlParseBufferEx may succeed. This causes a basic ixml
|
||||||
|
tree to be created. The return statement at line 554 leaves this tree in
|
||||||
|
memory without cleaning it up.
|
||||||
|
|
||||||
|
There are two options: either add code prior to the return at 554 to clean
|
||||||
|
up the tree, or simply allow a NumArg parameter of 0 to be passed.
|
||||||
|
|
||||||
|
I prefer the second method -- there doesn't seem to be any need to pass
|
||||||
|
*any* arguments to this function.
|
||||||
|
|
||||||
|
In my local copy of upnptools.c, I have simply replaced the "return NULL"
|
||||||
|
in line 554 to "return PropSet".
|
||||||
|
|
||||||
|
I've attached the source file.
|
||||||
|
|
||||||
|
2008-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Bug Tracker [ 1903069 ]
|
||||||
|
Subs (not services) not marked 'active'
|
||||||
|
Submitted By: Bob Ciora - bobciora
|
||||||
|
|
||||||
|
If the UpnpAcceptSubscription is not called, the subscription is not marked
|
||||||
|
as "active", so no state variables will ever be sent.
|
||||||
|
|
||||||
|
I have a "lazy" architecture where a service may not be ready to publish
|
||||||
|
any state data at the time of a subscription. Subscriptions are still
|
||||||
|
accepted, there's just nothing to send, so UpnpAcceptSubscription is never
|
||||||
|
called. As a result, the subscription is never marked as "active" via the
|
||||||
|
genaInitNotify functions.
|
||||||
|
|
||||||
|
A best course of action would be to modify UpnpAcceptSubscription<...>
|
||||||
|
functions so that they can accept *no* initial state information, but can
|
||||||
|
still result in the subscription being marked as active. Technically,
|
||||||
|
then, the "active" flag should be set here, not in the genaInitNotify<...>
|
||||||
|
functions.
|
||||||
|
|
||||||
|
But the UpnpAccept functions don't muck with the subscription table, and
|
||||||
|
it's more work than it's worth to move that code from the gena fucntions to
|
||||||
|
the upnpapi functions.
|
||||||
|
|
||||||
|
So--- what I've done to correct this problem is to modify both
|
||||||
|
UpnpAcceptSubscription<...> functions (in upnppapi.c) to accept an empty
|
||||||
|
state list and still call the gena layer functions. The gena layer
|
||||||
|
genaInitNotify<...> functions (gena_device.c) then mark the subscription as
|
||||||
|
"active" *before* checking for an empty state set.
|
||||||
|
|
||||||
|
In genaInitNotify, a check for "var_count <= 0" is added immediately after
|
||||||
|
the "subs->active = 1;" line. If this occurs, then all cleanup is
|
||||||
|
performed and the function returns GENA_SUCCESS (since now, an empty state
|
||||||
|
list is not an error). The same check is made for "PropSet == 0" in
|
||||||
|
genaInitNotifyExt (just after the "subs->active = 1;" line).
|
||||||
|
|
||||||
|
I've modifified my proxy layer to call UpnpAcceptSubscriptionExt even when
|
||||||
|
there is no state data to send. With the suggested changes to
|
||||||
|
gena_device.c, later state changes are sent correctly.
|
||||||
|
|
||||||
|
This has solved my problem.
|
||||||
|
|
||||||
|
2008-04-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* Fix in function SetSeed() in threadutil/src/ThreadPool.c for CYGWIN
|
||||||
|
compilation. Thanks to Gary Chan.
|
||||||
|
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
Version 1.6.6
|
Version 1.6.6
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
@@ -219,7 +937,7 @@ Version 1.6.1
|
|||||||
handle accordingly.
|
handle accordingly.
|
||||||
|
|
||||||
2007-08-05 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-08-05 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Merge of Mac OS X patch from St<EFBFBD>phane Corth<EFBFBD>sy (davelopper),
|
* Merge of Mac OS X patch from Stéphane Corthésy (davelopper),
|
||||||
SF Bug Tracker [ 1686420 ] Modifications for MacOSX.
|
SF Bug Tracker [ 1686420 ] Modifications for MacOSX.
|
||||||
Some of the proposed changes were already done by Rene Hexel's patch.
|
Some of the proposed changes were already done by Rene Hexel's patch.
|
||||||
|
|
||||||
@@ -643,14 +1361,14 @@ Version 1.4.0
|
|||||||
FORK FROM DEAD libupnp
|
FORK FROM DEAD libupnp
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
2006-04-29 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-04-29 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* THANKS: new file with list of contributors
|
* THANKS: new file with list of contributors
|
||||||
|
|
||||||
* upnp/src/gena/gena_device.c (respond_ok): add 'Content-Length: 0'
|
* upnp/src/gena/gena_device.c (respond_ok): add 'Content-Length: 0'
|
||||||
in subscription response. Patch by Chaos (Bug # 1455367).
|
in subscription response. Patch by Chaos (Bug # 1455367).
|
||||||
|
|
||||||
2006-04-08 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-04-08 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/doc/UPnP_Programming_Guide.pdf: replace this document with
|
* upnp/doc/UPnP_Programming_Guide.pdf: replace this document with
|
||||||
the one in libupnp-doc-1.2.1 because current CVS version
|
the one in libupnp-doc-1.2.1 because current CVS version
|
||||||
@@ -661,20 +1379,20 @@ FORK FROM DEAD libupnp
|
|||||||
* changes applied to several files to work under Sparc Solaris, temporarily
|
* changes applied to several files to work under Sparc Solaris, temporarily
|
||||||
requiring a define SPARC_SOLARIS
|
requiring a define SPARC_SOLARIS
|
||||||
|
|
||||||
2006-04-03 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-04-03 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/Makefile.am: install upnp samples in $(docdir)/examples
|
* upnp/Makefile.am: install upnp samples in $(docdir)/examples
|
||||||
|
|
||||||
2006-03-28 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-28 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* configure.ac: add --with-docdir option to choose where documentation
|
* configure.ac: add --with-docdir option to choose where documentation
|
||||||
is installed (or -without-docdir to not install the documentation)
|
is installed (or -without-docdir to not install the documentation)
|
||||||
|
|
||||||
2006-03-27 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-27 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* ixml/test: add simple test suite for xml parser
|
* ixml/test: add simple test suite for xml parser
|
||||||
|
|
||||||
2006-03-26 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-26 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* ixml/src/ixmlparser.c (Parser_processCDSect): fix bug which prevents
|
* ixml/src/ixmlparser.c (Parser_processCDSect): fix bug which prevents
|
||||||
CDATA sections which contain a 0 (zero) to be parsed (instead the
|
CDATA sections which contain a 0 (zero) to be parsed (instead the
|
||||||
@@ -685,18 +1403,18 @@ FORK FROM DEAD libupnp
|
|||||||
option, and move samples compilation from check_PROGRAMS to
|
option, and move samples compilation from check_PROGRAMS to
|
||||||
noinst_PROGRAMS
|
noinst_PROGRAMS
|
||||||
|
|
||||||
2006-03-25 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-25 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/genlib/miniserver/miniserver.c (get_miniserver_sockets):
|
* upnp/src/genlib/miniserver/miniserver.c (get_miniserver_sockets):
|
||||||
fix bug if new socket created has fd 0 (can only occur when stdin
|
fix bug if new socket created has fd 0 (can only occur when stdin
|
||||||
has been closed). Patch by Oskar Liljeblad 2004-07-02 :
|
has been closed). Patch by Oskar Liljeblad 2004-07-02 :
|
||||||
http://sourceforge.net/mailarchive/message.php?msg_id=8870528
|
http://sourceforge.net/mailarchive/message.php?msg_id=8870528
|
||||||
|
|
||||||
2006-03-21 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-21 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/test/test_init.c: add some version checks and exit if failure
|
* upnp/test/test_init.c: add some version checks and exit if failure
|
||||||
|
|
||||||
2006-03-05 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-05 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* libupnp version 1.3.1
|
* libupnp version 1.3.1
|
||||||
|
|
||||||
@@ -711,11 +1429,11 @@ FORK FROM DEAD libupnp
|
|||||||
dependencies between upnp and ixml / threadutil, so that programs
|
dependencies between upnp and ixml / threadutil, so that programs
|
||||||
linking against upnp only still work.
|
linking against upnp only still work.
|
||||||
|
|
||||||
2006-03-04 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-04 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* libupnp version 1.3.0
|
* libupnp version 1.3.0
|
||||||
|
|
||||||
2006-03-03 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-03-03 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/genlib/net/http/httpreadwrite.c (get_sdk_info): use
|
* upnp/src/genlib/net/http/httpreadwrite.c (get_sdk_info): use
|
||||||
package version string from configure to set sdk info
|
package version string from configure to set sdk info
|
||||||
@@ -723,7 +1441,7 @@ FORK FROM DEAD libupnp
|
|||||||
* upnp/Makefile.am: add sample/tvdevice/web/ files in EXTRA_DIST
|
* upnp/Makefile.am: add sample/tvdevice/web/ files in EXTRA_DIST
|
||||||
+ do not distribute generated upnpconfig.h file.
|
+ do not distribute generated upnpconfig.h file.
|
||||||
|
|
||||||
2006-02-28 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-02-28 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/inc/config.h, configure.ac: use only new defines
|
* upnp/src/inc/config.h, configure.ac: use only new defines
|
||||||
UPNP_HAVE_xx instead of INCLUDE_yyy_APIS and INTERNAL_WEB_SERVER
|
UPNP_HAVE_xx instead of INCLUDE_yyy_APIS and INTERNAL_WEB_SERVER
|
||||||
@@ -732,7 +1450,7 @@ FORK FROM DEAD libupnp
|
|||||||
the librarie LDFLAGS in order to export only the symbols defined
|
the librarie LDFLAGS in order to export only the symbols defined
|
||||||
in the API
|
in the API
|
||||||
|
|
||||||
2006-02-27 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-02-27 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* configure.ac: add libtool versions for the 3 libraries
|
* configure.ac: add libtool versions for the 3 libraries
|
||||||
|
|
||||||
@@ -740,7 +1458,7 @@ FORK FROM DEAD libupnp
|
|||||||
|
|
||||||
* threadutil/src/ThreadPool.c (SetSeed): add missing 'static'
|
* threadutil/src/ThreadPool.c (SetSeed): add missing 'static'
|
||||||
|
|
||||||
2006-02-26 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-02-26 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* threadutil/inc/iasnprintf.h: add gcc __printf__ format attribute
|
* threadutil/inc/iasnprintf.h: add gcc __printf__ format attribute
|
||||||
to "iasnprintf"
|
to "iasnprintf"
|
||||||
@@ -761,11 +1479,11 @@ FORK FROM DEAD libupnp
|
|||||||
the configuration of the installed libraries (generates installed
|
the configuration of the installed libraries (generates installed
|
||||||
file <upnp/upnpconfig.h>)
|
file <upnp/upnpconfig.h>)
|
||||||
|
|
||||||
2006-02-22 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-02-22 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/ : add missing include of config.h in some .c files
|
* upnp/ : add missing include of config.h in some .c files
|
||||||
|
|
||||||
2006-02-21 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-02-21 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/inc/upnp.h: move some definitions which should not be
|
* upnp/inc/upnp.h: move some definitions which should not be
|
||||||
exported into "upnp/src/inc/util.h"
|
exported into "upnp/src/inc/util.h"
|
||||||
@@ -773,12 +1491,12 @@ FORK FROM DEAD libupnp
|
|||||||
* import all modifications below from libupnp in djmount 0.51
|
* import all modifications below from libupnp in djmount 0.51
|
||||||
into official libupnp
|
into official libupnp
|
||||||
|
|
||||||
2006-01-17 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-01-17 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* threadutil/Makefile.am (libthreadutil_la_SOURCES): remove extraneous
|
* threadutil/Makefile.am (libthreadutil_la_SOURCES): remove extraneous
|
||||||
file
|
file
|
||||||
|
|
||||||
2006-01-15 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-01-15 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* configure.ac: add checks for large-file support
|
* configure.ac: add checks for large-file support
|
||||||
|
|
||||||
@@ -798,53 +1516,53 @@ FORK FROM DEAD libupnp
|
|||||||
* ixml/src/node.c (ixmlNode_getNodeType): fix compilation warning
|
* ixml/src/node.c (ixmlNode_getNodeType): fix compilation warning
|
||||||
on const return type
|
on const return type
|
||||||
|
|
||||||
2006-01-12 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-01-12 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/inc/readwrite.h : suppress unused C++ header file
|
* upnp/src/inc/readwrite.h : suppress unused C++ header file
|
||||||
|
|
||||||
2006-01-11 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2006-01-11 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/inc/config.h, upnp/src/inc/upnpapi.h,
|
* upnp/inc/config.h, upnp/src/inc/upnpapi.h,
|
||||||
upnp/src/inc/httpreadwrite.h: remove internal configuration variable
|
upnp/src/inc/httpreadwrite.h: remove internal configuration variable
|
||||||
MINIMUM_DELAY (no clear purpose)
|
MINIMUM_DELAY (no clear purpose)
|
||||||
|
|
||||||
2005-12-05 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-12-05 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/inc/upnp.h: re-declare obsolete method UpnpSetContentLength,
|
* upnp/inc/upnp.h: re-declare obsolete method UpnpSetContentLength,
|
||||||
for binary compatibility with previous libupnp version.
|
for binary compatibility with previous libupnp version.
|
||||||
|
|
||||||
* upnp/src/api/upnpapi.c: correct type of g_maxContentLength to size_t
|
* upnp/src/api/upnpapi.c: correct type of g_maxContentLength to size_t
|
||||||
|
|
||||||
2005-11-01 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-11-01 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* autoconfiscate library : replace all makefiles by Makefile.am
|
* autoconfiscate library : replace all makefiles by Makefile.am
|
||||||
for automake support, + preliminary autoconf support
|
for automake support, + preliminary autoconf support
|
||||||
(generated config.h not yet used in source files)
|
(generated config.h not yet used in source files)
|
||||||
|
|
||||||
2005-10-18 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-10-18 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/makefile: fix location of DEBUG STATIC libupnp library
|
* upnp/src/makefile: fix location of DEBUG STATIC libupnp library
|
||||||
|
|
||||||
* upnp/sample/tvctrlpt/linux/Makefile,
|
* upnp/sample/tvctrlpt/linux/Makefile,
|
||||||
upnp/sample/tvdevice/linux/Makefile: fix STATIC library support
|
upnp/sample/tvdevice/linux/Makefile: fix STATIC library support
|
||||||
|
|
||||||
2005-10-16 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-10-16 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* threadutil/src/Makefile (clean): remove built library
|
* threadutil/src/Makefile (clean): remove built library
|
||||||
|
|
||||||
2005-08-28 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-08-28 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* ixml/src/ixml.h, ixml/src/ixml.c (ixmlRelaxParser) : new function
|
* ixml/src/ixml.h, ixml/src/ixml.c (ixmlRelaxParser) : new function
|
||||||
|
|
||||||
* ixml/src/ixmlparser.h, ixml/src/ixmlparser.c (Parser_setErrorChar) :
|
* ixml/src/ixmlparser.h, ixml/src/ixmlparser.c (Parser_setErrorChar) :
|
||||||
new function
|
new function
|
||||||
|
|
||||||
2005-08-02 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-08-02 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* ixml/src/Makefile: correct bug for static library being incorrectly
|
* ixml/src/Makefile: correct bug for static library being incorrectly
|
||||||
stripped when building non-debug
|
stripped when building non-debug
|
||||||
|
|
||||||
2005-06-09 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-06-09 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* ixml/src/element.c (ixmlElement_removeAttributeNode):
|
* ixml/src/element.c (ixmlElement_removeAttributeNode):
|
||||||
remove some compilation warning
|
remove some compilation warning
|
||||||
@@ -855,7 +1573,7 @@ FORK FROM DEAD libupnp
|
|||||||
* upnp/inc/upnptools.h, upnp/src/api/upnptools.c :
|
* upnp/inc/upnptools.h, upnp/src/api/upnptools.c :
|
||||||
add missing const's in public API
|
add missing const's in public API
|
||||||
|
|
||||||
2005-05-28 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-05-28 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/inc/config.h: suppress HTTP_READ_BYTES (unused)
|
* upnp/inc/config.h: suppress HTTP_READ_BYTES (unused)
|
||||||
and replace by DEFAULT_SOAP_CONTENT_LENGTH (previously in upnpapi.h)
|
and replace by DEFAULT_SOAP_CONTENT_LENGTH (previously in upnpapi.h)
|
||||||
@@ -876,7 +1594,7 @@ FORK FROM DEAD libupnp
|
|||||||
* upnp/src/genlib/net/http/httpreadwrite.c : corrected an incorrect
|
* upnp/src/genlib/net/http/httpreadwrite.c : corrected an incorrect
|
||||||
sprintf format
|
sprintf format
|
||||||
|
|
||||||
2005-05-27 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-05-27 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/makefile, upnp/src/makefile,
|
* upnp/makefile, upnp/src/makefile,
|
||||||
ixml/Makefile, ixml/src/Makefile,
|
ixml/Makefile, ixml/src/Makefile,
|
||||||
@@ -884,7 +1602,7 @@ FORK FROM DEAD libupnp
|
|||||||
implement STATIC library support (from patch at
|
implement STATIC library support (from patch at
|
||||||
http://sourceforge.net/tracker/?group_id=7189&atid=307189 )
|
http://sourceforge.net/tracker/?group_id=7189&atid=307189 )
|
||||||
|
|
||||||
2005-05-26 R<EFBFBD>mi Turboult <r3mi(at)users.sourceforge.net>
|
2005-05-26 Rémi Turboult <r3mi(at)users.sourceforge.net>
|
||||||
|
|
||||||
* upnp/src/api/upnpapi.c, upnp/src/soap/soap_device.c,
|
* upnp/src/api/upnpapi.c, upnp/src/soap/soap_device.c,
|
||||||
upnp/src/soap/makefile :
|
upnp/src/soap/makefile :
|
||||||
|
|||||||
12
Doxyfile
12
Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME = libUPnP
|
|||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 1.4.7
|
PROJECT_NUMBER = 1.8.0
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||||
# base path where the generated documentation will be put.
|
# 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
|
# Doxygen will generate a detailed section even if there is only a brief
|
||||||
# description.
|
# description.
|
||||||
|
|
||||||
ALWAYS_DETAILED_SEC = NO
|
ALWAYS_DETAILED_SEC = YES
|
||||||
|
|
||||||
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
|
# 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
|
# 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.
|
# to NO (the default) then the documentation will be excluded.
|
||||||
# Set it to YES to include the internal documentation.
|
# 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
|
# 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
|
# 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
|
# directories like "/usr/src/myproject". Separate the files or directories
|
||||||
# with spaces.
|
# 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
|
# 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
|
# 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
|
# compilation will be performed. Macro expansion can be done in a controlled
|
||||||
# way by setting EXPAND_ONLY_PREDEF to YES.
|
# 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
|
# 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
|
# 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
|
# undefined via #undef or recursively expanded use the := operator
|
||||||
# instead of 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
|
# 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.
|
# this tag can be used to specify a list of macro names that should be expanded.
|
||||||
|
|||||||
18
Makefile.am
18
Makefile.am
@@ -16,6 +16,7 @@ SUBDIRS = \
|
|||||||
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
|
Doxyfile \
|
||||||
libupnp.pc.in \
|
libupnp.pc.in \
|
||||||
LICENSE \
|
LICENSE \
|
||||||
THANKS \
|
THANKS \
|
||||||
@@ -27,7 +28,22 @@ EXTRA_DIST = \
|
|||||||
build/inc/autoconfig.h \
|
build/inc/autoconfig.h \
|
||||||
build/inc/config.h \
|
build/inc/config.h \
|
||||||
build/inc/upnpconfig.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
|
# This variable must have 'exec' in its name, in order to be installed
|
||||||
|
|||||||
7
THANKS
7
THANKS
@@ -8,13 +8,17 @@ exempt of errors.
|
|||||||
|
|
||||||
- Alex (afaucher)
|
- Alex (afaucher)
|
||||||
- Andre Sodermans (wienerschnitzel)
|
- Andre Sodermans (wienerschnitzel)
|
||||||
|
- Anthony Viallard (homer242)
|
||||||
- Apostolos Syropoulos
|
- Apostolos Syropoulos
|
||||||
- Arno Willig
|
- Arno Willig
|
||||||
- Bob Ciora
|
- Bob Ciora
|
||||||
|
- Carlo Parata
|
||||||
- Chaos
|
- Chaos
|
||||||
- Charles Nepveu (cnepveu)
|
- Charles Nepveu (cnepveu)
|
||||||
- Chris Pickel
|
- Chris Pickel
|
||||||
|
- Chuck Thomason (cyt4)
|
||||||
- Craig Nelson
|
- Craig Nelson
|
||||||
|
- David Blanchet
|
||||||
- David Maass
|
- David Maass
|
||||||
- Emil Ljungdahl
|
- Emil Ljungdahl
|
||||||
- Erik Johansson
|
- Erik Johansson
|
||||||
@@ -37,12 +41,15 @@ exempt of errors.
|
|||||||
- Marcelo Roberto Jimenez (mroberto)
|
- Marcelo Roberto Jimenez (mroberto)
|
||||||
- Markus Strobl
|
- Markus Strobl
|
||||||
- Nektarios K. Papadopoulos (npapadop)
|
- Nektarios K. Papadopoulos (npapadop)
|
||||||
|
- Nicholas Kraft
|
||||||
|
- Nick Leverton (leveret)
|
||||||
- Oskar Liljeblad
|
- Oskar Liljeblad
|
||||||
- Michael (oxygenic)
|
- Michael (oxygenic)
|
||||||
- Paul Vixie
|
- Paul Vixie
|
||||||
- Peter Hartley
|
- Peter Hartley
|
||||||
- Rene Hexel
|
- Rene Hexel
|
||||||
- Robert Gingher (robsbox)
|
- Robert Gingher (robsbox)
|
||||||
|
- Ronan Menard
|
||||||
- Siva Chandran
|
- Siva Chandran
|
||||||
- Stéphane Corthésy
|
- Stéphane Corthésy
|
||||||
- Steve Bresson
|
- Steve Bresson
|
||||||
|
|||||||
11
TODO
11
TODO
@@ -18,12 +18,13 @@ http://sourceforge.net/tracker/?group_id=7189&atid=307189
|
|||||||
|
|
||||||
- make API clean for large files and 64 bits
|
- make API clean for large files and 64 bits
|
||||||
|
|
||||||
|
- Why is NUM_HANDLE defined to 200 when we can register only:
|
||||||
|
A) One client(1)
|
||||||
|
B) An IPv4 and IPv6 device (2)
|
||||||
|
NUM_HANDLE should be 3
|
||||||
|
|
||||||
To Be Decided
|
- A sane way to implement the virtual directory callback initialization and checking
|
||||||
=============
|
against NULL pointers.
|
||||||
|
|
||||||
- IPV6 support ?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,11 +82,14 @@
|
|||||||
/* Define to 1 if you have the `vprintf' function. */
|
/* Define to 1 if you have the `vprintf' function. */
|
||||||
#define HAVE_VPRINTF 1
|
#define HAVE_VPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ws2tcpip.h> header file. */
|
||||||
|
/* #undef HAVE_WS2TCPIP_H */
|
||||||
|
|
||||||
/* Define to 1 to prevent compilation of assert() */
|
/* Define to 1 to prevent compilation of assert() */
|
||||||
#define NDEBUG 1
|
/* #undef NDEBUG */
|
||||||
|
|
||||||
/* Define to 1 to prevent some debug code */
|
/* Define to 1 to prevent some debug code */
|
||||||
#define NO_DEBUG 1
|
/* #undef NO_DEBUG */
|
||||||
|
|
||||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||||
/* #undef NO_MINUS_C_MINUS_O */
|
/* #undef NO_MINUS_C_MINUS_O */
|
||||||
@@ -101,13 +104,13 @@
|
|||||||
#define PACKAGE_NAME "libupnp"
|
#define PACKAGE_NAME "libupnp"
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
/* Define to the full name and version of this package. */
|
||||||
#define PACKAGE_STRING "libupnp 1.4.7"
|
#define PACKAGE_STRING "libupnp 1.8.0"
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#define PACKAGE_TARNAME "libupnp"
|
#define PACKAGE_TARNAME "libupnp"
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#define PACKAGE_VERSION "1.4.7"
|
#define PACKAGE_VERSION "1.8.0"
|
||||||
|
|
||||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||||
your system. */
|
your system. */
|
||||||
@@ -120,7 +123,7 @@
|
|||||||
#define UPNP_HAVE_CLIENT 1
|
#define UPNP_HAVE_CLIENT 1
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
/* #undef UPNP_HAVE_DEBUG */
|
#define UPNP_HAVE_DEBUG 1
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_HAVE_DEVICE 1
|
#define UPNP_HAVE_DEVICE 1
|
||||||
@@ -131,20 +134,23 @@
|
|||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_HAVE_WEBSERVER 1
|
#define UPNP_HAVE_WEBSERVER 1
|
||||||
|
|
||||||
|
/* Do not use pthread_rwlock_t */
|
||||||
|
#define UPNP_USE_RWLOCK 1
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_MAJOR 1
|
#define UPNP_VERSION_MAJOR 1
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_MINOR 4
|
#define UPNP_VERSION_MINOR 8
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_PATCH 7
|
#define UPNP_VERSION_PATCH 0
|
||||||
|
|
||||||
/* see upnpconfig.h */
|
/* see upnpconfig.h */
|
||||||
#define UPNP_VERSION_STRING "1.4.7"
|
#define UPNP_VERSION_STRING "1.8.0"
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#define VERSION "1.4.7"
|
#define VERSION "1.8.0"
|
||||||
|
|
||||||
/* File Offset size */
|
/* File Offset size */
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
@@ -164,5 +170,5 @@
|
|||||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
/* #undef size_t */
|
/* #undef size_t */
|
||||||
|
|
||||||
/* Substitute for socklen_t */
|
/* Type for storing the length of struct sockaddr */
|
||||||
/* #undef socklen_t */
|
/* #undef socklen_t */
|
||||||
|
|||||||
@@ -1,148 +1,183 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef INTERNAL_CONFIG_H
|
#ifndef INTERNAL_CONFIG_H
|
||||||
#define INTERNAL_CONFIG_H
|
#define INTERNAL_CONFIG_H
|
||||||
|
|
||||||
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
|
||||||
/** @name Compile time configuration options
|
/*!
|
||||||
|
* \name Compile time configuration options
|
||||||
|
*
|
||||||
* The Linux SDK for UPnP Devices contains some compile-time parameters
|
* The Linux SDK for UPnP Devices contains some compile-time parameters
|
||||||
* that effect the behavior of the SDK. All configuration options are
|
* that effect the behavior of the SDK. All configuration options are
|
||||||
* located in {\tt src/inc/config.h}.
|
* located in {\tt src/inc/config.h}.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
|
|
||||||
/** @name THREAD_IDLE_TIME
|
|
||||||
|
/*!
|
||||||
|
* \name THREAD_IDLE_TIME
|
||||||
|
*
|
||||||
* The {\tt THREAD_IDLE_TIME} constant determines when a thread will be
|
* The {\tt THREAD_IDLE_TIME} constant determines when a thread will be
|
||||||
* removed from the thread pool and returned to the operating system. When
|
* 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
|
* 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
|
* the thread will be released from the thread pool. The default value is
|
||||||
* 5000 milliseconds (5 seconds).
|
* 5000 milliseconds (5 seconds).
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
#define THREAD_IDLE_TIME 5000
|
#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
|
* \name JOBS_PER_THREAD
|
||||||
* 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
|
* The {\tt JOBS_PER_THREAD} constant determines when a new thread will be
|
||||||
* allocated to the thread pool. The default ratio is 10 jobs/thread.
|
* 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
|
#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
|
* \name MIN_THREADS
|
||||||
* always have this number of threads. These threads are used
|
*
|
||||||
* for both callbacks into applications built on top of the SDK and also
|
* The {\tt MIN_THREADS} constant defines the minimum number of threads the
|
||||||
* for making connections to other control points and devices. This number
|
* thread pool inside the SDK will create. The thread pool will
|
||||||
* includes persistent threads. The default value is two threads.
|
* 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
|
#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
|
* \name MAX_THREADS
|
||||||
* 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
|
* The {\tt MAX_THREADS} constant defines the maximum number of threads the
|
||||||
* recommended that this value be below 10, since the threads are
|
* thread pool inside the SDK will create. These threads are used
|
||||||
* necessary for correct operation. This value can be increased for greater
|
* for both callbacks into applications built on top of the library and also
|
||||||
* performance in operation at the expense of greater memory overhead. The
|
* for making connections to other control points and devices. It is not
|
||||||
* default value is 12.
|
* 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
|
#define MAX_THREADS 12
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name MAX_JOBS_TOTAL
|
|
||||||
|
/*! \name MAX_JOBS_TOTAL
|
||||||
|
*
|
||||||
* The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
|
* 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
|
* that can be queued. If this limit is reached further jobs will be thrown
|
||||||
* to avoid memory exhaustion. The default value 100.
|
* to avoid memory exhaustion. The default value 100.
|
||||||
* (Added by Axis.)
|
* (Added by Axis.)
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
#define MAX_JOBS_TOTAL 100
|
#define MAX_JOBS_TOTAL 100
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name DEFAULT_SOAP_CONTENT_LENGTH
|
|
||||||
|
/*!
|
||||||
|
* \name DEFAULT_SOAP_CONTENT_LENGTH
|
||||||
|
*
|
||||||
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
* SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
|
||||||
* This prevents devices that have a misbehaving web server to send
|
* This prevents devices that have a misbehaving web server to send
|
||||||
* a large amount of data to the control point causing it to crash.
|
* a large amount of data to the control point causing it to crash.
|
||||||
* This can be adjusted dynamically with {\tt UpnpSetMaxContentLength}.
|
* This can be adjusted dynamically with {\tt UpnpSetMaxContentLength}.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
//@{
|
|
||||||
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
|
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name NUM_SSDP_COPY
|
|
||||||
|
/*!
|
||||||
|
* \name NUM_SSDP_COPY
|
||||||
|
*
|
||||||
* This configuration parameter determines how many copies of each SSDP
|
* This configuration parameter determines how many copies of each SSDP
|
||||||
* advertisement and search packets will be sent. By default it will send two
|
* advertisement and search packets will be sent. By default it will send two
|
||||||
* copies of every packet.
|
* copies of every packet.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
//@{
|
|
||||||
#define NUM_SSDP_COPY 2
|
#define NUM_SSDP_COPY 2
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name SSDP_PAUSE
|
|
||||||
|
/*!
|
||||||
|
* \name SSDP_PAUSE
|
||||||
|
*
|
||||||
* This configuration parameter determines the pause between identical SSDP
|
* This configuration parameter determines the pause between identical SSDP
|
||||||
* advertisement and search packets. The pause is measured in milliseconds
|
* advertisement and search packets. The pause is measured in milliseconds
|
||||||
* and defaults to 100.
|
* and defaults to 100.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
//@{
|
|
||||||
#define SSDP_PAUSE 100
|
#define SSDP_PAUSE 100
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name WEB_SERVER_BUF_SIZE
|
/*!
|
||||||
|
* \name WEB_SERVER_BUF_SIZE
|
||||||
|
*
|
||||||
* This configuration parameter sets the maximum buffer size for the
|
* This configuration parameter sets the maximum buffer size for the
|
||||||
* webserver. The default value is 1MB.
|
* webserver. The default value is 1MB.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
//@{
|
|
||||||
#define WEB_SERVER_BUF_SIZE (1024*1024)
|
#define WEB_SERVER_BUF_SIZE (1024*1024)
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name AUTO_RENEW_TIME
|
/*!
|
||||||
|
* \name AUTO_RENEW_TIME
|
||||||
|
*
|
||||||
* The {\tt AUTO_RENEW_TIME} is the time, in seconds, before a subscription
|
* The {\tt AUTO_RENEW_TIME} is the time, in seconds, before a subscription
|
||||||
* expires that the SDK automatically resubscribes. The default
|
* expires that the SDK automatically resubscribes. The default
|
||||||
* value is 10 seconds. Setting this value too low can result in the
|
* value is 10 seconds. Setting this value too low can result in the
|
||||||
@@ -150,89 +185,104 @@
|
|||||||
* subscription to timeout. In order to avoid continually resubscribing
|
* subscription to timeout. In order to avoid continually resubscribing
|
||||||
* the minimum subscription time is five seconds more than the auto renew
|
* the minimum subscription time is five seconds more than the auto renew
|
||||||
* time.
|
* time.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
#define AUTO_RENEW_TIME 10
|
#define AUTO_RENEW_TIME 10
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name CP_MINIMUM_SUBSCRIPTION_TIME
|
/*!
|
||||||
|
* \name CP_MINIMUM_SUBSCRIPTION_TIME
|
||||||
|
*
|
||||||
* The {\tt CP_MINIMUM_SUBSCRIPTION_TIME} is the 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
|
* allowed for a control point using the SDK. Subscribing for less than
|
||||||
* this time automatically results in a subscription for this amount. The
|
* 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
|
* default value is 5 seconds more than the {\tt AUTO_RENEW_TIME}, or 15
|
||||||
* seconds.
|
* seconds.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
#define CP_MINIMUM_SUBSCRIPTION_TIME (AUTO_RENEW_TIME + 5)
|
#define CP_MINIMUM_SUBSCRIPTION_TIME (AUTO_RENEW_TIME + 5)
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name MAX_SEARCH_TIME
|
|
||||||
|
/*!
|
||||||
|
* \name MAX_SEARCH_TIME
|
||||||
|
*
|
||||||
* The {\tt MAX_SEARCH_TIME} is the maximum time
|
* The {\tt MAX_SEARCH_TIME} is the maximum time
|
||||||
* allowed for an SSDP search by a control point. Searching for greater than
|
* 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
|
* this time automatically results in a search for this amount. The default
|
||||||
* value is 80 seconds.
|
* value is 80 seconds.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@{
|
|
||||||
#define MAX_SEARCH_TIME 80
|
#define MAX_SEARCH_TIME 80
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
/** @name MIN_SEARCH_TIME
|
|
||||||
|
/*!
|
||||||
|
* \name MIN_SEARCH_TIME
|
||||||
|
*
|
||||||
* The {\tt MIN_SEARCH_TIME} is the minimumm time
|
* The {\tt MIN_SEARCH_TIME} is the minimumm time
|
||||||
* allowed for an SSDP search by a control point. Searching for less than
|
* 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
|
* this time automatically results in a search for this amount. The default
|
||||||
* value is 2 seconds.
|
* 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 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_SSDP 0
|
||||||
#define EXCLUDE_SOAP 0
|
#define EXCLUDE_SOAP 0
|
||||||
#define EXCLUDE_GENA 0
|
#define EXCLUDE_GENA 0
|
||||||
@@ -244,24 +294,28 @@
|
|||||||
#else
|
#else
|
||||||
# define EXCLUDE_JNI 1
|
# define EXCLUDE_JNI 1
|
||||||
#endif
|
#endif
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
/** @name DEBUG_TARGET
|
/*!
|
||||||
* The user has the option to redirect the library output debug messages
|
* \name DEBUG_TARGET
|
||||||
* 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
|
* The user has the option to redirect the library output debug messages
|
||||||
* greater than zero will be redirected to {\tt upnp.out}.
|
* 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
|
#define DEBUG_TARGET 1
|
||||||
//@}
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
/** @name Other debugging features
|
/*!
|
||||||
The UPnP SDK contains other features to aid in debugging:
|
* \name Other debugging features
|
||||||
see <upnp/inc/upnpdebug.h>
|
*
|
||||||
|
* The UPnP SDK contains other features to aid in debugging:
|
||||||
|
* see <upnp/inc/upnpdebug.h>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEBUG_ALL 1
|
#define DEBUG_ALL 1
|
||||||
@@ -274,38 +328,46 @@
|
|||||||
#define DEBUG_HTTP 0
|
#define DEBUG_HTTP 0
|
||||||
#define DEBUG_API 0
|
#define DEBUG_API 0
|
||||||
|
|
||||||
//@} // Compile time configuration options
|
|
||||||
|
/*
|
||||||
|
* @} Compile time configuration options
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Do not change, Internal purpose only!!!
|
* Do not change, Internal purpose only!!!
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
//@{
|
/*!
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set additional defines based on requested configuration
|
* Set additional defines based on requested configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// configure --enable-client
|
|
||||||
|
/* configure --enable-client */
|
||||||
#if UPNP_HAVE_CLIENT
|
#if UPNP_HAVE_CLIENT
|
||||||
# define INCLUDE_CLIENT_APIS 1
|
# define INCLUDE_CLIENT_APIS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// configure --enable-device
|
|
||||||
|
/* configure --enable-device */
|
||||||
#if UPNP_HAVE_DEVICE
|
#if UPNP_HAVE_DEVICE
|
||||||
# define INCLUDE_DEVICE_APIS 1
|
# define INCLUDE_DEVICE_APIS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// configure --enable-webserver --enable-device
|
|
||||||
|
/* configure --enable-webserver --enable-device */
|
||||||
#if UPNP_HAVE_WEBSERVER
|
#if UPNP_HAVE_WEBSERVER
|
||||||
# define INTERNAL_WEB_SERVER 1
|
# define INTERNAL_WEB_SERVER 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#undef EXCLUDE_WEB_SERVER
|
||||||
#undef EXCLUDE_WEB_SERVER
|
#undef EXCLUDE_MINISERVER
|
||||||
#undef EXCLUDE_MINISERVER
|
|
||||||
#ifdef INTERNAL_WEB_SERVER
|
#ifdef INTERNAL_WEB_SERVER
|
||||||
# define EXCLUDE_WEB_SERVER 0
|
# define EXCLUDE_WEB_SERVER 0
|
||||||
# define EXCLUDE_MINISERVER 0
|
# define EXCLUDE_MINISERVER 0
|
||||||
@@ -314,16 +376,18 @@
|
|||||||
# define EXCLUDE_MINISERVER 1
|
# define EXCLUDE_MINISERVER 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
|
#if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
|
||||||
# undef EXCLUDE_MINISERVER
|
# undef EXCLUDE_MINISERVER
|
||||||
# define EXCLUDE_MINISERVER 1
|
# define EXCLUDE_MINISERVER 1
|
||||||
# if INTERNAL_WEB_SERVER
|
# if INTERNAL_WEB_SERVER
|
||||||
# error "conflicting settings: use configure --disable-webserver"
|
# error "conflicting settings: use configure --disable-webserver"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
|
#if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
|
||||||
# undef EXCLUDE_MINISERVER
|
# undef EXCLUDE_MINISERVER
|
||||||
# define EXCLUDE_MINISERVER 0
|
# define EXCLUDE_MINISERVER 0
|
||||||
# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
|
||||||
# error "conflicting settings : use configure --enable-webserver"
|
# error "conflicting settings : use configure --enable-webserver"
|
||||||
@@ -331,13 +395,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
# define CLIENTONLY(x) x
|
# define CLIENTONLY(x) x
|
||||||
#else
|
#else /* INCLUDE_CLIENT_APIS */
|
||||||
# define CLIENTONLY(x)
|
# define CLIENTONLY(x)
|
||||||
#endif
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
//@}
|
|
||||||
#endif
|
/*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INTERNAL_CONFIG_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
|
/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */
|
||||||
// -*- C -*-
|
/* -*- C -*- */
|
||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
* Copyright (c) 2006 R<>mi Turboult <r3mi@users.sourceforge.net>
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef UPNP_CONFIG_H
|
#ifndef UPNP_CONFIG_H
|
||||||
#define UPNP_CONFIG_H
|
#define UPNP_CONFIG_H
|
||||||
@@ -40,16 +40,16 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/** The library version (string) e.g. "1.3.0" */
|
/** The library version (string) e.g. "1.3.0" */
|
||||||
#define UPNP_VERSION_STRING "1.4.7"
|
#define UPNP_VERSION_STRING "1.8.0"
|
||||||
|
|
||||||
/** Major version of the library */
|
/** Major version of the library */
|
||||||
#define UPNP_VERSION_MAJOR 1
|
#define UPNP_VERSION_MAJOR 1
|
||||||
|
|
||||||
/** Minor version of the library */
|
/** Minor version of the library */
|
||||||
#define UPNP_VERSION_MINOR 4
|
#define UPNP_VERSION_MINOR 8
|
||||||
|
|
||||||
/** Patch version of the library */
|
/** Patch version of the library */
|
||||||
#define UPNP_VERSION_PATCH 7
|
#define UPNP_VERSION_PATCH 0
|
||||||
|
|
||||||
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
/** The library version (numeric) e.g. 10300 means version 1.3.0 */
|
||||||
#define UPNP_VERSION \
|
#define UPNP_VERSION \
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
/** Defined to 1 if the library has been compiled with DEBUG enabled
|
/** Defined to 1 if the library has been compiled with DEBUG enabled
|
||||||
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
|
* (i.e. configure --enable-debug) : <upnp/upnpdebug.h> file is available */
|
||||||
/* #undef UPNP_HAVE_DEBUG */
|
#define UPNP_HAVE_DEBUG 1
|
||||||
|
|
||||||
|
|
||||||
/** Defined to 1 if the library has been compiled with client API enabled
|
/** Defined to 1 if the library has been compiled with client API enabled
|
||||||
@@ -92,6 +92,5 @@
|
|||||||
#define UPNP_HAVE_TOOLS 1
|
#define UPNP_HAVE_TOOLS 1
|
||||||
|
|
||||||
|
|
||||||
#endif // UPNP_CONFIG_H
|
#endif /* UPNP_CONFIG_H */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,223 +1,217 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="ixml"
|
Name="ixml"
|
||||||
ProjectGUID="{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}"
|
ProjectGUID="{AD489FAF-9CDD-411B-BFE9-1B9C6C16D427}"
|
||||||
RootNamespace="ixml"
|
RootNamespace="ixml"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="4"
|
ConfigurationType="4"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc"
|
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc;..\..\upnp\inc"
|
||||||
PreprocessorDefinitions="WIN32;DEBUG"
|
PreprocessorDefinitions="WIN32;DEBUG"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="1"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="true"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
CompileAs="1"
|
||||||
<Tool
|
/>
|
||||||
Name="VCManagedResourceCompilerTool"
|
<Tool
|
||||||
/>
|
Name="VCManagedResourceCompilerTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCResourceCompilerTool"
|
<Tool
|
||||||
/>
|
Name="VCResourceCompilerTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCPreLinkEventTool"
|
<Tool
|
||||||
/>
|
Name="VCPreLinkEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCLibrarianTool"
|
<Tool
|
||||||
/>
|
Name="VCLibrarianTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCALinkTool"
|
<Tool
|
||||||
/>
|
Name="VCALinkTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCXDCMakeTool"
|
<Tool
|
||||||
/>
|
Name="VCXDCMakeTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCBscMakeTool"
|
<Tool
|
||||||
/>
|
Name="VCBscMakeTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCFxCopTool"
|
<Tool
|
||||||
/>
|
Name="VCFxCopTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCPostBuildEventTool"
|
<Tool
|
||||||
/>
|
Name="VCPostBuildEventTool"
|
||||||
</Configuration>
|
/>
|
||||||
<Configuration
|
</Configuration>
|
||||||
Name="Release|Win32"
|
<Configuration
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
Name="Release|Win32"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="1"
|
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
CharacterSet="2"
|
ConfigurationType="4"
|
||||||
WholeProgramOptimization="1"
|
UseOfMFC="0"
|
||||||
>
|
CharacterSet="2"
|
||||||
<Tool
|
WholeProgramOptimization="1"
|
||||||
Name="VCPreBuildEventTool"
|
>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCPreBuildEventTool"
|
||||||
Name="VCCustomBuildTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCCustomBuildTool"
|
||||||
Name="VCXMLDataGeneratorTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCXMLDataGeneratorTool"
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
Name="VCMIDLTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCMIDLTool"
|
||||||
Name="VCCLCompilerTool"
|
/>
|
||||||
RuntimeLibrary="2"
|
<Tool
|
||||||
WarningLevel="3"
|
Name="VCCLCompilerTool"
|
||||||
Detect64BitPortabilityProblems="true"
|
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc"
|
||||||
DebugInformationFormat="3"
|
PreprocessorDefinitions="WIN32;IXML_INLINE="
|
||||||
/>
|
RuntimeLibrary="0"
|
||||||
<Tool
|
WarningLevel="3"
|
||||||
Name="VCManagedResourceCompilerTool"
|
Detect64BitPortabilityProblems="true"
|
||||||
/>
|
DebugInformationFormat="3"
|
||||||
<Tool
|
CompileAs="1"
|
||||||
Name="VCResourceCompilerTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCManagedResourceCompilerTool"
|
||||||
Name="VCPreLinkEventTool"
|
/>
|
||||||
/>
|
<Tool
|
||||||
<Tool
|
Name="VCResourceCompilerTool"
|
||||||
Name="VCLinkerTool"
|
/>
|
||||||
GenerateDebugInformation="true"
|
<Tool
|
||||||
OptimizeReferences="2"
|
Name="VCPreLinkEventTool"
|
||||||
EnableCOMDATFolding="2"
|
/>
|
||||||
TargetMachine="1"
|
<Tool
|
||||||
/>
|
Name="VCLibrarianTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCALinkTool"
|
<Tool
|
||||||
/>
|
Name="VCALinkTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCManifestTool"
|
<Tool
|
||||||
/>
|
Name="VCXDCMakeTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCXDCMakeTool"
|
<Tool
|
||||||
/>
|
Name="VCBscMakeTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCBscMakeTool"
|
<Tool
|
||||||
/>
|
Name="VCFxCopTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCFxCopTool"
|
<Tool
|
||||||
/>
|
Name="VCPostBuildEventTool"
|
||||||
<Tool
|
/>
|
||||||
Name="VCAppVerifierTool"
|
</Configuration>
|
||||||
/>
|
</Configurations>
|
||||||
<Tool
|
<References>
|
||||||
Name="VCWebDeploymentTool"
|
</References>
|
||||||
/>
|
<Files>
|
||||||
<Tool
|
<Filter
|
||||||
Name="VCPostBuildEventTool"
|
Name="Source Files"
|
||||||
/>
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
</Configuration>
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
</Configurations>
|
>
|
||||||
<References>
|
<File
|
||||||
</References>
|
RelativePath="..\..\ixml\src\attr.c"
|
||||||
<Files>
|
>
|
||||||
<Filter
|
</File>
|
||||||
Name="Source Files"
|
<File
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
RelativePath="..\..\ixml\src\document.c"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
>
|
||||||
>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\attr.c"
|
RelativePath="..\..\ixml\src\element.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\document.c"
|
RelativePath="..\..\ixml\src\ixml.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\element.c"
|
RelativePath="..\..\ixml\src\ixmldebug.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\ixml.c"
|
RelativePath="..\..\ixml\src\ixmlmembuf.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\ixmlmembuf.c"
|
RelativePath="..\..\ixml\src\ixmlparser.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\ixmlparser.c"
|
RelativePath="..\..\ixml\src\namedNodeMap.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\namedNodeMap.c"
|
RelativePath="..\..\ixml\src\node.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\node.c"
|
RelativePath="..\..\ixml\src\nodeList.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
</Filter>
|
||||||
RelativePath="..\..\ixml\src\nodeList.c"
|
<Filter
|
||||||
>
|
Name="Header Files"
|
||||||
</File>
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
</Filter>
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
<Filter
|
>
|
||||||
Name="Header Files"
|
<File
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
RelativePath="..\..\ixml\inc\ixml.h"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
>
|
||||||
>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\inc\ixml.h"
|
RelativePath="..\..\ixml\inc\ixmldebug.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
|
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\inc\ixmlparser.h"
|
RelativePath="..\..\ixml\src\inc\ixmlparser.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
</Files>
|
||||||
Name="Resource Files"
|
<Globals>
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
</Globals>
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
</VisualStudioProject>
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="libupnp"
|
Name="libupnp"
|
||||||
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
|
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
|
||||||
|
RootNamespace="libupnp"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
@@ -15,8 +16,8 @@
|
|||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory=".\Release"
|
OutputDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory=".\Release"
|
IntermediateDirectory=".\out.vc8.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||||
UseOfMFC="0"
|
UseOfMFC="0"
|
||||||
@@ -48,18 +49,19 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
InlineFunctionExpansion="1"
|
InlineFunctionExpansion="1"
|
||||||
AdditionalIncludeDirectories="..\..\pthreads\include,..\ixml\src\inc,..\ixml\inc,..\threadutil\inc,..\upnp\inc,..\upnp\src\inc,.\inc"
|
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"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
PrecompiledHeaderFile=".\Release/libupnp.pch"
|
PrecompiledHeaderFile=".\Release/libupnp.pch"
|
||||||
AssemblerListingLocation=".\Release/"
|
AssemblerListingLocation="$(OutDir)\"
|
||||||
ObjectFile=".\Release/"
|
ObjectFile="$(OutDir)\"
|
||||||
ProgramDataBaseFileName=".\Release/"
|
ProgramDataBaseFileName="$(OutDir)\"
|
||||||
BrowseInformation="1"
|
BrowseInformation="1"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
@@ -74,8 +76,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib"
|
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib"
|
||||||
OutputFile=".\Release/libupnp.dll"
|
OutputFile="$(OutDir)\libupnp.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
ProgramDatabaseFile=".\Release/libupnp.pdb"
|
ProgramDatabaseFile=".\Release/libupnp.pdb"
|
||||||
@@ -144,7 +146,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\..\pthreads\include;..\..\ixml\src\inc;..\..\ixml\inc;..\..\threadutil\inc;..\..\upnp\inc;..\..\upnp\src\inc;..\inc;..\msvc"
|
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"
|
PreprocessorDefinitions="DEBUG;WIN32;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
@@ -156,6 +158,7 @@
|
|||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
@@ -170,10 +173,11 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib"
|
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib ixml.lib"
|
||||||
OutputFile="$(OutDir)\libupnp.dll"
|
OutputFile="$(OutDir)\libupnp.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
|
AdditionalLibraryDirectories="$(OutDir)\..\ixml"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(OutDir)\libupnp.pdb"
|
ProgramDatabaseFile="$(OutDir)\libupnp.pdb"
|
||||||
ImportLibrary="$(OutDir)\libupnp.lib"
|
ImportLibrary="$(OutDir)\libupnp.lib"
|
||||||
@@ -214,6 +218,14 @@
|
|||||||
Name="sources"
|
Name="sources"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
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
|
<File
|
||||||
RelativePath="..\..\ixml\src\attr.c"
|
RelativePath="..\..\ixml\src\attr.c"
|
||||||
>
|
>
|
||||||
@@ -222,6 +234,10 @@
|
|||||||
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
|
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\Discovery.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\document.c"
|
RelativePath="..\..\ixml\src\document.c"
|
||||||
>
|
>
|
||||||
@@ -230,6 +246,18 @@
|
|||||||
RelativePath="..\..\ixml\src\element.c"
|
RelativePath="..\..\ixml\src\element.c"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath="..\..\threadutil\src\FreeList.c"
|
RelativePath="..\..\threadutil\src\FreeList.c"
|
||||||
>
|
>
|
||||||
@@ -330,6 +358,10 @@
|
|||||||
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
|
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
|
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
|
||||||
>
|
>
|
||||||
@@ -338,10 +370,22 @@
|
|||||||
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
|
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\StateVarComplete.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\StateVarRequest.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
|
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\SubscriptionRequest.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\uuid\sysdep.c"
|
RelativePath="..\..\upnp\src\uuid\sysdep.c"
|
||||||
>
|
>
|
||||||
@@ -366,6 +410,10 @@
|
|||||||
RelativePath="..\..\upnp\src\api\upnpdebug.c"
|
RelativePath="..\..\upnp\src\api\upnpdebug.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\UpnpString.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\api\upnptools.c"
|
RelativePath="..\..\upnp\src\api\upnptools.c"
|
||||||
>
|
>
|
||||||
@@ -399,6 +447,14 @@
|
|||||||
Name="headers"
|
Name="headers"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\ActionComplete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\actionrequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\client_table.h"
|
RelativePath="..\..\upnp\src\inc\client_table.h"
|
||||||
>
|
>
|
||||||
@@ -407,6 +463,22 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\config.h"
|
RelativePath="..\..\upnp\src\inc\config.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\gena.h"
|
RelativePath="..\..\upnp\src\inc\gena.h"
|
||||||
>
|
>
|
||||||
@@ -479,6 +551,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\sock.h"
|
RelativePath="..\..\upnp\src\inc\sock.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\ssdplib.h"
|
RelativePath="..\..\upnp\src\inc\ssdplib.h"
|
||||||
>
|
>
|
||||||
@@ -487,6 +563,14 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\statcodes.h"
|
RelativePath="..\..\upnp\src\inc\statcodes.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\StateVarComplete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\statevarrequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\statuscodes.h"
|
RelativePath="..\..\upnp\src\inc\statuscodes.h"
|
||||||
>
|
>
|
||||||
@@ -495,6 +579,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\strintmap.h"
|
RelativePath="..\..\upnp\src\inc\strintmap.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\SubscriptionRequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\sysdep.h"
|
RelativePath="..\..\upnp\src\inc\sysdep.h"
|
||||||
>
|
>
|
||||||
@@ -503,6 +591,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\unixutil.h"
|
RelativePath="..\..\upnp\src\inc\unixutil.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\upnp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
|
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
|
||||||
>
|
>
|
||||||
@@ -519,6 +611,14 @@
|
|||||||
RelativePath="..\..\upnp\inc\upnpdebug.h"
|
RelativePath="..\..\upnp\inc\upnpdebug.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\UpnpString.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\upnptools.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\uri.h"
|
RelativePath="..\..\upnp\src\inc\uri.h"
|
||||||
>
|
>
|
||||||
@@ -544,11 +644,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="resources"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\..\libupnp_win32.patch"
|
RelativePath="..\..\..\..\libupnp_win32.patch"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="4"
|
ConfigurationType="4"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc"
|
AdditionalIncludeDirectories="..\..\ixml\inc;..\..\ixml\src\inc;..\inc;..\..\upnp\inc"
|
||||||
PreprocessorDefinitions="DEBUG;WIN32"
|
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
@@ -78,10 +78,10 @@
|
|||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="4"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
@@ -103,6 +103,8 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
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"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
@@ -118,18 +120,11 @@
|
|||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLibrarianTool"
|
||||||
GenerateDebugInformation="true"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
@@ -139,9 +134,6 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
@@ -171,6 +163,10 @@
|
|||||||
RelativePath="..\..\ixml\src\ixml.c"
|
RelativePath="..\..\ixml\src\ixml.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ixml\src\ixmldebug.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\ixmlmembuf.c"
|
RelativePath="..\..\ixml\src\ixmlmembuf.c"
|
||||||
>
|
>
|
||||||
@@ -201,6 +197,10 @@
|
|||||||
RelativePath="..\..\ixml\inc\ixml.h"
|
RelativePath="..\..\ixml\inc\ixml.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ixml\inc\ixmldebug.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
|
RelativePath="..\..\ixml\src\inc\ixmlmembuf.h"
|
||||||
>
|
>
|
||||||
@@ -210,12 +210,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</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>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|||||||
@@ -1,35 +1,29 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual C++ Express 2008
|
# Visual Studio 2008
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libupnp", "libupnp.vcproj", "{6227F51A-1498-4C4A-B213-F6FDED605125}"
|
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
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ixml", "ixml.vcproj", "{9C2C266D-35A3-465F-A297-0E21D54E5C89}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ixml", "ixml.vcproj", "{9C2C266D-35A3-465F-A297-0E21D54E5C89}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "threadutil", "threadutil.vcproj", "{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "threadutil", "threadutil.vcproj", "{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
|
||||||
{9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvctrlpt", "tvctrlpt.vcproj", "{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvctrlpt", "tvctrlpt.vcproj", "{8FB56F1C-E617-4B79-96AE-1FA499A3A9B5}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
||||||
{9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89}
|
|
||||||
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvdevice", "tvdevice.vcproj", "{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvdevice", "tvdevice.vcproj", "{7FB5F4A6-74F9-471D-B358-BAA0AC1CCA0A}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
||||||
{9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89}
|
|
||||||
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvcombo", "tvcombo.vcproj", "{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tvcombo", "tvcombo.vcproj", "{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
{6227F51A-1498-4C4A-B213-F6FDED605125} = {6227F51A-1498-4C4A-B213-F6FDED605125}
|
||||||
{9C2C266D-35A3-465F-A297-0E21D54E5C89} = {9C2C266D-35A3-465F-A297-0E21D54E5C89}
|
|
||||||
{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D} = {1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="libupnp"
|
Name="libupnp"
|
||||||
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
|
ProjectGUID="{6227F51A-1498-4C4A-B213-F6FDED605125}"
|
||||||
|
RootNamespace="libupnp"
|
||||||
TargetFrameworkVersion="131072"
|
TargetFrameworkVersion="131072"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
@@ -16,13 +17,13 @@
|
|||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory=".\Release"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory=".\Release"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||||
UseOfMFC="0"
|
UseOfMFC="0"
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
@@ -50,9 +51,9 @@
|
|||||||
Optimization="2"
|
Optimization="2"
|
||||||
InlineFunctionExpansion="1"
|
InlineFunctionExpansion="1"
|
||||||
AdditionalIncludeDirectories="..\..\pthreads\include,..\ixml\src\inc,..\ixml\inc,..\threadutil\inc,..\upnp\inc,..\upnp\src\inc,.\inc"
|
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"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBUPNP_EXPORTS;PTW32_STATIC_LIB;UPNP_STATIC_LIB;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
PrecompiledHeaderFile=".\Release/libupnp.pch"
|
PrecompiledHeaderFile=".\Release/libupnp.pch"
|
||||||
AssemblerListingLocation=".\Release/"
|
AssemblerListingLocation=".\Release/"
|
||||||
@@ -75,7 +76,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib"
|
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib"
|
||||||
OutputFile=".\Release/libupnp.dll"
|
OutputFile=".\Release/libupnp.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
@@ -117,7 +118,7 @@
|
|||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||||
UseOfMFC="0"
|
UseOfMFC="0"
|
||||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
@@ -144,10 +145,10 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\..\pthreads\include;..\..\ixml\src\inc;..\..\ixml\inc;..\..\threadutil\inc;..\..\upnp\inc;..\..\upnp\src\inc;..\inc;..\msvc"
|
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"
|
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="3"
|
||||||
PrecompiledHeaderFile="$(OutDir)\libupnp.pch"
|
PrecompiledHeaderFile="$(OutDir)\libupnp.pch"
|
||||||
AssemblerListingLocation="$(OutDir)\"
|
AssemblerListingLocation="$(OutDir)\"
|
||||||
ObjectFile="$(OutDir)\"
|
ObjectFile="$(OutDir)\"
|
||||||
@@ -170,7 +171,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib"
|
AdditionalDependencies="..\..\pthreads\lib\pthreadvc2.lib ws2_32.lib iphlpapi.lib $(TargetDir)..\ixml\ixml.lib"
|
||||||
OutputFile="$(OutDir)\libupnp.dll"
|
OutputFile="$(OutDir)\libupnp.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
@@ -213,6 +214,14 @@
|
|||||||
Name="sources"
|
Name="sources"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
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
|
<File
|
||||||
RelativePath="..\..\ixml\src\attr.c"
|
RelativePath="..\..\ixml\src\attr.c"
|
||||||
>
|
>
|
||||||
@@ -221,6 +230,10 @@
|
|||||||
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
|
RelativePath="..\..\upnp\src\genlib\client_table\client_table.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\Discovery.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\ixml\src\document.c"
|
RelativePath="..\..\ixml\src\document.c"
|
||||||
>
|
>
|
||||||
@@ -229,6 +242,18 @@
|
|||||||
RelativePath="..\..\ixml\src\element.c"
|
RelativePath="..\..\ixml\src\element.c"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath="..\..\threadutil\src\FreeList.c"
|
RelativePath="..\..\threadutil\src\FreeList.c"
|
||||||
>
|
>
|
||||||
@@ -329,6 +354,10 @@
|
|||||||
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
|
RelativePath="..\..\upnp\src\ssdp\ssdp_device.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
|
RelativePath="..\..\upnp\src\ssdp\ssdp_server.c"
|
||||||
>
|
>
|
||||||
@@ -337,10 +366,22 @@
|
|||||||
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
|
RelativePath="..\..\upnp\src\genlib\net\http\statcodes.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\StateVarComplete.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\StateVarRequest.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
|
RelativePath="..\..\upnp\src\genlib\util\strintmap.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\SubscriptionRequest.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\uuid\sysdep.c"
|
RelativePath="..\..\upnp\src\uuid\sysdep.c"
|
||||||
>
|
>
|
||||||
@@ -365,6 +406,10 @@
|
|||||||
RelativePath="..\..\upnp\src\api\upnpdebug.c"
|
RelativePath="..\..\upnp\src\api\upnpdebug.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\api\UpnpString.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\api\upnptools.c"
|
RelativePath="..\..\upnp\src\api\upnptools.c"
|
||||||
>
|
>
|
||||||
@@ -398,6 +443,14 @@
|
|||||||
Name="headers"
|
Name="headers"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\ActionComplete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\ActionRequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\client_table.h"
|
RelativePath="..\..\upnp\src\inc\client_table.h"
|
||||||
>
|
>
|
||||||
@@ -406,6 +459,22 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\config.h"
|
RelativePath="..\..\upnp\src\inc\config.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\gena.h"
|
RelativePath="..\..\upnp\src\inc\gena.h"
|
||||||
>
|
>
|
||||||
@@ -478,6 +547,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\sock.h"
|
RelativePath="..\..\upnp\src\inc\sock.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\src\ssdp\ssdp_ResultData.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\ssdplib.h"
|
RelativePath="..\..\upnp\src\inc\ssdplib.h"
|
||||||
>
|
>
|
||||||
@@ -486,6 +559,14 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\statcodes.h"
|
RelativePath="..\..\upnp\src\inc\statcodes.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\StateVarComplete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\StateVarRequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\statuscodes.h"
|
RelativePath="..\..\upnp\src\inc\statuscodes.h"
|
||||||
>
|
>
|
||||||
@@ -494,6 +575,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\strintmap.h"
|
RelativePath="..\..\upnp\src\inc\strintmap.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\SubscriptionRequest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\sysdep.h"
|
RelativePath="..\..\upnp\src\inc\sysdep.h"
|
||||||
>
|
>
|
||||||
@@ -502,6 +587,10 @@
|
|||||||
RelativePath="..\..\upnp\src\inc\unixutil.h"
|
RelativePath="..\..\upnp\src\inc\unixutil.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\upnp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
|
RelativePath="..\..\upnp\src\inc\upnp_timeout.h"
|
||||||
>
|
>
|
||||||
@@ -518,6 +607,14 @@
|
|||||||
RelativePath="..\..\upnp\inc\upnpdebug.h"
|
RelativePath="..\..\upnp\inc\upnpdebug.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\UpnpString.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\upnp\inc\upnptools.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\upnp\src\inc\uri.h"
|
RelativePath="..\..\upnp\src\inc\uri.h"
|
||||||
>
|
>
|
||||||
@@ -543,11 +640,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="resources"
|
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\..\libupnp_win32.patch"
|
RelativePath="..\..\..\..\libupnp_win32.patch"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="threadutil"
|
Name="threadutil"
|
||||||
ProjectGUID="{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
|
ProjectGUID="{1D3EEF7A-D248-48C0-B6B5-ECA229FE4B3D}"
|
||||||
RootNamespace="threadutil"
|
RootNamespace="threadutil"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="4"
|
ConfigurationType="4"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
@@ -41,12 +41,13 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\..\threadutil\inc;..\..\upnp\inc;..\..\ixml\inc;..\..\pthreads\include"
|
AdditionalIncludeDirectories="..\..\threadutil\inc;..\..\upnp\inc;..\..\ixml\inc;..\..\pthreads\include"
|
||||||
PreprocessorDefinitions="WIN32;DEBUG"
|
PreprocessorDefinitions="DEBUG;WIN32;_USRDLL;LIBUPNP_EXPORTS;UPNP_USE_MSVCPP;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
@@ -80,10 +81,10 @@
|
|||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2"
|
CharacterSet="0"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
@@ -105,10 +106,13 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
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"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="tvcombo"
|
Name="tvcombo"
|
||||||
ProjectGUID="{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
|
ProjectGUID="{6365804B-22C6-4D5E-91F3-0C052EB55B4F}"
|
||||||
RootNamespace="tvcombo"
|
RootNamespace="tvcombo"
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
@@ -59,8 +60,8 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib ixml.lib threadutil.lib libupnp.lib"
|
AdditionalDependencies="..\..\pthreads\lib\pthreadVC2.lib $(TargetDir)..\libupnp\libupnp.lib"
|
||||||
AdditionalLibraryDirectories=""$(OutDir)";".\out.vc9.$(ConfigurationName)\ixml";".\out.vc9.$(ConfigurationName)\threadutil";".\out.vc9.$(ConfigurationName)\libupnp""
|
AdditionalLibraryDirectories=""$(TargetDir)..\ixml";"$(TargetDir)..\threadutil";"$(TargetDir)..\libupnp""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
@@ -88,8 +89,8 @@
|
|||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory=".\out.vc9.$(ConfigurationName)\$(ProjectName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
@@ -117,6 +118,7 @@
|
|||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
|||||||
81
configure.ac
81
configure.ac
@@ -4,12 +4,12 @@
|
|||||||
#
|
#
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
#
|
#
|
||||||
# (C) Copyright 2005-2007 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
|
# (C) Copyright 2005-2007 Rémi Turboult <r3mi@users.sourceforge.net>
|
||||||
#
|
#
|
||||||
|
|
||||||
AC_PREREQ(2.60)
|
AC_PREREQ(2.60)
|
||||||
|
|
||||||
AC_INIT([libupnp], [1.6.6], [mroberto@users.sourceforge.net])
|
AC_INIT([libupnp], [1.8.0], [mroberto@users.sourceforge.net])
|
||||||
dnl ############################################################################
|
dnl ############################################################################
|
||||||
dnl # *Independently* of the above libupnp package version, the libtool version
|
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 # of the 3 libraries need to be updated whenever there is a change released:
|
||||||
@@ -144,9 +144,30 @@ dnl #AC_SUBST([LT_VERSION_THREADUTIL], [4:3:2])
|
|||||||
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
|
dnl #AC_SUBST([LT_VERSION_UPNP], [3:5:0])
|
||||||
dnl #
|
dnl #
|
||||||
dnl ############################################################################
|
dnl ############################################################################
|
||||||
|
dnl # Release 1.8.0:
|
||||||
|
dnl # "current:revision:age"
|
||||||
|
dnl #
|
||||||
|
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 # - Interface has been removed in upnp
|
||||||
|
dnl # age = 0
|
||||||
|
dnl # - Code has changed in threadutil
|
||||||
|
dnl # revision: 3 -> 4
|
||||||
|
dnl # - Interfaces have been changed, added and removed in upnp
|
||||||
|
dnl # current: 4 -> 5
|
||||||
|
dnl # revision: 4 -> 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], [4:0:0])
|
||||||
|
dnl #
|
||||||
|
dnl ############################################################################
|
||||||
AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
AC_SUBST([LT_VERSION_IXML], [2:4:0])
|
||||||
AC_SUBST([LT_VERSION_THREADUTIL], [4:3:2])
|
AC_SUBST([LT_VERSION_THREADUTIL], [5:0:2])
|
||||||
AC_SUBST([LT_VERSION_UPNP], [3:5:0])
|
AC_SUBST([LT_VERSION_UPNP], [4:0:0])
|
||||||
dnl ############################################################################
|
dnl ############################################################################
|
||||||
dnl # Repeating the algorithm to place it closer to the modificatin place:
|
dnl # Repeating the algorithm to place it closer to the modificatin place:
|
||||||
dnl # - library code modified: revision++
|
dnl # - library code modified: revision++
|
||||||
@@ -325,9 +346,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
|
AC_HEADER_STDC
|
||||||
|
if test "$ac_cv_win32" = "no"; then
|
||||||
# libupnp code doesn't use autoconf variables yet,
|
# libupnp code doesn't use autoconf variables yet,
|
||||||
# so just abort if a header file is not found.
|
# so just abort if a header file is not found.
|
||||||
AC_CHECK_HEADERS(
|
AC_CHECK_HEADERS(
|
||||||
@@ -343,19 +381,43 @@ AC_CHECK_HEADERS(
|
|||||||
sys/ioctl.h \
|
sys/ioctl.h \
|
||||||
sys/socket.h \
|
sys/socket.h \
|
||||||
sys/time.h \
|
sys/time.h \
|
||||||
sys/timeb.h \
|
|
||||||
syslog.h \
|
syslog.h \
|
||||||
unistd.h \
|
unistd.h \
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([required header file missing])])
|
[AC_MSG_ERROR([required header file missing])])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Checks for typedefs, structures, and compiler characteristics
|
# Checks for typedefs, structures, and compiler characteristics
|
||||||
#
|
#
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -364,6 +426,11 @@ TYPE_SOCKLEN_T
|
|||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)])
|
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])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -24,15 +24,23 @@ libixml_la_LDFLAGS = -version-info $(LT_VERSION_IXML) \
|
|||||||
-export-symbols-regex '^ixml.*'
|
-export-symbols-regex '^ixml.*'
|
||||||
|
|
||||||
libixml_la_SOURCES = \
|
libixml_la_SOURCES = \
|
||||||
src/ixml.c src/node.c src/ixmlparser.c \
|
src/attr.c \
|
||||||
src/ixmlmembuf.c src/nodeList.c \
|
src/document.c \
|
||||||
src/element.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/namedNodeMap.c \
|
||||||
src/inc/ixmlmembuf.h src/inc/ixmlparser.h
|
src/node.c \
|
||||||
|
src/nodeList.c
|
||||||
|
|
||||||
upnpincludedir = $(includedir)/upnp
|
upnpincludedir = $(includedir)/upnp
|
||||||
upnpinclude_HEADERS = inc/ixml.h
|
upnpinclude_HEADERS = \
|
||||||
|
inc/ixml.h \
|
||||||
|
inc/ixmldebug.h
|
||||||
|
|
||||||
check_PROGRAMS = test_document
|
check_PROGRAMS = test_document
|
||||||
TESTS = test/test_document.sh
|
TESTS = test/test_document.sh
|
||||||
@@ -47,4 +55,3 @@ dist-hook:
|
|||||||
clean-local:
|
clean-local:
|
||||||
@if [ -d bin ] ; then rm -rf bin ; fi
|
@if [ -d bin ] ; then rm -rf bin ; fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3230
ixml/inc/ixml.h
3230
ixml/inc/ixml.h
File diff suppressed because it is too large
Load Diff
67
ixml/inc/ixmldebug.h
Normal file
67
ixml/inc/ixmldebug.h
Normal 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 */
|
||||||
|
|
||||||
@@ -1,60 +1,53 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* Function: Attr_init
|
#include <string.h>
|
||||||
* Initializes an attribute node
|
|
||||||
* External function.
|
|
||||||
*
|
void ixmlAttr_init(IN IXML_Attr *attr)
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixmlAttr_init( IN IXML_Attr * attr )
|
|
||||||
{
|
{
|
||||||
if( attr != NULL ) {
|
if (attr != NULL) {
|
||||||
memset( attr, 0, sizeof( IXML_Attr ) );
|
memset(attr, 0, sizeof (IXML_Attr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* Function: Attr_free
|
void ixmlAttr_free(IN IXML_Attr *attr)
|
||||||
* Frees an attribute node.
|
|
||||||
* external function.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixmlAttr_free( IN IXML_Attr * attr )
|
|
||||||
{
|
{
|
||||||
if( attr != NULL ) {
|
if (attr != NULL) {
|
||||||
ixmlNode_free( ( IXML_Node * ) attr );
|
ixmlNode_free((IXML_Node *)attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1135
ixml/src/document.c
1135
ixml/src/document.c
File diff suppressed because it is too large
Load Diff
1434
ixml/src/element.c
1434
ixml/src/element.c
File diff suppressed because it is too large
Load Diff
@@ -1,73 +1,173 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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"
|
#include "ixml.h"
|
||||||
|
|
||||||
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
|
|
||||||
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
#include <stdlib.h> /* for size_t */
|
||||||
|
|
||||||
|
|
||||||
|
#define MINVAL(a, b) ( (a) < (b) ? (a) : (b) )
|
||||||
|
#define MAXVAL(a, b) ( (a) > (b) ? (a) : (b) )
|
||||||
|
|
||||||
|
|
||||||
#define MEMBUF_DEF_SIZE_INC 20
|
#define MEMBUF_DEF_SIZE_INC 20
|
||||||
|
|
||||||
|
|
||||||
typedef struct // ixml_membuf
|
/*!
|
||||||
|
* \brief The ixml_membuf type.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
size_t length;
|
||||||
size_t length;
|
size_t capacity;
|
||||||
size_t capacity;
|
size_t size_inc;
|
||||||
size_t size_inc;
|
|
||||||
|
|
||||||
} ixml_membuf;
|
} 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);
|
* \brief ixml_membuf initialization routine.
|
||||||
int ixml_membuf_assign(INOUT ixml_membuf *m, IN const void *buf,
|
*/
|
||||||
IN size_t buf_len );
|
void ixml_membuf_init(
|
||||||
int ixml_membuf_assign_str(INOUT ixml_membuf *m, IN const char *c_str );
|
/*! [in,out] The memory buffer to initializa. */
|
||||||
int ixml_membuf_append(INOUT ixml_membuf *m, IN const void *buf);
|
ixml_membuf *m);
|
||||||
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 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
|
|
||||||
|
|||||||
@@ -1,41 +1,49 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef _IXMLPARSER_H
|
|
||||||
#define _IXMLPARSER_H
|
#ifndef IXMLPARSER_H
|
||||||
|
#define IXMLPARSER_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ixml.h"
|
#include "ixml.h"
|
||||||
#include "ixmlmembuf.h"
|
#include "ixmlmembuf.h"
|
||||||
|
|
||||||
// Parser definitions
|
|
||||||
|
/* Parser definitions */
|
||||||
#define QUOT """
|
#define QUOT """
|
||||||
#define LT "<"
|
#define LT "<"
|
||||||
#define GT ">"
|
#define GT ">"
|
||||||
@@ -44,77 +52,218 @@
|
|||||||
#define ESC_HEX "&#x"
|
#define ESC_HEX "&#x"
|
||||||
#define ESC_DEC "&#"
|
#define ESC_DEC "&#"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _IXML_NamespaceURI
|
typedef struct _IXML_NamespaceURI
|
||||||
{
|
{
|
||||||
char *nsURI;
|
char *nsURI;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
struct _IXML_NamespaceURI *nextNsURI;
|
struct _IXML_NamespaceURI *nextNsURI;
|
||||||
} IXML_NamespaceURI;
|
} IXML_NamespaceURI;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _IXML_ElementStack
|
typedef struct _IXML_ElementStack
|
||||||
{
|
{
|
||||||
char *element;
|
char *element;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
char *namespaceUri;
|
char *namespaceUri;
|
||||||
IXML_NamespaceURI *pNsURI;
|
IXML_NamespaceURI *pNsURI;
|
||||||
struct _IXML_ElementStack *nextElement;
|
struct _IXML_ElementStack *nextElement;
|
||||||
} IXML_ElementStack;
|
} IXML_ElementStack;
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
eELEMENT,
|
eELEMENT,
|
||||||
eATTRIBUTE,
|
eATTRIBUTE,
|
||||||
eCONTENT,
|
eCONTENT,
|
||||||
} PARSER_STATE;
|
} PARSER_STATE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Parser
|
typedef struct _Parser
|
||||||
{
|
{
|
||||||
char *dataBuffer; //data buffer
|
/*! Data buffer. */
|
||||||
char *curPtr; //ptr to the token parsed
|
char *dataBuffer;
|
||||||
char *savePtr; //Saves for backup
|
/*! Pointer to the token parsed. */
|
||||||
ixml_membuf lastElem;
|
char *curPtr;
|
||||||
ixml_membuf tokenBuf;
|
/*! Saves for backup. */
|
||||||
|
char *savePtr;
|
||||||
IXML_Node *pNeedPrefixNode;
|
ixml_membuf lastElem;
|
||||||
IXML_ElementStack *pCurElement;
|
ixml_membuf tokenBuf;
|
||||||
IXML_Node *currentNodePtr;
|
IXML_Node *pNeedPrefixNode;
|
||||||
PARSER_STATE state;
|
IXML_ElementStack *pCurElement;
|
||||||
|
IXML_Node *currentNodePtr;
|
||||||
BOOL bHasTopLevel;
|
PARSER_STATE state;
|
||||||
|
BOOL bHasTopLevel;
|
||||||
} Parser;
|
} 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 Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
|
||||||
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add);
|
|
||||||
|
|
||||||
void ixmlNode_init(IXML_Node *IXML_Nodeptr);
|
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
|
||||||
BOOL ixmlNode_compare(IXML_Node *srcIXML_Node, IXML_Node *destIXML_Node);
|
|
||||||
|
|
||||||
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);
|
void ixmlAttr_init(IXML_Attr *attrNode);
|
||||||
int ixmlNode_setNodeName( IXML_Node* node, const DOMString qualifiedName);
|
|
||||||
|
|
||||||
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 */
|
||||||
|
|
||||||
|
|||||||
956
ixml/src/ixml.c
956
ixml/src/ixml.c
@@ -1,531 +1,469 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixmldebug.h"
|
||||||
#include "ixmlmembuf.h"
|
#include "ixmlmembuf.h"
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* copy_with_escape
|
#include <stdlib.h> /* for free() */
|
||||||
*
|
#include <string.h>
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
static void
|
/*!
|
||||||
copy_with_escape( INOUT ixml_membuf * buf,
|
* \brief Appends a string to a buffer, substituting some characters by escape
|
||||||
IN const char *p )
|
* 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 i;
|
||||||
int plen;
|
int plen;
|
||||||
|
|
||||||
if( p == NULL )
|
if (p == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
plen = strlen( p );
|
|
||||||
|
plen = strlen( p );
|
||||||
for( i = 0; i < plen; i++ ) {
|
|
||||||
switch ( p[i] ) {
|
for (i = 0; i < plen; i++) {
|
||||||
case '<':
|
switch (p[i]) {
|
||||||
ixml_membuf_append_str( buf, "<" );
|
case '<':
|
||||||
break;
|
ixml_membuf_append_str(buf, "<");
|
||||||
|
break;
|
||||||
case '>':
|
|
||||||
ixml_membuf_append_str( buf, ">" );
|
case '>':
|
||||||
break;
|
ixml_membuf_append_str(buf, ">");
|
||||||
|
break;
|
||||||
case '&':
|
|
||||||
ixml_membuf_append_str( buf, "&" );
|
case '&':
|
||||||
break;
|
ixml_membuf_append_str(buf, "&");
|
||||||
|
break;
|
||||||
case '\'':
|
|
||||||
ixml_membuf_append_str( buf, "'" );
|
case '\'':
|
||||||
break;
|
ixml_membuf_append_str(buf, "'");
|
||||||
|
break;
|
||||||
case '\"':
|
|
||||||
ixml_membuf_append_str( buf, """ );
|
case '\"':
|
||||||
break;
|
ixml_membuf_append_str(buf, """);
|
||||||
|
break;
|
||||||
default:
|
|
||||||
ixml_membuf_append( buf, &p[i] );
|
default:
|
||||||
}
|
ixml_membuf_append(buf, &p[i]);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*================================================================
|
|
||||||
* 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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*================================================================
|
/*!
|
||||||
* ixmlParseBufferEx
|
* \brief Recursive function to print all the node in a tree.
|
||||||
* Parse xml file stored in buffer.
|
* Internal to parser only.
|
||||||
* External function.
|
*/
|
||||||
*
|
static void ixmlPrintDomTreeRecursive(
|
||||||
*=================================================================*/
|
/*! [in] \todo documentation. */
|
||||||
int
|
IXML_Node *nodeptr,
|
||||||
ixmlParseBufferEx( IN const char *buffer,
|
/*! [in] \todo documentation. */
|
||||||
IXML_Document ** retDoc )
|
ixml_membuf *buf)
|
||||||
{
|
{
|
||||||
|
const char *nodeName = NULL;
|
||||||
|
const char *nodeValue = NULL;
|
||||||
|
IXML_Node *child = NULL,
|
||||||
|
*sibling = NULL;
|
||||||
|
|
||||||
if( ( buffer == NULL ) || ( retDoc == NULL ) ) {
|
if (nodeptr != NULL) {
|
||||||
return IXML_INVALID_PARAMETER;
|
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' ) {
|
case eCDATA_SECTION_NODE:
|
||||||
return IXML_INVALID_PARAMETER;
|
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
|
int ixmlLoadDocumentEx(const char *xmlFile, IXML_Document **doc)
|
||||||
* Frees a DOM String.
|
|
||||||
* External function.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixmlFreeDOMString( IN DOMString buf )
|
|
||||||
{
|
{
|
||||||
if( buf != NULL ) {
|
if (xmlFile == NULL || doc == NULL) {
|
||||||
free( buf );
|
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
70
ixml/src/ixmldebug.c
Normal 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
|
||||||
|
|
||||||
@@ -1,236 +1,218 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixmlmembuf.h"
|
||||||
|
#include "ixml.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ixmlmembuf.h"
|
|
||||||
#include "ixml.h"
|
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixml_membuf_set_size
|
/*!
|
||||||
*
|
* \brief Increases or decreases buffer capacity so that at least 'new_length'
|
||||||
* Increases or decreases buffer cap so that at least
|
* bytes can be stored.
|
||||||
* 'new_length' bytes can be stored
|
*
|
||||||
*
|
* On error, m's fields do not change.
|
||||||
* On error, m's fields do not change.
|
*
|
||||||
*
|
* \return
|
||||||
* returns:
|
* \li UPNP_E_SUCCESS
|
||||||
* UPNP_E_SUCCESS
|
* \li UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_OUTOF_MEMORY
|
*/
|
||||||
*
|
static int ixml_membuf_set_size(
|
||||||
*=================================================================*/
|
/*! [in,out] The memory buffer. */
|
||||||
static int
|
INOUT ixml_membuf *m,
|
||||||
ixml_membuf_set_size( INOUT ixml_membuf * m,
|
/*! [in] The new lenght. */
|
||||||
IN size_t new_length )
|
IN size_t new_length)
|
||||||
{
|
{
|
||||||
size_t diff;
|
size_t diff;
|
||||||
size_t alloc_len;
|
size_t alloc_len;
|
||||||
char *temp_buf;
|
char *temp_buf;
|
||||||
|
|
||||||
if( new_length >= m->length ) // increase length
|
if (new_length >= m->length) {
|
||||||
{
|
/* increase length */
|
||||||
// need more mem?
|
/* need more mem? */
|
||||||
if( new_length <= m->capacity ) {
|
if (new_length <= m->capacity) {
|
||||||
return 0; // have enough mem; done
|
/* have enough mem; done */
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
diff = new_length - m->length;
|
diff = new_length - m->length;
|
||||||
alloc_len = MAXVAL( m->size_inc, diff ) + m->capacity;
|
alloc_len = MAXVAL(m->size_inc, diff) + m->capacity;
|
||||||
} else // decrease length
|
} else {
|
||||||
{
|
// decrease length
|
||||||
assert( new_length <= m->length );
|
assert(new_length <= m->length);
|
||||||
|
|
||||||
// if diff is 0..m->size_inc, don't free
|
// if diff is 0..m->size_inc, don't free
|
||||||
if( ( m->capacity - new_length ) <= m->size_inc ) {
|
if ((m->capacity - new_length) <= m->size_inc) {
|
||||||
return 0;
|
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 );
|
return 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* membuffer_init
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixml_membuf_init( INOUT ixml_membuf * m )
|
|
||||||
{
|
|
||||||
assert( m != NULL );
|
|
||||||
|
|
||||||
m->size_inc = MEMBUF_DEF_SIZE_INC;
|
void ixml_membuf_init(ixml_membuf *m)
|
||||||
m->buf = NULL;
|
{
|
||||||
m->length = 0;
|
assert(m != NULL);
|
||||||
m->capacity = 0;
|
|
||||||
|
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 );
|
void ixml_membuf_destroy(ixml_membuf *m)
|
||||||
ixml_membuf_init( m );
|
{
|
||||||
|
if (m == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(m->buf);
|
||||||
|
ixml_membuf_init(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixml_membuf_assign
|
int ixml_membuf_assign(
|
||||||
*
|
ixml_membuf *m,
|
||||||
*
|
const void *buf,
|
||||||
*=================================================================*/
|
size_t buf_len)
|
||||||
int
|
|
||||||
ixml_membuf_assign( INOUT ixml_membuf * m,
|
|
||||||
IN const void *buf,
|
|
||||||
IN size_t buf_len )
|
|
||||||
{
|
{
|
||||||
int return_code;
|
int return_code;
|
||||||
|
|
||||||
assert( m != NULL );
|
assert(m != NULL);
|
||||||
|
|
||||||
// set value to null
|
// set value to null
|
||||||
if( buf == NULL ) {
|
if (buf == NULL) {
|
||||||
ixml_membuf_destroy( m );
|
ixml_membuf_destroy(m);
|
||||||
return IXML_SUCCESS;
|
return IXML_SUCCESS;
|
||||||
}
|
}
|
||||||
// alloc mem
|
// alloc mem
|
||||||
return_code = ixml_membuf_set_size( m, buf_len );
|
return_code = ixml_membuf_set_size(m, buf_len);
|
||||||
if( return_code != 0 ) {
|
if (return_code != 0) {
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
// copy
|
|
||||||
memcpy( m->buf, buf, buf_len );
|
|
||||||
m->buf[buf_len] = 0; // null-terminate
|
|
||||||
|
|
||||||
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(
|
||||||
*
|
ixml_membuf *m,
|
||||||
*
|
const char *c_str)
|
||||||
*=================================================================*/
|
|
||||||
int
|
|
||||||
ixml_membuf_assign_str( INOUT ixml_membuf * m,
|
|
||||||
IN 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
|
int index)
|
||||||
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 )
|
if (index < 0 || index > (int)m->length) {
|
||||||
return IXML_INDEX_SIZE_ERR;
|
return IXML_INDEX_SIZE_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
if( buf == NULL || buf_len == 0 ) {
|
if (buf == NULL || buf_len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// alloc mem
|
/* alloc mem */
|
||||||
return_code = ixml_membuf_set_size( m, m->length + buf_len );
|
return_code = ixml_membuf_set_size(m, m->length + buf_len);
|
||||||
if( return_code != 0 ) {
|
if (return_code != 0) {
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
// insert data
|
/* insert data */
|
||||||
// move data to right of insertion point
|
/* move data to right of insertion point */
|
||||||
memmove( m->buf + index + buf_len, m->buf + index, m->length - index );
|
memmove(m->buf + index + buf_len, m->buf + index, m->length - index);
|
||||||
memcpy( m->buf + index, buf, buf_len );
|
memcpy(m->buf + index, buf, buf_len);
|
||||||
m->length += buf_len;
|
m->length += buf_len;
|
||||||
m->buf[m->length] = 0; // null-terminate
|
/* Null terminate */
|
||||||
|
m->buf[m->length] = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,242 +1,195 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* NamedNodeMap_getItemNumber
|
#include <assert.h>
|
||||||
* return the item number of a item in NamedNodeMap.
|
#include <stdlib.h> /* for free(), malloc() */
|
||||||
* Internal to parser only.
|
#include <string.h>
|
||||||
* Parameters:
|
|
||||||
* name: the name of the item to find
|
|
||||||
*
|
/*!
|
||||||
*=================================================================*/
|
* \brief Return the item number of a item in NamedNodeMap.
|
||||||
unsigned long
|
*/
|
||||||
ixmlNamedNodeMap_getItemNumber( IN IXML_NamedNodeMap * nnMap,
|
static unsigned long ixmlNamedNodeMap_getItemNumber(
|
||||||
IN const char *name )
|
/*! [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;
|
IXML_Node *tempNode;
|
||||||
unsigned long returnItemNo = 0;
|
unsigned long returnItemNo = 0;
|
||||||
|
|
||||||
assert( nnMap != NULL && name != NULL );
|
assert(nnMap != NULL && name != NULL);
|
||||||
if( ( nnMap == NULL ) || ( name == NULL ) ) {
|
if (nnMap == NULL || name == NULL) {
|
||||||
return IXML_INVALID_ITEM_NUMBER;
|
return IXML_INVALID_ITEM_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempNode = nnMap->nodeItem;
|
tempNode = nnMap->nodeItem;
|
||||||
while( tempNode != NULL ) {
|
while (tempNode != NULL) {
|
||||||
if( strcmp( name, tempNode->nodeName ) == 0 ) {
|
if (strcmp(name, tempNode->nodeName) == 0) {
|
||||||
return returnItemNo;
|
return returnItemNo;
|
||||||
}
|
}
|
||||||
|
tempNode = tempNode->nextSibling;
|
||||||
|
returnItemNo++;
|
||||||
|
}
|
||||||
|
|
||||||
tempNode = tempNode->nextSibling;
|
return IXML_INVALID_ITEM_NUMBER;
|
||||||
returnItemNo++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return IXML_INVALID_ITEM_NUMBER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* NamedNodeMap_init
|
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
|
||||||
* Initializes a NamedNodeMap object.
|
|
||||||
* External function.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixmlNamedNodeMap_init( IN IXML_NamedNodeMap * nnMap )
|
|
||||||
{
|
{
|
||||||
assert( nnMap != NULL );
|
assert(nnMap != NULL);
|
||||||
memset( nnMap, 0, sizeof( IXML_NamedNodeMap ) );
|
|
||||||
|
memset(nnMap, 0, sizeof (IXML_NamedNodeMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* NamedNodeMap_getNamedItem
|
IXML_Node *ixmlNamedNodeMap_getNamedItem(
|
||||||
* Retrieves a node specified by name.
|
IXML_NamedNodeMap *nnMap,
|
||||||
* External function.
|
const DOMString name)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
long index;
|
long index;
|
||||||
|
|
||||||
if( ( nnMap == NULL ) || ( name == NULL ) ) {
|
if (nnMap == NULL || name == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = ixmlNamedNodeMap_getItemNumber( nnMap, name );
|
index = ixmlNamedNodeMap_getItemNumber(nnMap, name);
|
||||||
if( index == IXML_INVALID_ITEM_NUMBER ) {
|
if (index == IXML_INVALID_ITEM_NUMBER) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return ( ixmlNamedNodeMap_item( nnMap, ( unsigned long )index ) );
|
return ixmlNamedNodeMap_item(nnMap, (unsigned long)index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* NamedNodeMap_item
|
IXML_Node *ixmlNamedNodeMap_item(
|
||||||
* Returns the indexth item in the map. If index is greater than or
|
IN IXML_NamedNodeMap *nnMap,
|
||||||
* equal to the number of nodes in this map, this returns null.
|
IN unsigned long index )
|
||||||
* 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 *tempNode;
|
IXML_Node *tempNode;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if( nnMap == NULL ) {
|
if (nnMap == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( index > ixmlNamedNodeMap_getLength( nnMap ) - 1 ) {
|
if (index > ixmlNamedNodeMap_getLength(nnMap) - 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempNode = nnMap->nodeItem;
|
tempNode = nnMap->nodeItem;
|
||||||
for( i = 0; i < index && tempNode != NULL; ++i ) {
|
for (i = 0; i < index && tempNode != NULL; ++i) {
|
||||||
tempNode = tempNode->nextSibling;
|
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 ) {
|
unsigned long ixmlNamedNodeMap_getLength(IXML_NamedNodeMap *nnMap)
|
||||||
tempNode = nnMap->nodeItem;
|
{
|
||||||
for( length = 0; tempNode != NULL; ++length ) {
|
IXML_Node *tempNode;
|
||||||
tempNode = tempNode->nextSibling;
|
unsigned long length = 0;
|
||||||
}
|
|
||||||
}
|
if (nnMap != NULL) {
|
||||||
return length;
|
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 ) {
|
void ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap)
|
||||||
pNext = nnMap->next;
|
{
|
||||||
free( nnMap );
|
IXML_NamedNodeMap *pNext;
|
||||||
nnMap = pNext;
|
|
||||||
}
|
while (nnMap != NULL) {
|
||||||
|
pNext = nnMap->next;
|
||||||
|
free(nnMap);
|
||||||
|
nnMap = pNext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* NamedNodeMap_addToNamedNodeMap
|
int ixmlNamedNodeMap_addToNamedNodeMap(
|
||||||
* add a node to a NamedNodeMap.
|
IXML_NamedNodeMap **nnMap,
|
||||||
* Internal to parser only.
|
IXML_Node *add)
|
||||||
* Parameters:
|
|
||||||
* add: the node to add into NamedNodeMap.
|
|
||||||
* Return:
|
|
||||||
* IXML_SUCCESS or failure.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
int
|
|
||||||
ixmlNamedNodeMap_addToNamedNodeMap( IN IXML_NamedNodeMap ** nnMap,
|
|
||||||
IN IXML_Node * add )
|
|
||||||
{
|
{
|
||||||
IXML_NamedNodeMap *traverse = NULL,
|
IXML_NamedNodeMap *traverse = NULL;
|
||||||
*p = NULL;
|
IXML_NamedNodeMap *p = NULL;
|
||||||
IXML_NamedNodeMap *newItem = NULL;
|
IXML_NamedNodeMap *newItem = NULL;
|
||||||
|
|
||||||
if( add == NULL ) {
|
if(add == NULL) {
|
||||||
return IXML_SUCCESS;
|
return IXML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *nnMap == NULL ) // nodelist is empty
|
if (*nnMap == NULL) {
|
||||||
{
|
// nodelist is empty
|
||||||
*nnMap =
|
*nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
|
||||||
( IXML_NamedNodeMap * ) malloc( sizeof( IXML_NamedNodeMap ) );
|
if (*nnMap == NULL) {
|
||||||
if( *nnMap == NULL ) {
|
return IXML_INSUFFICIENT_MEMORY;
|
||||||
return IXML_INSUFFICIENT_MEMORY;
|
}
|
||||||
}
|
ixmlNamedNodeMap_init(*nnMap);
|
||||||
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 ) {
|
return IXML_SUCCESS;
|
||||||
( *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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2790
ixml/src/node.c
2790
ixml/src/node.c
File diff suppressed because it is too large
Load Diff
@@ -1,176 +1,152 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ixmlparser.h"
|
#include "ixmlparser.h"
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixmlNodeList_init
|
#include <assert.h>
|
||||||
* initializes a nodelist
|
#include <string.h>
|
||||||
* External function.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
void ixmlNodeList_init(IXML_NodeList *nList)
|
||||||
void
|
|
||||||
ixmlNodeList_init( IXML_NodeList * nList )
|
|
||||||
{
|
{
|
||||||
assert( nList != NULL );
|
assert(nList != NULL);
|
||||||
|
|
||||||
memset( nList, 0, sizeof( IXML_NodeList ) );
|
|
||||||
|
|
||||||
|
memset(nList, 0, sizeof (IXML_NodeList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixmlNodeList_item
|
IXML_Node *ixmlNodeList_item(
|
||||||
* Returns the indexth item in the collection. If index is greater
|
IXML_NodeList *nList,
|
||||||
* than or equal to the number of nodes in the list, this returns
|
unsigned long index)
|
||||||
* null.
|
|
||||||
* External function.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
IXML_Node *
|
|
||||||
ixmlNodeList_item( IXML_NodeList * nList,
|
|
||||||
unsigned long index )
|
|
||||||
{
|
{
|
||||||
IXML_NodeList *next;
|
IXML_NodeList *next;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
// if the list ptr is NULL
|
// if the list ptr is NULL
|
||||||
if( nList == NULL ) {
|
if (nList == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// if index is more than list length
|
// if index is more than list length
|
||||||
if( index > ixmlNodeList_length( nList ) - 1 ) {
|
if (index > ixmlNodeList_length(nList) - 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
next = nList;
|
next = nList;
|
||||||
for( i = 0; i < index && next != NULL; ++i ) {
|
for (i = 0; i < index && next != NULL; ++i) {
|
||||||
next = next->next;
|
next = next->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( next == NULL ) return NULL;
|
if (next == NULL) {
|
||||||
|
return NULL;
|
||||||
return next->nodeItem;
|
}
|
||||||
|
|
||||||
|
return next->nodeItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
int ixmlNodeList_addToNodeList(
|
||||||
* ixmlNodeList_addToNodeList
|
IXML_NodeList **nList,
|
||||||
* Add a node to nodelist
|
IXML_Node *add)
|
||||||
* Internal to parser only.
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
int
|
|
||||||
ixmlNodeList_addToNodeList( IN IXML_NodeList ** nList,
|
|
||||||
IN IXML_Node * add )
|
|
||||||
{
|
{
|
||||||
IXML_NodeList *traverse,
|
IXML_NodeList *traverse = NULL;
|
||||||
*p = NULL;
|
IXML_NodeList *p = NULL;
|
||||||
IXML_NodeList *newListItem;
|
IXML_NodeList *newListItem;
|
||||||
|
|
||||||
assert( add != NULL );
|
assert(add != NULL);
|
||||||
|
|
||||||
if( add == NULL ) {
|
if (add == NULL) {
|
||||||
return IXML_FAILED;
|
return IXML_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *nList == NULL ) // nodelist is empty
|
if (*nList == NULL) {
|
||||||
{
|
// nodelist is empty
|
||||||
*nList = ( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
|
*nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
|
||||||
if( *nList == NULL ) {
|
if (*nList == NULL) {
|
||||||
return IXML_INSUFFICIENT_MEMORY;
|
return IXML_INSUFFICIENT_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ixmlNodeList_init( *nList );
|
ixmlNodeList_init(*nList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( *nList )->nodeItem == NULL ) {
|
if ((*nList)->nodeItem == NULL) {
|
||||||
( *nList )->nodeItem = add;
|
(*nList)->nodeItem = add;
|
||||||
} else {
|
} else {
|
||||||
traverse = *nList;
|
traverse = *nList;
|
||||||
while( traverse != NULL ) {
|
while (traverse != NULL) {
|
||||||
p = traverse;
|
p = traverse;
|
||||||
traverse = traverse->next;
|
traverse = traverse->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
newListItem =
|
newListItem = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
|
||||||
( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
|
if (newListItem == NULL) {
|
||||||
if( newListItem == NULL ) {
|
return IXML_INSUFFICIENT_MEMORY;
|
||||||
return IXML_INSUFFICIENT_MEMORY;
|
}
|
||||||
}
|
p->next = newListItem;
|
||||||
p->next = newListItem;
|
newListItem->nodeItem = add;
|
||||||
newListItem->nodeItem = add;
|
newListItem->next = NULL;
|
||||||
newListItem->next = NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return IXML_SUCCESS;
|
return IXML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixmlNodeList_length
|
unsigned long ixmlNodeList_length(IXML_NodeList *nList)
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
IXML_NodeList *list;
|
IXML_NodeList *list;
|
||||||
unsigned long length = 0;
|
unsigned long length = 0;
|
||||||
|
|
||||||
list = nList;
|
list = nList;
|
||||||
while( list != NULL ) {
|
while (list != NULL) {
|
||||||
++length;
|
++length;
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*================================================================
|
|
||||||
* ixmlNodeList_free
|
void ixmlNodeList_free(IXML_NodeList *nList)
|
||||||
* frees a nodeList
|
|
||||||
* External function
|
|
||||||
*
|
|
||||||
*=================================================================*/
|
|
||||||
void
|
|
||||||
ixmlNodeList_free( IN IXML_NodeList * nList )
|
|
||||||
{
|
{
|
||||||
IXML_NodeList *next;
|
IXML_NodeList *next;
|
||||||
|
|
||||||
while( nList != NULL ) {
|
|
||||||
next = nList->next;
|
|
||||||
|
|
||||||
free( nList );
|
|
||||||
nList = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
while (nList != NULL) {
|
||||||
|
next = nList->next;
|
||||||
|
free(nList);
|
||||||
|
nList = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ includedir=@includedir@
|
|||||||
Name: libupnp
|
Name: libupnp
|
||||||
Description: Linux SDK for UPnP Devices
|
Description: Linux SDK for UPnP Devices
|
||||||
Version: @VERSION@
|
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
|
Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,24 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef FREE_LIST_H
|
#ifndef FREE_LIST_H
|
||||||
#define FREE_LIST_H
|
#define FREE_LIST_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -29,21 +29,32 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef LINKED_LIST_H
|
#ifndef LINKED_LIST_H
|
||||||
#define LINKED_LIST_H
|
#define LINKED_LIST_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "FreeList.h"
|
#include "FreeList.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define EOUTOFMEM (-7 & 1<<29)
|
#define EOUTOFMEM (-7 & 1<<29)
|
||||||
|
|
||||||
|
|
||||||
#define FREELISTSIZE 100
|
#define FREELISTSIZE 100
|
||||||
#define LIST_SUCCESS 1
|
#define LIST_SUCCESS 1
|
||||||
#define LIST_FAIL 0
|
#define LIST_FAIL 0
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: free_routine
|
* Name: free_routine
|
||||||
*
|
*
|
||||||
@@ -52,6 +63,7 @@ extern "C" {
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef void (*free_function)(void *arg);
|
typedef void (*free_function)(void *arg);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmp_routine
|
* Name: cmp_routine
|
||||||
*
|
*
|
||||||
@@ -61,6 +73,7 @@ typedef void (*free_function)(void *arg);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef int (*cmp_routine)(void *itemA,void *itemB);
|
typedef int (*cmp_routine)(void *itemA,void *itemB);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ListNode
|
* Name: ListNode
|
||||||
*
|
*
|
||||||
@@ -75,6 +88,7 @@ typedef struct LISTNODE
|
|||||||
void *item;
|
void *item;
|
||||||
} ListNode;
|
} ListNode;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: LinkedList
|
* Name: LinkedList
|
||||||
*
|
*
|
||||||
@@ -104,6 +118,7 @@ typedef struct LINKEDLIST
|
|||||||
cmp_routine cmp_func; /* compare function to use */
|
cmp_routine cmp_func; /* compare function to use */
|
||||||
} LinkedList;
|
} LinkedList;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListInit
|
* Function: ListInit
|
||||||
*
|
*
|
||||||
@@ -119,6 +134,7 @@ typedef struct LINKEDLIST
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
|
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListAddHead
|
* Function: ListAddHead
|
||||||
*
|
*
|
||||||
@@ -135,6 +151,7 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode *ListAddHead(LinkedList *list, void *item);
|
ListNode *ListAddHead(LinkedList *list, void *item);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListAddTail
|
* Function: ListAddTail
|
||||||
*
|
*
|
||||||
@@ -151,6 +168,7 @@ ListNode *ListAddHead(LinkedList *list, void *item);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode *ListAddTail(LinkedList *list, void *item);
|
ListNode *ListAddTail(LinkedList *list, void *item);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListAddAfter
|
* Function: ListAddAfter
|
||||||
*
|
*
|
||||||
@@ -205,6 +223,7 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
|
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListDestroy
|
* Function: ListDestroy
|
||||||
*
|
*
|
||||||
@@ -240,6 +259,7 @@ int ListDestroy(LinkedList *list, int freeItem);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode* ListHead(LinkedList *list);
|
ListNode* ListHead(LinkedList *list);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListTail
|
* Function: ListTail
|
||||||
*
|
*
|
||||||
@@ -256,6 +276,7 @@ ListNode* ListHead(LinkedList *list);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode* ListTail(LinkedList *list);
|
ListNode* ListTail(LinkedList *list);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListNext
|
* Function: ListNext
|
||||||
*
|
*
|
||||||
@@ -272,6 +293,7 @@ ListNode* ListTail(LinkedList *list);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode* ListNext(LinkedList *list, ListNode * node);
|
ListNode* ListNext(LinkedList *list, ListNode * node);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListPrev
|
* Function: ListPrev
|
||||||
*
|
*
|
||||||
@@ -288,6 +310,7 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode* ListPrev(LinkedList *list, ListNode * node);
|
ListNode* ListPrev(LinkedList *list, ListNode * node);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListFind
|
* Function: ListFind
|
||||||
*
|
*
|
||||||
@@ -307,6 +330,7 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
|
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ListSize
|
* Function: ListSize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -29,80 +29,134 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef THREADPOOL_H
|
#ifndef THREADPOOL_H
|
||||||
#define THREADPOOL_H
|
#define THREADPOOL_H
|
||||||
|
|
||||||
#ifdef UPNP_USE_MSVCPP
|
|
||||||
#define UPNP_INLINE
|
/*!
|
||||||
#else
|
* \file
|
||||||
#define UPNP_INLINE inline
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Size of job free list */
|
|
||||||
|
/*! Size of job free list */
|
||||||
#define JOBFREELISTSIZE 100
|
#define JOBFREELISTSIZE 100
|
||||||
|
|
||||||
|
|
||||||
#define INFINITE_THREADS -1
|
#define INFINITE_THREADS -1
|
||||||
|
|
||||||
|
|
||||||
#define EMAXTHREADS (-8 & 1<<29)
|
#define EMAXTHREADS (-8 & 1<<29)
|
||||||
|
|
||||||
/* Invalid Policy */
|
|
||||||
|
/*! Invalid Policy */
|
||||||
#define INVALID_POLICY (-9 & 1<<29)
|
#define INVALID_POLICY (-9 & 1<<29)
|
||||||
|
|
||||||
/* Invalid JOB Id */
|
|
||||||
|
/*! Invalid JOB Id */
|
||||||
#define INVALID_JOB_ID (-2 & 1<<29)
|
#define INVALID_JOB_ID (-2 & 1<<29)
|
||||||
|
|
||||||
typedef enum duration {SHORT_TERM,PERSISTENT} Duration;
|
|
||||||
|
|
||||||
typedef enum priority {LOW_PRIORITY,
|
typedef enum duration {
|
||||||
MED_PRIORITY,
|
SHORT_TERM,
|
||||||
HIGH_PRIORITY} ThreadPriority;
|
PERSISTENT
|
||||||
|
} Duration;
|
||||||
|
|
||||||
#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 */
|
|
||||||
|
|
||||||
/* Statistics */
|
typedef enum priority {
|
||||||
/* always include stats because code change is minimal */
|
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 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
|
#define STATS 1
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "LinkedList.h"
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <time.h>
|
|
||||||
#include <winsock2.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/time.h> /* for gettimeofday() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FreeList.h"
|
|
||||||
|
|
||||||
#include "ithread.h"
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define EXPORT
|
|
||||||
|
|
||||||
typedef int PolicyType;
|
typedef int PolicyType;
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_POLICY SCHED_OTHER
|
#define DEFAULT_POLICY SCHED_OTHER
|
||||||
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
|
||||||
|
|
||||||
|
/*! Default priority */
|
||||||
|
#define DEFAULT_SCHED_PARAM 0
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: free_routine
|
* Name: free_routine
|
||||||
@@ -112,6 +166,7 @@ typedef int PolicyType;
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef void (*free_routine)(void *arg);
|
typedef void (*free_routine)(void *arg);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ThreadPoolAttr
|
* Name: ThreadPoolAttr
|
||||||
*
|
*
|
||||||
@@ -145,6 +200,7 @@ typedef struct THREADPOOLATTR
|
|||||||
PolicyType schedPolicy;
|
PolicyType schedPolicy;
|
||||||
} ThreadPoolAttr;
|
} ThreadPoolAttr;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ThreadPool
|
* Name: ThreadPool
|
||||||
*
|
*
|
||||||
@@ -161,13 +217,13 @@ typedef struct THREADPOOLJOB
|
|||||||
int jobId;
|
int jobId;
|
||||||
} ThreadPoolJob;
|
} ThreadPoolJob;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ThreadPoolStats
|
* Name: ThreadPoolStats
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Structure to hold statistics
|
* Structure to hold statistics
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
typedef struct TPOOLSTATS
|
typedef struct TPOOLSTATS
|
||||||
{
|
{
|
||||||
double totalTimeHQ;
|
double totalTimeHQ;
|
||||||
@@ -192,50 +248,43 @@ typedef struct TPOOLSTATS
|
|||||||
} ThreadPoolStats;
|
} ThreadPoolStats;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/*!
|
||||||
* Name: ThreadPool
|
* \brief A thread pool similar to the thread pool in the UPnP SDK.
|
||||||
*
|
*
|
||||||
* Description:
|
* Allows jobs to be scheduled for running by threads in a
|
||||||
* A thread pool similar to the thread pool in the UPnP SDK.
|
* thread pool. The thread pool is initialized with a
|
||||||
* Allows jobs to be scheduled for running by threads in a
|
* minimum and maximum thread number as well as a max idle time
|
||||||
* thread pool. The thread pool is initialized with a
|
* and a jobs per thread ratio. If a worker thread waits the whole
|
||||||
* minimum and maximum thread number as well as a
|
* max idle time without receiving a job and the thread pool
|
||||||
* max idle time
|
* currently has more threads running than the minimum
|
||||||
* and a jobs per thread ratio. If a worker thread waits the whole
|
* then the worker thread will exit. If when
|
||||||
* max idle time without receiving a job and the thread pool
|
* scheduling a job the current job to thread ratio
|
||||||
* currently has more threads running than the minimum
|
* becomes greater than the set ratio and the thread pool currently has
|
||||||
* then the worker thread will exit. If when
|
* less than the maximum threads then a new thread will
|
||||||
* scheduling a job the current job to thread ratio
|
* be created.
|
||||||
* 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
|
typedef struct THREADPOOL
|
||||||
{
|
{
|
||||||
ithread_mutex_t mutex; /* mutex to protect job qs */
|
ithread_mutex_t mutex; /* mutex to protect job qs */
|
||||||
ithread_cond_t condition; /* condition variable to signal Q */
|
ithread_cond_t condition; /* condition variable to signal Q */
|
||||||
ithread_cond_t start_and_shutdown; /* condition variable for start
|
ithread_cond_t start_and_shutdown; /* condition variable for start and stop */
|
||||||
and stop */
|
int lastJobId; /* ids for jobs */
|
||||||
int lastJobId; /* ids for jobs */
|
int shutdown; /* whether or not we are shutting down */
|
||||||
int shutdown; /* whether or not we are shutting down */
|
int totalThreads; /* total number of threads */
|
||||||
int totalThreads; /* total number of threads */
|
int busyThreads; /* number of threads that are currently executing jobs */
|
||||||
int persistentThreads; /* number of persistent threads */
|
int persistentThreads; /* number of persistent threads */
|
||||||
FreeList jobFreeList; /* free list of jobs */
|
FreeList jobFreeList; /* free list of jobs */
|
||||||
LinkedList lowJobQ; /* low priority job Q */
|
LinkedList lowJobQ; /* low priority job Q */
|
||||||
LinkedList medJobQ; /* med priority job Q */
|
LinkedList medJobQ; /* med priority job Q */
|
||||||
LinkedList highJobQ; /* high priority job Q */
|
LinkedList highJobQ; /* high priority job Q */
|
||||||
ThreadPoolJob *persistentJob; /* persistent job */
|
ThreadPoolJob *persistentJob; /* persistent job */
|
||||||
|
ThreadPoolAttr attr; /* thread pool attributes */
|
||||||
ThreadPoolAttr attr; /* thread pool attributes */
|
|
||||||
|
|
||||||
/* statistics */
|
/* statistics */
|
||||||
ThreadPoolStats stats;
|
ThreadPoolStats stats;
|
||||||
} ThreadPool;
|
} ThreadPool;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolInit
|
* Function: ThreadPoolInit
|
||||||
*
|
*
|
||||||
@@ -274,6 +323,7 @@ typedef struct THREADPOOL
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolAddPersistent
|
* Function: ThreadPoolAddPersistent
|
||||||
*
|
*
|
||||||
@@ -296,6 +346,7 @@ int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolGetAttr
|
* Function: ThreadPoolGetAttr
|
||||||
*
|
*
|
||||||
@@ -310,6 +361,8 @@ int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
|||||||
* Always returns 0.
|
* Always returns 0.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolSetAttr
|
* Function: ThreadPoolSetAttr
|
||||||
*
|
*
|
||||||
@@ -325,6 +378,7 @@ int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolAdd
|
* Function: ThreadPoolAdd
|
||||||
*
|
*
|
||||||
@@ -344,6 +398,7 @@ int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolRemove
|
* Function: ThreadPoolRemove
|
||||||
*
|
*
|
||||||
@@ -396,6 +451,7 @@ int ThreadPoolShutdown(ThreadPool *tp);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
|
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPJobSetPriority
|
* Function: TPJobSetPriority
|
||||||
*
|
*
|
||||||
@@ -409,6 +465,7 @@ int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPJobSetFreeFunction
|
* Function: TPJobSetFreeFunction
|
||||||
*
|
*
|
||||||
@@ -422,6 +479,7 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrInit
|
* Function: TPAttrInit
|
||||||
*
|
*
|
||||||
@@ -435,6 +493,7 @@ int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrInit(ThreadPoolAttr *attr);
|
int TPAttrInit(ThreadPoolAttr *attr);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetMaxThreads
|
* Function: TPAttrSetMaxThreads
|
||||||
*
|
*
|
||||||
@@ -448,6 +507,7 @@ int TPAttrInit(ThreadPoolAttr *attr);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetMinThreads
|
* Function: TPAttrSetMinThreads
|
||||||
*
|
*
|
||||||
@@ -461,6 +521,7 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetIdleTime
|
* Function: TPAttrSetIdleTime
|
||||||
*
|
*
|
||||||
@@ -473,6 +534,7 @@ int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
|
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetJobsPerThread
|
* Function: TPAttrSetJobsPerThread
|
||||||
*
|
*
|
||||||
@@ -486,6 +548,7 @@ int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
|
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetStarvationTime
|
* Function: TPAttrSetStarvationTime
|
||||||
*
|
*
|
||||||
@@ -499,6 +562,7 @@ int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
|
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: TPAttrSetSchedPolicy
|
* Function: TPAttrSetSchedPolicy
|
||||||
*
|
*
|
||||||
@@ -526,6 +590,7 @@ int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolGetStats
|
* Function: ThreadPoolGetStats
|
||||||
*
|
*
|
||||||
@@ -540,18 +605,20 @@ int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
|||||||
* Always returns 0.
|
* Always returns 0.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#ifdef STATS
|
#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
|
#else
|
||||||
static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {}
|
static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {}
|
||||||
|
|
||||||
static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {}
|
static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ThreadPool */
|
|
||||||
|
#endif /* THREADPOOL_H */
|
||||||
|
|
||||||
|
|||||||
@@ -29,160 +29,139 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef TIMERTHREAD_H
|
#ifndef TIMERTHREAD_H
|
||||||
#define TIMERTHREAD_H
|
#define TIMERTHREAD_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "FreeList.h"
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include "LinkedList.h"
|
#include "LinkedList.h"
|
||||||
#include "FreeList.h"
|
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define INVALID_EVENT_ID (-10 & 1<<29)
|
#define INVALID_EVENT_ID (-10 & 1<<29)
|
||||||
|
|
||||||
|
|
||||||
/* Timeout Types */
|
/* Timeout Types */
|
||||||
/* absolute means in seconds from Jan 1, 1970 */
|
/* absolute means in seconds from Jan 1, 1970 */
|
||||||
/* relative means in seconds from current time */
|
/* relative means in seconds from current time */
|
||||||
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
|
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/*!
|
||||||
* Name: TimerThread
|
* 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.
|
||||||
* Description:
|
*
|
||||||
* A timer thread similar to the one in the Upnp SDK that allows
|
* Because the timer thread uses the thread pool there is no
|
||||||
* the scheduling of a job to run at a specified time in the future
|
* gurantee of timing, only approximate timing.
|
||||||
* Because the timer thread uses the thread pool there is no
|
*
|
||||||
* gurantee of timing, only approximate timing.
|
* Uses ThreadPool, Mutex, Condition, Thread.
|
||||||
* Uses ThreadPool, Mutex, Condition, Thread
|
*/
|
||||||
*
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
typedef struct TIMERTHREAD
|
typedef struct TIMERTHREAD
|
||||||
{
|
{
|
||||||
ithread_mutex_t mutex;
|
ithread_mutex_t mutex;
|
||||||
ithread_cond_t condition;
|
ithread_cond_t condition;
|
||||||
int lastEventId;
|
int lastEventId;
|
||||||
LinkedList eventQ;
|
LinkedList eventQ;
|
||||||
int shutdown;
|
int shutdown;
|
||||||
FreeList freeEvents;
|
FreeList freeEvents;
|
||||||
ThreadPool *tp;
|
ThreadPool *tp;
|
||||||
} TimerThread;
|
} TimerThread;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/*!
|
||||||
* Name: TimerEvent
|
* Struct to contain information for a timer event.
|
||||||
*
|
*
|
||||||
* Description:
|
* Internal to the TimerThread.
|
||||||
*
|
*/
|
||||||
* Struct to contain information for a timer event.
|
|
||||||
* Internal to the TimerThread
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
typedef struct TIMEREVENT
|
typedef struct TIMEREVENT
|
||||||
{
|
{
|
||||||
ThreadPoolJob job;
|
ThreadPoolJob job;
|
||||||
time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */
|
/*! [in] Absolute time for event in seconds since Jan 1, 1970. */
|
||||||
Duration persistent; /* long term or short term job */
|
time_t eventTime;
|
||||||
int id;
|
/*! [in] Long term or short term job. */
|
||||||
|
Duration persistent;
|
||||||
|
int id;
|
||||||
} TimerEvent;
|
} TimerEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes and starts timer thread.
|
||||||
/************************************************************************
|
|
||||||
* Function: TimerThreadInit
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Initializes and starts timer thread.
|
|
||||||
*
|
*
|
||||||
* Parameters:
|
* \return 0 on success, nonzero on failure. Returns error from
|
||||||
* timer - valid timer thread pointer.
|
* ThreadPoolAddPersistent on failure.
|
||||||
* tp - valid thread pool to use. Must be
|
*/
|
||||||
* started. Must be valid for lifetime
|
int TimerThreadInit(
|
||||||
* of timer. Timer must be shutdown
|
/*! [in] Valid timer thread pointer. */
|
||||||
* BEFORE thread pool.
|
TimerThread *timer,
|
||||||
* Return:
|
/*! [in] Valid thread pool to use. Must be started. Must be valid for
|
||||||
* 0 on success, nonzero on failure
|
* lifetime of timer. Timer must be shutdown BEFORE thread pool. */
|
||||||
* Returns error from ThreadPoolAddPersistent on failure.
|
ThreadPool *tp);
|
||||||
*
|
|
||||||
************************************************************************/
|
|
||||||
int TimerThreadInit(TimerThread *timer,
|
|
||||||
ThreadPool *tp);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: TimerThreadSchedule
|
* \brief Schedules an event to run at a specified time.
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Schedules an event to run at a specified time.
|
|
||||||
*
|
*
|
||||||
* Parameters:
|
* \return 0 on success, nonzero on failure, EOUTOFMEM if not enough memory
|
||||||
* timer - valid timer thread pointer.
|
* to schedule job.
|
||||||
* time_t - time of event.
|
*/
|
||||||
* either in absolute seconds,
|
int TimerThreadSchedule(
|
||||||
* or relative seconds in the future.
|
/*! [in] Valid timer thread pointer. */
|
||||||
* timeoutType - either ABS_SEC, or REL_SEC.
|
TimerThread* timer,
|
||||||
* if REL_SEC, then the event
|
/*! [in] time of event. Either in absolute seconds, or relative
|
||||||
* will be scheduled at the
|
* seconds in the future. */
|
||||||
* current time + REL_SEC.
|
time_t time,
|
||||||
* job-> valid Thread pool job with following fields
|
/*! [in] either ABS_SEC, or REL_SEC. If REL_SEC, then the event
|
||||||
* func - function to schedule
|
* will be scheduled at the current time + REL_SEC. */
|
||||||
* arg - argument to function
|
TimeoutType type,
|
||||||
* priority - priority of job.
|
/*! [in] Valid Thread pool job with following fields. */
|
||||||
*
|
ThreadPoolJob *job,
|
||||||
* id - id of timer event. (out, can be null)
|
/*! [in] . */
|
||||||
* Return:
|
Duration duration,
|
||||||
* 0 on success, nonzero on failure
|
/*! [in] Id of timer event. (out, can be null). */
|
||||||
* EOUTOFMEM if not enough memory to schedule job.
|
int *id);
|
||||||
*
|
|
||||||
************************************************************************/
|
|
||||||
int TimerThreadSchedule(TimerThread* timer,
|
|
||||||
time_t time,
|
|
||||||
TimeoutType type,
|
|
||||||
ThreadPoolJob *job,
|
|
||||||
Duration duration,
|
|
||||||
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
|
* \brief Removes an event from the timer Q.
|
||||||
*
|
*
|
||||||
* Description:
|
* Events can only be removed before they have been placed in the thread pool.
|
||||||
* Shutdown the timer thread
|
*
|
||||||
* Events scheduled in the future will NOT be run.
|
* \return 0 on success, INVALID_EVENT_ID on failure.
|
||||||
* Timer thread should be shutdown BEFORE it's associated
|
*/
|
||||||
* thread pool.
|
int TimerThreadRemove(
|
||||||
* Returns:
|
/*! [in] Valid timer thread pointer. */
|
||||||
* returns 0 if succesfull,
|
TimerThread *timer,
|
||||||
* nonzero otherwise.
|
/*! [in] Id of event to remove. */
|
||||||
* Always returns 0.
|
int id,
|
||||||
***********************************************************************/
|
/*! [in] Space for thread pool job. */
|
||||||
int TimerThreadShutdown(TimerThread *timer);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,22 +29,42 @@
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
/* Do not #include <unistd.h> */
|
||||||
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
|
#if defined(BSD)
|
||||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PTHREAD_MUTEX_RECURSIVE
|
#ifdef PTHREAD_MUTEX_RECURSIVE
|
||||||
/* This system has SuS2-compliant mutex attributes.
|
/* This system has SuS2-compliant mutex attributes.
|
||||||
* E.g. on Cygwin, where we don't have the old nonportable (NP) symbols
|
* E.g. on Cygwin, where we don't have the old nonportable (NP) symbols
|
||||||
@@ -74,7 +94,8 @@ extern "C" {
|
|||||||
* typedef to pthread_t.
|
* typedef to pthread_t.
|
||||||
* Internal Use Only.
|
* Internal Use Only.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
typedef pthread_t ithread_t;
|
typedef pthread_t ithread_t;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ithread_attr_t
|
* Name: ithread_attr_t
|
||||||
@@ -94,7 +115,7 @@ typedef pthread_attr_t ithread_attr_t;
|
|||||||
* Thread start routine
|
* Thread start routine
|
||||||
* Internal Use Only.
|
* Internal Use Only.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
typedef void * (*start_routine) (void *arg);
|
typedef void *(*start_routine)(void *arg);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -161,7 +182,96 @@ typedef pthread_rwlockattr_t ithread_rwlockattr_t;
|
|||||||
* typedef to pthread_rwlock_t
|
* typedef to pthread_rwlock_t
|
||||||
* Internal Use Only
|
* Internal Use Only
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
typedef pthread_rwlock_t ithread_rwlock_t;
|
typedef pthread_rwlock_t ithread_rwlock_t;
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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
|
* Function: ithread_mutexattr_init
|
||||||
@@ -402,8 +512,8 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Must be called before use.
|
* Must be called before use.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
||||||
* const ithread_rwlockattr_t * rwlock_attr
|
* const ithread_rwlockattr_t *rwlock_attr
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 on success, Nonzero on failure.
|
* 0 on success, Nonzero on failure.
|
||||||
* Always returns 0.
|
* Always returns 0.
|
||||||
@@ -418,7 +528,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Description:
|
* Description:
|
||||||
* Locks rwlock for reading.
|
* Locks rwlock for reading.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
||||||
* rwlock must be initialized.
|
* rwlock must be initialized.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -435,7 +545,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Description:
|
* Description:
|
||||||
* Locks rwlock for writting.
|
* Locks rwlock for writting.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
||||||
* rwlock must be initialized.
|
* rwlock must be initialized.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -453,7 +563,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Unlocks rwlock.
|
* Unlocks rwlock.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
||||||
* rwlock must be initialized.
|
* rwlock must be initialized.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -473,7 +583,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* rwlock is only destroyed when there are no longer any threads waiting on it.
|
* rwlock is only destroyed when there are no longer any threads waiting on it.
|
||||||
* rwlock cannot be destroyed if it is locked.
|
* rwlock cannot be destroyed if it is locked.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
* ithread_rwlock_t *rwlock (must be valid non NULL pointer to pthread_rwlock_t)
|
||||||
* rwlock must be initialized.
|
* rwlock must be initialized.
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 on success. Nonzero on failure.
|
* 0 on success. Nonzero on failure.
|
||||||
@@ -490,8 +600,8 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Initializes condition variable.
|
* Initializes condition variable.
|
||||||
* Must be called before use.
|
* Must be called before use.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ithread_cond_t * cond (must be valid non NULL pointer to pthread_cond_t)
|
* ithread_cond_t *cond (must be valid non NULL pointer to pthread_cond_t)
|
||||||
* const ithread_condattr_t * cond_attr (ignored)
|
* const ithread_condattr_t *cond_attr (ignored)
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 on success, Nonzero on failure.
|
* 0 on success, Nonzero on failure.
|
||||||
* See man page for pthread_cond_init
|
* See man page for pthread_cond_init
|
||||||
@@ -499,7 +609,6 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
#define ithread_cond_init pthread_cond_init
|
#define ithread_cond_init pthread_cond_init
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ithread_cond_signal
|
* Function: ithread_cond_signal
|
||||||
*
|
*
|
||||||
@@ -507,7 +616,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Wakes up exactly one thread waiting on condition.
|
* Wakes up exactly one thread waiting on condition.
|
||||||
* Associated mutex MUST be locked by thread before entering this call.
|
* Associated mutex MUST be locked by thread before entering this call.
|
||||||
* Parameters:
|
* 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)
|
* ithread_cond_t)
|
||||||
* cond must be initialized
|
* cond must be initialized
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -524,7 +633,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Wakes up all threads waiting on condition.
|
* Wakes up all threads waiting on condition.
|
||||||
* Associated mutex MUST be locked by thread before entering this call.
|
* Associated mutex MUST be locked by thread before entering this call.
|
||||||
* Parameters:
|
* 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)
|
* ithread_cond_t)
|
||||||
* cond must be initialized
|
* cond must be initialized
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -542,7 +651,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Associated mutex MUST be locked by thread before entering this call.
|
* Associated mutex MUST be locked by thread before entering this call.
|
||||||
* Mutex is reacquired when call returns.
|
* Mutex is reacquired when call returns.
|
||||||
* Parameters:
|
* 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)
|
* ithread_cond_t)
|
||||||
* cond must be initialized
|
* cond must be initialized
|
||||||
* ithread_mutex_t *mutex (must be valid non NULL pointer to
|
* ithread_mutex_t *mutex (must be valid non NULL pointer to
|
||||||
@@ -558,23 +667,19 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: pthread_cond_timedwait
|
* Function: pthread_cond_timedwait
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Atomically releases the associated mutex and waits on the condition.
|
* Atomically releases the associated mutex and waits on the
|
||||||
* If the condition is not signaled in the specified time
|
* condition.
|
||||||
* than the
|
* If the condition is not signaled in the specified time than the
|
||||||
* call times out and returns.
|
* call times out and returns.
|
||||||
* Associated mutex MUST be locked by thread before entering
|
* Associated mutex MUST be locked by thread before entering this call.
|
||||||
* this call.
|
* Mutex is reacquired when call returns.
|
||||||
* Mutex is reacquired when call returns.
|
|
||||||
* Parameters:
|
* 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)
|
||||||
* ithread_cond_t)
|
* cond must be initialized
|
||||||
* cond must be initialized
|
* ithread_mutex_t *mutex (must be valid non NULL pointer to ithread_mutex_t)
|
||||||
* ithread_mutex_t *mutex (must be valid non NULL pointer to
|
* Mutex must be locked.
|
||||||
* ithread_mutex_t)
|
* const struct timespec *abstime (absolute time, measured from Jan 1, 1970)
|
||||||
* Mutex must be locked.
|
|
||||||
* const struct timespec *abstime (absolute time, measured
|
|
||||||
* from Jan 1, 1970)
|
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 on success. ETIMEDOUT on timeout. Nonzero on failure.
|
* 0 on success. ETIMEDOUT on timeout. Nonzero on failure.
|
||||||
* See man page for pthread_cond_timedwait
|
* See man page for pthread_cond_timedwait
|
||||||
@@ -590,7 +695,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* Releases any resources held by the condition variable.
|
* Releases any resources held by the condition variable.
|
||||||
* Condition variable can no longer be used after this call.
|
* Condition variable can no longer be used after this call.
|
||||||
* Parameters:
|
* 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)
|
* ithread_cond_t)
|
||||||
* cond must be initialized.
|
* cond must be initialized.
|
||||||
* Returns:
|
* Returns:
|
||||||
@@ -646,6 +751,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define ithread_exit pthread_exit
|
#define ithread_exit pthread_exit
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ithread_get_current_thread_id
|
* Function: ithread_get_current_thread_id
|
||||||
*
|
*
|
||||||
@@ -669,6 +775,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define ithread_self pthread_self
|
#define ithread_self pthread_self
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ithread_detach
|
* Function: ithread_detach
|
||||||
*
|
*
|
||||||
@@ -682,6 +789,7 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define ithread_detach pthread_detach
|
#define ithread_detach pthread_detach
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ithread_join
|
* Function: ithread_join
|
||||||
*
|
*
|
||||||
@@ -701,7 +809,6 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
#define ithread_join pthread_join
|
#define ithread_join pthread_join
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: isleep
|
* Function: isleep
|
||||||
*
|
*
|
||||||
@@ -715,12 +822,13 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* 0 on success, Nonzero on failure.
|
* 0 on success, Nonzero on failure.
|
||||||
* See man page for sleep (man 3 sleep)
|
* See man page for sleep (man 3 sleep)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
#define isleep sleep
|
#define isleep(x) Sleep((x)*1000)
|
||||||
#else
|
#else
|
||||||
#define isleep(x) Sleep((x)*1000)
|
#define isleep sleep
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: isleep
|
* Function: isleep
|
||||||
*
|
*
|
||||||
@@ -734,25 +842,10 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
* 0 on success, Nonzero on failure.
|
* 0 on success, Nonzero on failure.
|
||||||
* See man page for sleep (man 3 sleep)
|
* See man page for sleep (man 3 sleep)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#ifndef WIN32
|
|
||||||
#define imillisleep(x) usleep(1000*x)
|
|
||||||
#else
|
|
||||||
#define imillisleep Sleep
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#ifndef UPNP_STATIC_LIB
|
#define imillisleep Sleep
|
||||||
#ifdef LIBUPNP_EXPORTS
|
|
||||||
/* set up declspec for dll export to make functions visible to library users */
|
|
||||||
#define EXPORT_SPEC __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define EXPORT_SPEC __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define EXPORT_SPEC
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define EXPORT_SPEC
|
#define imillisleep(x) usleep(1000*x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -761,9 +854,11 @@ typedef pthread_rwlock_t ithread_rwlock_t;
|
|||||||
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ITHREADH */
|
|
||||||
|
#endif /* ITHREAD_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +1,55 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "LinkedList.h"
|
#include "LinkedList.h"
|
||||||
#ifndef WIN32
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/* Do not #include <sys/param.h> */
|
||||||
|
#else
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__)
|
#if (defined(BSD) && BSD >= 199306) || defined(__OSX__) || defined(__APPLE__)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#else
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
freeListNode( ListNode * node,
|
freeListNode( ListNode * node,
|
||||||
LinkedList * list )
|
LinkedList * list )
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,68 +1,69 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "TimerThread.h"
|
#include "TimerThread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: FreeTimerEvent
|
/*!
|
||||||
*
|
* \brief Deallocates a dynamically allocated TimerEvent.
|
||||||
* Description:
|
*/
|
||||||
* Deallocates a dynamically allocated TimerEvent.
|
static void FreeTimerEvent(
|
||||||
* Parameters:
|
/*! [in] Valid timer thread pointer. */
|
||||||
* TimerEvent *event - must be allocated with CreateTimerEvent
|
TimerThread *timer,
|
||||||
*****************************************************************************/
|
/*! [in] Must be allocated with CreateTimerEvent*/
|
||||||
static void
|
TimerEvent *event)
|
||||||
FreeTimerEvent( TimerThread * timer,
|
|
||||||
TimerEvent * event )
|
|
||||||
{
|
{
|
||||||
|
assert(timer != NULL);
|
||||||
|
|
||||||
assert( timer != NULL );
|
FreeListFree(&timer->freeEvents, event);
|
||||||
|
|
||||||
FreeListFree( &timer->freeEvents, event );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: TimerThreadWorker
|
/*!
|
||||||
|
* \brief Implements timer thread.
|
||||||
*
|
*
|
||||||
* Description:
|
* Waits for next event to occur and schedules associated job into threadpool.
|
||||||
* Implements timer thread.
|
*/
|
||||||
* Waits for next event to occur and schedules
|
static void *TimerThreadWorker(
|
||||||
* associated job into threadpool.
|
/*! [in] arg is cast to (TimerThread *). */
|
||||||
* Internal Only.
|
void *arg)
|
||||||
* Parameters:
|
|
||||||
* void * arg -> is cast to TimerThread *
|
|
||||||
*****************************************************************************/
|
|
||||||
static void *
|
|
||||||
TimerThreadWorker( void *arg )
|
|
||||||
{
|
{
|
||||||
TimerThread *timer = ( TimerThread * ) arg;
|
TimerThread *timer = ( TimerThread * ) arg;
|
||||||
ListNode *head = NULL;
|
ListNode *head = NULL;
|
||||||
@@ -81,19 +82,14 @@ TimerThreadWorker( void *arg )
|
|||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
|
|
||||||
//mutex should always be locked at top of loop
|
//mutex should always be locked at top of loop
|
||||||
|
|
||||||
//Check for shutdown
|
//Check for shutdown
|
||||||
|
|
||||||
if( timer->shutdown )
|
if( timer->shutdown )
|
||||||
{
|
{
|
||||||
|
|
||||||
timer->shutdown = 0;
|
timer->shutdown = 0;
|
||||||
ithread_cond_signal( &timer->condition );
|
ithread_cond_signal( &timer->condition );
|
||||||
ithread_mutex_unlock( &timer->mutex );
|
ithread_mutex_unlock( &timer->mutex );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextEvent = NULL;
|
nextEvent = NULL;
|
||||||
@@ -102,7 +98,6 @@ TimerThreadWorker( void *arg )
|
|||||||
if( timer->eventQ.size > 0 )
|
if( timer->eventQ.size > 0 )
|
||||||
{
|
{
|
||||||
head = ListHead( &timer->eventQ );
|
head = ListHead( &timer->eventQ );
|
||||||
|
|
||||||
nextEvent = ( TimerEvent * ) head->item;
|
nextEvent = ( TimerEvent * ) head->item;
|
||||||
nextEventTime = nextEvent->eventTime;
|
nextEventTime = nextEvent->eventTime;
|
||||||
}
|
}
|
||||||
@@ -110,54 +105,42 @@ TimerThreadWorker( void *arg )
|
|||||||
currentTime = time( NULL );
|
currentTime = time( NULL );
|
||||||
|
|
||||||
//If time has elapsed, schedule job
|
//If time has elapsed, schedule job
|
||||||
|
|
||||||
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
|
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( nextEvent->persistent ) {
|
if( nextEvent->persistent ) {
|
||||||
|
|
||||||
ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
|
ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
|
||||||
&tempId );
|
&tempId );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
|
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
|
||||||
}
|
}
|
||||||
|
|
||||||
ListDelNode( &timer->eventQ, head, 0 );
|
ListDelNode( &timer->eventQ, head, 0 );
|
||||||
FreeTimerEvent( timer, nextEvent );
|
FreeTimerEvent( timer, nextEvent );
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextEvent != NULL ) {
|
if( nextEvent != NULL ) {
|
||||||
timeToWait.tv_nsec = 0;
|
timeToWait.tv_nsec = 0;
|
||||||
timeToWait.tv_sec = nextEvent->eventTime;
|
timeToWait.tv_sec = nextEvent->eventTime;
|
||||||
|
|
||||||
ithread_cond_timedwait( &timer->condition, &timer->mutex,
|
ithread_cond_timedwait( &timer->condition, &timer->mutex,
|
||||||
&timeToWait );
|
&timeToWait );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ithread_cond_wait( &timer->condition, &timer->mutex );
|
ithread_cond_wait( &timer->condition, &timer->mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: CalculateEventTime
|
/*!
|
||||||
|
* \brief Calculates the appropriate timeout in absolute seconds
|
||||||
|
* since Jan 1, 1970.
|
||||||
*
|
*
|
||||||
* Description:
|
* \return
|
||||||
* Calculates the appropriate timeout in absolute seconds since
|
*/
|
||||||
* Jan 1, 1970
|
static int CalculateEventTime(
|
||||||
* Internal Only.
|
/*! [in] Timeout. */
|
||||||
* Parameters:
|
time_t *timeout,
|
||||||
* time_t *timeout - timeout
|
/*! [in] Timeout type. */
|
||||||
*
|
TimeoutType type)
|
||||||
*****************************************************************************/
|
|
||||||
static int
|
|
||||||
CalculateEventTime( time_t * timeout,
|
|
||||||
TimeoutType type )
|
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
@@ -175,29 +158,22 @@ CalculateEventTime( time_t * timeout,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/*!
|
||||||
* Function: CreateTimerEvent
|
* \brief Creates a Timer Event. (Dynamically allocated).
|
||||||
*
|
*
|
||||||
* Description:
|
* \return (TimerEvent *) on success, NULL on failure.
|
||||||
* Creates a Timer Event. (Dynamically allocated)
|
*/
|
||||||
* Internal to timer thread.
|
static TimerEvent *CreateTimerEvent(
|
||||||
* Parameters:
|
/*! [in] Valid timer thread pointer. */
|
||||||
* func - thread function to run.
|
TimerThread *timer,
|
||||||
* arg - argument to function.
|
/*! [in] . */
|
||||||
* priority - priority of job.
|
ThreadPoolJob *job,
|
||||||
* eventTime - the absoule time of the event
|
/*! [in] . */
|
||||||
* in seconds from Jan, 1970
|
Duration persistent,
|
||||||
* id - id of job
|
/*! [in] The absoule time of the event in seconds from Jan, 1970. */
|
||||||
*
|
time_t eventTime,
|
||||||
* Returns:
|
/*! [in] Id of job. */
|
||||||
* TimerEvent * on success, NULL on failure.
|
int id)
|
||||||
****************************************************************************/
|
|
||||||
static TimerEvent *
|
|
||||||
CreateTimerEvent( TimerThread * timer,
|
|
||||||
ThreadPoolJob * job,
|
|
||||||
Duration persistent,
|
|
||||||
time_t eventTime,
|
|
||||||
int id )
|
|
||||||
{
|
{
|
||||||
TimerEvent *temp = NULL;
|
TimerEvent *temp = NULL;
|
||||||
|
|
||||||
@@ -215,25 +191,8 @@ CreateTimerEvent( TimerThread * timer,
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: TimerThreadInit
|
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
|
||||||
*
|
|
||||||
* 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 rc = 0;
|
int rc = 0;
|
||||||
@@ -290,37 +249,14 @@ TimerThreadInit( TimerThread * timer,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: TimerThreadSchedule
|
int TimerThreadSchedule(
|
||||||
*
|
TimerThread *timer,
|
||||||
* Description:
|
time_t timeout,
|
||||||
* Schedules an event to run at a specified time.
|
TimeoutType type,
|
||||||
*
|
ThreadPoolJob *job,
|
||||||
* Parameters:
|
Duration duration,
|
||||||
* timer - valid timer thread pointer.
|
int *id)
|
||||||
* 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 rc = EOUTOFMEM;
|
int rc = EOUTOFMEM;
|
||||||
@@ -394,28 +330,11 @@ TimerThreadSchedule( TimerThread * timer,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: TimerThreadRemove
|
int TimerThreadRemove(
|
||||||
*
|
TimerThread *timer,
|
||||||
* Description:
|
int id,
|
||||||
* Removes an event from the timer Q.
|
ThreadPoolJob *out)
|
||||||
* 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 rc = INVALID_EVENT_ID;
|
int rc = INVALID_EVENT_ID;
|
||||||
ListNode *tempNode = NULL;
|
ListNode *tempNode = NULL;
|
||||||
@@ -450,21 +369,8 @@ TimerThreadRemove( TimerThread * timer,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: TimerThreadShutdown
|
int TimerThreadShutdown(TimerThread *timer)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
ListNode *tempNode2 = NULL;
|
ListNode *tempNode2 = NULL;
|
||||||
ListNode *tempNode = NULL;
|
ListNode *tempNode = NULL;
|
||||||
@@ -517,3 +423,4 @@ TimerThreadShutdown( TimerThread * timer )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# "Makefile.am" for "libupnp/upnp"
|
# "Makefile.am" for "libupnp/upnp"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005 R<EFBFBD>mi Turboult <r3mi@users.sourceforge.net>
|
# Copyright (C) 2005 Rémi Turboult <r3mi@users.sourceforge.net>
|
||||||
#
|
#
|
||||||
|
|
||||||
SUBDIRS = doc . sample
|
SUBDIRS = doc . sample
|
||||||
@@ -19,8 +19,20 @@ LDADD = \
|
|||||||
|
|
||||||
upnpincludedir = $(includedir)/upnp
|
upnpincludedir = $(includedir)/upnp
|
||||||
upnpinclude_HEADERS = \
|
upnpinclude_HEADERS = \
|
||||||
|
inc/ActionComplete.h \
|
||||||
|
inc/ActionRequest.h \
|
||||||
|
inc/Discovery.h \
|
||||||
|
inc/Event.h \
|
||||||
|
inc/EventSubscribe.h \
|
||||||
|
inc/FileInfo.h \
|
||||||
|
inc/StateVarComplete.h \
|
||||||
|
inc/StateVarRequest.h \
|
||||||
|
inc/SubscriptionRequest.h \
|
||||||
|
inc/UpnpString.h \
|
||||||
inc/upnp.h \
|
inc/upnp.h \
|
||||||
inc/upnpdebug.h
|
inc/upnpdebug.h \
|
||||||
|
inc/UpnpGlobal.h \
|
||||||
|
inc/UpnpInet.h
|
||||||
|
|
||||||
nodist_upnpinclude_HEADERS = inc/upnpconfig.h
|
nodist_upnpinclude_HEADERS = inc/upnpconfig.h
|
||||||
if ENABLE_TOOLS
|
if ENABLE_TOOLS
|
||||||
@@ -41,12 +53,12 @@ libupnp_la_LDFLAGS = \
|
|||||||
libupnp_la_SOURCES = \
|
libupnp_la_SOURCES = \
|
||||||
src/inc/config.h \
|
src/inc/config.h \
|
||||||
src/inc/client_table.h \
|
src/inc/client_table.h \
|
||||||
|
src/inc/ClientSubscription.h \
|
||||||
src/inc/gena.h \
|
src/inc/gena.h \
|
||||||
src/inc/gena_ctrlpt.h \
|
src/inc/gena_ctrlpt.h \
|
||||||
src/inc/gena_device.h \
|
src/inc/gena_device.h \
|
||||||
src/inc/global.h \
|
src/inc/global.h \
|
||||||
src/inc/gmtdate.h \
|
src/inc/gmtdate.h \
|
||||||
src/inc/http_client.h \
|
|
||||||
src/inc/httpparser.h \
|
src/inc/httpparser.h \
|
||||||
src/inc/httpreadwrite.h \
|
src/inc/httpreadwrite.h \
|
||||||
src/inc/md5.h \
|
src/inc/md5.h \
|
||||||
@@ -72,10 +84,13 @@ libupnp_la_SOURCES = \
|
|||||||
src/inc/util.h \
|
src/inc/util.h \
|
||||||
src/inc/utilall.h \
|
src/inc/utilall.h \
|
||||||
src/inc/uuid.h \
|
src/inc/uuid.h \
|
||||||
|
src/inc/VirtualDir.h \
|
||||||
src/inc/webserver.h
|
src/inc/webserver.h
|
||||||
|
|
||||||
# ssdp
|
# ssdp
|
||||||
libupnp_la_SOURCES += \
|
libupnp_la_SOURCES += \
|
||||||
|
src/ssdp/ssdp_ResultData.c \
|
||||||
|
src/ssdp/ssdp_ResultData.h \
|
||||||
src/ssdp/ssdp_device.c \
|
src/ssdp/ssdp_device.c \
|
||||||
src/ssdp/ssdp_ctrlpt.c \
|
src/ssdp/ssdp_ctrlpt.c \
|
||||||
src/ssdp/ssdp_server.c
|
src/ssdp/ssdp_server.c
|
||||||
@@ -89,12 +104,13 @@ libupnp_la_SOURCES += \
|
|||||||
# genlib
|
# genlib
|
||||||
libupnp_la_SOURCES += \
|
libupnp_la_SOURCES += \
|
||||||
src/genlib/miniserver/miniserver.c \
|
src/genlib/miniserver/miniserver.c \
|
||||||
|
src/genlib/client_table/client_table.c \
|
||||||
|
src/genlib/client_table/ClientSubscription.c \
|
||||||
src/genlib/service_table/service_table.c \
|
src/genlib/service_table/service_table.c \
|
||||||
src/genlib/util/membuffer.c \
|
src/genlib/util/membuffer.c \
|
||||||
src/genlib/util/strintmap.c \
|
src/genlib/util/strintmap.c \
|
||||||
src/genlib/util/upnp_timeout.c \
|
src/genlib/util/upnp_timeout.c \
|
||||||
src/genlib/util/util.c \
|
src/genlib/util/util.c \
|
||||||
src/genlib/client_table/client_table.c \
|
|
||||||
src/genlib/net/sock.c \
|
src/genlib/net/sock.c \
|
||||||
src/genlib/net/http/httpparser.c \
|
src/genlib/net/http/httpparser.c \
|
||||||
src/genlib/net/http/httpreadwrite.c \
|
src/genlib/net/http/httpreadwrite.c \
|
||||||
@@ -110,10 +126,23 @@ libupnp_la_SOURCES += \
|
|||||||
src/gena/gena_callback2.c
|
src/gena/gena_callback2.c
|
||||||
|
|
||||||
# api
|
# api
|
||||||
libupnp_la_SOURCES += src/api/upnpapi.c
|
libupnp_la_SOURCES += \
|
||||||
|
src/api/ActionComplete.c \
|
||||||
|
src/api/ActionRequest.c \
|
||||||
|
src/api/Discovery.c \
|
||||||
|
src/api/Event.c \
|
||||||
|
src/api/EventSubscribe.c \
|
||||||
|
src/api/FileInfo.c \
|
||||||
|
src/api/StateVarComplete.c \
|
||||||
|
src/api/StateVarRequest.c \
|
||||||
|
src/api/SubscriptionRequest.c \
|
||||||
|
src/api/UpnpString.c \
|
||||||
|
src/api/upnpapi.c
|
||||||
|
|
||||||
if ENABLE_TOOLS
|
if ENABLE_TOOLS
|
||||||
libupnp_la_SOURCES += src/api/upnptools.c
|
libupnp_la_SOURCES += src/api/upnptools.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_DEBUG
|
if ENABLE_DEBUG
|
||||||
libupnp_la_SOURCES += src/api/upnpdebug.c
|
libupnp_la_SOURCES += src/api/upnpdebug.c
|
||||||
endif
|
endif
|
||||||
@@ -130,6 +159,12 @@ libupnp_la_SOURCES += \
|
|||||||
libupnp_la_SOURCES += src/urlconfig/urlconfig.c
|
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 / distcheck tests
|
||||||
check_PROGRAMS = test_init
|
check_PROGRAMS = test_init
|
||||||
TESTS = test_init
|
TESTS = test_init
|
||||||
@@ -138,8 +173,7 @@ test_init_SOURCES = test/test_init.c
|
|||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
LICENSE \
|
LICENSE \
|
||||||
src/inc/inet_pton.h \
|
m4/libupnp.m4 \
|
||||||
src/inet_pton.c \
|
|
||||||
src/win_dll.c
|
src/win_dll.c
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
173
upnp/inc/ActionComplete.h
Normal file
173
upnp/inc/ActionComplete.h
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef ACTIONCOMPLETE_H
|
||||||
|
#define ACTIONCOMPLETE_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpActionComplete object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The type of an UpnpActionComplete object.
|
||||||
|
*/
|
||||||
|
typedef struct s_UpnpActionComplete UpnpActionComplete;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for IXML_Document */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructor.
|
||||||
|
*
|
||||||
|
* \return Pointer to the newly created object.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC UpnpActionComplete *UpnpActionComplete_new();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructor.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_delete(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Copy Constructor.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC UpnpActionComplete *UpnpActionComplete_dup(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Assignment operator.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_assign(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] \b that pointer. */
|
||||||
|
const UpnpActionComplete *q);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Error code getter.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC int UpnpActionComplete_get_ErrCode(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Error code setter.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_set_ErrCode(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] The error code to set. */
|
||||||
|
int n);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Control URL getter.
|
||||||
|
*
|
||||||
|
* \return The control URL string.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpActionComplete_get_CtrlUrl(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Control URL getter as a C string
|
||||||
|
*
|
||||||
|
* \return The control URL string.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC const char *UpnpActionComplete_get_CtrlUrl_cstr(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Control URL setter.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_set_CtrlUrl(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] The control URL string to copy. */
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Set the control URL from a null terminated C string.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_strcpy_CtrlUrl(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] The null terminated control URL C string to copy. */
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ActionRequest document getter.
|
||||||
|
*
|
||||||
|
* \return A pointer to the document object.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpActionComplete_get_ActionRequest(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ActionRequest document setter.
|
||||||
|
*
|
||||||
|
* \note The ActionComplete object takes ownership of the document parameter,
|
||||||
|
* i.e. it is responsible for deleting it upon destruction.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_set_ActionRequest(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] Document to copy. */
|
||||||
|
IXML_Document *d);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ActionResult document getter.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpActionComplete_get_ActionResult(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
const UpnpActionComplete *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ActionResult document setter.
|
||||||
|
*
|
||||||
|
* \note The ActionComplete object takes ownership of the document parameter,
|
||||||
|
* i.e. it is responsible for deleting it upon destruction.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpActionComplete_set_ActionResult(
|
||||||
|
/*! [in] \b this pointer. */
|
||||||
|
UpnpActionComplete *p,
|
||||||
|
/*! [in] Document to copy. */
|
||||||
|
IXML_Document *d);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ACTIONCOMPLETE_H */
|
||||||
|
|
||||||
96
upnp/inc/ActionRequest.h
Normal file
96
upnp/inc/ActionRequest.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef ACTIONREQUEST_H
|
||||||
|
#define ACTIONREQUEST_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpActionRequest object declaration.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returned as part of a \b UPNP_CONTROL_ACTION_COMPLETE callback. */
|
||||||
|
typedef struct s_UpnpActionRequest UpnpActionRequest;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for IXML_Document */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpActionRequest *UpnpActionRequest_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_delete(UpnpActionRequest *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpActionRequest *UpnpActionRequest_dup(const UpnpActionRequest *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_assign(UpnpActionRequest *p, const UpnpActionRequest *q);
|
||||||
|
|
||||||
|
/*! The result of the operation */
|
||||||
|
EXPORT_SPEC int UpnpActionRequest_get_ErrCode(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ErrCode(UpnpActionRequest *p, int n);
|
||||||
|
|
||||||
|
/*! The socket number of the connection to the requestor */
|
||||||
|
EXPORT_SPEC int UpnpActionRequest_get_Socket(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_Socket(UpnpActionRequest *p, int n);
|
||||||
|
|
||||||
|
/*! The error string in case of error */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ErrStr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpActionRequest_get_ErrStr_cstr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ErrStr(UpnpActionRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_strcpy_ErrStr(UpnpActionRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! The Action Name */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ActionName(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpActionRequest_get_ActionName_cstr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ActionName(UpnpActionRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_strcpy_ActionName(UpnpActionRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! The unique device ID */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_DevUDN(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpActionRequest_get_DevUDN_cstr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_DevUDN(UpnpActionRequest *p, const UpnpString *s);
|
||||||
|
|
||||||
|
/*! The service ID */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpActionRequest_get_ServiceID(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpActionRequest_get_ServiceID_cstr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ServiceID(UpnpActionRequest *p, const UpnpString *s);
|
||||||
|
|
||||||
|
/*! The DOM document describing the action */
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_ActionRequest(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ActionRequest(UpnpActionRequest *p, IXML_Document *d);
|
||||||
|
|
||||||
|
/*! The DOM document describing the result of the action */
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_ActionResult(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_ActionResult(UpnpActionRequest *p, IXML_Document *d);
|
||||||
|
|
||||||
|
/*! The DOM document containing the information from the SOAP header */
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpActionRequest_get_SoapHeader(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_SoapHeader(UpnpActionRequest *p, IXML_Document *d);
|
||||||
|
|
||||||
|
/*! IP address of the control point requesting this action */
|
||||||
|
EXPORT_SPEC const struct sockaddr *UpnpActionRequest_get_CtrlPtIPAddr(const UpnpActionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpActionRequest_set_CtrlPtIPAddr(UpnpActionRequest *p, const struct sockaddr *sa);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ACTIONREQUEST_H */
|
||||||
|
|
||||||
112
upnp/inc/Discovery.h
Normal file
112
upnp/inc/Discovery.h
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef DISCOVERY_H
|
||||||
|
#define DISCOVERY_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpDiscovery object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returned in a \b UPNP_DISCOVERY_RESULT callback. */
|
||||||
|
typedef struct s_UpnpDiscovery UpnpDiscovery;
|
||||||
|
|
||||||
|
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpDiscovery *UpnpDiscovery_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_delete(UpnpDiscovery *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpDiscovery *UpnpDiscovery_dup(const UpnpDiscovery *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_assign(UpnpDiscovery *p, const UpnpDiscovery *q);
|
||||||
|
|
||||||
|
/*! The result code of the \b UpnpSearchAsync call. */
|
||||||
|
EXPORT_SPEC int UpnpDiscovery_get_ErrCode(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_ErrCode(UpnpDiscovery *p, int n);
|
||||||
|
|
||||||
|
/*! The expiration time of the advertisement. */
|
||||||
|
EXPORT_SPEC int UpnpDiscovery_get_Expires(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_Expires(UpnpDiscovery *p, int n);
|
||||||
|
|
||||||
|
/*! The unique device identifier. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_DeviceID(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_DeviceID_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_DeviceID(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_DeviceID(UpnpDiscovery *p, const char *s);
|
||||||
|
|
||||||
|
/*! The device type. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_DeviceType(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_DeviceType_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_DeviceType(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_DeviceType(UpnpDiscovery *p, const char *s);
|
||||||
|
|
||||||
|
/*! The ServiceType. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_ServiceType(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_ServiceType_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_ServiceType(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_ServiceType(UpnpDiscovery *p, const char *s);
|
||||||
|
|
||||||
|
/*! The service version. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_ServiceVer(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_ServiceVer_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_ServiceVer(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_ServiceVer(UpnpDiscovery *p, const char *s);
|
||||||
|
|
||||||
|
/*! The URL to the UPnP description document for the device. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Location(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_Location_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_Location(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_Location(UpnpDiscovery *p, const char *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strncpy_Location(UpnpDiscovery *p, const char *s, int n);
|
||||||
|
|
||||||
|
/*! The operating system the device is running. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Os(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_Os_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_Os(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_Os(UpnpDiscovery *p, const char *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strncpy_Os(UpnpDiscovery *p, const char *s, int n);
|
||||||
|
|
||||||
|
/*! Date when the response was generated. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Date(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_Date_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_Date(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_Date(UpnpDiscovery *p, const char *s);
|
||||||
|
|
||||||
|
/*! Confirmation that the MAN header was understood by the device. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpDiscovery_get_Ext(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC const char *UpnpDiscovery_get_Ext_cstr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_Ext(UpnpDiscovery *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strcpy_Ext(UpnpDiscovery *p, const char *s);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_strncpy_Ext(UpnpDiscovery *p, const char *s, int n);
|
||||||
|
|
||||||
|
/*! The host address of the device responding to the search. */
|
||||||
|
EXPORT_SPEC const struct sockaddr *UpnpDiscovery_get_DestAddr(const UpnpDiscovery *p);
|
||||||
|
EXPORT_SPEC void UpnpDiscovery_set_DestAddr(UpnpDiscovery *p, const struct sockaddr *sa);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DISCOVERY_H */
|
||||||
|
|
||||||
62
upnp/inc/Event.h
Normal file
62
upnp/inc/Event.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef EVENT_H
|
||||||
|
#define EVENT_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpEvent object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returned along with a \b UPNP_EVENT_RECEIVED callback. */
|
||||||
|
typedef struct s_UpnpEvent UpnpEvent;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for IXML_Document */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpEvent *UpnpEvent_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpEvent_delete(UpnpEvent *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpEvent *UpnpEvent_dup(const UpnpEvent *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q);
|
||||||
|
|
||||||
|
/*! The event sequence number. */
|
||||||
|
EXPORT_SPEC int UpnpEvent_get_EventKey(const UpnpEvent *p);
|
||||||
|
EXPORT_SPEC void UpnpEvent_set_EventKey(UpnpEvent *p, int n);
|
||||||
|
|
||||||
|
/*! The DOM tree representing the changes generating the event. */
|
||||||
|
EXPORT_SPEC IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p);
|
||||||
|
EXPORT_SPEC void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d);
|
||||||
|
|
||||||
|
/*! The subscription ID for this subscription. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p);
|
||||||
|
EXPORT_SPEC const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p);
|
||||||
|
EXPORT_SPEC void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EVENT_H */
|
||||||
|
|
||||||
74
upnp/inc/EventSubscribe.h
Normal file
74
upnp/inc/EventSubscribe.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef EVENTSUBSCRIBE_H
|
||||||
|
#define EVENTSUBSCRIBE_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpEventSubscribe object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returned along with a \b UPNP_EVENT_SUBSCRIBE_COMPLETE or
|
||||||
|
* \b UPNP_EVENT_UNSUBSCRIBE_COMPLETE callback. */
|
||||||
|
typedef struct s_UpnpEventSubscribe UpnpEventSubscribe;
|
||||||
|
|
||||||
|
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpEventSubscribe *UpnpEventSubscribe_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_delete(UpnpEventSubscribe *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpEventSubscribe *UpnpEventSubscribe_dup(const UpnpEventSubscribe *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_assign(UpnpEventSubscribe *p, const UpnpEventSubscribe *q);
|
||||||
|
|
||||||
|
/*! The result of the operation. */
|
||||||
|
EXPORT_SPEC int UpnpEventSubscribe_get_ErrCode(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_set_ErrCode(UpnpEventSubscribe *p, int n);
|
||||||
|
|
||||||
|
/*! The actual subscription time (for subscriptions only). */
|
||||||
|
EXPORT_SPEC int UpnpEventSubscribe_get_TimeOut(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_set_TimeOut(UpnpEventSubscribe *p, int n);
|
||||||
|
|
||||||
|
/*! The SID for this subscription. For subscriptions, this only
|
||||||
|
* contains a valid SID if the \b Upnp_EventSubscribe.result field
|
||||||
|
* contains a \b UPNP_E_SUCCESS result code. For unsubscriptions,
|
||||||
|
* this contains the SID from which the subscription is being
|
||||||
|
* unsubscribed. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpEventSubscribe_get_SID(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC const char *UpnpEventSubscribe_get_SID_cstr(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_set_SID(UpnpEventSubscribe *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_strcpy_SID(UpnpEventSubscribe *p, const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*! The event URL being subscribed to or removed from. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpEventSubscribe_get_PublisherUrl(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC const char *UpnpEventSubscribe_get_PublisherUrl_cstr(const UpnpEventSubscribe *p);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_set_PublisherUrl(UpnpEventSubscribe *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpEventSubscribe_strcpy_PublisherUrl(UpnpEventSubscribe *p, const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EVENTSUBSCRIBE_H */
|
||||||
|
|
||||||
84
upnp/inc/FileInfo.h
Normal file
84
upnp/inc/FileInfo.h
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef FILEINFO_H
|
||||||
|
#define FILEINFO_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpFileInfo object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Detailed description of this class should go here */
|
||||||
|
typedef struct s_UpnpFileInfo UpnpFileInfo;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for DOMString */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/types.h> /* for off_t */
|
||||||
|
#include <time.h> /* for time_t */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpFileInfo *UpnpFileInfo_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_delete(UpnpFileInfo *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpFileInfo *UpnpFileInfo_dup(const UpnpFileInfo *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_assign(UpnpFileInfo *p, const UpnpFileInfo *q);
|
||||||
|
|
||||||
|
/*! The length of the file. A length less than 0 indicates the size
|
||||||
|
* is unknown, and data will be sent until 0 bytes are returned from
|
||||||
|
* a read call. */
|
||||||
|
EXPORT_SPEC off_t UpnpFileInfo_get_FileLength(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_FileLength(UpnpFileInfo *p, off_t l);
|
||||||
|
|
||||||
|
/*! The time at which the contents of the file was modified;
|
||||||
|
* The time system is always local (not GMT). */
|
||||||
|
EXPORT_SPEC const time_t *UpnpFileInfo_get_LastModified(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_LastModified(UpnpFileInfo *p, const time_t *t);
|
||||||
|
|
||||||
|
/*! If the file is a directory, \b is_directory contains
|
||||||
|
* a non-zero value. For a regular file, it should be 0. */
|
||||||
|
EXPORT_SPEC int UpnpFileInfo_get_IsDirectory(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_IsDirectory(UpnpFileInfo *p, int b);
|
||||||
|
|
||||||
|
/*! If the file or directory is readable, this contains
|
||||||
|
* a non-zero value. If unreadable, it should be set to 0. */
|
||||||
|
EXPORT_SPEC int UpnpFileInfo_get_IsReadable(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_IsReadable(UpnpFileInfo *p, int b);
|
||||||
|
|
||||||
|
/*! The content type of the file. */
|
||||||
|
EXPORT_SPEC const DOMString UpnpFileInfo_get_ContentType(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC const char *UpnpFileInfo_get_ContentType_cstr(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_ContentType(UpnpFileInfo *p, const DOMString s);
|
||||||
|
|
||||||
|
/*! Additional HTTP headers to return. Each header line should be
|
||||||
|
* followed by "\r\n". */
|
||||||
|
EXPORT_SPEC const DOMString UpnpFileInfo_get_ExtraHeaders(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC const char *UpnpFileInfo_get_ExtraHeaders_cstr(const UpnpFileInfo *p);
|
||||||
|
EXPORT_SPEC void UpnpFileInfo_set_ExtraHeaders(UpnpFileInfo *p, const DOMString s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FILEINFO_H */
|
||||||
|
|
||||||
72
upnp/inc/StateVarComplete.h
Normal file
72
upnp/inc/StateVarComplete.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef STATEVARCOMPLETE_H
|
||||||
|
#define STATEVARCOMPLETE_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpStateVarComplete object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Represents the reply for the current value of a state variable in an
|
||||||
|
* asynchronous call. */
|
||||||
|
typedef struct s_UpnpStateVarComplete UpnpStateVarComplete;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for DOMString */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpStateVarComplete *UpnpStateVarComplete_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_delete(UpnpStateVarComplete *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpStateVarComplete *UpnpStateVarComplete_dup(const UpnpStateVarComplete *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_assign(UpnpStateVarComplete *p, const UpnpStateVarComplete *q);
|
||||||
|
|
||||||
|
/*! The result of the operation */
|
||||||
|
EXPORT_SPEC int UpnpStateVarComplete_get_ErrCode(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_set_ErrCode(UpnpStateVarComplete *p, int n);
|
||||||
|
|
||||||
|
/*! The control URL for the service. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarComplete_get_CtrlUrl(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarComplete_get_CtrlUrl_cstr(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_set_CtrlUrl(UpnpStateVarComplete *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_strcpy_CtrlUrl(UpnpStateVarComplete *p, const char *s);
|
||||||
|
|
||||||
|
/*! The name of the variable. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarComplete_get_StateVarName(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarComplete_get_StateVarName_cstr(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_set_StateVarName(UpnpStateVarComplete *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_strcpy_StateVarName(UpnpStateVarComplete *p, const char *s);
|
||||||
|
|
||||||
|
/*! The current value of the variable. This needs to be allocated by
|
||||||
|
* the caller. When finished with it, the SDK frees this \b DOMString. */
|
||||||
|
EXPORT_SPEC const DOMString UpnpStateVarComplete_get_CurrentVal(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarComplete_get_CurrentVal_cstr(const UpnpStateVarComplete *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarComplete_set_CurrentVal(UpnpStateVarComplete *p, const DOMString s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* STATEVARCOMPLETE_H */
|
||||||
|
|
||||||
91
upnp/inc/StateVarRequest.h
Normal file
91
upnp/inc/StateVarRequest.h
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef STATEVARREQUEST_H
|
||||||
|
#define STATEVARREQUEST_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpStateVarRequest object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Represents the request for current value of a state variable in a service
|
||||||
|
* state table. */
|
||||||
|
typedef struct s_UpnpStateVarRequest UpnpStateVarRequest;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" /* for DOMString */
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpInet.h" /* for sockaddr, sockaddr_storage */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpStateVarRequest *UpnpStateVarRequest_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_delete(UpnpStateVarRequest *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpStateVarRequest *UpnpStateVarRequest_dup(const UpnpStateVarRequest *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_assign(UpnpStateVarRequest *p, const UpnpStateVarRequest *q);
|
||||||
|
|
||||||
|
/*! The result of the operation */
|
||||||
|
EXPORT_SPEC int UpnpStateVarRequest_get_ErrCode(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_ErrCode(UpnpStateVarRequest *p, int n);
|
||||||
|
|
||||||
|
/*! The socket number of the connection to the requestor */
|
||||||
|
EXPORT_SPEC int UpnpStateVarRequest_get_Socket(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_Socket(UpnpStateVarRequest *p, int n);
|
||||||
|
|
||||||
|
/*! The error string in case of error */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_ErrStr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarRequest_get_ErrStr_cstr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_ErrStr(UpnpStateVarRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_strcpy_ErrStr(UpnpStateVarRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! The unique device ID */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_DevUDN(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarRequest_get_DevUDN_cstr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_DevUDN(UpnpStateVarRequest *p, const UpnpString *s);
|
||||||
|
|
||||||
|
/*! The service ID */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_ServiceID(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarRequest_get_ServiceID_cstr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_ServiceID(UpnpStateVarRequest *p, const UpnpString *s);
|
||||||
|
|
||||||
|
/*! The name of the variable. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpStateVarRequest_get_StateVarName(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarRequest_get_StateVarName_cstr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_StateVarName(UpnpStateVarRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_strcpy_StateVarName(UpnpStateVarRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! IP address of sender requesting the state variable. */
|
||||||
|
EXPORT_SPEC const struct sockaddr *UpnpStateVarRequest_get_CtrlPtIPAddr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_CtrlPtIPAddr(UpnpStateVarRequest *p, const struct sockaddr *sa);
|
||||||
|
|
||||||
|
/*! The current value of the variable. This needs to be allocated by
|
||||||
|
* the caller. When finished with it, the SDK frees this \b DOMString. */
|
||||||
|
EXPORT_SPEC const DOMString UpnpStateVarRequest_get_CurrentVal(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpStateVarRequest_get_CurrentVal_cstr(const UpnpStateVarRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpStateVarRequest_set_CurrentVal(UpnpStateVarRequest *p, const DOMString s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* STATEVARREQUEST_H */
|
||||||
|
|
||||||
66
upnp/inc/SubscriptionRequest.h
Normal file
66
upnp/inc/SubscriptionRequest.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef SUBSCRIPTIONREQUEST_H
|
||||||
|
#define SUBSCRIPTIONREQUEST_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpSubscriptionRequest object declararion.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returned along with a \b UPNP_EVENT_SUBSCRIPTION_REQUEST callback. */
|
||||||
|
typedef struct s_UpnpSubscriptionRequest UpnpSubscriptionRequest;
|
||||||
|
|
||||||
|
|
||||||
|
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*! Constructor */
|
||||||
|
EXPORT_SPEC UpnpSubscriptionRequest *UpnpSubscriptionRequest_new();
|
||||||
|
|
||||||
|
/*! Destructor */
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p);
|
||||||
|
|
||||||
|
/*! Copy Constructor */
|
||||||
|
EXPORT_SPEC UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p);
|
||||||
|
|
||||||
|
/*! Assignment operator */
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *p, const UpnpSubscriptionRequest *q);
|
||||||
|
|
||||||
|
/*! The identifier for the service being subscribed to. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_ServiceId_cstr(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! Universal device name. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_UDN_cstr(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s);
|
||||||
|
|
||||||
|
/*! The assigned subscription ID for this subscription. */
|
||||||
|
EXPORT_SPEC const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC const char *UpnpSubscriptionRequest_get_SID_cstr(const UpnpSubscriptionRequest *p);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||||
|
EXPORT_SPEC void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SUBSCRIPTIONREQUEST_H */
|
||||||
|
|
||||||
120
upnp/inc/UpnpGlobal.h
Normal file
120
upnp/inc/UpnpGlobal.h
Normal 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 */
|
||||||
|
|
||||||
30
upnp/inc/UpnpInet.h
Normal file
30
upnp/inc/UpnpInet.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef UPNPINET_H
|
||||||
|
#define UPNPINET_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief Provides a platform independent way to include TCP/IP types and functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <Ws2tcpip.h>
|
||||||
|
#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>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* UPNPINET_H */
|
||||||
|
|
||||||
133
upnp/inc/UpnpString.h
Normal file
133
upnp/inc/UpnpString.h
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
|
||||||
|
|
||||||
|
#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 int UpnpString_get_Length(
|
||||||
|
/*! [in] The \em \b this pointer. */
|
||||||
|
const UpnpString *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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 void 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 void 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.*/
|
||||||
|
int n);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clears the string, sets its size to zero.
|
||||||
|
*/
|
||||||
|
EXPORT_SPEC void UpnpString_clear(
|
||||||
|
/*! [in] The \em \b this pointer. */
|
||||||
|
UpnpString *p);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/* @} UpnpString The UpnpString API */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* STRING_H */
|
||||||
|
|
||||||
4324
upnp/inc/upnp.h
4324
upnp/inc/upnp.h
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,12 @@
|
|||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@@ -33,25 +33,34 @@
|
|||||||
#ifndef UPNP_DEBUG_H
|
#ifndef UPNP_DEBUG_H
|
||||||
#define UPNP_DEBUG_H
|
#define UPNP_DEBUG_H
|
||||||
|
|
||||||
#include "upnp.h"
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ThreadPool.h"
|
||||||
#include "upnpconfig.h"
|
#include "upnpconfig.h"
|
||||||
|
#include "UpnpGlobal.h" /* for UPNP_INLINE */
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** @name Other debugging features
|
/** \name Other debugging features
|
||||||
The UPnP SDK contains other features to aid in debugging.
|
*
|
||||||
|
* 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,
|
* 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
|
* The critical level will show only those messages
|
||||||
* which can halt the normal processing of the library, like memory
|
* which can halt the normal processing of the library, like memory
|
||||||
* allocation errors. The remaining three levels are just for debugging
|
* allocation errors. The remaining three levels are just for debugging
|
||||||
@@ -60,14 +69,11 @@ extern "C" {
|
|||||||
* Info Level displays the other important operational information
|
* Info Level displays the other important operational information
|
||||||
* regarding the working of the library. If the user selects All,
|
* regarding the working of the library. If the user selects All,
|
||||||
* then the library displays all the debugging information that it has.
|
* then the library displays all the debugging information that it has.
|
||||||
* \begin{itemize}
|
* \li \c UPNP_CRITICAL [0]
|
||||||
* \item {\tt UPNP_CRITICAL [0]}
|
* \li \c UPNP_PACKET [1]
|
||||||
* \item {\tt UPNP_PACKET [1]}
|
* \li \c UPNP_INFO [2]
|
||||||
* \item {\tt UPNP_INFO [2]}
|
* \li \c UPNP_ALL [3]
|
||||||
* \item {\tt UPNP_ALL [3]}
|
|
||||||
* \end{itemize}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum Upnp_Module {
|
typedef enum Upnp_Module {
|
||||||
SSDP,
|
SSDP,
|
||||||
SOAP,
|
SOAP,
|
||||||
@@ -79,91 +85,69 @@ typedef enum Upnp_Module {
|
|||||||
HTTP
|
HTTP
|
||||||
} Dbg_Module;
|
} Dbg_Module;
|
||||||
|
|
||||||
/*! @{ */
|
|
||||||
|
/*@{*/
|
||||||
typedef enum Upnp_LogLevel_e {
|
typedef enum Upnp_LogLevel_e {
|
||||||
UPNP_CRITICAL,
|
UPNP_CRITICAL,
|
||||||
UPNP_PACKET,
|
UPNP_PACKET,
|
||||||
UPNP_INFO,
|
UPNP_INFO,
|
||||||
UPNP_ALL
|
UPNP_ALL
|
||||||
} Upnp_LogLevel;
|
} Upnp_LogLevel;
|
||||||
/*! @} */
|
/*@}*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default log level : see {\tt Upnp_LogLevel}
|
* Default log level : see \c Upnp_LogLevel
|
||||||
*/
|
*/
|
||||||
#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
|
#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpInitLog
|
* \brief Initialize the log files.
|
||||||
*
|
*
|
||||||
* Parameters: void
|
* \return -1 if fails or UPNP_E_SUCCESS if succeeds.
|
||||||
*
|
*/
|
||||||
* Description:
|
|
||||||
* This functions initializes the log files
|
|
||||||
*
|
|
||||||
* Returns: int
|
|
||||||
* -1 : If fails
|
|
||||||
* UPNP_E_SUCCESS : if success
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int UpnpInitLog();
|
int UpnpInitLog(void);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; }
|
static UPNP_INLINE int UpnpInitLog(void)
|
||||||
|
{
|
||||||
|
return UPNP_E_SUCCESS;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpSetLogLevel
|
* \brief Set the log level (see \c Upnp_LogLevel).
|
||||||
*
|
*/
|
||||||
* Parameters: Upnp_LogLevel log_level
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This functions set the log level (see {\tt Upnp_LogLevel}
|
|
||||||
* Returns: void
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpSetLogLevel(Upnp_LogLevel log_level);
|
void UpnpSetLogLevel(
|
||||||
|
/*! [in] Log level. */
|
||||||
|
Upnp_LogLevel log_level);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
|
static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpCloseLog
|
* \brief Closes the log files.
|
||||||
*
|
*/
|
||||||
* Parameters: void
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This functions closes the log files
|
|
||||||
* Returns: void
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpCloseLog();
|
void UpnpCloseLog(void);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void UpnpCloseLog() {}
|
static UPNP_INLINE void UpnpCloseLog(void) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpSetLogFileNames
|
* \brief Set the name for error and information files, respectively.
|
||||||
*
|
*/
|
||||||
* 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
|
|
||||||
***************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpSetLogFileNames(
|
void UpnpSetLogFileNames(
|
||||||
|
/*! [in] Name of the error file. */
|
||||||
const char *ErrFileName,
|
const char *ErrFileName,
|
||||||
|
/*! [in] Name of the information file. */
|
||||||
const char *InfoFileName);
|
const char *InfoFileName);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void UpnpSetLogFileNames(
|
static UPNP_INLINE void UpnpSetLogFileNames(
|
||||||
@@ -172,24 +156,20 @@ static UPNP_INLINE void UpnpSetLogFileNames(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpGetDebugFile
|
* \brief Check if the module is turned on for debug and returns the file
|
||||||
*
|
* descriptor corresponding to the debug level
|
||||||
* Parameters:
|
*
|
||||||
* IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
|
* \return NULL if the module is turn off for debug otheriwse returns the
|
||||||
* whether debug statement will go to standard output,
|
* right file descriptor.
|
||||||
* 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
|
#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
|
#else
|
||||||
static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
|
static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
|
||||||
{
|
{
|
||||||
@@ -198,60 +178,47 @@ static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : DebugAtThisLevel
|
* \brief Returns true if debug output should be done in this module.
|
||||||
*
|
|
||||||
* 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
|
* \return Nonzero value if true, zero if false.
|
||||||
***************************************************************************/
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int DebugAtThisLevel(
|
int DebugAtThisLevel(
|
||||||
IN Upnp_LogLevel DLevel,
|
/*! [in] The level of the debug logging. It will decide whether debug
|
||||||
IN Dbg_Module Module);
|
* 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
|
#else
|
||||||
static UPNP_INLINE int DebugAtThisLevel(
|
static UPNP_INLINE int DebugAtThisLevel(
|
||||||
IN Upnp_LogLevel DLevel,
|
Upnp_LogLevel DLevel,
|
||||||
IN Dbg_Module Module) { return 0; }
|
Dbg_Module Module)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpPrintf
|
* \brief Prints the debug statement either on the standard output or log file
|
||||||
*
|
* along with the information from where this debug statement is coming.
|
||||||
* 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
|
#ifdef DEBUG
|
||||||
void UpnpPrintf(
|
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,
|
Upnp_LogLevel DLevel,
|
||||||
|
/*! [in] debug will go in the name of this module. */
|
||||||
Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
|
/*! [in] Name of the file from where debug statement is coming. */
|
||||||
const char* DbgFileName,
|
const char* DbgFileName,
|
||||||
|
/*! [in] Line number of the file from where debug statement is coming. */
|
||||||
int DbgLineNo,
|
int DbgLineNo,
|
||||||
|
/*! [in] Printf like format specification. */
|
||||||
const char* FmtStr,
|
const char* FmtStr,
|
||||||
|
/*! [in] Printf like Variable number of arguments that will go in the debug
|
||||||
|
* statement. */
|
||||||
...)
|
...)
|
||||||
#if (__GNUC__ >= 3)
|
#if (__GNUC__ >= 3)
|
||||||
/* This enables printf like format checking by the compiler */
|
/* This enables printf like format checking by the compiler */
|
||||||
@@ -265,29 +232,44 @@ static UPNP_INLINE void UpnpPrintf(
|
|||||||
const char* DbgFileName,
|
const char* DbgFileName,
|
||||||
int DbgLineNo,
|
int DbgLineNo,
|
||||||
const char* FmtStr,
|
const char* FmtStr,
|
||||||
...) {}
|
...)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpDisplayBanner
|
* \brief Writes the file name and file number from where debug statement is
|
||||||
*
|
* coming to the log file.
|
||||||
* Parameters:
|
*/
|
||||||
* IN FILE *fd: file descriptor where the banner will be written
|
#ifdef DEBUG
|
||||||
* IN char **lines: The buffer that will be written
|
void UpnpDisplayFileAndLine(
|
||||||
* IN int size: Size of the buffer
|
/*! [in] File descriptor where line number and file name will be written. */
|
||||||
* IN int starLength: This parameter provides the width of the banner
|
FILE *fd,
|
||||||
*
|
/*! [in] Name of the file. */
|
||||||
* Description:
|
const char *DbgFileName,
|
||||||
* This functions takes the buffer and writes the buffer in the file as
|
/*! [in] Line number of the file. */
|
||||||
* per the requested banner
|
int DbgLineNo);
|
||||||
* Returns: void
|
#else
|
||||||
***************************************************************************/
|
static UPNP_INLINE void UpnpDisplayFileAndLine(
|
||||||
|
FILE *fd,
|
||||||
|
const char *DbgFileName,
|
||||||
|
int DbgLineNo) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Writes the buffer in the file as per the requested banner
|
||||||
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpnpDisplayBanner(
|
void UpnpDisplayBanner(
|
||||||
|
/*! [in] file descriptor where the banner will be written. */
|
||||||
FILE *fd,
|
FILE *fd,
|
||||||
|
/*! [in] The buffer that will be written. */
|
||||||
const char **lines,
|
const char **lines,
|
||||||
|
/*! [in] Size of the buffer. */
|
||||||
size_t size,
|
size_t size,
|
||||||
|
/*! [in] This parameter provides the width of the banner. */
|
||||||
int starlength);
|
int starlength);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void UpnpDisplayBanner(
|
static UPNP_INLINE void UpnpDisplayBanner(
|
||||||
@@ -298,33 +280,31 @@ static UPNP_INLINE void UpnpDisplayBanner(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/*!
|
||||||
* Function : UpnpDisplayFileAndLine
|
* \brief Prints thread pool statistics.
|
||||||
*
|
*/
|
||||||
* 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
|
#ifdef DEBUG
|
||||||
void UpnpDisplayFileAndLine(
|
void PrintThreadPoolStats(
|
||||||
FILE *fd,
|
/*! [in] The thread pool. */
|
||||||
|
ThreadPool *tp,
|
||||||
|
/*! [in] The file name that called this function, use the macro __FILE__. */
|
||||||
const char *DbgFileName,
|
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
|
#else
|
||||||
static UPNP_INLINE void UpnpDisplayFileAndLine(
|
static UPNP_INLINE void PrintThreadPoolStats(
|
||||||
FILE *fd,
|
ThreadPool *tp,
|
||||||
const char *DbgFileName,
|
const char *DbgFileName,
|
||||||
int DbgLineNo) {}
|
int DbgLineNo,
|
||||||
|
const char *msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! @} */
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
#ifndef UPNP_TOOLS_H
|
||||||
#define 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 */
|
/* Function declarations only if tools compiled into the library */
|
||||||
#if UPNP_HAVE_TOOLS
|
#if UPNP_HAVE_TOOLS
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* \brief Converts an SDK error code into a string error message suitable for
|
||||||
* {\bf BaseURL} and {\bf RelURL} combined.
|
* display. The memory returned from this function should NOT be freed.
|
||||||
*
|
*
|
||||||
* @return [int] An integer representing one of the following:
|
* \return An ASCII text string representation of the error message associated
|
||||||
* \begin{itemize}
|
* with the error code or the string "Unknown error code"
|
||||||
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
|
*/
|
||||||
* \item {\tt UPNP_E_INVALID_PARAM}: {\bf RelURL} is {\tt NULL}.
|
EXPORT_SPEC const char *UpnpGetErrorMessage(
|
||||||
* \item {\tt UPNP_E_INVALID_URL}: The {\bf BaseURL} / {\bf RelURL}
|
/*! [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.
|
* 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.
|
* complete this operation.
|
||||||
* \end{itemize}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EXPORT_SPEC int UpnpResolveURL(
|
EXPORT_SPEC int UpnpResolveURL(
|
||||||
IN const char * BaseURL, /** The base URL to combine. */
|
/*! [in] The base URL to combine. */
|
||||||
IN const char * RelURL, /** The relative URL to {\bf BaseURL}. */
|
const char *BaseURL,
|
||||||
OUT char * AbsURL /** A pointer to a buffer to store the
|
/*! [in] The relative URL to \b BaseURL. */
|
||||||
absolute URL. */
|
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. */
|
* \brief Creates an action request packet based on its input parameters
|
||||||
IN const char * ServType, /** The service type. */
|
* (status variable name and value pair).
|
||||||
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.
|
|
||||||
*
|
*
|
||||||
* @return [int] An integer representing one of the following:
|
* Any number of input parameters can be passed to this function but every
|
||||||
* \begin{itemize}
|
* input variable name should have a matching value argument.
|
||||||
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
|
*
|
||||||
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
|
* It is a wrapper function that calls makeAction() function to create the
|
||||||
* are invalid.
|
* action request.
|
||||||
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
|
*
|
||||||
* complete this operation.
|
* \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
|
||||||
* \end{itemize}
|
* 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(
|
EXPORT_SPEC int UpnpAddToAction(
|
||||||
IN OUT IXML_Document ** ActionDoc,
|
/*! [in,out] A pointer to store the action document node. */
|
||||||
/** A pointer to store the action
|
IXML_Document **ActionDoc,
|
||||||
document node. */
|
/*! [in] The action name. */
|
||||||
IN const char * ActionName, /** The action name. */
|
const char *ActionName,
|
||||||
IN const char * ServType, /** The service type. */
|
/*! [in] The service type. */
|
||||||
IN const char * ArgName, /** The status variable name. */
|
const char *ServType,
|
||||||
IN const char * ArgVal /** The status variable value. */
|
/*! [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. */
|
* \brief Creates an action response packet based on its output parameters
|
||||||
IN const char * ServType, /** The service type. */
|
* (status variable name and value pair).
|
||||||
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.
|
|
||||||
*
|
*
|
||||||
* @return [int] An integer representing one of the following:
|
* This API is especially suitable inside a loop to add any number of input
|
||||||
* \begin{itemize}
|
* parameters into an existing action response. If no action document exists
|
||||||
* \item {\tt UPNP_E_SUCCESS}: The operation completed successfully.
|
* in the beginning, a \b Upnp_Document variable initialized with <tt>NULL</tt>
|
||||||
* \item {\tt UPNP_E_INVALID_PARAM}: One or more of the parameters
|
* should be passed as a parameter.
|
||||||
* are invalid.
|
*
|
||||||
* \item {\tt UPNP_E_OUTOF_MEMORY}: Insufficient resources exist to
|
* It is a wrapper function that calls addToAction() function to add the
|
||||||
* complete this operation.
|
* argument in the action request.
|
||||||
* \end{itemize}
|
*
|
||||||
|
* \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(
|
EXPORT_SPEC int UpnpAddToActionResponse(
|
||||||
IN OUT IXML_Document ** ActionResponse,
|
/*! [in,out] Pointer to a document to store the action document node. */
|
||||||
/** Pointer to a document to
|
IXML_Document **ActionResponse,
|
||||||
store the action document
|
/*! [in] The action name. */
|
||||||
node. */
|
const char *ActionName,
|
||||||
IN const char * ActionName, /** The action name. */
|
/*! [in] The service type. */
|
||||||
IN const char * ServType, /** The service type. */
|
const char *ServType,
|
||||||
IN const char * ArgName, /** The status variable name. */
|
/*! [in] The status variable name. */
|
||||||
IN const char * ArgVal /** The status variable value. */
|
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
|
* \brief Creates a property set message packet.
|
||||||
* 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}
|
|
||||||
*
|
*
|
||||||
|
* 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(
|
EXPORT_SPEC int UpnpAddToPropertySet(
|
||||||
IN OUT IXML_Document **PropSet,
|
/*! [in,out] A pointer to the document containing the property set document node. */
|
||||||
/** A pointer to the document containing
|
IXML_Document **PropSet,
|
||||||
the property set document node. */
|
/*! [in] The status variable name. */
|
||||||
IN const char * ArgName, /** The status variable name. */
|
const char *ArgName,
|
||||||
IN const char * ArgVal /** The status variable value. */
|
/*! [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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*! @} */
|
||||||
|
|
||||||
|
|
||||||
#endif /* UPNP_HAVE_TOOLS */
|
#endif /* UPNP_HAVE_TOOLS */
|
||||||
|
|
||||||
|
|
||||||
#endif /* UPNP_TOOLS_H */
|
#endif /* UPNP_TOOLS_H */
|
||||||
|
|
||||||
|
|||||||
97
upnp/m4/libupnp.m4
Normal file
97
upnp/m4/libupnp.m4
Normal 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
|
||||||
|
])
|
||||||
@@ -69,8 +69,9 @@ upnp_tv_combo_SOURCES = \
|
|||||||
if WITH_DOCUMENTATION
|
if WITH_DOCUMENTATION
|
||||||
examplesdir = $(docdir)/examples
|
examplesdir = $(docdir)/examples
|
||||||
examples_DATA = \
|
examples_DATA = \
|
||||||
$(upnp_tv_ctrlpt_SOURCES) \
|
$(sort \
|
||||||
$(upnp_tv_device_SOURCES)
|
$(upnp_tv_ctrlpt_SOURCES) \
|
||||||
|
$(upnp_tv_device_SOURCES))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,55 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef SAMPLE_UTIL_H
|
#ifndef SAMPLE_UTIL_H
|
||||||
#define SAMPLE_UTIL_H
|
#define SAMPLE_UTIL_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include "ixml.h"
|
#include "ixml.h" /* for IXML_Document, IXML_Element */
|
||||||
|
#include "upnp.h" /* for Upnp_EventType */
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
|
|
||||||
|
|
||||||
// mutex to control displaying of events
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* mutex to control displaying of events */
|
||||||
extern ithread_mutex_t display_mutex;
|
extern ithread_mutex_t display_mutex;
|
||||||
|
|
||||||
|
|
||||||
@@ -166,7 +170,7 @@ int SampleUtil_PrintEvent(IN Upnp_EventType EventType,
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int SampleUtil_FindAndParseService (
|
int SampleUtil_FindAndParseService (
|
||||||
IN IXML_Document *DescDoc,
|
IN IXML_Document *DescDoc,
|
||||||
IN char* location,
|
IN const char* location,
|
||||||
IN char *serviceType,
|
IN char *serviceType,
|
||||||
OUT char **serviceId,
|
OUT char **serviceId,
|
||||||
OUT char **eventURL,
|
OUT char **eventURL,
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
@@ -130,7 +130,8 @@ TvCtrlPointPrintLongHelp( void )
|
|||||||
SampleUtil_Print( "" );
|
SampleUtil_Print( "" );
|
||||||
SampleUtil_Print( "This sample control point application automatically searches" );
|
SampleUtil_Print( "This sample control point application automatically searches" );
|
||||||
SampleUtil_Print( "for and subscribes to the services of television device emulator" );
|
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( "" );
|
||||||
SampleUtil_Print( "Commands:" );
|
SampleUtil_Print( "Commands:" );
|
||||||
SampleUtil_Print( " Help" );
|
SampleUtil_Print( " Help" );
|
||||||
@@ -456,7 +457,8 @@ int main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
ithread_t cmdloop_thread;
|
ithread_t cmdloop_thread;
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
#else
|
||||||
int sig;
|
int sig;
|
||||||
sigset_t sigs_to_catch;
|
sigset_t sigs_to_catch;
|
||||||
#endif
|
#endif
|
||||||
@@ -471,7 +473,9 @@ int main( int argc, char **argv )
|
|||||||
/* start a command loop thread */
|
/* start a command loop thread */
|
||||||
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
|
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
ithread_join(cmdloop_thread, NULL);
|
||||||
|
#else
|
||||||
/*
|
/*
|
||||||
Catch Ctrl-C and properly shutdown
|
Catch Ctrl-C and properly shutdown
|
||||||
*/
|
*/
|
||||||
@@ -480,12 +484,8 @@ int main( int argc, char **argv )
|
|||||||
sigwait( &sigs_to_catch, &sig );
|
sigwait( &sigs_to_catch, &sig );
|
||||||
|
|
||||||
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
||||||
#else
|
|
||||||
ithread_join(cmdloop_thread, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
TvDeviceStop();
|
TvDeviceStop();
|
||||||
rc = TvCtrlPointStop();
|
rc = TvCtrlPointStop();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#include "upnp_tv_ctrlpt.h"
|
#include "upnp_tv_ctrlpt.h"
|
||||||
|
|
||||||
@@ -138,11 +138,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
|
|||||||
* UDN -- The Unique Device Name for the device to remove
|
* UDN -- The Unique Device Name for the device to remove
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointRemoveDevice(const char *UDN)
|
||||||
TvCtrlPointRemoveDevice( char *UDN )
|
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *curdevnode,
|
struct TvDeviceNode *curdevnode;
|
||||||
*prevdevnode;
|
struct TvDeviceNode *prevdevnode;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
@@ -668,8 +667,8 @@ TvCtrlPointPrintDevice( int devnum )
|
|||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void
|
||||||
TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
TvCtrlPointAddDevice( IXML_Document *DescDoc,
|
||||||
char *location,
|
const char *location,
|
||||||
int expires )
|
int expires )
|
||||||
{
|
{
|
||||||
char *deviceType = NULL;
|
char *deviceType = NULL;
|
||||||
@@ -682,20 +681,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
|||||||
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
||||||
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
||||||
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
|
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
|
||||||
int TimeOut[TV_SERVICE_SERVCOUNT] =
|
int TimeOut[TV_SERVICE_SERVCOUNT] = {
|
||||||
{ default_timeout, default_timeout };
|
default_timeout,
|
||||||
|
default_timeout };
|
||||||
struct TvDeviceNode *deviceNode;
|
struct TvDeviceNode *deviceNode;
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int service,
|
int service;
|
||||||
var;
|
int var;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
/*
|
/* Read key elements from description document */
|
||||||
Read key elements from description document
|
|
||||||
*/
|
|
||||||
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
|
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
|
||||||
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
|
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
|
||||||
friendlyName =
|
friendlyName =
|
||||||
@@ -703,9 +701,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
|||||||
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
|
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
|
||||||
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
|
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
|
||||||
|
|
||||||
ret =
|
ret = UpnpResolveURL(
|
||||||
UpnpResolveURL( ( baseURL ? baseURL : location ), relURL,
|
( baseURL ? baseURL : location ), relURL, presURL);
|
||||||
presURL );
|
|
||||||
|
|
||||||
if( UPNP_E_SUCCESS != ret )
|
if( UPNP_E_SUCCESS != ret )
|
||||||
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
|
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
|
||||||
@@ -939,34 +936,38 @@ TvStateUpdate( char *UDN,
|
|||||||
* changes -- The DOM document representing the changes
|
* changes -- The DOM document representing the changes
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleEvent(
|
||||||
TvCtrlPointHandleEvent( Upnp_SID sid,
|
const UpnpString *sid,
|
||||||
int evntkey,
|
int evntkey,
|
||||||
IXML_Document * changes )
|
IXML_Document *changes)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
|
const char *aux_sid = NULL;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock(&DeviceListMutex);
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while( tmpdevnode ) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
|
||||||
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
|
aux_sid = UpnpString_get_String(sid);
|
||||||
0 ) {
|
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
|
||||||
SampleUtil_Print( "Received Tv %s Event: %d for SID %s",
|
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
||||||
TvServiceName[service], evntkey, sid );
|
TvServiceName[service],
|
||||||
|
evntkey,
|
||||||
|
aux_sid);
|
||||||
|
TvStateUpdate(
|
||||||
|
tmpdevnode->device.UDN,
|
||||||
|
service,
|
||||||
|
changes,
|
||||||
|
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmpdevnode = tmpdevnode->next;
|
||||||
|
}
|
||||||
|
|
||||||
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
|
ithread_mutex_unlock(&DeviceListMutex);
|
||||||
( char ** )&tmpdevnode->device.
|
|
||||||
TvService[service].VariableStrVal );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmpdevnode = tmpdevnode->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
ithread_mutex_unlock( &DeviceListMutex );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@@ -983,10 +984,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid,
|
|||||||
* timeout -- The new timeout for the subscription
|
* timeout -- The new timeout for the subscription
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleSubscribeUpdate(
|
||||||
TvCtrlPointHandleSubscribeUpdate( char *eventURL,
|
const char *eventURL,
|
||||||
Upnp_SID sid,
|
const Upnp_SID sid,
|
||||||
int timeout )
|
int timeout)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
@@ -1014,10 +1015,10 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL,
|
|||||||
ithread_mutex_unlock( &DeviceListMutex );
|
ithread_mutex_unlock( &DeviceListMutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void TvCtrlPointHandleGetVar(
|
||||||
TvCtrlPointHandleGetVar( char *controlURL,
|
const char *controlURL,
|
||||||
char *varName,
|
const char *varName,
|
||||||
DOMString varValue )
|
const DOMString varValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
@@ -1026,14 +1027,11 @@ TvCtrlPointHandleGetVar( char *controlURL,
|
|||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while( tmpdevnode ) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
|
||||||
if( strcmp
|
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL) == 0) {
|
||||||
( tmpdevnode->device.TvService[service].ControlURL,
|
SampleUtil_StateUpdate(
|
||||||
controlURL ) == 0 ) {
|
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE);
|
||||||
SampleUtil_StateUpdate( varName, varValue,
|
|
||||||
tmpdevnode->device.UDN,
|
|
||||||
GET_VAR_COMPLETE );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1057,186 +1055,142 @@ TvCtrlPointHandleGetVar( char *controlURL,
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvCtrlPointCallbackEventHandler( Upnp_EventType EventType,
|
|
||||||
void *Event,
|
|
||||||
void *Cookie )
|
|
||||||
{
|
{
|
||||||
SampleUtil_PrintEvent( EventType, Event );
|
int errCode = 0;
|
||||||
|
|
||||||
switch ( EventType ) {
|
SampleUtil_PrintEvent(EventType, Event);
|
||||||
/*
|
switch ( EventType ) {
|
||||||
SSDP Stuff
|
/* SSDP Stuff */
|
||||||
*/
|
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
case UPNP_DISCOVERY_SEARCH_RESULT: {
|
||||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
|
||||||
{
|
IXML_Document *DescDoc = NULL;
|
||||||
struct Upnp_Discovery *d_event =
|
const char *location = NULL;
|
||||||
( struct Upnp_Discovery * )Event;
|
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||||
IXML_Document *DescDoc = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print( "Error in Discovery Callback -- %d",
|
SampleUtil_Print(
|
||||||
d_event->ErrCode );
|
"Error in Discovery Callback -- %d", errCode);
|
||||||
}
|
}
|
||||||
|
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
|
||||||
|
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
|
||||||
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error obtaining device description from %s -- error = %d",
|
||||||
|
location, errCode);
|
||||||
|
} else {
|
||||||
|
TvCtrlPointAddDevice(
|
||||||
|
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
|
||||||
|
}
|
||||||
|
if (DescDoc) {
|
||||||
|
ixmlDocument_free(DescDoc);
|
||||||
|
}
|
||||||
|
TvCtrlPointPrintList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||||
|
/* Nothing to do here... */
|
||||||
|
break;
|
||||||
|
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
|
||||||
|
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
|
||||||
|
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||||
|
const char *deviceId = UpnpString_get_String(
|
||||||
|
UpnpDiscovery_get_DeviceID(d_event));
|
||||||
|
|
||||||
if( ( ret =
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
UpnpDownloadXmlDoc( d_event->Location,
|
SampleUtil_Print(
|
||||||
&DescDoc ) ) !=
|
"Error in Discovery ByeBye Callback -- %d", errCode);
|
||||||
UPNP_E_SUCCESS ) {
|
}
|
||||||
SampleUtil_Print
|
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
|
||||||
( "Error obtaining device description from %s -- error = %d",
|
TvCtrlPointRemoveDevice(deviceId);
|
||||||
d_event->Location, ret );
|
SampleUtil_Print("After byebye:");
|
||||||
} else {
|
TvCtrlPointPrintList();
|
||||||
TvCtrlPointAddDevice( DescDoc, d_event->Location,
|
break;
|
||||||
d_event->Expires );
|
}
|
||||||
}
|
/* SOAP Stuff */
|
||||||
|
case UPNP_CONTROL_ACTION_COMPLETE: {
|
||||||
|
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
|
||||||
|
int errCode = UpnpActionComplete_get_ErrCode(a_event);
|
||||||
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Action Complete Callback -- %d",
|
||||||
|
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: {
|
||||||
|
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
|
||||||
|
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
|
||||||
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Get Var Complete Callback -- %d", errCode);
|
||||||
|
} else {
|
||||||
|
TvCtrlPointHandleGetVar(
|
||||||
|
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
|
||||||
|
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
|
||||||
|
UpnpStateVarComplete_get_CurrentVal(sv_event));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* GENA Stuff */
|
||||||
|
case UPNP_EVENT_RECEIVED: {
|
||||||
|
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||||
|
TvCtrlPointHandleEvent(
|
||||||
|
UpnpEvent_get_SID(e_event),
|
||||||
|
UpnpEvent_get_EventKey(e_event),
|
||||||
|
UpnpEvent_get_ChangedVariables(e_event));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||||
|
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||||
|
case UPNP_EVENT_RENEWAL_COMPLETE: {
|
||||||
|
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||||
|
|
||||||
if( DescDoc )
|
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
|
||||||
ixmlDocument_free( DescDoc );
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Event Subscribe Callback -- %d", errCode);
|
||||||
|
} else {
|
||||||
|
TvCtrlPointHandleSubscribeUpdate(
|
||||||
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
|
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
|
||||||
|
UpnpEventSubscribe_get_TimeOut(es_event));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case UPNP_EVENT_AUTORENEWAL_FAILED:
|
||||||
|
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
|
||||||
|
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||||
|
int TimeOut = default_timeout;
|
||||||
|
Upnp_SID newSID;
|
||||||
|
|
||||||
TvCtrlPointPrintList();
|
errCode = UpnpSubscribe(
|
||||||
break;
|
ctrlpt_handle,
|
||||||
}
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
|
&TimeOut,
|
||||||
|
newSID);
|
||||||
|
if (errCode == UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
|
||||||
|
TvCtrlPointHandleSubscribeUpdate(
|
||||||
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
|
newSID,
|
||||||
|
TimeOut);
|
||||||
|
} else {
|
||||||
|
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
return 0;
|
||||||
/*
|
|
||||||
Nothing to do here...
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
|
||||||
{
|
|
||||||
struct Upnp_Discovery *d_event =
|
|
||||||
( struct Upnp_Discovery * )Event;
|
|
||||||
|
|
||||||
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( 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@@ -1320,12 +1274,12 @@ TvCtrlPointVerifyTimeouts( int incr )
|
|||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void *
|
static int TvCtrlPointTimerLoopRun = 1;
|
||||||
TvCtrlPointTimerLoop( void *args )
|
void *TvCtrlPointTimerLoop(void *args)
|
||||||
{
|
{
|
||||||
int incr = 30; // how often to verify the timeouts, in seconds
|
int incr = 30; // how often to verify the timeouts, in seconds
|
||||||
|
|
||||||
while( 1 ) {
|
while (TvCtrlPointTimerLoopRun) {
|
||||||
isleep( incr );
|
isleep( incr );
|
||||||
TvCtrlPointVerifyTimeouts( incr );
|
TvCtrlPointVerifyTimeouts( incr );
|
||||||
}
|
}
|
||||||
@@ -1348,70 +1302,72 @@ TvCtrlPointTimerLoop( void *args )
|
|||||||
* TV_SUCCESS if everything went well, else TV_ERROR
|
* TV_SUCCESS if everything went well, else TV_ERROR
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
|
||||||
TvCtrlPointStart( print_string printFunctionPtr,
|
|
||||||
state_update updateFunctionPtr )
|
|
||||||
{
|
{
|
||||||
ithread_t timer_thread;
|
ithread_t timer_thread;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char *ip_address = NULL;
|
char *ip_address = NULL;
|
||||||
|
|
||||||
SampleUtil_Initialize( printFunctionPtr );
|
SampleUtil_Initialize(printFunctionPtr);
|
||||||
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
|
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
|
||||||
|
|
||||||
ithread_mutex_init( &DeviceListMutex, 0 );
|
ithread_mutex_init(&DeviceListMutex, 0);
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"Initializing UPnP Sdk with\n"
|
"Initializing UPnP Sdk with\n"
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port);
|
||||||
|
|
||||||
rc = UpnpInit( ip_address, port );
|
rc = UpnpInit(ip_address, port);
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
|
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
|
||||||
//UpnpFinish();
|
/*
|
||||||
//return TV_ERROR;
|
UpnpFinish();
|
||||||
}
|
return TV_ERROR;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if (!ip_address) {
|
||||||
|
ip_address = UpnpGetServerIpAddress();
|
||||||
|
}
|
||||||
|
if (!port) {
|
||||||
|
port = UpnpGetServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL == ip_address ) {
|
SampleUtil_Print(
|
||||||
ip_address = UpnpGetServerIpAddress();
|
"UPnP Initialized\n"
|
||||||
}
|
"\tipaddress= %s port = %u\n",
|
||||||
if( 0 == port ) {
|
ip_address, port);
|
||||||
port = UpnpGetServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Registering Control Point");
|
||||||
"UPnP Initialized\n"
|
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
|
||||||
"\tipaddress= %s port = %u\n",
|
&ctrlpt_handle, &ctrlpt_handle);
|
||||||
ip_address, port );
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print( "Error registering CP: %d", rc );
|
||||||
|
UpnpFinish();
|
||||||
|
|
||||||
SampleUtil_Print( "Registering Control Point" );
|
return TV_ERROR;
|
||||||
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( "Control Point Registered" );
|
SampleUtil_Print("Control Point Registered");
|
||||||
|
|
||||||
TvCtrlPointRefresh();
|
TvCtrlPointRefresh();
|
||||||
|
|
||||||
// start a timer thread
|
/* start a timer thread */
|
||||||
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
|
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
|
||||||
|
ithread_detach(timer_thread);
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int TvCtrlPointStop(void)
|
||||||
TvCtrlPointStop( void )
|
|
||||||
{
|
{
|
||||||
TvCtrlPointRemoveAll();
|
TvCtrlPointTimerLoopRun = 0;
|
||||||
UpnpUnRegisterClient( ctrlpt_handle );
|
TvCtrlPointRemoveAll();
|
||||||
UpnpFinish();
|
UpnpUnRegisterClient( ctrlpt_handle );
|
||||||
SampleUtil_Finish();
|
UpnpFinish();
|
||||||
|
SampleUtil_Finish();
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,65 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPNP_TV_CTRLPT_H
|
#ifndef UPNP_TV_CTRLPT_H
|
||||||
#define UPNP_TV_CTRLPT_H
|
#define UPNP_TV_CTRLPT_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
#include "sample_util.h"
|
||||||
|
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
#include "sample_util.h"
|
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/* Do not #include <unistd.h> */
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define TV_SERVICE_SERVCOUNT 2
|
#define TV_SERVICE_SERVCOUNT 2
|
||||||
#define TV_SERVICE_CONTROL 0
|
#define TV_SERVICE_CONTROL 0
|
||||||
@@ -68,12 +78,12 @@ extern "C" {
|
|||||||
|
|
||||||
#define TV_MAX_VAL_LEN 5
|
#define TV_MAX_VAL_LEN 5
|
||||||
|
|
||||||
#define TV_SUCCESS 0
|
#define TV_SUCCESS 0
|
||||||
#define TV_ERROR (-1)
|
#define TV_ERROR (-1)
|
||||||
#define TV_WARNING 1
|
#define TV_WARNING 1
|
||||||
|
|
||||||
/* This should be the maximum VARCOUNT from above */
|
/* 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 TvDeviceType[];
|
||||||
extern char *TvServiceType[];
|
extern char *TvServiceType[];
|
||||||
@@ -110,11 +120,11 @@ extern ithread_mutex_t DeviceListMutex;
|
|||||||
|
|
||||||
extern UpnpClient_Handle ctrlpt_handle;
|
extern UpnpClient_Handle ctrlpt_handle;
|
||||||
|
|
||||||
void TvCtrlPointPrintHelp( void );
|
void TvCtrlPointPrintHelp();
|
||||||
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
|
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
|
||||||
int TvCtrlPointRemoveDevice(char*);
|
int TvCtrlPointRemoveDevice(const char *);
|
||||||
int TvCtrlPointRemoveAll( void );
|
int TvCtrlPointRemoveAll();
|
||||||
int TvCtrlPointRefresh( void );
|
int TvCtrlPointRefresh();
|
||||||
|
|
||||||
|
|
||||||
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
|
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
|
||||||
@@ -140,11 +150,11 @@ int TvCtrlPointGetBrightness(int);
|
|||||||
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
||||||
int TvCtrlPointPrintList( void );
|
int TvCtrlPointPrintList( void );
|
||||||
int TvCtrlPointPrintDevice(int);
|
int TvCtrlPointPrintDevice(int);
|
||||||
void TvCtrlPointAddDevice (IXML_Document *, char *, int);
|
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
||||||
void TvCtrlPointHandleGetVar(char *,char *,DOMString);
|
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
||||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||||
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
|
void TvCtrlPointHandleEvent(const UpnpString *, int, IXML_Document *);
|
||||||
void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
|
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
||||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||||
void TvCtrlPointVerifyTimeouts(int);
|
void TvCtrlPointVerifyTimeouts(int);
|
||||||
void TvCtrlPointPrintCommands( void );
|
void TvCtrlPointPrintCommands( void );
|
||||||
|
|||||||
@@ -1,36 +1,41 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "upnp_tv_device.h"
|
#include "upnp_tv_device.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_WEB_DIR "./web"
|
#define DEFAULT_WEB_DIR "./web"
|
||||||
|
|
||||||
#define DESC_URL_SIZE 200
|
#define DESC_URL_SIZE 200
|
||||||
@@ -178,7 +183,6 @@ SetServiceTable( IN int serviceType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return SetActionTable( serviceType, out );
|
return SetActionTable( serviceType, out );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -249,7 +253,6 @@ SetActionTable( IN int serviceType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -366,61 +369,68 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
|||||||
* sr_event -- The subscription request event structure
|
* sr_event -- The subscription request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||||
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
|
||||||
*sr_event )
|
|
||||||
{
|
{
|
||||||
unsigned int i = 0; //,j=0;
|
unsigned int i = 0;
|
||||||
|
//unsigned int j = 0;
|
||||||
|
int cmp1 = 0;
|
||||||
|
int cmp2 = 0;
|
||||||
|
const char *l_serviceId = NULL;
|
||||||
|
const char *l_udn = NULL;
|
||||||
|
const char *l_sid = NULL;
|
||||||
|
// IXML_Document *PropSet = NULL;
|
||||||
|
|
||||||
// IXML_Document *PropSet=NULL;
|
// lock state mutex
|
||||||
|
ithread_mutex_lock( &TVDevMutex );
|
||||||
|
|
||||||
//lock state mutex
|
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||||
ithread_mutex_lock( &TVDevMutex );
|
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||||
|
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||||
|
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||||
|
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||||
|
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||||
|
if (cmp1 == 0 && cmp2 == 0) {
|
||||||
|
#if 0
|
||||||
|
PropSet = NULL;
|
||||||
|
|
||||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
|
||||||
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
|
// add each variable to the property set
|
||||||
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
|
// for initial state dump
|
||||||
== 0 ) ) {
|
UpnpAddToPropertySet(
|
||||||
|
&PropSet,
|
||||||
|
tv_service_table[i].VariableName[j],
|
||||||
|
tv_service_table[i].VariableStrVal[j]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// dump initial state
|
||||||
PropSet = NULL;
|
UpnpAcceptSubscriptionExt(
|
||||||
|
device_handle,
|
||||||
|
l_udn,
|
||||||
|
l_serviceId,
|
||||||
|
PropSet,
|
||||||
|
l_sid);
|
||||||
|
// free document
|
||||||
|
Document_free(PropSet);
|
||||||
|
#endif
|
||||||
|
UpnpAcceptSubscription(
|
||||||
|
device_handle,
|
||||||
|
l_udn,
|
||||||
|
l_serviceId,
|
||||||
|
(const char **)tv_service_table[i].
|
||||||
|
VariableName,
|
||||||
|
(const char **)tv_service_table[i].
|
||||||
|
VariableStrVal,
|
||||||
|
tv_service_table[i].VariableCount,
|
||||||
|
l_sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (j=0; j< tv_service_table[i].VariableCount; j++)
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
{
|
|
||||||
//add each variable to the property set
|
|
||||||
//for initial state dump
|
|
||||||
UpnpAddToPropertySet(&PropSet,
|
|
||||||
tv_service_table[i].VariableName[j],
|
|
||||||
tv_service_table[i].VariableStrVal[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//dump initial state
|
return 1;
|
||||||
UpnpAcceptSubscriptionExt(device_handle, sr_event->UDN,
|
|
||||||
sr_event->ServiceId,
|
|
||||||
PropSet,sr_event->Sid);
|
|
||||||
//free document
|
|
||||||
Document_free(PropSet);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
UpnpAcceptSubscription( device_handle,
|
|
||||||
sr_event->UDN,
|
|
||||||
sr_event->ServiceId,
|
|
||||||
( const char ** )tv_service_table[i].
|
|
||||||
VariableName,
|
|
||||||
( const char ** )tv_service_table[i].
|
|
||||||
VariableStrVal,
|
|
||||||
tv_service_table[i].VariableCount,
|
|
||||||
sr_event->Sid );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ithread_mutex_unlock( &TVDevMutex );
|
|
||||||
|
|
||||||
return ( 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleGetVarRequest
|
* TvDeviceHandleGetVarRequest
|
||||||
*
|
*
|
||||||
@@ -434,31 +444,32 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||||
*cgv_event )
|
|
||||||
{
|
{
|
||||||
unsigned int i = 0,
|
unsigned int i = 0;
|
||||||
j = 0;
|
unsigned int j = 0;
|
||||||
int getvar_succeeded = 0;
|
int getvar_succeeded = 0;
|
||||||
|
|
||||||
cgv_event->CurrentVal = NULL;
|
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||||
|
|
||||||
ithread_mutex_lock( &TVDevMutex );
|
ithread_mutex_lock( &TVDevMutex );
|
||||||
|
|
||||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||||
//check udn and service id
|
// check udn and service id
|
||||||
if( ( strcmp( cgv_event->DevUDN, tv_service_table[i].UDN ) == 0 )
|
const char *devUDN =
|
||||||
&&
|
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||||
( strcmp( cgv_event->ServiceID, tv_service_table[i].ServiceId )
|
const char *serviceID =
|
||||||
== 0 ) ) {
|
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||||
//check variable name
|
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||||
|
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
|
||||||
|
// check variable name
|
||||||
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
||||||
if( strcmp( cgv_event->StateVarName,
|
const char *stateVarName =
|
||||||
tv_service_table[i].VariableName[j] ) == 0 ) {
|
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||||
|
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
|
||||||
getvar_succeeded = 1;
|
getvar_succeeded = 1;
|
||||||
cgv_event->CurrentVal =
|
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||||
ixmlCloneDOMString( tv_service_table[i].
|
tv_service_table[i].VariableStrVal[j] );
|
||||||
VariableStrVal[j] );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,19 +477,19 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( getvar_succeeded ) {
|
if( getvar_succeeded ) {
|
||||||
cgv_event->ErrCode = UPNP_E_SUCCESS;
|
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print
|
SampleUtil_Print(
|
||||||
( "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" );
|
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||||
SampleUtil_Print( " Unknown variable name = %s\n",
|
" Unknown variable name = %s\n",
|
||||||
cgv_event->StateVarName );
|
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
|
||||||
cgv_event->ErrCode = 404;
|
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||||
strcpy( cgv_event->ErrStr, "Invalid Variable" );
|
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_unlock( &TVDevMutex );
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
|
|
||||||
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
|
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -494,9 +505,8 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Defaults if action not found
|
Defaults if action not found
|
||||||
*/
|
*/
|
||||||
@@ -505,51 +515,38 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
int service = -1;
|
int service = -1;
|
||||||
int retCode = 0;
|
int retCode = 0;
|
||||||
char *errorString = NULL;
|
char *errorString = NULL;
|
||||||
|
const char *devUDN = NULL;
|
||||||
|
const char *serviceID = NULL;
|
||||||
|
const char *actionName = NULL;
|
||||||
|
IXML_Document *actionResult = NULL;
|
||||||
|
|
||||||
ca_event->ErrCode = 0;
|
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||||
ca_event->ActionResult = NULL;
|
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||||
|
|
||||||
if( ( strcmp( ca_event->DevUDN,
|
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||||
tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||||
( strcmp
|
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||||
( ca_event->ServiceID,
|
if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
||||||
tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
( strcmp( serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
||||||
/*
|
/* Request for action in the TvDevice Control Service */
|
||||||
Request for action in the TvDevice Control Service
|
|
||||||
*/
|
|
||||||
service = TV_SERVICE_CONTROL;
|
service = TV_SERVICE_CONTROL;
|
||||||
} else if( ( strcmp( ca_event->DevUDN,
|
} else if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) &&
|
||||||
tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 )
|
( strcmp( serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == 0 ) ) {
|
||||||
&&
|
/* Request for action in the TvDevice Picture Service */
|
||||||
( strcmp
|
|
||||||
( ca_event->ServiceID,
|
|
||||||
tv_service_table[TV_SERVICE_PICTURE].ServiceId ) ==
|
|
||||||
0 ) ) {
|
|
||||||
/*
|
|
||||||
Request for action in the TvDevice Picture Service
|
|
||||||
*/
|
|
||||||
service = TV_SERVICE_PICTURE;
|
service = TV_SERVICE_PICTURE;
|
||||||
}
|
}
|
||||||
//Find and call appropriate procedure based on action name
|
/* Find and call appropriate procedure based on action name
|
||||||
//Each action name has an associated procedure stored in the
|
* Each action name has an associated procedure stored in the
|
||||||
//service table. These are set at initialization.
|
* service table. These are set at initialization. */
|
||||||
|
for( i = 0; i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL; i++ ) {
|
||||||
for( i = 0; ( ( i < TV_MAXACTIONS ) &&
|
if( !strcmp( actionName, tv_service_table[service].ActionNames[i] ) ) {
|
||||||
( tv_service_table[service].ActionNames[i] != NULL ) );
|
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[TV_CONTROL_POWER], "1" ) ) ||
|
||||||
i++ ) {
|
( !strcmp( actionName, "PowerOn" ) ) ) {
|
||||||
|
retCode = tv_service_table[service].actions[i](
|
||||||
if( !strcmp( ca_event->ActionName,
|
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||||
tv_service_table[service].ActionNames[i] ) ) {
|
&actionResult,
|
||||||
|
&errorString );
|
||||||
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].
|
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||||
VariableStrVal[TV_CONTROL_POWER], "1" ) )
|
|
||||||
|| ( !strcmp( ca_event->ActionName, "PowerOn" ) ) ) {
|
|
||||||
retCode =
|
|
||||||
tv_service_table[service].actions[i] ( ca_event->
|
|
||||||
ActionRequest,
|
|
||||||
&ca_event->
|
|
||||||
ActionResult,
|
|
||||||
&errorString );
|
|
||||||
} else {
|
} else {
|
||||||
errorString = "Power is Off";
|
errorString = "Power is Off";
|
||||||
retCode = UPNP_E_INTERNAL_ERROR;
|
retCode = UPNP_E_INTERNAL_ERROR;
|
||||||
@@ -560,25 +557,25 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !action_found ) {
|
if( !action_found ) {
|
||||||
ca_event->ActionResult = NULL;
|
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||||
strcpy( ca_event->ErrStr, "Invalid Action" );
|
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
|
||||||
ca_event->ErrCode = 401;
|
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||||
} else {
|
} else {
|
||||||
if( retCode == UPNP_E_SUCCESS ) {
|
if( retCode == UPNP_E_SUCCESS ) {
|
||||||
ca_event->ErrCode = UPNP_E_SUCCESS;
|
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
//copy the error string
|
// copy the error string
|
||||||
strcpy( ca_event->ErrStr, errorString );
|
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
|
||||||
switch ( retCode ) {
|
switch ( retCode ) {
|
||||||
case UPNP_E_INVALID_PARAM:
|
case UPNP_E_INVALID_PARAM:
|
||||||
{
|
{
|
||||||
ca_event->ErrCode = 402;
|
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UPNP_E_INTERNAL_ERROR:
|
case UPNP_E_INTERNAL_ERROR:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ca_event->ErrCode = 501;
|
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +583,7 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( ca_event->ErrCode );
|
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -649,7 +646,6 @@ TvDeviceSetServiceTableVar( IN unsigned int service,
|
|||||||
ithread_mutex_unlock( &TVDevMutex );
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
|
|
||||||
return ( 1 );
|
return ( 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -672,7 +668,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
|
|
||||||
if( on != POWER_ON && on != POWER_OFF ) {
|
if( on != POWER_ON && on != POWER_OFF ) {
|
||||||
SampleUtil_Print( "error: can't set power to value %d\n", on );
|
SampleUtil_Print( "error: can't set power to value %d\n", on );
|
||||||
return ( 0 );
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -683,7 +679,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER,
|
ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER,
|
||||||
value );
|
value );
|
||||||
|
|
||||||
return ( ret );
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -700,9 +696,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDevicePowerOn( IN IXML_Document * in,
|
TvDevicePowerOn( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
( *errorString ) = NULL;
|
( *errorString ) = NULL;
|
||||||
@@ -722,7 +716,6 @@ TvDevicePowerOn( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -740,7 +733,7 @@ TvDevicePowerOn( IN IXML_Document * in,
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDevicePowerOff( IN IXML_Document * in,
|
TvDevicePowerOff( IN IXML_Document * in,
|
||||||
OUT IXML_Document ** out,
|
OUT IXML_Document **out,
|
||||||
OUT char **errorString )
|
OUT char **errorString )
|
||||||
{
|
{
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -779,11 +772,8 @@ TvDevicePowerOff( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetChannel( IN IXML_Document * in,
|
TvDeviceSetChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
@@ -828,7 +818,6 @@ TvDeviceSetChannel( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -846,13 +835,10 @@ TvDeviceSetChannel( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementChannel( IN int incr,
|
IncrementChannel( IN int incr, IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curchannel,
|
int curchannel;
|
||||||
newchannel;
|
int newchannel;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
@@ -914,12 +900,9 @@ IncrementChannel( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseChannel( IN IXML_Document * in,
|
TvDeviceDecreaseChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementChannel( -1, in, out, errorString );
|
return IncrementChannel( -1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -936,12 +919,9 @@ TvDeviceDecreaseChannel( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseChannel( IN IXML_Document * in,
|
TvDeviceIncreaseChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementChannel( 1, in, out, errorString );
|
return IncrementChannel( 1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -960,13 +940,9 @@ TvDeviceIncreaseChannel( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetVolume( IN IXML_Document * in,
|
TvDeviceSetVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int volume = 0;
|
int volume = 0;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1007,7 +983,6 @@ TvDeviceSetVolume( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1026,10 +1001,7 @@ TvDeviceSetVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementVolume( IN int incr,
|
IncrementVolume( IN int incr, IN IXML_Document *in,OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curvolume,
|
int curvolume,
|
||||||
newvolume;
|
newvolume;
|
||||||
@@ -1066,8 +1038,7 @@ IncrementVolume( IN int incr,
|
|||||||
TV_CONTROL_VOLUME, value ) ) {
|
TV_CONTROL_VOLUME, value ) ) {
|
||||||
if( UpnpAddToActionResponse( out, actionName,
|
if( UpnpAddToActionResponse( out, actionName,
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
"Volume", value ) != UPNP_E_SUCCESS )
|
"Volume", value ) != UPNP_E_SUCCESS ) {
|
||||||
{
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
@@ -1077,7 +1048,6 @@ IncrementVolume( IN int incr,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1094,13 +1064,9 @@ IncrementVolume( IN int incr,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseVolume( IN IXML_Document * in,
|
TvDeviceIncreaseVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementVolume( 1, in, out, errorString );
|
return IncrementVolume( 1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1117,13 +1083,9 @@ TvDeviceIncreaseVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseVolume( IN IXML_Document * in,
|
TvDeviceDecreaseVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementVolume( -1, in, out, errorString );
|
return IncrementVolume( -1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1142,13 +1104,9 @@ TvDeviceDecreaseVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetColor( IN IXML_Document * in,
|
TvDeviceSetColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int color = 0;
|
int color = 0;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1188,7 +1146,6 @@ TvDeviceSetColor( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1205,16 +1162,11 @@ TvDeviceSetColor( IN IXML_Document * in,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
IncrementColor( IN int incr,
|
IncrementColor( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curcolor,
|
int curcolor;
|
||||||
newcolor;
|
int newcolor;
|
||||||
|
|
||||||
char *actionName;
|
char *actionName;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1272,11 +1224,8 @@ IncrementColor( IN int incr,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseColor( IN IXML_Document * in,
|
TvDeviceDecreaseColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementColor( -1, in, out, errorString );
|
return IncrementColor( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1293,11 +1242,8 @@ TvDeviceDecreaseColor( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseColor( IN IXML_Document * in,
|
TvDeviceIncreaseColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementColor( 1, in, out, errorString );
|
return IncrementColor( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,13 +1263,9 @@ TvDeviceIncreaseColor( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetTint( IN IXML_Document * in,
|
TvDeviceSetTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int tint = -1;
|
int tint = -1;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1382,14 +1324,10 @@ TvDeviceSetTint( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementTint( IN int incr,
|
IncrementTint( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curtint,
|
int curtint;
|
||||||
newtint;
|
int newtint;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1432,7 +1370,6 @@ IncrementTint( IN int incr,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1449,11 +1386,8 @@ IncrementTint( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseTint( IN IXML_Document * in,
|
TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementTint( 1, in, out, errorString );
|
return IncrementTint( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1471,11 +1405,8 @@ TvDeviceIncreaseTint( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseTint( IN IXML_Document * in,
|
TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementTint( -1, in, out, errorString );
|
return IncrementTint( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1495,11 +1426,8 @@ TvDeviceDecreaseTint( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetContrast( IN IXML_Document * in,
|
TvDeviceSetContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int contrast = -1;
|
int contrast = -1;
|
||||||
|
|
||||||
@@ -1560,14 +1488,10 @@ TvDeviceSetContrast( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementContrast( IN int incr,
|
IncrementContrast( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curcontrast,
|
int curcontrast;
|
||||||
newcontrast;
|
int newcontrast;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1629,11 +1553,8 @@ IncrementContrast( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseContrast( IN IXML_Document * in,
|
TvDeviceIncreaseContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementContrast( 1, in, out, errorString );
|
return IncrementContrast( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1651,9 +1572,7 @@ TvDeviceIncreaseContrast( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseContrast( IXML_Document * in,
|
TvDeviceDecreaseContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IXML_Document ** out,
|
|
||||||
char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementContrast( -1, in, out, errorString );
|
return IncrementContrast( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1671,11 +1590,8 @@ TvDeviceDecreaseContrast( IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetBrightness( IN IXML_Document * in,
|
TvDeviceSetBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int brightness = -1;
|
int brightness = -1;
|
||||||
|
|
||||||
@@ -1718,7 +1634,6 @@ TvDeviceSetBrightness( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1736,13 +1651,10 @@ TvDeviceSetBrightness( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementBrightness( IN int incr,
|
IncrementBrightness( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curbrightness,
|
int curbrightness;
|
||||||
newbrightness;
|
int newbrightness;
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1803,9 +1715,7 @@ IncrementBrightness( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseBrightness( IN IXML_Document * in,
|
TvDeviceIncreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementBrightness( 1, in, out, errorString );
|
return IncrementBrightness( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1823,9 +1733,7 @@ TvDeviceIncreaseBrightness( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseBrightness( IN IXML_Document * in,
|
TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementBrightness( -1, in, out, errorString );
|
return IncrementBrightness( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1849,29 +1757,19 @@ TvDeviceDecreaseBrightness( IN IXML_Document * in,
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvDeviceCallbackEventHandler( Upnp_EventType EventType,
|
|
||||||
void *Event,
|
|
||||||
void *Cookie )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ( EventType ) {
|
switch ( EventType ) {
|
||||||
|
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
|
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||||
TvDeviceHandleSubscriptionRequest( ( struct
|
|
||||||
Upnp_Subscription_Request
|
|
||||||
* )Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||||
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
|
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
|
||||||
* )Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPNP_CONTROL_ACTION_REQUEST:
|
case UPNP_CONTROL_ACTION_REQUEST:
|
||||||
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
|
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
|
||||||
Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1890,17 +1788,14 @@ TvDeviceCallbackEventHandler( Upnp_EventType EventType,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SampleUtil_Print
|
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||||
( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
EventType );
|
||||||
EventType );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Print a summary of the event received */
|
||||||
Print a summary of the event received
|
|
||||||
*/
|
|
||||||
SampleUtil_PrintEvent( EventType, Event );
|
SampleUtil_PrintEvent( EventType, Event );
|
||||||
|
|
||||||
return ( 0 );
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1919,6 +1814,7 @@ TvDeviceStop()
|
|||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
SampleUtil_Finish();
|
SampleUtil_Finish();
|
||||||
ithread_mutex_destroy( &TVDevMutex );
|
ithread_mutex_destroy( &TVDevMutex );
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1951,7 +1847,6 @@ TvDeviceStart( char *ip_address,
|
|||||||
print_string pfun )
|
print_string pfun )
|
||||||
{
|
{
|
||||||
int ret = UPNP_E_SUCCESS;
|
int ret = UPNP_E_SUCCESS;
|
||||||
|
|
||||||
char desc_doc_url[DESC_URL_SIZE];
|
char desc_doc_url[DESC_URL_SIZE];
|
||||||
|
|
||||||
ithread_mutex_init( &TVDevMutex, NULL );
|
ithread_mutex_init( &TVDevMutex, NULL );
|
||||||
@@ -1963,19 +1858,15 @@ TvDeviceStart( char *ip_address,
|
|||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port );
|
||||||
|
|
||||||
if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) {
|
ret = UpnpInit( ip_address, port );
|
||||||
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
|
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ip_address == NULL ) {
|
ip_address = UpnpGetServerIpAddress();
|
||||||
ip_address = UpnpGetServerIpAddress();
|
port = UpnpGetServerPort();
|
||||||
}
|
|
||||||
|
|
||||||
if( port == 0 ) {
|
|
||||||
port = UpnpGetServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"UPnP Initialized\n"
|
"UPnP Initialized\n"
|
||||||
@@ -1995,12 +1886,12 @@ TvDeviceStart( char *ip_address,
|
|||||||
|
|
||||||
SampleUtil_Print( "Specifying the webserver root directory -- %s\n",
|
SampleUtil_Print( "Specifying the webserver root directory -- %s\n",
|
||||||
web_dir_path );
|
web_dir_path );
|
||||||
if( ( ret =
|
ret = UpnpSetWebServerRootDir( web_dir_path );
|
||||||
UpnpSetWebServerRootDir( web_dir_path ) ) != UPNP_E_SUCCESS ) {
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
SampleUtil_Print
|
SampleUtil_Print( "Error specifying webserver root directory -- %s: %d\n",
|
||||||
( "Error specifying webserver root directory -- %s: %d\n",
|
|
||||||
web_dir_path, ret );
|
web_dir_path, ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2009,12 +1900,12 @@ TvDeviceStart( char *ip_address,
|
|||||||
"\t with desc_doc_url: %s\n",
|
"\t with desc_doc_url: %s\n",
|
||||||
desc_doc_url );
|
desc_doc_url );
|
||||||
|
|
||||||
if( ( ret = UpnpRegisterRootDevice( desc_doc_url,
|
ret = UpnpRegisterRootDevice( desc_doc_url, TvDeviceCallbackEventHandler,
|
||||||
TvDeviceCallbackEventHandler,
|
&device_handle, &device_handle );
|
||||||
&device_handle, &device_handle ) )
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
!= UPNP_E_SUCCESS ) {
|
|
||||||
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
|
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
@@ -2022,17 +1913,17 @@ TvDeviceStart( char *ip_address,
|
|||||||
"Initializing State Table\n");
|
"Initializing State Table\n");
|
||||||
TvDeviceStateTableInit( desc_doc_url );
|
TvDeviceStateTableInit( desc_doc_url );
|
||||||
SampleUtil_Print("State Table Initialized\n");
|
SampleUtil_Print("State Table Initialized\n");
|
||||||
|
ret = UpnpSendAdvertisement( device_handle, default_advr_expire );
|
||||||
if( ( ret =
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
UpnpSendAdvertisement( device_handle, default_advr_expire ) )
|
|
||||||
!= UPNP_E_SUCCESS ) {
|
|
||||||
SampleUtil_Print( "Error sending advertisements : %d\n", ret );
|
SampleUtil_Print( "Error sending advertisements : %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SampleUtil_Print("Advertisements Sent\n");
|
SampleUtil_Print("Advertisements Sent\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +1,66 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPNP_TV_DEVICE_H
|
#ifndef UPNP_TV_DEVICE_H
|
||||||
#define UPNP_TV_DEVICE_H
|
#define UPNP_TV_DEVICE_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ithread.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <string.h>
|
|
||||||
#include "upnp.h"
|
|
||||||
#include "sample_util.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
|
//Color constants
|
||||||
#define MAX_COLOR 10
|
#define MAX_COLOR 10
|
||||||
#define MIN_COLOR 1
|
#define MIN_COLOR 1
|
||||||
@@ -148,8 +161,7 @@ extern char *TvServiceType[];
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
|
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
|
||||||
char **errorString);
|
|
||||||
|
|
||||||
/* Structure for storing Tv Service
|
/* Structure for storing Tv Service
|
||||||
identifiers and state table */
|
identifiers and state table */
|
||||||
@@ -193,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
|
|||||||
* struct TvService *out - service containing action table to set.
|
* struct TvService *out - service containing action table to set.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int SetActionTable(int serviceType, struct TvService * out);
|
int SetActionTable(int serviceType, struct TvService *out);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceStateTableInit
|
* TvDeviceStateTableInit
|
||||||
@@ -227,7 +239,7 @@ int TvDeviceStateTableInit(char*);
|
|||||||
* sr_event -- The subscription request event structure
|
* sr_event -- The subscription request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleGetVarRequest
|
* TvDeviceHandleGetVarRequest
|
||||||
@@ -241,7 +253,7 @@ int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
|||||||
* cgv_event -- The control get variable request event structure
|
* cgv_event -- The control get variable request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
|
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleActionRequest
|
* TvDeviceHandleActionRequest
|
||||||
@@ -255,7 +267,7 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
|
|||||||
* ca_event -- The control action request event structure
|
* ca_event -- The control action request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
|
int TvDeviceHandleActionRequest(UpnpActionRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceCallbackEventHandler
|
* TvDeviceCallbackEventHandler
|
||||||
@@ -313,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDevicePowerOff
|
* TvDevicePowerOff
|
||||||
@@ -329,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetChannel
|
* TvDeviceSetChannel
|
||||||
@@ -347,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseChannel
|
* TvDeviceIncreaseChannel
|
||||||
@@ -363,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseChannel
|
* TvDeviceDecreaseChannel
|
||||||
*
|
*
|
||||||
@@ -378,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetVolume
|
* TvDeviceSetVolume
|
||||||
*
|
*
|
||||||
@@ -395,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseVolume
|
* TvDeviceIncreaseVolume
|
||||||
@@ -411,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -428,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
//Picture Service Actions
|
//Picture Service Actions
|
||||||
@@ -449,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -465,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseColor
|
* TvDeviceDecreaseColor
|
||||||
@@ -480,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetTint
|
* TvDeviceSetTint
|
||||||
@@ -498,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseTint
|
* TvDeviceIncreaseTint
|
||||||
@@ -514,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseTint
|
* TvDeviceDecreaseTint
|
||||||
@@ -530,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* TvDeviceSetContrast
|
* TvDeviceSetContrast
|
||||||
@@ -548,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseContrast
|
* TvDeviceIncreaseContrast
|
||||||
@@ -565,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseContrast
|
* TvDeviceDecreaseContrast
|
||||||
*
|
*
|
||||||
@@ -580,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetBrightness
|
* TvDeviceSetBrightness
|
||||||
@@ -595,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* brightness -- The brightness value to change to.
|
* brightness -- The brightness value to change to.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseBrightness
|
* TvDeviceIncreaseBrightness
|
||||||
@@ -611,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseBrightness
|
* TvDeviceDecreaseBrightness
|
||||||
@@ -626,8 +619,7 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
||||||
char *web_dir_path, print_string pfun);
|
char *web_dir_path, print_string pfun);
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
@@ -401,29 +401,29 @@ TvCtrlPointProcessCommand( char *cmdline )
|
|||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main( int argc, char **argv )
|
||||||
main( int argc,
|
|
||||||
char **argv )
|
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
ithread_t cmdloop_thread;
|
ithread_t cmdloop_thread;
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
#else
|
||||||
int sig;
|
int sig;
|
||||||
sigset_t sigs_to_catch;
|
sigset_t sigs_to_catch;
|
||||||
#endif
|
#endif
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
|
||||||
rc = TvCtrlPointStart( linux_print, NULL );
|
rc = TvCtrlPointStart( linux_print, NULL );
|
||||||
if( rc != TV_SUCCESS ) {
|
if( rc != TV_SUCCESS ) {
|
||||||
SampleUtil_Print( "Error starting UPnP TV Control Point" );
|
SampleUtil_Print( "Error starting UPnP TV Control Point" );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
// start a command loop thread
|
/* start a command loop thread */
|
||||||
code =
|
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
|
||||||
ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
ithread_join(cmdloop_thread, NULL);
|
||||||
|
#else
|
||||||
/*
|
/*
|
||||||
Catch Ctrl-C and properly shutdown
|
Catch Ctrl-C and properly shutdown
|
||||||
*/
|
*/
|
||||||
@@ -431,11 +431,11 @@ main( int argc,
|
|||||||
sigaddset( &sigs_to_catch, SIGINT );
|
sigaddset( &sigs_to_catch, SIGINT );
|
||||||
sigwait( &sigs_to_catch, &sig );
|
sigwait( &sigs_to_catch, &sig );
|
||||||
|
|
||||||
SampleUtil_Print( "Shutting down on signal %d...", sig );
|
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
||||||
#else
|
|
||||||
ithread_join(cmdloop_thread, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = TvCtrlPointStop();
|
rc = TvCtrlPointStop();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,42 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "upnp_tv_ctrlpt.h"
|
#include "upnp_tv_ctrlpt.h"
|
||||||
|
|
||||||
/*
|
|
||||||
|
#include "upnp.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
Mutex for protecting the global device list
|
Mutex for protecting the global device list
|
||||||
in a multi-threaded, asynchronous environment.
|
in a multi-threaded, asynchronous environment.
|
||||||
All functions should lock this mutex before reading
|
All functions should lock this mutex before reading
|
||||||
@@ -48,7 +53,7 @@ char *TvServiceType[] = {
|
|||||||
};
|
};
|
||||||
char *TvServiceName[] = { "Control", "Picture" };
|
char *TvServiceName[] = { "Control", "Picture" };
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
Global arrays for storing variable names and counts for
|
Global arrays for storing variable names and counts for
|
||||||
TvControl and TvPicture services
|
TvControl and TvPicture services
|
||||||
*/
|
*/
|
||||||
@@ -59,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
|
|||||||
char TvVarCount[TV_SERVICE_SERVCOUNT] =
|
char TvVarCount[TV_SERVICE_SERVCOUNT] =
|
||||||
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
|
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
Timeout to request during subscriptions
|
Timeout to request during subscriptions
|
||||||
*/
|
*/
|
||||||
int default_timeout = 1801;
|
int default_timeout = 1801;
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
The first node in the global device list, or NULL if empty
|
The first node in the global device list, or NULL if empty
|
||||||
*/
|
*/
|
||||||
struct TvDeviceNode *GlobalDeviceList = NULL;
|
struct TvDeviceNode *GlobalDeviceList = NULL;
|
||||||
@@ -139,10 +144,10 @@ TvCtrlPointDeleteNode( struct TvDeviceNode *node )
|
|||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int
|
||||||
TvCtrlPointRemoveDevice( char *UDN )
|
TvCtrlPointRemoveDevice(const char *UDN)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *curdevnode,
|
struct TvDeviceNode *curdevnode;
|
||||||
*prevdevnode;
|
struct TvDeviceNode *prevdevnode;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
@@ -668,8 +673,8 @@ TvCtrlPointPrintDevice( int devnum )
|
|||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void
|
||||||
TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
TvCtrlPointAddDevice( IXML_Document *DescDoc,
|
||||||
char *location,
|
const char *location,
|
||||||
int expires )
|
int expires )
|
||||||
{
|
{
|
||||||
char *deviceType = NULL;
|
char *deviceType = NULL;
|
||||||
@@ -682,20 +687,19 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
|||||||
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
||||||
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL };
|
||||||
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
|
Upnp_SID eventSID[TV_SERVICE_SERVCOUNT];
|
||||||
int TimeOut[TV_SERVICE_SERVCOUNT] =
|
int TimeOut[TV_SERVICE_SERVCOUNT] = {
|
||||||
{ default_timeout, default_timeout };
|
default_timeout,
|
||||||
|
default_timeout };
|
||||||
struct TvDeviceNode *deviceNode;
|
struct TvDeviceNode *deviceNode;
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int service,
|
int service;
|
||||||
var;
|
int var;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
/*
|
/* Read key elements from description document */
|
||||||
Read key elements from description document
|
|
||||||
*/
|
|
||||||
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
|
UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" );
|
||||||
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
|
deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" );
|
||||||
friendlyName =
|
friendlyName =
|
||||||
@@ -703,9 +707,8 @@ TvCtrlPointAddDevice( IXML_Document * DescDoc,
|
|||||||
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
|
baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" );
|
||||||
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
|
relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" );
|
||||||
|
|
||||||
ret =
|
ret = UpnpResolveURL(
|
||||||
UpnpResolveURL( ( baseURL ? baseURL : location ), relURL,
|
( baseURL ? baseURL : location ), relURL, presURL);
|
||||||
presURL );
|
|
||||||
|
|
||||||
if( UPNP_E_SUCCESS != ret )
|
if( UPNP_E_SUCCESS != ret )
|
||||||
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
|
SampleUtil_Print( "Error generating presURL from %s + %s", baseURL,
|
||||||
@@ -939,34 +942,38 @@ TvStateUpdate( char *UDN,
|
|||||||
* changes -- The DOM document representing the changes
|
* changes -- The DOM document representing the changes
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleEvent(
|
||||||
TvCtrlPointHandleEvent( Upnp_SID sid,
|
const UpnpString *sid,
|
||||||
int evntkey,
|
int evntkey,
|
||||||
IXML_Document * changes )
|
IXML_Document *changes)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
|
const char *aux_sid = NULL;
|
||||||
|
|
||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock(&DeviceListMutex);
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while( tmpdevnode ) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
|
||||||
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
|
aux_sid = UpnpString_get_String(sid);
|
||||||
0 ) {
|
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
|
||||||
SampleUtil_Print( "Received Tv %s Event: %d for SID %s",
|
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
||||||
TvServiceName[service], evntkey, sid );
|
TvServiceName[service],
|
||||||
|
evntkey,
|
||||||
|
aux_sid);
|
||||||
|
TvStateUpdate(
|
||||||
|
tmpdevnode->device.UDN,
|
||||||
|
service,
|
||||||
|
changes,
|
||||||
|
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmpdevnode = tmpdevnode->next;
|
||||||
|
}
|
||||||
|
|
||||||
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
|
ithread_mutex_unlock(&DeviceListMutex);
|
||||||
( char ** )&tmpdevnode->device.
|
|
||||||
TvService[service].VariableStrVal );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmpdevnode = tmpdevnode->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
ithread_mutex_unlock( &DeviceListMutex );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@@ -983,10 +990,10 @@ TvCtrlPointHandleEvent( Upnp_SID sid,
|
|||||||
* timeout -- The new timeout for the subscription
|
* timeout -- The new timeout for the subscription
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleSubscribeUpdate(
|
||||||
TvCtrlPointHandleSubscribeUpdate( char *eventURL,
|
const char *eventURL,
|
||||||
Upnp_SID sid,
|
const Upnp_SID sid,
|
||||||
int timeout )
|
int timeout)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
@@ -1015,9 +1022,9 @@ TvCtrlPointHandleSubscribeUpdate( char *eventURL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TvCtrlPointHandleGetVar( char *controlURL,
|
TvCtrlPointHandleGetVar( const char *controlURL,
|
||||||
char *varName,
|
const char *varName,
|
||||||
DOMString varValue )
|
const DOMString varValue )
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
@@ -1026,14 +1033,11 @@ TvCtrlPointHandleGetVar( char *controlURL,
|
|||||||
ithread_mutex_lock( &DeviceListMutex );
|
ithread_mutex_lock( &DeviceListMutex );
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while( tmpdevnode ) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; service++) {
|
||||||
if( strcmp
|
if (strcmp(tmpdevnode->device.TvService[service].ControlURL, controlURL ) == 0 ) {
|
||||||
( tmpdevnode->device.TvService[service].ControlURL,
|
SampleUtil_StateUpdate(
|
||||||
controlURL ) == 0 ) {
|
varName, varValue, tmpdevnode->device.UDN, GET_VAR_COMPLETE );
|
||||||
SampleUtil_StateUpdate( varName, varValue,
|
|
||||||
tmpdevnode->device.UDN,
|
|
||||||
GET_VAR_COMPLETE );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1057,186 +1061,160 @@ TvCtrlPointHandleGetVar( char *controlURL,
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvCtrlPointCallbackEventHandler( Upnp_EventType EventType,
|
|
||||||
void *Event,
|
|
||||||
void *Cookie )
|
|
||||||
{
|
{
|
||||||
SampleUtil_PrintEvent( EventType, Event );
|
int errCode = 0;
|
||||||
|
|
||||||
switch ( EventType ) {
|
SampleUtil_PrintEvent(EventType, Event);
|
||||||
/*
|
switch ( EventType ) {
|
||||||
SSDP Stuff
|
/* SSDP Stuff */
|
||||||
*/
|
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
case UPNP_DISCOVERY_SEARCH_RESULT: {
|
||||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
|
||||||
{
|
IXML_Document *DescDoc = NULL;
|
||||||
struct Upnp_Discovery *d_event =
|
const char *location = NULL;
|
||||||
( struct Upnp_Discovery * )Event;
|
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||||
IXML_Document *DescDoc = NULL;
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
int ret;
|
SampleUtil_Print(
|
||||||
|
"Error in Discovery Callback -- %d", errCode);
|
||||||
|
}
|
||||||
|
|
||||||
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
|
location = UpnpString_get_String(UpnpDiscovery_get_Location(d_event));
|
||||||
SampleUtil_Print( "Error in Discovery Callback -- %d",
|
errCode = UpnpDownloadXmlDoc(location, &DescDoc);
|
||||||
d_event->ErrCode );
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
}
|
SampleUtil_Print(
|
||||||
|
"Error obtaining device description from %s -- error = %d",
|
||||||
|
location, errCode);
|
||||||
|
} else {
|
||||||
|
TvCtrlPointAddDevice(
|
||||||
|
DescDoc, location, UpnpDiscovery_get_Expires(d_event));
|
||||||
|
}
|
||||||
|
|
||||||
if( ( ret =
|
if( DescDoc ) {
|
||||||
UpnpDownloadXmlDoc( d_event->Location,
|
ixmlDocument_free(DescDoc);
|
||||||
&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( DescDoc )
|
TvCtrlPointPrintList();
|
||||||
ixmlDocument_free( DescDoc );
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
TvCtrlPointPrintList();
|
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
||||||
break;
|
/* Nothing to do here... */
|
||||||
}
|
break;
|
||||||
|
|
||||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT:
|
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
|
||||||
/*
|
UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
|
||||||
Nothing to do here...
|
int errCode = UpnpDiscovery_get_ErrCode(d_event);
|
||||||
*/
|
const char *deviceId = UpnpString_get_String(
|
||||||
break;
|
UpnpDiscovery_get_DeviceID(d_event));
|
||||||
|
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
{
|
SampleUtil_Print(
|
||||||
struct Upnp_Discovery *d_event =
|
"Error in Discovery ByeBye Callback -- %d", errCode);
|
||||||
( struct Upnp_Discovery * )Event;
|
}
|
||||||
|
|
||||||
if( d_event->ErrCode != UPNP_E_SUCCESS ) {
|
SampleUtil_Print("Received ByeBye for Device: %s", deviceId);
|
||||||
SampleUtil_Print
|
TvCtrlPointRemoveDevice(deviceId);
|
||||||
( "Error in Discovery ByeBye Callback -- %d",
|
|
||||||
d_event->ErrCode );
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print( "Received ByeBye for Device: %s",
|
SampleUtil_Print("After byebye:");
|
||||||
d_event->DeviceId );
|
TvCtrlPointPrintList();
|
||||||
TvCtrlPointRemoveDevice( d_event->DeviceId );
|
|
||||||
|
|
||||||
SampleUtil_Print( "After byebye:" );
|
break;
|
||||||
TvCtrlPointPrintList();
|
}
|
||||||
|
|
||||||
break;
|
/* SOAP Stuff */
|
||||||
}
|
case UPNP_CONTROL_ACTION_COMPLETE: {
|
||||||
|
UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
|
||||||
|
int errCode = UpnpActionComplete_get_ErrCode(a_event);
|
||||||
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Action Complete Callback -- %d",
|
||||||
|
errCode);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/* No need for any processing here, just print out results.
|
||||||
SOAP Stuff
|
* Service state table updates are handled by events. */
|
||||||
*/
|
|
||||||
case UPNP_CONTROL_ACTION_COMPLETE:
|
|
||||||
{
|
|
||||||
struct Upnp_Action_Complete *a_event =
|
|
||||||
( struct Upnp_Action_Complete * )Event;
|
|
||||||
|
|
||||||
if( a_event->ErrCode != UPNP_E_SUCCESS ) {
|
break;
|
||||||
SampleUtil_Print
|
}
|
||||||
( "Error in Action Complete Callback -- %d",
|
|
||||||
a_event->ErrCode );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
case UPNP_CONTROL_GET_VAR_COMPLETE: {
|
||||||
No need for any processing here, just print out results. Service state
|
UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
|
||||||
table updates are handled by events.
|
int errCode = UpnpStateVarComplete_get_ErrCode(sv_event);
|
||||||
*/
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Get Var Complete Callback -- %d",
|
||||||
|
errCode );
|
||||||
|
} else {
|
||||||
|
TvCtrlPointHandleGetVar(
|
||||||
|
UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(sv_event)),
|
||||||
|
UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(sv_event)),
|
||||||
|
UpnpStateVarComplete_get_CurrentVal(sv_event) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
/* GENA Stuff */
|
||||||
}
|
case UPNP_EVENT_RECEIVED: {
|
||||||
|
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||||
|
TvCtrlPointHandleEvent(
|
||||||
|
UpnpEvent_get_SID(e_event),
|
||||||
|
UpnpEvent_get_EventKey(e_event),
|
||||||
|
UpnpEvent_get_ChangedVariables(e_event));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case UPNP_CONTROL_GET_VAR_COMPLETE:
|
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
||||||
{
|
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
||||||
struct Upnp_State_Var_Complete *sv_event =
|
case UPNP_EVENT_RENEWAL_COMPLETE: {
|
||||||
( struct Upnp_State_Var_Complete * )Event;
|
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||||
|
errCode = UpnpEventSubscribe_get_ErrCode(es_event);
|
||||||
|
if (errCode != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print(
|
||||||
|
"Error in Event Subscribe Callback -- %d",
|
||||||
|
errCode);
|
||||||
|
} else {
|
||||||
|
TvCtrlPointHandleSubscribeUpdate(
|
||||||
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
|
UpnpString_get_String(UpnpEventSubscribe_get_SID(es_event)),
|
||||||
|
UpnpEventSubscribe_get_TimeOut(es_event));
|
||||||
|
}
|
||||||
|
|
||||||
if( sv_event->ErrCode != UPNP_E_SUCCESS ) {
|
break;
|
||||||
SampleUtil_Print
|
}
|
||||||
( "Error in Get Var Complete Callback -- %d",
|
|
||||||
sv_event->ErrCode );
|
|
||||||
} else {
|
|
||||||
TvCtrlPointHandleGetVar( sv_event->CtrlUrl,
|
|
||||||
sv_event->StateVarName,
|
|
||||||
sv_event->CurrentVal );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
case UPNP_EVENT_AUTORENEWAL_FAILED:
|
||||||
}
|
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: {
|
||||||
|
UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
|
||||||
|
int TimeOut = default_timeout;
|
||||||
|
Upnp_SID newSID;
|
||||||
|
|
||||||
/*
|
errCode = UpnpSubscribe(
|
||||||
GENA Stuff
|
ctrlpt_handle,
|
||||||
*/
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
case UPNP_EVENT_RECEIVED:
|
&TimeOut,
|
||||||
{
|
newSID);
|
||||||
struct Upnp_Event *e_event = ( struct Upnp_Event * )Event;
|
|
||||||
|
|
||||||
TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey,
|
if (errCode == UPNP_E_SUCCESS) {
|
||||||
e_event->ChangedVariables );
|
SampleUtil_Print("Subscribed to EventURL with SID=%s", newSID);
|
||||||
break;
|
TvCtrlPointHandleSubscribeUpdate(
|
||||||
}
|
UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(es_event)),
|
||||||
|
newSID,
|
||||||
|
TimeOut);
|
||||||
|
} else {
|
||||||
|
SampleUtil_Print("Error Subscribing to EventURL -- %d", errCode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case UPNP_EVENT_SUBSCRIBE_COMPLETE:
|
/* ignore these cases, since this is not a device */
|
||||||
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
case UPNP_EVENT_RENEWAL_COMPLETE:
|
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||||
{
|
case UPNP_CONTROL_ACTION_REQUEST:
|
||||||
struct Upnp_Event_Subscribe *es_event =
|
break;
|
||||||
( struct Upnp_Event_Subscribe * )Event;
|
}
|
||||||
|
|
||||||
if( es_event->ErrCode != UPNP_E_SUCCESS ) {
|
return 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
@@ -1320,12 +1298,12 @@ TvCtrlPointVerifyTimeouts( int incr )
|
|||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void *
|
static int TvCtrlPointTimerLoopRun = 1;
|
||||||
TvCtrlPointTimerLoop( void *args )
|
void *TvCtrlPointTimerLoop(void *args)
|
||||||
{
|
{
|
||||||
int incr = 30; // how often to verify the timeouts, in seconds
|
int incr = 30; // how often to verify the timeouts, in seconds
|
||||||
|
|
||||||
while( 1 ) {
|
while (TvCtrlPointTimerLoopRun) {
|
||||||
isleep( incr );
|
isleep( incr );
|
||||||
TvCtrlPointVerifyTimeouts( incr );
|
TvCtrlPointVerifyTimeouts( incr );
|
||||||
}
|
}
|
||||||
@@ -1348,70 +1326,70 @@ TvCtrlPointTimerLoop( void *args )
|
|||||||
* TV_SUCCESS if everything went well, else TV_ERROR
|
* TV_SUCCESS if everything went well, else TV_ERROR
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
|
||||||
TvCtrlPointStart( print_string printFunctionPtr,
|
|
||||||
state_update updateFunctionPtr )
|
|
||||||
{
|
{
|
||||||
ithread_t timer_thread;
|
ithread_t timer_thread;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char *ip_address = NULL;
|
char *ip_address = NULL;
|
||||||
|
|
||||||
SampleUtil_Initialize( printFunctionPtr );
|
SampleUtil_Initialize(printFunctionPtr);
|
||||||
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
|
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
|
||||||
|
|
||||||
ithread_mutex_init( &DeviceListMutex, 0 );
|
ithread_mutex_init(&DeviceListMutex, 0);
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"Initializing UPnP Sdk with\n"
|
"Initializing UPnP Sdk with\n"
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port);
|
||||||
|
|
||||||
rc = UpnpInit( ip_address, port );
|
rc = UpnpInit(ip_address, port);
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
|
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
return TV_ERROR;
|
return TV_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!ip_address) {
|
||||||
|
ip_address = UpnpGetServerIpAddress();
|
||||||
|
}
|
||||||
|
if (!port) {
|
||||||
|
port = UpnpGetServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL == ip_address ) {
|
SampleUtil_Print(
|
||||||
ip_address = UpnpGetServerIpAddress();
|
"UPnP Initialized\n"
|
||||||
}
|
"\tipaddress= %s port = %u\n",
|
||||||
if( 0 == port ) {
|
ip_address, port);
|
||||||
port = UpnpGetServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Registering Control Point");
|
||||||
"UPnP Initialized\n"
|
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
|
||||||
"\tipaddress= %s port = %u\n",
|
&ctrlpt_handle, &ctrlpt_handle);
|
||||||
ip_address, port );
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print( "Error registering CP: %d", rc );
|
||||||
|
UpnpFinish();
|
||||||
|
|
||||||
SampleUtil_Print( "Registering Control Point" );
|
return TV_ERROR;
|
||||||
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( "Control Point Registered" );
|
SampleUtil_Print("Control Point Registered");
|
||||||
|
|
||||||
TvCtrlPointRefresh();
|
TvCtrlPointRefresh();
|
||||||
|
|
||||||
// start a timer thread
|
/* start a timer thread */
|
||||||
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
|
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
|
||||||
|
ithread_detach(timer_thread);
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int TvCtrlPointStop(void)
|
||||||
TvCtrlPointStop( void )
|
|
||||||
{
|
{
|
||||||
TvCtrlPointRemoveAll();
|
TvCtrlPointTimerLoopRun = 0;
|
||||||
UpnpUnRegisterClient( ctrlpt_handle );
|
TvCtrlPointRemoveAll();
|
||||||
UpnpFinish();
|
UpnpUnRegisterClient( ctrlpt_handle );
|
||||||
SampleUtil_Finish();
|
UpnpFinish();
|
||||||
|
SampleUtil_Finish();
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,65 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPNP_TV_CTRLPT_H
|
#ifndef UPNP_TV_CTRLPT_H
|
||||||
#define UPNP_TV_CTRLPT_H
|
#define UPNP_TV_CTRLPT_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
#include "sample_util.h"
|
||||||
|
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
#include "sample_util.h"
|
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/* Do not #include <unistd.h> */
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define TV_SERVICE_SERVCOUNT 2
|
#define TV_SERVICE_SERVCOUNT 2
|
||||||
#define TV_SERVICE_CONTROL 0
|
#define TV_SERVICE_CONTROL 0
|
||||||
@@ -68,12 +78,12 @@ extern "C" {
|
|||||||
|
|
||||||
#define TV_MAX_VAL_LEN 5
|
#define TV_MAX_VAL_LEN 5
|
||||||
|
|
||||||
#define TV_SUCCESS 0
|
#define TV_SUCCESS 0
|
||||||
#define TV_ERROR (-1)
|
#define TV_ERROR (-1)
|
||||||
#define TV_WARNING 1
|
#define TV_WARNING 1
|
||||||
|
|
||||||
/* This should be the maximum VARCOUNT from above */
|
/* 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 TvDeviceType[];
|
||||||
extern char *TvServiceType[];
|
extern char *TvServiceType[];
|
||||||
@@ -110,11 +120,11 @@ extern ithread_mutex_t DeviceListMutex;
|
|||||||
|
|
||||||
extern UpnpClient_Handle ctrlpt_handle;
|
extern UpnpClient_Handle ctrlpt_handle;
|
||||||
|
|
||||||
void TvCtrlPointPrintHelp( void );
|
void TvCtrlPointPrintHelp();
|
||||||
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
|
int TvCtrlPointDeleteNode(struct TvDeviceNode*);
|
||||||
int TvCtrlPointRemoveDevice(char*);
|
int TvCtrlPointRemoveDevice(const char *);
|
||||||
int TvCtrlPointRemoveAll( void );
|
int TvCtrlPointRemoveAll();
|
||||||
int TvCtrlPointRefresh( void );
|
int TvCtrlPointRefresh();
|
||||||
|
|
||||||
|
|
||||||
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
|
int TvCtrlPointSendAction(int, int, char *, char **, char **, int);
|
||||||
@@ -140,11 +150,11 @@ int TvCtrlPointGetBrightness(int);
|
|||||||
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
int TvCtrlPointGetDevice(int, struct TvDeviceNode **);
|
||||||
int TvCtrlPointPrintList( void );
|
int TvCtrlPointPrintList( void );
|
||||||
int TvCtrlPointPrintDevice(int);
|
int TvCtrlPointPrintDevice(int);
|
||||||
void TvCtrlPointAddDevice (IXML_Document *, char *, int);
|
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
||||||
void TvCtrlPointHandleGetVar(char *,char *,DOMString);
|
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
||||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||||
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
|
void TvCtrlPointHandleEvent(const UpnpString *, int, IXML_Document *);
|
||||||
void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int);
|
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
||||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||||
void TvCtrlPointVerifyTimeouts(int);
|
void TvCtrlPointVerifyTimeouts(int);
|
||||||
void TvCtrlPointPrintCommands( void );
|
void TvCtrlPointPrintCommands( void );
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
@@ -130,7 +130,8 @@ int main( IN int argc, IN char **argv )
|
|||||||
*web_dir_path = NULL;
|
*web_dir_path = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
ithread_t cmdloop_thread;
|
ithread_t cmdloop_thread;
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
#else
|
||||||
int sig;
|
int sig;
|
||||||
sigset_t sigs_to_catch;
|
sigset_t sigs_to_catch;
|
||||||
#endif
|
#endif
|
||||||
@@ -178,7 +179,9 @@ int main( IN int argc, IN char **argv )
|
|||||||
/* start a command loop thread */
|
/* start a command loop thread */
|
||||||
code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, NULL );
|
code = ithread_create( &cmdloop_thread, NULL, TvDeviceCommandLoop, NULL );
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
|
ithread_join(cmdloop_thread, NULL);
|
||||||
|
#else
|
||||||
/*
|
/*
|
||||||
Catch Ctrl-C and properly shutdown
|
Catch Ctrl-C and properly shutdown
|
||||||
*/
|
*/
|
||||||
@@ -187,8 +190,6 @@ int main( IN int argc, IN char **argv )
|
|||||||
sigwait( &sigs_to_catch, &sig );
|
sigwait( &sigs_to_catch, &sig );
|
||||||
|
|
||||||
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
SampleUtil_Print( "Shutting down on signal %d...\n", sig );
|
||||||
#else
|
|
||||||
ithread_join(cmdloop_thread, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
rc = TvDeviceStop();
|
rc = TvDeviceStop();
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,47 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "upnp_tv_device.h"
|
#include "upnp_tv_device.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_WEB_DIR "./web"
|
#define DEFAULT_WEB_DIR "./web"
|
||||||
|
|
||||||
|
|
||||||
#define DESC_URL_SIZE 200
|
#define DESC_URL_SIZE 200
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Device type for tv device
|
Device type for tv device
|
||||||
*/
|
*/
|
||||||
@@ -180,7 +187,6 @@ SetServiceTable( IN int serviceType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return SetActionTable( serviceType, out );
|
return SetActionTable( serviceType, out );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -251,7 +257,6 @@ SetActionTable( IN int serviceType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -368,61 +373,68 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
|||||||
* sr_event -- The subscription request event structure
|
* sr_event -- The subscription request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||||
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
|
||||||
*sr_event )
|
|
||||||
{
|
{
|
||||||
unsigned int i = 0; //,j=0;
|
unsigned int i = 0;
|
||||||
|
//unsigned int j = 0;
|
||||||
|
int cmp1 = 0;
|
||||||
|
int cmp2 = 0;
|
||||||
|
const char *l_serviceId = NULL;
|
||||||
|
const char *l_udn = NULL;
|
||||||
|
const char *l_sid = NULL;
|
||||||
|
// IXML_Document *PropSet = NULL;
|
||||||
|
|
||||||
// IXML_Document *PropSet=NULL;
|
// lock state mutex
|
||||||
|
ithread_mutex_lock( &TVDevMutex );
|
||||||
|
|
||||||
//lock state mutex
|
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||||
ithread_mutex_lock( &TVDevMutex );
|
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||||
|
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||||
|
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||||
|
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||||
|
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||||
|
if (cmp1 == 0 && cmp2 == 0) {
|
||||||
|
#if 0
|
||||||
|
PropSet = NULL;
|
||||||
|
|
||||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
|
||||||
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
|
// add each variable to the property set
|
||||||
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
|
// for initial state dump
|
||||||
== 0 ) ) {
|
UpnpAddToPropertySet(
|
||||||
|
&PropSet,
|
||||||
|
tv_service_table[i].VariableName[j],
|
||||||
|
tv_service_table[i].VariableStrVal[j]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// dump initial state
|
||||||
PropSet = NULL;
|
UpnpAcceptSubscriptionExt(
|
||||||
|
device_handle,
|
||||||
|
l_udn,
|
||||||
|
l_serviceId,
|
||||||
|
PropSet,
|
||||||
|
l_sid);
|
||||||
|
// free document
|
||||||
|
Document_free(PropSet);
|
||||||
|
#endif
|
||||||
|
UpnpAcceptSubscription(
|
||||||
|
device_handle,
|
||||||
|
l_udn,
|
||||||
|
l_serviceId,
|
||||||
|
(const char **)tv_service_table[i].
|
||||||
|
VariableName,
|
||||||
|
(const char **)tv_service_table[i].
|
||||||
|
VariableStrVal,
|
||||||
|
tv_service_table[i].VariableCount,
|
||||||
|
l_sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (j=0; j< tv_service_table[i].VariableCount; j++)
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
{
|
|
||||||
//add each variable to the property set
|
|
||||||
//for initial state dump
|
|
||||||
UpnpAddToPropertySet(&PropSet,
|
|
||||||
tv_service_table[i].VariableName[j],
|
|
||||||
tv_service_table[i].VariableStrVal[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//dump initial state
|
return 1;
|
||||||
UpnpAcceptSubscriptionExt(device_handle, sr_event->UDN,
|
|
||||||
sr_event->ServiceId,
|
|
||||||
PropSet,sr_event->Sid);
|
|
||||||
//free document
|
|
||||||
Document_free(PropSet);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
UpnpAcceptSubscription( device_handle,
|
|
||||||
sr_event->UDN,
|
|
||||||
sr_event->ServiceId,
|
|
||||||
( const char ** )tv_service_table[i].
|
|
||||||
VariableName,
|
|
||||||
( const char ** )tv_service_table[i].
|
|
||||||
VariableStrVal,
|
|
||||||
tv_service_table[i].VariableCount,
|
|
||||||
sr_event->Sid );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ithread_mutex_unlock( &TVDevMutex );
|
|
||||||
|
|
||||||
return ( 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleGetVarRequest
|
* TvDeviceHandleGetVarRequest
|
||||||
*
|
*
|
||||||
@@ -436,31 +448,32 @@ TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
TvDeviceHandleGetVarRequest( INOUT UpnpStateVarRequest *cgv_event )
|
||||||
*cgv_event )
|
|
||||||
{
|
{
|
||||||
unsigned int i = 0,
|
unsigned int i = 0;
|
||||||
j = 0;
|
unsigned int j = 0;
|
||||||
int getvar_succeeded = 0;
|
int getvar_succeeded = 0;
|
||||||
|
|
||||||
cgv_event->CurrentVal = NULL;
|
UpnpStateVarRequest_set_CurrentVal(cgv_event, NULL);
|
||||||
|
|
||||||
ithread_mutex_lock( &TVDevMutex );
|
ithread_mutex_lock( &TVDevMutex );
|
||||||
|
|
||||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||||
//check udn and service id
|
// check udn and service id
|
||||||
if( ( strcmp( cgv_event->DevUDN, tv_service_table[i].UDN ) == 0 )
|
const char *devUDN =
|
||||||
&&
|
UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(cgv_event));
|
||||||
( strcmp( cgv_event->ServiceID, tv_service_table[i].ServiceId )
|
const char *serviceID =
|
||||||
== 0 ) ) {
|
UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(cgv_event));
|
||||||
//check variable name
|
if( ( strcmp( devUDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||||
|
( strcmp( serviceID, tv_service_table[i].ServiceId ) == 0 ) ) {
|
||||||
|
// check variable name
|
||||||
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
for( j = 0; j < tv_service_table[i].VariableCount; j++ ) {
|
||||||
if( strcmp( cgv_event->StateVarName,
|
const char *stateVarName =
|
||||||
tv_service_table[i].VariableName[j] ) == 0 ) {
|
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event));
|
||||||
|
if( strcmp( stateVarName, tv_service_table[i].VariableName[j] ) == 0 ) {
|
||||||
getvar_succeeded = 1;
|
getvar_succeeded = 1;
|
||||||
cgv_event->CurrentVal =
|
UpnpStateVarRequest_set_CurrentVal(cgv_event,
|
||||||
ixmlCloneDOMString( tv_service_table[i].
|
tv_service_table[i].VariableStrVal[j] );
|
||||||
VariableStrVal[j] );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,19 +481,19 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( getvar_succeeded ) {
|
if( getvar_succeeded ) {
|
||||||
cgv_event->ErrCode = UPNP_E_SUCCESS;
|
UpnpStateVarRequest_set_ErrCode(cgv_event, UPNP_E_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print
|
SampleUtil_Print(
|
||||||
( "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" );
|
"Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n"
|
||||||
SampleUtil_Print( " Unknown variable name = %s\n",
|
" Unknown variable name = %s\n",
|
||||||
cgv_event->StateVarName );
|
UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(cgv_event)) );
|
||||||
cgv_event->ErrCode = 404;
|
UpnpStateVarRequest_set_ErrCode(cgv_event, 404);
|
||||||
strcpy( cgv_event->ErrStr, "Invalid Variable" );
|
UpnpStateVarRequest_strcpy_ErrStr(cgv_event, "Invalid Variable" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ithread_mutex_unlock( &TVDevMutex );
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
|
|
||||||
return ( cgv_event->ErrCode == UPNP_E_SUCCESS );
|
return UpnpStateVarRequest_get_ErrCode(cgv_event) == UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -496,9 +509,8 @@ TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
TvDeviceHandleActionRequest( INOUT UpnpActionRequest *ca_event )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Defaults if action not found
|
Defaults if action not found
|
||||||
*/
|
*/
|
||||||
@@ -507,51 +519,38 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
int service = -1;
|
int service = -1;
|
||||||
int retCode = 0;
|
int retCode = 0;
|
||||||
char *errorString = NULL;
|
char *errorString = NULL;
|
||||||
|
const char *devUDN = NULL;
|
||||||
|
const char *serviceID = NULL;
|
||||||
|
const char *actionName = NULL;
|
||||||
|
IXML_Document *actionResult = NULL;
|
||||||
|
|
||||||
ca_event->ErrCode = 0;
|
UpnpActionRequest_set_ErrCode(ca_event, 0);
|
||||||
ca_event->ActionResult = NULL;
|
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||||
|
|
||||||
if( ( strcmp( ca_event->DevUDN,
|
devUDN = UpnpString_get_String(UpnpActionRequest_get_DevUDN( ca_event));
|
||||||
tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
serviceID = UpnpString_get_String(UpnpActionRequest_get_ServiceID( ca_event));
|
||||||
( strcmp
|
actionName = UpnpString_get_String(UpnpActionRequest_get_ActionName(ca_event));
|
||||||
( ca_event->ServiceID,
|
if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) &&
|
||||||
tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
( strcmp( serviceID, tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) {
|
||||||
/*
|
/* Request for action in the TvDevice Control Service */
|
||||||
Request for action in the TvDevice Control Service
|
|
||||||
*/
|
|
||||||
service = TV_SERVICE_CONTROL;
|
service = TV_SERVICE_CONTROL;
|
||||||
} else if( ( strcmp( ca_event->DevUDN,
|
} else if( ( strcmp( devUDN, tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) &&
|
||||||
tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 )
|
( strcmp( serviceID, tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == 0 ) ) {
|
||||||
&&
|
/* Request for action in the TvDevice Picture Service */
|
||||||
( strcmp
|
|
||||||
( ca_event->ServiceID,
|
|
||||||
tv_service_table[TV_SERVICE_PICTURE].ServiceId ) ==
|
|
||||||
0 ) ) {
|
|
||||||
/*
|
|
||||||
Request for action in the TvDevice Picture Service
|
|
||||||
*/
|
|
||||||
service = TV_SERVICE_PICTURE;
|
service = TV_SERVICE_PICTURE;
|
||||||
}
|
}
|
||||||
//Find and call appropriate procedure based on action name
|
/* Find and call appropriate procedure based on action name
|
||||||
//Each action name has an associated procedure stored in the
|
* Each action name has an associated procedure stored in the
|
||||||
//service table. These are set at initialization.
|
* service table. These are set at initialization. */
|
||||||
|
for( i = 0; i < TV_MAXACTIONS && tv_service_table[service].ActionNames[i] != NULL; i++ ) {
|
||||||
for( i = 0; ( ( i < TV_MAXACTIONS ) &&
|
if( !strcmp( actionName, tv_service_table[service].ActionNames[i] ) ) {
|
||||||
( tv_service_table[service].ActionNames[i] != NULL ) );
|
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[TV_CONTROL_POWER], "1" ) ) ||
|
||||||
i++ ) {
|
( !strcmp( actionName, "PowerOn" ) ) ) {
|
||||||
|
retCode = tv_service_table[service].actions[i](
|
||||||
if( !strcmp( ca_event->ActionName,
|
UpnpActionRequest_get_ActionRequest(ca_event),
|
||||||
tv_service_table[service].ActionNames[i] ) ) {
|
&actionResult,
|
||||||
|
&errorString );
|
||||||
if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL].
|
UpnpActionRequest_set_ActionResult(ca_event, actionResult);
|
||||||
VariableStrVal[TV_CONTROL_POWER], "1" ) )
|
|
||||||
|| ( !strcmp( ca_event->ActionName, "PowerOn" ) ) ) {
|
|
||||||
retCode =
|
|
||||||
tv_service_table[service].actions[i] ( ca_event->
|
|
||||||
ActionRequest,
|
|
||||||
&ca_event->
|
|
||||||
ActionResult,
|
|
||||||
&errorString );
|
|
||||||
} else {
|
} else {
|
||||||
errorString = "Power is Off";
|
errorString = "Power is Off";
|
||||||
retCode = UPNP_E_INTERNAL_ERROR;
|
retCode = UPNP_E_INTERNAL_ERROR;
|
||||||
@@ -562,25 +561,25 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !action_found ) {
|
if( !action_found ) {
|
||||||
ca_event->ActionResult = NULL;
|
UpnpActionRequest_set_ActionResult(ca_event, NULL);
|
||||||
strcpy( ca_event->ErrStr, "Invalid Action" );
|
UpnpActionRequest_strcpy_ErrStr(ca_event, "Invalid Action" );
|
||||||
ca_event->ErrCode = 401;
|
UpnpActionRequest_set_ErrCode(ca_event, 401);
|
||||||
} else {
|
} else {
|
||||||
if( retCode == UPNP_E_SUCCESS ) {
|
if( retCode == UPNP_E_SUCCESS ) {
|
||||||
ca_event->ErrCode = UPNP_E_SUCCESS;
|
UpnpActionRequest_set_ErrCode(ca_event, UPNP_E_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
//copy the error string
|
// copy the error string
|
||||||
strcpy( ca_event->ErrStr, errorString );
|
UpnpActionRequest_strcpy_ErrStr(ca_event, errorString );
|
||||||
switch ( retCode ) {
|
switch ( retCode ) {
|
||||||
case UPNP_E_INVALID_PARAM:
|
case UPNP_E_INVALID_PARAM:
|
||||||
{
|
{
|
||||||
ca_event->ErrCode = 402;
|
UpnpActionRequest_set_ErrCode(ca_event, 402);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UPNP_E_INTERNAL_ERROR:
|
case UPNP_E_INTERNAL_ERROR:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ca_event->ErrCode = 501;
|
UpnpActionRequest_set_ErrCode(ca_event, 501);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +587,7 @@ TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( ca_event->ErrCode );
|
return UpnpActionRequest_get_ErrCode(ca_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -651,7 +650,6 @@ TvDeviceSetServiceTableVar( IN unsigned int service,
|
|||||||
ithread_mutex_unlock( &TVDevMutex );
|
ithread_mutex_unlock( &TVDevMutex );
|
||||||
|
|
||||||
return ( 1 );
|
return ( 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -674,7 +672,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
|
|
||||||
if( on != POWER_ON && on != POWER_OFF ) {
|
if( on != POWER_ON && on != POWER_OFF ) {
|
||||||
SampleUtil_Print( "error: can't set power to value %d\n", on );
|
SampleUtil_Print( "error: can't set power to value %d\n", on );
|
||||||
return ( 0 );
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -685,7 +683,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER,
|
ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER,
|
||||||
value );
|
value );
|
||||||
|
|
||||||
return ( ret );
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -702,9 +700,7 @@ TvDeviceSetPower( IN int on )
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDevicePowerOn( IN IXML_Document * in,
|
TvDevicePowerOn( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
( *errorString ) = NULL;
|
( *errorString ) = NULL;
|
||||||
@@ -724,7 +720,6 @@ TvDevicePowerOn( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -742,7 +737,7 @@ TvDevicePowerOn( IN IXML_Document * in,
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDevicePowerOff( IN IXML_Document * in,
|
TvDevicePowerOff( IN IXML_Document * in,
|
||||||
OUT IXML_Document ** out,
|
OUT IXML_Document **out,
|
||||||
OUT char **errorString )
|
OUT char **errorString )
|
||||||
{
|
{
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -781,11 +776,8 @@ TvDevicePowerOff( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetChannel( IN IXML_Document * in,
|
TvDeviceSetChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
@@ -830,7 +822,6 @@ TvDeviceSetChannel( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -848,13 +839,10 @@ TvDeviceSetChannel( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementChannel( IN int incr,
|
IncrementChannel( IN int incr, IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curchannel,
|
int curchannel;
|
||||||
newchannel;
|
int newchannel;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
@@ -916,12 +904,9 @@ IncrementChannel( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseChannel( IN IXML_Document * in,
|
TvDeviceDecreaseChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementChannel( -1, in, out, errorString );
|
return IncrementChannel( -1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -938,12 +923,9 @@ TvDeviceDecreaseChannel( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseChannel( IN IXML_Document * in,
|
TvDeviceIncreaseChannel( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementChannel( 1, in, out, errorString );
|
return IncrementChannel( 1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -962,13 +944,9 @@ TvDeviceIncreaseChannel( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetVolume( IN IXML_Document * in,
|
TvDeviceSetVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int volume = 0;
|
int volume = 0;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1009,7 +987,6 @@ TvDeviceSetVolume( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1028,10 +1005,7 @@ TvDeviceSetVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementVolume( IN int incr,
|
IncrementVolume( IN int incr, IN IXML_Document *in,OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curvolume,
|
int curvolume,
|
||||||
newvolume;
|
newvolume;
|
||||||
@@ -1068,8 +1042,7 @@ IncrementVolume( IN int incr,
|
|||||||
TV_CONTROL_VOLUME, value ) ) {
|
TV_CONTROL_VOLUME, value ) ) {
|
||||||
if( UpnpAddToActionResponse( out, actionName,
|
if( UpnpAddToActionResponse( out, actionName,
|
||||||
TvServiceType[TV_SERVICE_CONTROL],
|
TvServiceType[TV_SERVICE_CONTROL],
|
||||||
"Volume", value ) != UPNP_E_SUCCESS )
|
"Volume", value ) != UPNP_E_SUCCESS ) {
|
||||||
{
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
@@ -1079,7 +1052,6 @@ IncrementVolume( IN int incr,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1096,13 +1068,9 @@ IncrementVolume( IN int incr,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseVolume( IN IXML_Document * in,
|
TvDeviceIncreaseVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementVolume( 1, in, out, errorString );
|
return IncrementVolume( 1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1119,13 +1087,9 @@ TvDeviceIncreaseVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseVolume( IN IXML_Document * in,
|
TvDeviceDecreaseVolume( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementVolume( -1, in, out, errorString );
|
return IncrementVolume( -1, in, out, errorString );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1144,13 +1108,9 @@ TvDeviceDecreaseVolume( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetColor( IN IXML_Document * in,
|
TvDeviceSetColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int color = 0;
|
int color = 0;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1190,7 +1150,6 @@ TvDeviceSetColor( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1207,16 +1166,11 @@ TvDeviceSetColor( IN IXML_Document * in,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
IncrementColor( IN int incr,
|
IncrementColor( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curcolor,
|
int curcolor;
|
||||||
newcolor;
|
int newcolor;
|
||||||
|
|
||||||
char *actionName;
|
char *actionName;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1274,11 +1228,8 @@ IncrementColor( IN int incr,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseColor( IN IXML_Document * in,
|
TvDeviceDecreaseColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementColor( -1, in, out, errorString );
|
return IncrementColor( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1295,11 +1246,8 @@ TvDeviceDecreaseColor( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseColor( IN IXML_Document * in,
|
TvDeviceIncreaseColor( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementColor( 1, in, out, errorString );
|
return IncrementColor( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,13 +1267,9 @@ TvDeviceIncreaseColor( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetTint( IN IXML_Document * in,
|
TvDeviceSetTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
int tint = -1;
|
int tint = -1;
|
||||||
|
|
||||||
( *out ) = NULL;
|
( *out ) = NULL;
|
||||||
@@ -1384,14 +1328,10 @@ TvDeviceSetTint( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementTint( IN int incr,
|
IncrementTint( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curtint,
|
int curtint;
|
||||||
newtint;
|
int newtint;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1434,7 +1374,6 @@ IncrementTint( IN int incr,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1451,11 +1390,8 @@ IncrementTint( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseTint( IN IXML_Document * in,
|
TvDeviceIncreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementTint( 1, in, out, errorString );
|
return IncrementTint( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1473,11 +1409,8 @@ TvDeviceIncreaseTint( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseTint( IN IXML_Document * in,
|
TvDeviceDecreaseTint( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementTint( -1, in, out, errorString );
|
return IncrementTint( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1497,11 +1430,8 @@ TvDeviceDecreaseTint( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetContrast( IN IXML_Document * in,
|
TvDeviceSetContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int contrast = -1;
|
int contrast = -1;
|
||||||
|
|
||||||
@@ -1562,14 +1492,10 @@ TvDeviceSetContrast( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementContrast( IN int incr,
|
IncrementContrast( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curcontrast,
|
int curcontrast;
|
||||||
newcontrast;
|
int newcontrast;
|
||||||
|
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1631,11 +1557,8 @@ IncrementContrast( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseContrast( IN IXML_Document * in,
|
TvDeviceIncreaseContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return IncrementContrast( 1, in, out, errorString );
|
return IncrementContrast( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1653,9 +1576,7 @@ TvDeviceIncreaseContrast( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseContrast( IXML_Document * in,
|
TvDeviceDecreaseContrast( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IXML_Document ** out,
|
|
||||||
char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementContrast( -1, in, out, errorString );
|
return IncrementContrast( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1673,11 +1594,8 @@ TvDeviceDecreaseContrast( IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceSetBrightness( IN IXML_Document * in,
|
TvDeviceSetBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
int brightness = -1;
|
int brightness = -1;
|
||||||
|
|
||||||
@@ -1720,7 +1638,6 @@ TvDeviceSetBrightness( IN IXML_Document * in,
|
|||||||
( *errorString ) = "Internal Error";
|
( *errorString ) = "Internal Error";
|
||||||
return UPNP_E_INTERNAL_ERROR;
|
return UPNP_E_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1738,13 +1655,10 @@ TvDeviceSetBrightness( IN IXML_Document * in,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
IncrementBrightness( IN int incr,
|
IncrementBrightness( IN int incr, IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
IN IXML_Document * in,
|
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
int curbrightness,
|
int curbrightness;
|
||||||
newbrightness;
|
int newbrightness;
|
||||||
char *actionName = NULL;
|
char *actionName = NULL;
|
||||||
char value[TV_MAX_VAL_LEN];
|
char value[TV_MAX_VAL_LEN];
|
||||||
|
|
||||||
@@ -1805,9 +1719,7 @@ IncrementBrightness( IN int incr,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceIncreaseBrightness( IN IXML_Document * in,
|
TvDeviceIncreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementBrightness( 1, in, out, errorString );
|
return IncrementBrightness( 1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1825,9 +1737,7 @@ TvDeviceIncreaseBrightness( IN IXML_Document * in,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceDecreaseBrightness( IN IXML_Document * in,
|
TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString )
|
||||||
OUT IXML_Document ** out,
|
|
||||||
OUT char **errorString )
|
|
||||||
{
|
{
|
||||||
return IncrementBrightness( -1, in, out, errorString );
|
return IncrementBrightness( -1, in, out, errorString );
|
||||||
}
|
}
|
||||||
@@ -1851,29 +1761,19 @@ TvDeviceDecreaseBrightness( IN IXML_Document * in,
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvDeviceCallbackEventHandler( Upnp_EventType EventType,
|
|
||||||
void *Event,
|
|
||||||
void *Cookie )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ( EventType ) {
|
switch ( EventType ) {
|
||||||
|
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
|
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||||
TvDeviceHandleSubscriptionRequest( ( struct
|
|
||||||
Upnp_Subscription_Request
|
|
||||||
* )Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||||
TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request
|
TvDeviceHandleGetVarRequest( (UpnpStateVarRequest *)Event );
|
||||||
* )Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPNP_CONTROL_ACTION_REQUEST:
|
case UPNP_CONTROL_ACTION_REQUEST:
|
||||||
TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * )
|
TvDeviceHandleActionRequest( (UpnpActionRequest *)Event );
|
||||||
Event );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1892,17 +1792,14 @@ TvDeviceCallbackEventHandler( Upnp_EventType EventType,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SampleUtil_Print
|
SampleUtil_Print( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
||||||
( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n",
|
EventType );
|
||||||
EventType );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Print a summary of the event received */
|
||||||
Print a summary of the event received
|
|
||||||
*/
|
|
||||||
SampleUtil_PrintEvent( EventType, Event );
|
SampleUtil_PrintEvent( EventType, Event );
|
||||||
|
|
||||||
return ( 0 );
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -1915,12 +1812,13 @@ TvDeviceCallbackEventHandler( Upnp_EventType EventType,
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
TvDeviceStop()
|
TvDeviceStop(void)
|
||||||
{
|
{
|
||||||
UpnpUnRegisterRootDevice( device_handle );
|
UpnpUnRegisterRootDevice( device_handle );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
SampleUtil_Finish();
|
SampleUtil_Finish();
|
||||||
ithread_mutex_destroy( &TVDevMutex );
|
ithread_mutex_destroy( &TVDevMutex );
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1953,7 +1851,6 @@ TvDeviceStart( char *ip_address,
|
|||||||
print_string pfun )
|
print_string pfun )
|
||||||
{
|
{
|
||||||
int ret = UPNP_E_SUCCESS;
|
int ret = UPNP_E_SUCCESS;
|
||||||
|
|
||||||
char desc_doc_url[DESC_URL_SIZE];
|
char desc_doc_url[DESC_URL_SIZE];
|
||||||
|
|
||||||
ithread_mutex_init( &TVDevMutex, NULL );
|
ithread_mutex_init( &TVDevMutex, NULL );
|
||||||
@@ -1965,16 +1862,14 @@ TvDeviceStart( char *ip_address,
|
|||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port );
|
||||||
|
|
||||||
if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) {
|
ret = UpnpInit( ip_address, port );
|
||||||
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
|
SampleUtil_Print( "Error with UpnpInit -- %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ip_address == NULL ) {
|
ip_address = UpnpGetServerIpAddress();
|
||||||
ip_address = UpnpGetServerIpAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
port = UpnpGetServerPort();
|
port = UpnpGetServerPort();
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
@@ -1995,12 +1890,12 @@ TvDeviceStart( char *ip_address,
|
|||||||
|
|
||||||
SampleUtil_Print( "Specifying the webserver root directory -- %s\n",
|
SampleUtil_Print( "Specifying the webserver root directory -- %s\n",
|
||||||
web_dir_path );
|
web_dir_path );
|
||||||
if( ( ret =
|
ret = UpnpSetWebServerRootDir( web_dir_path );
|
||||||
UpnpSetWebServerRootDir( web_dir_path ) ) != UPNP_E_SUCCESS ) {
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
SampleUtil_Print
|
SampleUtil_Print( "Error specifying webserver root directory -- %s: %d\n",
|
||||||
( "Error specifying webserver root directory -- %s: %d\n",
|
|
||||||
web_dir_path, ret );
|
web_dir_path, ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2009,12 +1904,12 @@ TvDeviceStart( char *ip_address,
|
|||||||
"\t with desc_doc_url: %s\n",
|
"\t with desc_doc_url: %s\n",
|
||||||
desc_doc_url );
|
desc_doc_url );
|
||||||
|
|
||||||
if( ( ret = UpnpRegisterRootDevice( desc_doc_url,
|
ret = UpnpRegisterRootDevice( desc_doc_url, TvDeviceCallbackEventHandler,
|
||||||
TvDeviceCallbackEventHandler,
|
&device_handle, &device_handle );
|
||||||
&device_handle, &device_handle ) )
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
!= UPNP_E_SUCCESS ) {
|
|
||||||
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
|
SampleUtil_Print( "Error registering the rootdevice : %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
@@ -2022,17 +1917,17 @@ TvDeviceStart( char *ip_address,
|
|||||||
"Initializing State Table\n");
|
"Initializing State Table\n");
|
||||||
TvDeviceStateTableInit( desc_doc_url );
|
TvDeviceStateTableInit( desc_doc_url );
|
||||||
SampleUtil_Print("State Table Initialized\n");
|
SampleUtil_Print("State Table Initialized\n");
|
||||||
|
ret = UpnpSendAdvertisement( device_handle, default_advr_expire );
|
||||||
if( ( ret =
|
if( ret != UPNP_E_SUCCESS ) {
|
||||||
UpnpSendAdvertisement( device_handle, default_advr_expire ) )
|
|
||||||
!= UPNP_E_SUCCESS ) {
|
|
||||||
SampleUtil_Print( "Error sending advertisements : %d\n", ret );
|
SampleUtil_Print( "Error sending advertisements : %d\n", ret );
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SampleUtil_Print("Advertisements Sent\n");
|
SampleUtil_Print("Advertisements Sent\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +1,66 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPNP_TV_DEVICE_H
|
#ifndef UPNP_TV_DEVICE_H
|
||||||
#define UPNP_TV_DEVICE_H
|
#define UPNP_TV_DEVICE_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ithread.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <string.h>
|
|
||||||
#include "upnp.h"
|
|
||||||
#include "sample_util.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
|
//Color constants
|
||||||
#define MAX_COLOR 10
|
#define MAX_COLOR 10
|
||||||
#define MIN_COLOR 1
|
#define MIN_COLOR 1
|
||||||
@@ -148,8 +161,7 @@ extern char *TvServiceType[];
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out,
|
typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, char **errorString);
|
||||||
char **errorString);
|
|
||||||
|
|
||||||
/* Structure for storing Tv Service
|
/* Structure for storing Tv Service
|
||||||
identifiers and state table */
|
identifiers and state table */
|
||||||
@@ -193,7 +205,7 @@ extern ithread_mutex_t TVDevMutex;
|
|||||||
* struct TvService *out - service containing action table to set.
|
* struct TvService *out - service containing action table to set.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int SetActionTable(int serviceType, struct TvService * out);
|
int SetActionTable(int serviceType, struct TvService *out);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceStateTableInit
|
* TvDeviceStateTableInit
|
||||||
@@ -227,7 +239,7 @@ int TvDeviceStateTableInit(char*);
|
|||||||
* sr_event -- The subscription request event structure
|
* sr_event -- The subscription request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleGetVarRequest
|
* TvDeviceHandleGetVarRequest
|
||||||
@@ -241,7 +253,7 @@ int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
|||||||
* cgv_event -- The control get variable request event structure
|
* cgv_event -- The control get variable request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
|
int TvDeviceHandleGetVarRequest(UpnpStateVarRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceHandleActionRequest
|
* TvDeviceHandleActionRequest
|
||||||
@@ -255,7 +267,7 @@ int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *);
|
|||||||
* ca_event -- The control action request event structure
|
* ca_event -- The control action request event structure
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceHandleActionRequest(struct Upnp_Action_Request *);
|
int TvDeviceHandleActionRequest(UpnpActionRequest *);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceCallbackEventHandler
|
* TvDeviceCallbackEventHandler
|
||||||
@@ -313,8 +325,7 @@ int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*);
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDevicePowerOff
|
* TvDevicePowerOff
|
||||||
@@ -329,8 +340,7 @@ int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetChannel
|
* TvDeviceSetChannel
|
||||||
@@ -347,8 +357,7 @@ int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseChannel
|
* TvDeviceIncreaseChannel
|
||||||
@@ -363,8 +372,7 @@ int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseChannel
|
* TvDeviceDecreaseChannel
|
||||||
*
|
*
|
||||||
@@ -378,8 +386,7 @@ int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetVolume
|
* TvDeviceSetVolume
|
||||||
*
|
*
|
||||||
@@ -395,8 +402,7 @@ int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseVolume
|
* TvDeviceIncreaseVolume
|
||||||
@@ -411,8 +417,7 @@ int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -428,8 +433,7 @@ int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
//Picture Service Actions
|
//Picture Service Actions
|
||||||
@@ -449,8 +453,7 @@ int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -465,8 +468,7 @@ int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseColor
|
* TvDeviceDecreaseColor
|
||||||
@@ -480,8 +482,7 @@ int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* IXML_Document **out - action result document
|
* IXML_Document **out - action result document
|
||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetTint
|
* TvDeviceSetTint
|
||||||
@@ -498,8 +499,7 @@ int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseTint
|
* TvDeviceIncreaseTint
|
||||||
@@ -514,8 +514,7 @@ int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseTint
|
* TvDeviceDecreaseTint
|
||||||
@@ -530,8 +529,7 @@ int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* TvDeviceSetContrast
|
* TvDeviceSetContrast
|
||||||
@@ -548,8 +546,7 @@ int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseContrast
|
* TvDeviceIncreaseContrast
|
||||||
@@ -565,8 +562,7 @@ int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseContrast
|
* TvDeviceDecreaseContrast
|
||||||
*
|
*
|
||||||
@@ -580,8 +576,7 @@ int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceSetBrightness
|
* TvDeviceSetBrightness
|
||||||
@@ -595,8 +590,7 @@ int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* brightness -- The brightness value to change to.
|
* brightness -- The brightness value to change to.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceIncreaseBrightness
|
* TvDeviceIncreaseBrightness
|
||||||
@@ -611,8 +605,7 @@ int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TvDeviceDecreaseBrightness
|
* TvDeviceDecreaseBrightness
|
||||||
@@ -626,12 +619,11 @@ int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
|||||||
* char **errorString - errorString (in case action was unsuccessful)
|
* char **errorString - errorString (in case action was unsuccessful)
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out,
|
int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, OUT char **errorString);
|
||||||
OUT char **errorString);
|
|
||||||
|
|
||||||
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name,
|
||||||
char *web_dir_path, print_string pfun);
|
char *web_dir_path, print_string pfun);
|
||||||
int TvDeviceStop();
|
int TvDeviceStop(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
157
upnp/src/api/ActionComplete.c
Normal file
157
upnp/src/api/ActionComplete.c
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpActionComplete object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "ActionComplete.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Internal implementation of the UpnpActionComplete object.
|
||||||
|
*/
|
||||||
|
struct SUpnpActionComplete
|
||||||
|
{
|
||||||
|
/*! The result of the operation */
|
||||||
|
int m_errCode;
|
||||||
|
/*! The control URL for service. */
|
||||||
|
UpnpString *m_ctrlUrl;
|
||||||
|
/*! The DOM document describing the action. */
|
||||||
|
IXML_Document *m_actionRequest;
|
||||||
|
/*! The DOM document describing the result of the action */
|
||||||
|
IXML_Document *m_actionResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpActionComplete *UpnpActionComplete_new()
|
||||||
|
{
|
||||||
|
struct SUpnpActionComplete *p = calloc(1, sizeof (struct SUpnpActionComplete));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_errCode = 0;
|
||||||
|
#endif
|
||||||
|
p->m_ctrlUrl = UpnpString_new();
|
||||||
|
#if 0
|
||||||
|
p->m_actionRequest = NULL;
|
||||||
|
p->m_actionResult = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (UpnpActionComplete *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_delete(UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
struct SUpnpActionComplete *q = (struct SUpnpActionComplete *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_ctrlUrl);
|
||||||
|
q->m_ctrlUrl = NULL;
|
||||||
|
|
||||||
|
UpnpActionComplete_set_ActionRequest(p, NULL);
|
||||||
|
|
||||||
|
UpnpActionComplete_set_ActionResult(p, NULL);
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpActionComplete *UpnpActionComplete_dup(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
UpnpActionComplete *q = UpnpActionComplete_new();
|
||||||
|
|
||||||
|
UpnpActionComplete_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_assign(UpnpActionComplete *p, const UpnpActionComplete *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpActionComplete_set_ErrCode(p, UpnpActionComplete_get_ErrCode(q));
|
||||||
|
UpnpActionComplete_set_CtrlUrl(p, UpnpActionComplete_get_CtrlUrl(q));
|
||||||
|
UpnpActionComplete_set_ActionRequest(p, UpnpActionComplete_get_ActionRequest(q));
|
||||||
|
UpnpActionComplete_set_ActionResult(p, UpnpActionComplete_get_ActionResult(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpActionComplete_get_ErrCode(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionComplete *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_set_ErrCode(UpnpActionComplete *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpActionComplete *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpActionComplete_get_CtrlUrl(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionComplete *)p)->m_ctrlUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpActionComplete_get_CtrlUrl_cstr(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpActionComplete_get_CtrlUrl(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_set_CtrlUrl(UpnpActionComplete *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionComplete *)p)->m_ctrlUrl);
|
||||||
|
((struct SUpnpActionComplete *)p)->m_ctrlUrl = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_strcpy_CtrlUrl(UpnpActionComplete *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionComplete *)p)->m_ctrlUrl);
|
||||||
|
((struct SUpnpActionComplete *)p)->m_ctrlUrl = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpActionComplete *)p)->m_ctrlUrl, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpActionComplete_get_ActionRequest(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionComplete *)p)->m_actionRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_set_ActionRequest(UpnpActionComplete *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpActionComplete *)p)->m_actionRequest);
|
||||||
|
((struct SUpnpActionComplete *)p)->m_actionRequest = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpActionComplete_get_ActionResult(const UpnpActionComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionComplete *)p)->m_actionResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionComplete_set_ActionResult(UpnpActionComplete *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpActionComplete *)p)->m_actionResult);
|
||||||
|
((struct SUpnpActionComplete *)p)->m_actionResult = d;
|
||||||
|
}
|
||||||
|
|
||||||
283
upnp/src/api/ActionRequest.c
Normal file
283
upnp/src/api/ActionRequest.c
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpActionRequest object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "ActionRequest.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for memset(), strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpActionRequest
|
||||||
|
{
|
||||||
|
int m_errCode;
|
||||||
|
int m_socket;
|
||||||
|
UpnpString *m_errStr;
|
||||||
|
UpnpString *m_actionName;
|
||||||
|
UpnpString *m_devUDN;
|
||||||
|
UpnpString *m_serviceID;
|
||||||
|
IXML_Document *m_actionRequest;
|
||||||
|
IXML_Document *m_actionResult;
|
||||||
|
IXML_Document *m_soapHeader;
|
||||||
|
/* Variables should be declared with struct sockaddr_storage,
|
||||||
|
* but users must only see a struct sockaddr pointer */
|
||||||
|
struct sockaddr_storage m_ctrlPtIPAddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpActionRequest *UpnpActionRequest_new()
|
||||||
|
{
|
||||||
|
struct SUpnpActionRequest *p = calloc(1, sizeof (struct SUpnpActionRequest));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_errCode = 0;
|
||||||
|
p->m_socket = 0;
|
||||||
|
#endif
|
||||||
|
p->m_errStr = UpnpString_new();
|
||||||
|
p->m_actionName = UpnpString_new();
|
||||||
|
p->m_devUDN = UpnpString_new();
|
||||||
|
p->m_serviceID = UpnpString_new();
|
||||||
|
#if 0
|
||||||
|
p->m_actionRequest = NULL;
|
||||||
|
p->m_actionResult = NULL;
|
||||||
|
p->m_soapHeader = NULL;
|
||||||
|
memset(&p->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
|
||||||
|
#endif
|
||||||
|
return (UpnpActionRequest *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_delete(UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
struct SUpnpActionRequest *q = (struct SUpnpActionRequest *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
q->m_socket = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_errStr);
|
||||||
|
q->m_errStr = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_actionName);
|
||||||
|
q->m_actionName = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_devUDN);
|
||||||
|
q->m_devUDN = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_serviceID);
|
||||||
|
q->m_serviceID = NULL;
|
||||||
|
|
||||||
|
UpnpActionRequest_set_ActionRequest(p, NULL);
|
||||||
|
|
||||||
|
UpnpActionRequest_set_ActionResult(p, NULL);
|
||||||
|
|
||||||
|
UpnpActionRequest_set_SoapHeader(p, NULL);
|
||||||
|
|
||||||
|
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpActionRequest *UpnpActionRequest_dup(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
UpnpActionRequest *q = UpnpActionRequest_new();
|
||||||
|
|
||||||
|
UpnpActionRequest_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_assign(UpnpActionRequest *p, const UpnpActionRequest *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpActionRequest_set_ErrCode(p, UpnpActionRequest_get_ErrCode(q));
|
||||||
|
UpnpActionRequest_set_Socket(p, UpnpActionRequest_get_Socket(q));
|
||||||
|
UpnpActionRequest_set_ErrStr(p, UpnpActionRequest_get_ErrStr(q));
|
||||||
|
UpnpActionRequest_set_ActionName(p, UpnpActionRequest_get_ActionName(q));
|
||||||
|
UpnpActionRequest_set_DevUDN(p, UpnpActionRequest_get_DevUDN(q));
|
||||||
|
UpnpActionRequest_set_ServiceID(p, UpnpActionRequest_get_ServiceID(q));
|
||||||
|
UpnpActionRequest_set_ActionRequest(p, UpnpActionRequest_get_ActionRequest(q));
|
||||||
|
UpnpActionRequest_set_ActionResult(p, UpnpActionRequest_get_ActionResult(q));
|
||||||
|
UpnpActionRequest_set_CtrlPtIPAddr(p, UpnpActionRequest_get_CtrlPtIPAddr(q));
|
||||||
|
UpnpActionRequest_set_SoapHeader(p, UpnpActionRequest_get_SoapHeader(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpActionRequest_get_ErrCode(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ErrCode(UpnpActionRequest *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpActionRequest *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpActionRequest_get_Socket(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_Socket(UpnpActionRequest *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpActionRequest *)p)->m_socket = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpActionRequest_get_ErrStr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_errStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpActionRequest_get_ErrStr_cstr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpActionRequest_get_ErrStr(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ErrStr(UpnpActionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_errStr);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_errStr = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_strcpy_ErrStr(UpnpActionRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_errStr);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_errStr = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpActionRequest *)p)->m_errStr, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpActionRequest_get_ActionName(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_actionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpActionRequest_get_ActionName_cstr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpActionRequest_get_ActionName(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ActionName(UpnpActionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_actionName);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_actionName = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_strcpy_ActionName(UpnpActionRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_actionName);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_actionName = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpActionRequest *)p)->m_actionName, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpActionRequest_get_DevUDN(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_devUDN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpActionRequest_get_DevUDN_cstr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpActionRequest_get_DevUDN(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_DevUDN(UpnpActionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_devUDN);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_devUDN = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpActionRequest_get_ServiceID(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_serviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpActionRequest_get_ServiceID_cstr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpActionRequest_get_ServiceID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ServiceID(UpnpActionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpActionRequest *)p)->m_serviceID);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_serviceID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpActionRequest_get_ActionRequest(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_actionRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ActionRequest(UpnpActionRequest *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_actionRequest);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_actionRequest = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpActionRequest_get_ActionResult(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_actionResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_ActionResult(UpnpActionRequest *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_actionResult);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_actionResult = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const struct sockaddr *UpnpActionRequest_get_CtrlPtIPAddr(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return (struct sockaddr *)&((struct SUpnpActionRequest *)p)->m_ctrlPtIPAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_CtrlPtIPAddr(UpnpActionRequest *p, const struct sockaddr *ia)
|
||||||
|
{
|
||||||
|
((struct SUpnpActionRequest *)p)->m_ctrlPtIPAddr = *(struct sockaddr_storage *)ia;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpActionRequest_get_SoapHeader(const UpnpActionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpActionRequest *)p)->m_soapHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpActionRequest_set_SoapHeader(UpnpActionRequest *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpActionRequest *)p)->m_soapHeader);
|
||||||
|
((struct SUpnpActionRequest *)p)->m_soapHeader = d;
|
||||||
|
}
|
||||||
|
|
||||||
396
upnp/src/api/Discovery.c
Normal file
396
upnp/src/api/Discovery.c
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpDiscovery object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "Discovery.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for memset() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpDiscovery
|
||||||
|
{
|
||||||
|
int m_errCode;
|
||||||
|
int m_expires;
|
||||||
|
UpnpString *m_deviceID;
|
||||||
|
UpnpString *m_deviceType;
|
||||||
|
UpnpString *m_serviceType;
|
||||||
|
UpnpString *m_serviceVer;
|
||||||
|
UpnpString *m_location;
|
||||||
|
UpnpString *m_os;
|
||||||
|
UpnpString *m_date;
|
||||||
|
UpnpString *m_ext;
|
||||||
|
/* Variables should be declared with struct sockaddr_storage,
|
||||||
|
* but users must only see a struct sockaddr pointer */
|
||||||
|
struct sockaddr_storage m_destAddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpDiscovery *UpnpDiscovery_new()
|
||||||
|
{
|
||||||
|
struct SUpnpDiscovery *p = calloc(1, sizeof (struct SUpnpDiscovery));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->errCode = 0;
|
||||||
|
p->m_expires = 0;
|
||||||
|
#endif
|
||||||
|
p->m_deviceID = UpnpString_new();
|
||||||
|
p->m_deviceType = UpnpString_new();
|
||||||
|
p->m_serviceType = UpnpString_new();
|
||||||
|
p->m_serviceVer = UpnpString_new();
|
||||||
|
p->m_location = UpnpString_new();
|
||||||
|
p->m_os = UpnpString_new();
|
||||||
|
p->m_date = UpnpString_new();
|
||||||
|
p->m_ext = UpnpString_new();
|
||||||
|
memset(&p->m_destAddr, 0, sizeof(struct sockaddr_storage));
|
||||||
|
|
||||||
|
return (UpnpDiscovery *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_delete(UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
struct SUpnpDiscovery *q = (struct SUpnpDiscovery *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
q->m_expires = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_deviceID);
|
||||||
|
q->m_deviceID = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_deviceType);
|
||||||
|
q->m_deviceType = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_serviceType);
|
||||||
|
q->m_serviceType = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_serviceVer);
|
||||||
|
q->m_serviceVer = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_location);
|
||||||
|
q->m_location = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_os);
|
||||||
|
q->m_os = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_date);
|
||||||
|
q->m_date = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_ext);
|
||||||
|
q->m_ext = NULL;
|
||||||
|
|
||||||
|
memset(&q->m_destAddr, 0, sizeof(struct sockaddr_storage));
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpDiscovery *UpnpDiscovery_dup(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
UpnpDiscovery *q = UpnpDiscovery_new();
|
||||||
|
|
||||||
|
UpnpDiscovery_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_assign(UpnpDiscovery *p, const UpnpDiscovery *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpDiscovery_set_ErrCode(p, UpnpDiscovery_get_ErrCode(q));
|
||||||
|
UpnpDiscovery_set_Expires(p, UpnpDiscovery_get_Expires(q));
|
||||||
|
UpnpDiscovery_set_DeviceID(p, UpnpDiscovery_get_DeviceID(q));
|
||||||
|
UpnpDiscovery_set_DeviceType(p, UpnpDiscovery_get_DeviceType(q));
|
||||||
|
UpnpDiscovery_set_ServiceType(p, UpnpDiscovery_get_ServiceType(q));
|
||||||
|
UpnpDiscovery_set_ServiceVer(p, UpnpDiscovery_get_ServiceVer(q));
|
||||||
|
UpnpDiscovery_set_Location(p, UpnpDiscovery_get_Location(q));
|
||||||
|
UpnpDiscovery_set_Os(p, UpnpDiscovery_get_Os(q));
|
||||||
|
UpnpDiscovery_set_Date(p, UpnpDiscovery_get_Date(q));
|
||||||
|
UpnpDiscovery_set_Ext(p, UpnpDiscovery_get_Ext(q));
|
||||||
|
UpnpDiscovery_set_DestAddr(p, UpnpDiscovery_get_DestAddr(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpDiscovery_get_ErrCode(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_ErrCode(UpnpDiscovery *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpDiscovery *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpDiscovery_get_Expires(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_expires;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_Expires(UpnpDiscovery *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpDiscovery *)p)->m_expires = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_DeviceID(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_deviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_DeviceID_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_DeviceID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_DeviceID(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceID);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_deviceID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_DeviceID(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceID);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_deviceID = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_deviceID, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_DeviceType(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_DeviceType_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_DeviceType(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_DeviceType(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceType);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_deviceType = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_DeviceType(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_deviceType);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_deviceType = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_deviceType, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_ServiceType(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_serviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_ServiceType_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_ServiceType(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_ServiceType(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceType);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_serviceType = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_ServiceType(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceType);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_serviceType = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_serviceType, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_ServiceVer(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_serviceVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_ServiceVer_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_ServiceVer(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_ServiceVer(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceVer);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_serviceVer = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_ServiceVer(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_serviceVer);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_serviceVer = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_serviceVer, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_Location(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_location;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_Location_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_Location(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_Location(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_location = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_Location(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_location = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_location, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strncpy_Location(UpnpDiscovery *p, const char *s, int n)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_location);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_location = UpnpString_new();
|
||||||
|
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_location, s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_Os(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_os;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_Os_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_Os(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_Os(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_os = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_Os(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_os = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_os, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strncpy_Os(UpnpDiscovery *p, const char *s, int n)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_os);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_os = UpnpString_new();
|
||||||
|
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_os, s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_Date(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_Date_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_Date(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_Date(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_date);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_date = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_Date(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_date);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_date = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_date, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpDiscovery_get_Ext(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpDiscovery *)p)->m_ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpDiscovery_get_Ext_cstr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpDiscovery_get_Ext(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_Ext(UpnpDiscovery *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strcpy_Ext(UpnpDiscovery *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpDiscovery *)p)->m_ext, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_strncpy_Ext(UpnpDiscovery *p, const char *s, int n)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpDiscovery *)p)->m_ext);
|
||||||
|
((struct SUpnpDiscovery *)p)->m_ext = UpnpString_new();
|
||||||
|
UpnpString_set_StringN(((struct SUpnpDiscovery *)p)->m_ext, s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const struct sockaddr *UpnpDiscovery_get_DestAddr(const UpnpDiscovery *p)
|
||||||
|
{
|
||||||
|
return (struct sockaddr *)&((struct SUpnpDiscovery *)p)->m_destAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpDiscovery_set_DestAddr(UpnpDiscovery *p, const struct sockaddr *sa)
|
||||||
|
{
|
||||||
|
((struct SUpnpDiscovery *)p)->m_destAddr = *(struct sockaddr_storage *)sa;
|
||||||
|
}
|
||||||
|
|
||||||
121
upnp/src/api/Event.c
Normal file
121
upnp/src/api/Event.c
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpEvent object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpEvent
|
||||||
|
{
|
||||||
|
int m_eventKey;
|
||||||
|
IXML_Document *m_changedVariables;
|
||||||
|
UpnpString *m_SID;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEvent *UpnpEvent_new()
|
||||||
|
{
|
||||||
|
struct SUpnpEvent *p = calloc(1, sizeof (struct SUpnpEvent));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_eventKey = 0;
|
||||||
|
p->m_changedVariables = NULL;
|
||||||
|
#endif
|
||||||
|
p->m_SID = UpnpString_new();
|
||||||
|
|
||||||
|
return (UpnpEvent *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_delete(UpnpEvent *p)
|
||||||
|
{
|
||||||
|
struct SUpnpEvent *q = (struct SUpnpEvent *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_eventKey = 0;
|
||||||
|
|
||||||
|
q->m_changedVariables = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_SID);
|
||||||
|
q->m_SID = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEvent *UpnpEvent_dup(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
UpnpEvent *q = UpnpEvent_new();
|
||||||
|
|
||||||
|
UpnpEvent_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpEvent_set_EventKey(p, UpnpEvent_get_EventKey(q));
|
||||||
|
UpnpEvent_set_ChangedVariables(p, UpnpEvent_get_ChangedVariables(q));
|
||||||
|
UpnpEvent_set_SID(p, UpnpEvent_get_SID(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpEvent_get_EventKey(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_eventKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_EventKey(UpnpEvent *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpEvent *)p)->m_eventKey = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_changedVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpEvent *)p)->m_changedVariables);
|
||||||
|
((struct SUpnpEvent *)p)->m_changedVariables = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpEvent_get_SID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpEvent *)p)->m_SID);
|
||||||
|
((struct SUpnpEvent *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
159
upnp/src/api/EventSubscribe.c
Normal file
159
upnp/src/api/EventSubscribe.c
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpEventSubscribe object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "EventSubscribe.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SEventSubscribe
|
||||||
|
{
|
||||||
|
int m_errCode;
|
||||||
|
int m_timeOut;
|
||||||
|
UpnpString *m_SID;
|
||||||
|
UpnpString *m_publisherUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEventSubscribe *UpnpEventSubscribe_new()
|
||||||
|
{
|
||||||
|
struct SEventSubscribe *p = calloc(1, sizeof (struct SEventSubscribe));
|
||||||
|
#if 0
|
||||||
|
p->errCode = 0;
|
||||||
|
p->timeOut = 0;
|
||||||
|
#endif
|
||||||
|
p->m_SID = UpnpString_new();
|
||||||
|
p->m_publisherUrl = UpnpString_new();
|
||||||
|
|
||||||
|
return (UpnpEventSubscribe *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_delete(UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
struct SEventSubscribe *q = (struct SEventSubscribe *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
q->m_timeOut = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_publisherUrl);
|
||||||
|
q->m_publisherUrl = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_SID);
|
||||||
|
q->m_SID = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEventSubscribe *UpnpEventSubscribe_dup(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
UpnpEventSubscribe *q = UpnpEventSubscribe_new();
|
||||||
|
|
||||||
|
UpnpEventSubscribe_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_assign(UpnpEventSubscribe *p, const UpnpEventSubscribe *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpEventSubscribe_set_ErrCode(p, UpnpEventSubscribe_get_ErrCode(q));
|
||||||
|
UpnpEventSubscribe_set_TimeOut(p, UpnpEventSubscribe_get_TimeOut(q));
|
||||||
|
UpnpEventSubscribe_set_SID(p, UpnpEventSubscribe_get_SID(q));
|
||||||
|
UpnpEventSubscribe_set_PublisherUrl(p, UpnpEventSubscribe_get_PublisherUrl(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpEventSubscribe_get_ErrCode(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return ((struct SEventSubscribe *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_set_ErrCode(UpnpEventSubscribe *p, int n)
|
||||||
|
{
|
||||||
|
((struct SEventSubscribe *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpEventSubscribe_get_TimeOut(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return ((struct SEventSubscribe *)p)->m_timeOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_set_TimeOut(UpnpEventSubscribe *p, int n)
|
||||||
|
{
|
||||||
|
((struct SEventSubscribe *)p)->m_timeOut = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpEventSubscribe_get_SID(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return ((struct SEventSubscribe *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpEventSubscribe_get_SID_cstr(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpEventSubscribe_get_SID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_set_SID(UpnpEventSubscribe *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SEventSubscribe *)p)->m_SID);
|
||||||
|
((struct SEventSubscribe *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_strcpy_SID(UpnpEventSubscribe *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SEventSubscribe *)p)->m_SID);
|
||||||
|
((struct SEventSubscribe *)p)->m_SID = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SEventSubscribe *)p)->m_SID, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpEventSubscribe_get_PublisherUrl(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return ((struct SEventSubscribe *)p)->m_publisherUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpEventSubscribe_get_PublisherUrl_cstr(const UpnpEventSubscribe *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpEventSubscribe_get_PublisherUrl(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_set_PublisherUrl(UpnpEventSubscribe *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SEventSubscribe *)p)->m_publisherUrl);
|
||||||
|
((struct SEventSubscribe *)p)->m_publisherUrl = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEventSubscribe_strcpy_PublisherUrl(UpnpEventSubscribe *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SEventSubscribe *)p)->m_publisherUrl);
|
||||||
|
((struct SEventSubscribe *)p)->m_publisherUrl = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SEventSubscribe *)p)->m_publisherUrl, s);
|
||||||
|
}
|
||||||
|
|
||||||
179
upnp/src/api/FileInfo.c
Normal file
179
upnp/src/api/FileInfo.c
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpFileInfo object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "FileInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpFileInfo
|
||||||
|
{
|
||||||
|
off_t m_fileLength;
|
||||||
|
time_t m_lastModified;
|
||||||
|
int m_isDirectory;
|
||||||
|
int m_isReadable;
|
||||||
|
DOMString m_contentType;
|
||||||
|
DOMString m_extraHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpFileInfo *UpnpFileInfo_new()
|
||||||
|
{
|
||||||
|
struct SUpnpFileInfo *p = calloc(1, sizeof (struct SUpnpFileInfo));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_fileLength = 0;
|
||||||
|
p->m_lastModified = 0;
|
||||||
|
p->m_isDirectory = 0;
|
||||||
|
p->m_isReadable = 0;
|
||||||
|
p->m_contentType = NULL;
|
||||||
|
p->m_extraHeaders = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (UpnpFileInfo *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_delete(UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
struct SUpnpFileInfo *q = (struct SUpnpFileInfo *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_fileLength = 0;
|
||||||
|
|
||||||
|
q->m_lastModified = 0;
|
||||||
|
|
||||||
|
q->m_isDirectory = 0;
|
||||||
|
|
||||||
|
q->m_isReadable = 0;
|
||||||
|
|
||||||
|
ixmlFreeDOMString(q->m_contentType);
|
||||||
|
q->m_contentType = NULL;
|
||||||
|
|
||||||
|
ixmlFreeDOMString(q->m_extraHeaders);
|
||||||
|
q->m_extraHeaders = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpFileInfo *UpnpFileInfo_dup(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
UpnpFileInfo *q = UpnpFileInfo_new();
|
||||||
|
|
||||||
|
UpnpFileInfo_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_assign(UpnpFileInfo *p, const UpnpFileInfo *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpFileInfo_set_FileLength(p, UpnpFileInfo_get_FileLength(q));
|
||||||
|
UpnpFileInfo_set_LastModified(p, UpnpFileInfo_get_LastModified(q));
|
||||||
|
UpnpFileInfo_set_IsDirectory(p, UpnpFileInfo_get_IsDirectory(q));
|
||||||
|
UpnpFileInfo_set_IsReadable(p, UpnpFileInfo_get_IsReadable(q));
|
||||||
|
UpnpFileInfo_set_ContentType(p, UpnpFileInfo_get_ContentType(q));
|
||||||
|
UpnpFileInfo_set_ExtraHeaders(p, UpnpFileInfo_get_ExtraHeaders(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t UpnpFileInfo_get_FileLength(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpFileInfo *)p)->m_fileLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_FileLength(UpnpFileInfo *p, off_t l)
|
||||||
|
{
|
||||||
|
((struct SUpnpFileInfo *)p)->m_fileLength = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const time_t *UpnpFileInfo_get_LastModified(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return &((struct SUpnpFileInfo *)p)->m_lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_LastModified(UpnpFileInfo *p, const time_t *t)
|
||||||
|
{
|
||||||
|
((struct SUpnpFileInfo *)p)->m_lastModified = *t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpFileInfo_get_IsDirectory(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpFileInfo *)p)->m_isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_IsDirectory(UpnpFileInfo *p, int b)
|
||||||
|
{
|
||||||
|
((struct SUpnpFileInfo *)p)->m_isDirectory = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpFileInfo_get_IsReadable(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpFileInfo *)p)->m_isReadable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_IsReadable(UpnpFileInfo *p, int b)
|
||||||
|
{
|
||||||
|
((struct SUpnpFileInfo *)p)->m_isReadable = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const DOMString UpnpFileInfo_get_ContentType(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpFileInfo *)p)->m_contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpFileInfo_get_ContentType_cstr(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return (const char *)UpnpFileInfo_get_ContentType(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_ContentType(UpnpFileInfo *p, const DOMString s)
|
||||||
|
{
|
||||||
|
ixmlFreeDOMString(((struct SUpnpFileInfo *)p)->m_contentType);
|
||||||
|
((struct SUpnpFileInfo *)p)->m_contentType = ixmlCloneDOMString(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const DOMString UpnpFileInfo_get_ExtraHeaders(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpFileInfo *)p)->m_extraHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpFileInfo_get_ExtraHeaders_cstr(const UpnpFileInfo *p)
|
||||||
|
{
|
||||||
|
return (const char *)UpnpFileInfo_get_ExtraHeaders(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpFileInfo_set_ExtraHeaders(UpnpFileInfo *p, const DOMString s)
|
||||||
|
{
|
||||||
|
ixmlFreeDOMString(((struct SUpnpFileInfo *)p)->m_extraHeaders);
|
||||||
|
((struct SUpnpFileInfo *)p)->m_extraHeaders = ixmlCloneDOMString(s);
|
||||||
|
}
|
||||||
|
|
||||||
170
upnp/src/api/StateVarComplete.c
Normal file
170
upnp/src/api/StateVarComplete.c
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpStateVarComplete object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "StateVarComplete.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpStateVarComplete
|
||||||
|
{
|
||||||
|
int m_errCode;
|
||||||
|
UpnpString *m_ctrlUrl;
|
||||||
|
UpnpString *m_stateVarName;
|
||||||
|
DOMString m_currentVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpStateVarComplete *UpnpStateVarComplete_new()
|
||||||
|
{
|
||||||
|
struct SUpnpStateVarComplete *p = calloc(1, sizeof (struct SUpnpStateVarComplete));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_errCode = 0;
|
||||||
|
#endif
|
||||||
|
p->m_ctrlUrl = UpnpString_new();
|
||||||
|
p->m_stateVarName = UpnpString_new();
|
||||||
|
#if 0
|
||||||
|
p->m_currentVal = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (UpnpStateVarComplete *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_delete(UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
struct SUpnpStateVarComplete *q = (struct SUpnpStateVarComplete *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_ctrlUrl);
|
||||||
|
q->m_ctrlUrl = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_stateVarName);
|
||||||
|
q->m_stateVarName = NULL;
|
||||||
|
|
||||||
|
ixmlFreeDOMString(q->m_currentVal);
|
||||||
|
q->m_currentVal = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpStateVarComplete *UpnpStateVarComplete_dup(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
UpnpStateVarComplete *q = UpnpStateVarComplete_new();
|
||||||
|
|
||||||
|
UpnpStateVarComplete_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_assign(UpnpStateVarComplete *p, const UpnpStateVarComplete *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpStateVarComplete_set_ErrCode(p, UpnpStateVarComplete_get_ErrCode(q));
|
||||||
|
UpnpStateVarComplete_set_CtrlUrl(p, UpnpStateVarComplete_get_CtrlUrl(q));
|
||||||
|
UpnpStateVarComplete_set_StateVarName(p, UpnpStateVarComplete_get_StateVarName(q));
|
||||||
|
UpnpStateVarComplete_set_CurrentVal(p, UpnpStateVarComplete_get_CurrentVal(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpStateVarComplete_get_ErrCode(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarComplete *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_set_ErrCode(UpnpStateVarComplete *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarComplete_get_CtrlUrl(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarComplete *)p)->m_ctrlUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarComplete_get_CtrlUrl_cstr(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarComplete_get_CtrlUrl(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_set_CtrlUrl(UpnpStateVarComplete *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_strcpy_CtrlUrl(UpnpStateVarComplete *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarComplete_get_StateVarName(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarComplete *)p)->m_stateVarName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarComplete_get_StateVarName_cstr(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarComplete_get_StateVarName(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_set_StateVarName(UpnpStateVarComplete *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_stateVarName);
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_stateVarName = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_strcpy_StateVarName(UpnpStateVarComplete *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl);
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_ctrlUrl = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpStateVarComplete *)p)->m_ctrlUrl, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const DOMString UpnpStateVarComplete_get_CurrentVal(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarComplete *)p)->m_currentVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarComplete_get_CurrentVal_cstr(const UpnpStateVarComplete *p)
|
||||||
|
{
|
||||||
|
return (const char *)UpnpStateVarComplete_get_CurrentVal(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarComplete_set_CurrentVal(UpnpStateVarComplete *p, const DOMString s)
|
||||||
|
{
|
||||||
|
ixmlFreeDOMString(((struct SUpnpStateVarComplete *)p)->m_currentVal);
|
||||||
|
((struct SUpnpStateVarComplete *)p)->m_currentVal = ixmlCloneDOMString(s);
|
||||||
|
}
|
||||||
|
|
||||||
254
upnp/src/api/StateVarRequest.c
Normal file
254
upnp/src/api/StateVarRequest.c
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpStateVarRequest object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "StateVarRequest.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for memset(), strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpStateVarRequest
|
||||||
|
{
|
||||||
|
int m_errCode;
|
||||||
|
int m_socket;
|
||||||
|
UpnpString *m_errStr;
|
||||||
|
UpnpString *m_devUDN;
|
||||||
|
UpnpString *m_serviceID;
|
||||||
|
UpnpString *m_stateVarName;
|
||||||
|
/* Variables should be declared with struct sockaddr_storage,
|
||||||
|
* but users must only see a struct sockaddr pointer */
|
||||||
|
struct sockaddr_storage m_ctrlPtIPAddr;
|
||||||
|
DOMString m_currentVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpStateVarRequest *UpnpStateVarRequest_new()
|
||||||
|
{
|
||||||
|
struct SUpnpStateVarRequest *p = calloc(1, sizeof (struct SUpnpStateVarRequest));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_errCode = 0;
|
||||||
|
p->m_socket = 0;
|
||||||
|
#endif
|
||||||
|
p->m_errStr = UpnpString_new();
|
||||||
|
p->m_devUDN = UpnpString_new();
|
||||||
|
p->m_serviceID = UpnpString_new();
|
||||||
|
p->m_stateVarName = UpnpString_new();
|
||||||
|
#if 0
|
||||||
|
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
|
||||||
|
p->m_currentVal = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (UpnpStateVarRequest *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_delete(UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
struct SUpnpStateVarRequest *q = (struct SUpnpStateVarRequest *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_errCode = 0;
|
||||||
|
|
||||||
|
q->m_socket = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_errStr);
|
||||||
|
q->m_errStr = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_devUDN);
|
||||||
|
q->m_devUDN = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_serviceID);
|
||||||
|
q->m_serviceID = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_stateVarName);
|
||||||
|
q->m_stateVarName = NULL;
|
||||||
|
|
||||||
|
memset(&q->m_ctrlPtIPAddr, 0, sizeof (struct sockaddr_storage));
|
||||||
|
|
||||||
|
ixmlFreeDOMString(q->m_currentVal);
|
||||||
|
q->m_currentVal = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpStateVarRequest *UpnpStateVarRequest_dup(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
UpnpStateVarRequest *q = UpnpStateVarRequest_new();
|
||||||
|
|
||||||
|
UpnpStateVarRequest_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_assign(UpnpStateVarRequest *p, const UpnpStateVarRequest *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpStateVarRequest_set_ErrCode(p, UpnpStateVarRequest_get_ErrCode(q));
|
||||||
|
UpnpStateVarRequest_set_Socket(p, UpnpStateVarRequest_get_Socket(q));
|
||||||
|
UpnpStateVarRequest_set_ErrStr(p, UpnpStateVarRequest_get_ErrStr(q));
|
||||||
|
UpnpStateVarRequest_set_StateVarName(p, UpnpStateVarRequest_get_StateVarName(q));
|
||||||
|
UpnpStateVarRequest_set_DevUDN(p, UpnpStateVarRequest_get_DevUDN(q));
|
||||||
|
UpnpStateVarRequest_set_ServiceID(p, UpnpStateVarRequest_get_ServiceID(q));
|
||||||
|
UpnpStateVarRequest_set_CtrlPtIPAddr(p, UpnpStateVarRequest_get_CtrlPtIPAddr(q));
|
||||||
|
UpnpStateVarRequest_set_CurrentVal(p, UpnpStateVarRequest_get_CurrentVal(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpStateVarRequest_get_ErrCode(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_ErrCode(UpnpStateVarRequest *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_errCode = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpStateVarRequest_get_Socket(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_Socket(UpnpStateVarRequest *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_socket = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarRequest_get_ErrStr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_errStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarRequest_get_ErrStr_cstr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarRequest_get_ErrStr(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_ErrStr(UpnpStateVarRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_strcpy_ErrStr(UpnpStateVarRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpStateVarRequest *)p)->m_errStr, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarRequest_get_DevUDN(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_devUDN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarRequest_get_DevUDN_cstr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarRequest_get_DevUDN(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_DevUDN(UpnpStateVarRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_devUDN);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_devUDN = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarRequest_get_ServiceID(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_serviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarRequest_get_ServiceID_cstr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarRequest_get_ServiceID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_ServiceID(UpnpStateVarRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_serviceID);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_serviceID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpStateVarRequest_get_StateVarName(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_stateVarName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarRequest_get_StateVarName_cstr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpStateVarRequest_get_StateVarName(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_StateVarName(UpnpStateVarRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_stateVarName);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_stateVarName = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_strcpy_StateVarName(UpnpStateVarRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpStateVarRequest *)p)->m_errStr);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_errStr = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpStateVarRequest *)p)->m_errStr, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const struct sockaddr *UpnpStateVarRequest_get_CtrlPtIPAddr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return (struct sockaddr *)&((struct SUpnpStateVarRequest *)p)->m_ctrlPtIPAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_CtrlPtIPAddr(UpnpStateVarRequest *p, const struct sockaddr *sa)
|
||||||
|
{
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_ctrlPtIPAddr = *(struct sockaddr_storage *)sa;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const DOMString UpnpStateVarRequest_get_CurrentVal(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpStateVarRequest *)p)->m_currentVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpStateVarRequest_get_CurrentVal_cstr(const UpnpStateVarRequest *p)
|
||||||
|
{
|
||||||
|
return (const char *)UpnpStateVarRequest_get_CurrentVal(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpStateVarRequest_set_CurrentVal(UpnpStateVarRequest *p, const DOMString s)
|
||||||
|
{
|
||||||
|
ixmlFreeDOMString(((struct SUpnpStateVarRequest *)p)->m_currentVal);
|
||||||
|
((struct SUpnpStateVarRequest *)p)->m_currentVal = ixmlCloneDOMString(s);
|
||||||
|
}
|
||||||
|
|
||||||
157
upnp/src/api/SubscriptionRequest.c
Normal file
157
upnp/src/api/SubscriptionRequest.c
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief UpnpSubscriptionRequest object implementation.
|
||||||
|
*
|
||||||
|
* \author Marcelo Roberto Jimenez
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "SubscriptionRequest.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> /* for calloc(), free() */
|
||||||
|
#include <string.h> /* for memset(), strlen(), strdup() */
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpSubscriptionRequest
|
||||||
|
{
|
||||||
|
UpnpString *m_serviceId;
|
||||||
|
UpnpString *m_UDN;
|
||||||
|
UpnpString *m_SID;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpSubscriptionRequest *UpnpSubscriptionRequest_new()
|
||||||
|
{
|
||||||
|
struct SUpnpSubscriptionRequest *p = calloc(1, sizeof (struct SUpnpSubscriptionRequest));
|
||||||
|
|
||||||
|
p->m_serviceId = UpnpString_new();
|
||||||
|
p->m_UDN = UpnpString_new();
|
||||||
|
p->m_SID = UpnpString_new();
|
||||||
|
|
||||||
|
return (UpnpSubscriptionRequest *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
struct SUpnpSubscriptionRequest *q = (struct SUpnpSubscriptionRequest *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_serviceId);
|
||||||
|
q->m_serviceId = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_UDN);
|
||||||
|
q->m_UDN = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_SID);
|
||||||
|
q->m_SID = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
UpnpSubscriptionRequest *q = UpnpSubscriptionRequest_new();
|
||||||
|
|
||||||
|
UpnpSubscriptionRequest_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *p, const UpnpSubscriptionRequest *q)
|
||||||
|
{
|
||||||
|
if (p != q) {
|
||||||
|
UpnpSubscriptionRequest_set_ServiceId(p, UpnpSubscriptionRequest_get_ServiceId(q));
|
||||||
|
UpnpSubscriptionRequest_set_UDN(p, UpnpSubscriptionRequest_get_UDN(q));
|
||||||
|
UpnpSubscriptionRequest_set_SID(p, UpnpSubscriptionRequest_get_SID(q));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpSubscriptionRequest *)p)->m_serviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpSubscriptionRequest_get_ServiceId_cstr(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_serviceId, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpSubscriptionRequest *)p)->m_UDN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpSubscriptionRequest_get_UDN_cstr(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_UDN, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpSubscriptionRequest *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpSubscriptionRequest_get_SID_cstr(const UpnpSubscriptionRequest *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpSubscriptionRequest_get_SID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
|
||||||
|
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_SID, s);
|
||||||
|
}
|
||||||
|
|
||||||
156
upnp/src/api/UpnpString.c
Normal file
156
upnp/src/api/UpnpString.c
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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() */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpString_get_Length(const UpnpString *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpString *)p)->m_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *UpnpString_get_String(const UpnpString *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpString *)p)->m_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpString_set_String(UpnpString *p, const char *s)
|
||||||
|
{
|
||||||
|
free(((struct SUpnpString *)p)->m_string);
|
||||||
|
((struct SUpnpString *)p)->m_length = strlen(s);
|
||||||
|
((struct SUpnpString *)p)->m_string = strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpString_set_StringN(UpnpString *p, const char *s, int n)
|
||||||
|
{
|
||||||
|
free(((struct SUpnpString *)p)->m_string);
|
||||||
|
((struct SUpnpString *)p)->m_length = n;
|
||||||
|
((struct SUpnpString *)p)->m_string = (char *)malloc(n+1);
|
||||||
|
strncpy(((struct SUpnpString *)p)->m_string, s, n);
|
||||||
|
((struct SUpnpString *)p)->m_string[n] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @} UpnpString */
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,177 +1,121 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "ithread.h"
|
||||||
|
#include "ixml.h"
|
||||||
|
#include "upnp.h"
|
||||||
#include "upnpdebug.h"
|
#include "upnpdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ithread.h"
|
|
||||||
#include "upnp.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.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;
|
static ithread_mutex_t GlobalDebugMutex;
|
||||||
|
|
||||||
// Global log level
|
/*! Global log level */
|
||||||
static Upnp_LogLevel g_log_level = UPNP_DEFAULT_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;
|
static FILE *ErrFileHnd = NULL;
|
||||||
|
|
||||||
//File handle for the information log file
|
/*! File handle for the information log file */
|
||||||
static FILE *InfoFileHnd = NULL;
|
static FILE *InfoFileHnd = NULL;
|
||||||
|
|
||||||
//Name of the error file
|
/*! Name of the error file */
|
||||||
static const char *errFileName = "IUpnpErrFile.txt";
|
static const char *errFileName = "IUpnpErrFile.txt";
|
||||||
|
|
||||||
//Name of the info file
|
/*! Name of the info file */
|
||||||
static const char *infoFileName = "IUpnpInfoFile.txt";
|
static const char *infoFileName = "IUpnpInfoFile.txt";
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
* Function : UpnpSetLogFileNames
|
int UpnpInitLog(void)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
if( ErrFileName ) {
|
ithread_mutex_init(&GlobalDebugMutex, NULL);
|
||||||
errFileName = ErrFileName;
|
if(DEBUG_TARGET == 1) {
|
||||||
}
|
if((ErrFileHnd = fopen( errFileName, "a")) == NULL) {
|
||||||
if( InfoFileName ) {
|
return -1;
|
||||||
infoFileName = InfoFileName;
|
}
|
||||||
}
|
if((InfoFileHnd = fopen( infoFileName, "a")) == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
void UpnpSetLogLevel(Upnp_LogLevel log_level)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
g_log_level = log_level;
|
g_log_level = log_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
void UpnpCloseLog(void)
|
||||||
* Function : UpnpCloseLog
|
|
||||||
*
|
|
||||||
* Parameters: void
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This functions closes the log files
|
|
||||||
* Returns: void
|
|
||||||
***************************************************************************/
|
|
||||||
void
|
|
||||||
UpnpCloseLog()
|
|
||||||
{
|
{
|
||||||
if( DEBUG_TARGET == 1 ) {
|
if (DEBUG_TARGET == 1) {
|
||||||
fflush( ErrFileHnd );
|
fflush(ErrFileHnd);
|
||||||
fflush( InfoFileHnd );
|
fflush(InfoFileHnd);
|
||||||
fclose( ErrFileHnd );
|
fclose(ErrFileHnd);
|
||||||
fclose( InfoFileHnd );
|
fclose(InfoFileHnd);
|
||||||
}
|
}
|
||||||
ithread_mutex_destroy( &GlobalDebugMutex );
|
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(
|
int DebugAtThisLevel(
|
||||||
IN Upnp_LogLevel DLevel,
|
Upnp_LogLevel DLevel,
|
||||||
IN Dbg_Module Module)
|
Dbg_Module Module)
|
||||||
{
|
{
|
||||||
int ret = DLevel <= g_log_level;
|
int ret = DLevel <= g_log_level;
|
||||||
ret &=
|
ret &=
|
||||||
@@ -186,38 +130,15 @@ int DebugAtThisLevel(
|
|||||||
|
|
||||||
return ret;
|
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(
|
void UpnpPrintf(
|
||||||
IN Upnp_LogLevel DLevel,
|
Upnp_LogLevel DLevel,
|
||||||
IN Dbg_Module Module,
|
Dbg_Module Module,
|
||||||
IN const char *DbgFileName,
|
const char *DbgFileName,
|
||||||
IN int DbgLineNo,
|
int DbgLineNo,
|
||||||
IN const char *FmtStr,
|
const char *FmtStr,
|
||||||
... )
|
...)
|
||||||
{
|
{
|
||||||
va_list ArgList;
|
va_list ArgList;
|
||||||
|
|
||||||
@@ -228,7 +149,7 @@ void UpnpPrintf(
|
|||||||
ithread_mutex_lock(&GlobalDebugMutex);
|
ithread_mutex_lock(&GlobalDebugMutex);
|
||||||
va_start(ArgList, FmtStr);
|
va_start(ArgList, FmtStr);
|
||||||
if (!DEBUG_TARGET) {
|
if (!DEBUG_TARGET) {
|
||||||
if( DbgFileName ) {
|
if (DbgFileName) {
|
||||||
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
|
UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo);
|
||||||
}
|
}
|
||||||
vfprintf(stdout, FmtStr, ArgList);
|
vfprintf(stdout, FmtStr, ArgList);
|
||||||
@@ -249,27 +170,9 @@ void UpnpPrintf(
|
|||||||
va_end(ArgList);
|
va_end(ArgList);
|
||||||
ithread_mutex_unlock(&GlobalDebugMutex);
|
ithread_mutex_unlock(&GlobalDebugMutex);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
|
||||||
* 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 *ret;
|
FILE *ret;
|
||||||
|
|
||||||
@@ -287,28 +190,12 @@ FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
|
|||||||
|
|
||||||
return ret;
|
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(
|
void UpnpDisplayFileAndLine(
|
||||||
IN FILE * fd,
|
FILE *fd,
|
||||||
IN const char *DbgFileName,
|
const char *DbgFileName,
|
||||||
IN int DbgLineNo)
|
int DbgLineNo)
|
||||||
{
|
{
|
||||||
#define NLINES 2
|
#define NLINES 2
|
||||||
#define MAX_LINE_SIZE 512
|
#define MAX_LINE_SIZE 512
|
||||||
@@ -324,7 +211,12 @@ void UpnpDisplayFileAndLine(
|
|||||||
|
|
||||||
/* Put the debug lines in the buffer */
|
/* Put the debug lines in the buffer */
|
||||||
sprintf(buf[0], "DEBUG - THREAD ID: 0x%lX",
|
sprintf(buf[0], "DEBUG - THREAD ID: 0x%lX",
|
||||||
(unsigned long int)ithread_self());
|
#ifdef WIN32
|
||||||
|
(unsigned long int)ithread_self().p
|
||||||
|
#else
|
||||||
|
(unsigned long int)ithread_self()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
if (DbgFileName) {
|
if (DbgFileName) {
|
||||||
sprintf(buf[1],
|
sprintf(buf[1],
|
||||||
"FILE: %s, LINE: %d",
|
"FILE: %s, LINE: %d",
|
||||||
@@ -336,29 +228,13 @@ void UpnpDisplayFileAndLine(
|
|||||||
UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS);
|
UpnpDisplayBanner(fd, lines, NLINES, NUMBER_OF_STARS);
|
||||||
fflush(fd);
|
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(
|
void UpnpDisplayBanner(
|
||||||
IN FILE * fd,
|
FILE * fd,
|
||||||
IN const char **lines,
|
const char **lines,
|
||||||
IN size_t size,
|
size_t size,
|
||||||
IN int starLength)
|
int starLength)
|
||||||
{
|
{
|
||||||
int leftMarginLength = starLength / 2 + 1;
|
int leftMarginLength = starLength / 2 + 1;
|
||||||
int rightMarginLength = starLength / 2 + 1;
|
int rightMarginLength = starLength / 2 + 1;
|
||||||
@@ -399,12 +275,54 @@ void UpnpDisplayBanner(
|
|||||||
rightMargin[rightMarginLength] = 0;
|
rightMargin[rightMarginLength] = 0;
|
||||||
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
|
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
|
||||||
}
|
}
|
||||||
fprintf( fd, "%s\n\n", stars );
|
fprintf(fd, "%s\n\n", stars);
|
||||||
|
|
||||||
free( currentLine );
|
free(currentLine);
|
||||||
free( stars );
|
free(stars);
|
||||||
free( rightMargin );
|
free(rightMargin);
|
||||||
free( leftMargin );
|
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 */
|
||||||
|
|
||||||
|
|||||||
@@ -1,585 +1,475 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if EXCLUDE_DOM == 0
|
#if EXCLUDE_DOM == 0
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
|
#include "upnp.h"
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
|
|
||||||
|
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*! Maximum action header buffer length. */
|
||||||
#define HEADER_LENGTH 2000
|
#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 {
|
struct ErrorString {
|
||||||
int rc; /* error code */
|
/*! Error code. */
|
||||||
const char *rcError; /* error description */
|
int rc;
|
||||||
|
/*! Error description. */
|
||||||
|
const char *rcError;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initializing the array of error structures.
|
|
||||||
struct ErrorString ErrorMessages[] = { {UPNP_E_SUCCESS, "UPNP_E_SUCCESS"},
|
/*!
|
||||||
{UPNP_E_INVALID_HANDLE, "UPNP_E_INVALID_HANDLE"},
|
* \brief Array of error structures.
|
||||||
{UPNP_E_INVALID_PARAM, "UPNP_E_INVALID_PARAM"},
|
*/
|
||||||
{UPNP_E_OUTOF_HANDLE, "UPNP_E_OUTOF_HANDLE"},
|
struct ErrorString ErrorMessages[] = {
|
||||||
{UPNP_E_OUTOF_CONTEXT, "UPNP_E_OUTOF_CONTEXT"},
|
{UPNP_E_SUCCESS, "UPNP_E_SUCCESS"},
|
||||||
{UPNP_E_OUTOF_MEMORY, "UPNP_E_OUTOF_MEMOR"},
|
{UPNP_E_INVALID_HANDLE, "UPNP_E_INVALID_HANDLE"},
|
||||||
{UPNP_E_INIT, "UPNP_E_INIT"},
|
{UPNP_E_INVALID_PARAM, "UPNP_E_INVALID_PARAM"},
|
||||||
{UPNP_E_BUFFER_TOO_SMALL, "UPNP_E_BUFFER_TOO_SMALL"},
|
{UPNP_E_OUTOF_HANDLE, "UPNP_E_OUTOF_HANDLE"},
|
||||||
{UPNP_E_INVALID_DESC, "UPNP_E_INVALID_DESC"},
|
{UPNP_E_OUTOF_CONTEXT, "UPNP_E_OUTOF_CONTEXT"},
|
||||||
{UPNP_E_INVALID_URL, "UPNP_E_INVALID_URL"},
|
{UPNP_E_OUTOF_MEMORY, "UPNP_E_OUTOF_MEMORY"},
|
||||||
{UPNP_E_INVALID_SID, "UPNP_E_INVALID_SID"},
|
{UPNP_E_INIT, "UPNP_E_INIT"},
|
||||||
{UPNP_E_INVALID_DEVICE, "UPNP_E_INVALID_DEVICE"},
|
{UPNP_E_BUFFER_TOO_SMALL, "UPNP_E_BUFFER_TOO_SMALL"},
|
||||||
{UPNP_E_INVALID_SERVICE, "UPNP_E_INVALID_SERVICE"},
|
{UPNP_E_INVALID_DESC, "UPNP_E_INVALID_DESC"},
|
||||||
{UPNP_E_BAD_RESPONSE, "UPNP_E_BAD_RESPONSE"},
|
{UPNP_E_INVALID_URL, "UPNP_E_INVALID_URL"},
|
||||||
{UPNP_E_BAD_REQUEST, "UPNP_E_BAD_REQUEST"},
|
{UPNP_E_INVALID_SID, "UPNP_E_INVALID_SID"},
|
||||||
{UPNP_E_INVALID_ACTION, "UPNP_E_INVALID_ACTION"},
|
{UPNP_E_INVALID_DEVICE, "UPNP_E_INVALID_DEVICE"},
|
||||||
{UPNP_E_FINISH, "UPNP_E_FINISH"},
|
{UPNP_E_INVALID_SERVICE, "UPNP_E_INVALID_SERVICE"},
|
||||||
{UPNP_E_INIT_FAILED, "UPNP_E_INIT_FAILED"},
|
{UPNP_E_BAD_RESPONSE, "UPNP_E_BAD_RESPONSE"},
|
||||||
{UPNP_E_BAD_HTTPMSG, "UPNP_E_BAD_HTTPMSG"},
|
{UPNP_E_BAD_REQUEST, "UPNP_E_BAD_REQUEST"},
|
||||||
{UPNP_E_NETWORK_ERROR, "UPNP_E_NETWORK_ERROR"},
|
{UPNP_E_INVALID_ACTION, "UPNP_E_INVALID_ACTION"},
|
||||||
{UPNP_E_SOCKET_WRITE, "UPNP_E_SOCKET_WRITE"},
|
{UPNP_E_FINISH, "UPNP_E_FINISH"},
|
||||||
{UPNP_E_SOCKET_READ, "UPNP_E_SOCKET_READ"},
|
{UPNP_E_INIT_FAILED, "UPNP_E_INIT_FAILED"},
|
||||||
{UPNP_E_SOCKET_BIND, "UPNP_E_SOCKET_BIND"},
|
{UPNP_E_URL_TOO_BIG, "UPNP_E_URL_TOO_BIG"},
|
||||||
{UPNP_E_SOCKET_CONNECT, "UPNP_E_SOCKET_CONNECT"},
|
{UPNP_E_BAD_HTTPMSG, "UPNP_E_BAD_HTTPMSG"},
|
||||||
{UPNP_E_OUTOF_SOCKET, "UPNP_E_OUTOF_SOCKET"},
|
{UPNP_E_ALREADY_REGISTERED, "UPNP_E_ALREADY_REGISTERED"},
|
||||||
{UPNP_E_LISTEN, "UPNP_E_LISTEN"},
|
{UPNP_E_INVALID_INTERFACE, "UPNP_E_INVALID_INTERFACE"},
|
||||||
{UPNP_E_EVENT_PROTOCOL, "UPNP_E_EVENT_PROTOCOL"},
|
{UPNP_E_NETWORK_ERROR, "UPNP_E_NETWORK_ERROR"},
|
||||||
{UPNP_E_SUBSCRIBE_UNACCEPTED, "UPNP_E_SUBSCRIBE_UNACCEPTED"},
|
{UPNP_E_SOCKET_WRITE, "UPNP_E_SOCKET_WRITE"},
|
||||||
{UPNP_E_UNSUBSCRIBE_UNACCEPTED, "UPNP_E_UNSUBSCRIBE_UNACCEPTED"},
|
{UPNP_E_SOCKET_READ, "UPNP_E_SOCKET_READ"},
|
||||||
{UPNP_E_NOTIFY_UNACCEPTED, "UPNP_E_NOTIFY_UNACCEPTED"},
|
{UPNP_E_SOCKET_BIND, "UPNP_E_SOCKET_BIND"},
|
||||||
{UPNP_E_INTERNAL_ERROR, "UPNP_E_INTERNAL_ERROR"},
|
{UPNP_E_SOCKET_CONNECT, "UPNP_E_SOCKET_CONNECT"},
|
||||||
{UPNP_E_INVALID_ARGUMENT, "UPNP_E_INVALID_ARGUMENT"},
|
{UPNP_E_OUTOF_SOCKET, "UPNP_E_OUTOF_SOCKET"},
|
||||||
{UPNP_E_OUTOF_BOUNDS, "UPNP_E_OUTOF_BOUNDS"}
|
{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
|
const char *UpnpGetErrorMessage(int rc)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < sizeof( ErrorMessages ) / sizeof( ErrorMessages[0] );
|
for (i = 0; i < sizeof (ErrorMessages) / sizeof (ErrorMessages[0]); ++i) {
|
||||||
i++ ) {
|
if (rc == ErrorMessages[i].rc) {
|
||||||
if( rc == ErrorMessages[i].rc )
|
return ErrorMessages[i].rcError;
|
||||||
return ErrorMessages[i].rcError;
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown Error";
|
|
||||||
|
|
||||||
|
return "Unknown error code";
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : UpnpResolveURL
|
/*!
|
||||||
*
|
* \todo There is some unnecessary allocation and deallocation going on here
|
||||||
* Parameters:
|
* because of the way resolve_rel_url() was originally written and used. In the
|
||||||
* IN char * BaseURL: Base URL string
|
* future it would be nice to clean this up.
|
||||||
* IN char * RelURL: relative URL string
|
*/
|
||||||
* OUT char * AbsURL: Absolute URL string
|
int UpnpResolveURL(
|
||||||
* Description:
|
const char *BaseURL,
|
||||||
* This functions concatinates the base URL and relative URL to generate
|
const char *RelURL,
|
||||||
* the absolute URL
|
char *AbsURL)
|
||||||
* Returns: int
|
|
||||||
* return either UPNP_E_SUCCESS or appropriate error
|
|
||||||
***************************************************************************/
|
|
||||||
int
|
|
||||||
UpnpResolveURL( IN const char *BaseURL,
|
|
||||||
IN const char *RelURL,
|
|
||||||
OUT char *AbsURL )
|
|
||||||
{
|
{
|
||||||
// There is some unnecessary allocation and
|
int ret = UPNP_E_SUCCESS;
|
||||||
// deallocation going on here because of the way
|
char *tempRel = NULL;
|
||||||
// resolve_rel_url was originally written and used
|
|
||||||
// in the future it would be nice to clean this up
|
|
||||||
|
|
||||||
char *tempRel;
|
if (RelURL == NULL) {
|
||||||
|
ret = UPNP_E_INVALID_PARAM;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
|
||||||
if( RelURL == NULL )
|
tempRel = resolve_rel_url((char *)BaseURL, (char *)RelURL);
|
||||||
return UPNP_E_INVALID_PARAM;
|
if (tempRel) {
|
||||||
|
strcpy(AbsURL, tempRel);
|
||||||
tempRel = NULL;
|
free(tempRel);
|
||||||
|
} else {
|
||||||
tempRel = resolve_rel_url((char*) BaseURL, (char*) RelURL );
|
ret = UPNP_E_INVALID_URL;
|
||||||
|
}
|
||||||
if( tempRel ) {
|
|
||||||
strcpy( AbsURL, tempRel );
|
|
||||||
free( tempRel );
|
|
||||||
} else {
|
|
||||||
return UPNP_E_INVALID_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
|
||||||
|
|
||||||
|
ExitFunction:
|
||||||
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : addToAction
|
/*!
|
||||||
*
|
* \brief Adds the argument in the action request or response.
|
||||||
* Parameters:
|
*
|
||||||
* IN int response: flag to tell if the ActionDoc is for response
|
* This function creates the action request or response if it is a first
|
||||||
* or request
|
* argument, otherwise it will add the argument in the document.
|
||||||
* INOUT IXML_Document **ActionDoc: request or response document
|
*
|
||||||
* IN char *ActionName: Name of the action request or response
|
* \returns UPNP_E_SUCCESS if successful, otherwise the appropriate error.
|
||||||
* IN char *ServType: Service type
|
*/
|
||||||
* IN char * ArgName: Name of the argument
|
static int addToAction(
|
||||||
* IN char * ArgValue: Value of the argument
|
/*! [in] flag to tell if the ActionDoc is for response or request. */
|
||||||
*
|
int response,
|
||||||
* Description:
|
/*! [in,out] Request or response document. */
|
||||||
* This function adds the argument in the action request or response.
|
IXML_Document **ActionDoc,
|
||||||
* This function creates the action request or response if it is a first
|
/*! [in] Name of the action request or response. */
|
||||||
* argument else it will add the argument in the document
|
const char *ActionName,
|
||||||
*
|
/*! [in] Service type. */
|
||||||
* Returns: int
|
const char *ServType,
|
||||||
* returns UPNP_E_SUCCESS if successful else returns appropriate error
|
/*! [in] Name of the argument. */
|
||||||
***************************************************************************/
|
const char *ArgName,
|
||||||
static int
|
/*! [in] Value of the argument. */
|
||||||
addToAction( IN int response,
|
const char *ArgValue)
|
||||||
INOUT IXML_Document ** ActionDoc,
|
|
||||||
IN const char *ActionName,
|
|
||||||
IN const char *ServType,
|
|
||||||
IN const char *ArgName,
|
|
||||||
IN const char *ArgValue )
|
|
||||||
{
|
{
|
||||||
char *ActBuff = NULL;
|
char *ActBuff = NULL;
|
||||||
IXML_Node *node = NULL;
|
IXML_Node *node = NULL;
|
||||||
IXML_Element *Ele = NULL;
|
IXML_Element *Ele = NULL;
|
||||||
IXML_Node *Txt = NULL;
|
IXML_Node *Txt = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if( ActionName == NULL || ServType == NULL ) {
|
if (ActionName == NULL || ServType == NULL) {
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *ActionDoc == NULL ) {
|
if (*ActionDoc == NULL) {
|
||||||
ActBuff = ( char * )malloc( HEADER_LENGTH );
|
ActBuff = (char *)malloc(HEADER_LENGTH);
|
||||||
if( ActBuff == NULL ) {
|
if (ActBuff == NULL) {
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( response ) {
|
if (response) {
|
||||||
sprintf( ActBuff,
|
sprintf(ActBuff,
|
||||||
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
||||||
ActionName, ServType, ActionName );
|
ActionName, ServType, ActionName);
|
||||||
} else {
|
} else {
|
||||||
sprintf( ActBuff,
|
sprintf(ActBuff,
|
||||||
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
||||||
ActionName, ServType, ActionName );
|
ActionName, ServType, ActionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ixmlParseBufferEx( ActBuff, ActionDoc );
|
rc = ixmlParseBufferEx(ActBuff, ActionDoc);
|
||||||
free( ActBuff );
|
free(ActBuff);
|
||||||
if( rc != IXML_SUCCESS ) {
|
if (rc != IXML_SUCCESS) {
|
||||||
if( rc == IXML_INSUFFICIENT_MEMORY ) {
|
if (rc == IXML_INSUFFICIENT_MEMORY) {
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
return UPNP_E_INVALID_DESC;
|
return UPNP_E_INVALID_DESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ArgName != NULL /*&& ArgValue != NULL */ ) {
|
if (ArgName != NULL /*&& ArgValue != NULL */) {
|
||||||
node = ixmlNode_getFirstChild( ( IXML_Node * ) * ActionDoc );
|
node = ixmlNode_getFirstChild((IXML_Node *)*ActionDoc);
|
||||||
Ele = ixmlDocument_createElement( *ActionDoc, ArgName );
|
Ele = ixmlDocument_createElement(*ActionDoc, ArgName);
|
||||||
if( ArgValue ) {
|
if(ArgValue) {
|
||||||
Txt = ixmlDocument_createTextNode( *ActionDoc, ArgValue );
|
Txt = ixmlDocument_createTextNode(*ActionDoc, ArgValue);
|
||||||
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
|
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
|
/*!
|
||||||
*
|
* \brief Creates the action request or response from the argument list.
|
||||||
* Parameters:
|
*
|
||||||
* IN int response: flag to tell if the ActionDoc is for response
|
* \return Action request or response document if successful, otherwise
|
||||||
* or request
|
* returns NULL
|
||||||
* IN char * ActionName: Name of the action request or response
|
*/
|
||||||
* IN char * ServType: Service type
|
static IXML_Document *makeAction(
|
||||||
* IN int NumArg :Number of arguments in the action request or response
|
/*! [in] flag to tell if the ActionDoc is for response or request. */
|
||||||
* IN char * Arg : pointer to the first argument
|
int response,
|
||||||
* IN va_list ArgList: Argument list
|
/*! [in] Name of the action request or response. */
|
||||||
*
|
const char *ActionName,
|
||||||
* Description:
|
/*! [in] Service type. */
|
||||||
* This function creates the action request or response from the argument
|
const char *ServType,
|
||||||
* list.
|
/*! [in] Number of arguments in the action request or response. */
|
||||||
* Returns: IXML_Document *
|
int NumArg,
|
||||||
* returns action request or response document if successful
|
/*! [in] pointer to the first argument. */
|
||||||
* else returns NULL
|
const char *Arg,
|
||||||
***************************************************************************/
|
/*! [in] Argument list. */
|
||||||
static IXML_Document *
|
va_list ArgList)
|
||||||
makeAction( IN int response,
|
|
||||||
IN const char *ActionName,
|
|
||||||
IN const char *ServType,
|
|
||||||
IN int NumArg,
|
|
||||||
IN const char *Arg,
|
|
||||||
IN va_list ArgList )
|
|
||||||
{
|
{
|
||||||
const char *ArgName;
|
const char *ArgName;
|
||||||
const char *ArgValue;
|
const char *ArgValue;
|
||||||
char *ActBuff;
|
char *ActBuff;
|
||||||
int Idx = 0;
|
int Idx = 0;
|
||||||
IXML_Document *ActionDoc;
|
IXML_Document *ActionDoc;
|
||||||
IXML_Node *node;
|
IXML_Node *node;
|
||||||
IXML_Element *Ele;
|
IXML_Element *Ele;
|
||||||
IXML_Node *Txt = NULL;
|
IXML_Node *Txt = NULL;
|
||||||
|
|
||||||
if( ActionName == NULL || ServType == NULL ) {
|
if (ActionName == NULL || ServType == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActBuff = ( char * )malloc( HEADER_LENGTH );
|
ActBuff = (char *)malloc(HEADER_LENGTH);
|
||||||
if( ActBuff == NULL ) {
|
if (ActBuff == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( response ) {
|
if (response) {
|
||||||
sprintf( ActBuff,
|
sprintf(ActBuff,
|
||||||
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
"<u:%sResponse xmlns:u=\"%s\">\r\n</u:%sResponse>",
|
||||||
ActionName, ServType, ActionName );
|
ActionName, ServType, ActionName);
|
||||||
} else {
|
} else {
|
||||||
sprintf( ActBuff,
|
sprintf(ActBuff,
|
||||||
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
"<u:%s xmlns:u=\"%s\">\r\n</u:%s>",
|
||||||
ActionName, ServType, ActionName );
|
ActionName, ServType, ActionName);
|
||||||
}
|
}
|
||||||
|
if (ixmlParseBufferEx(ActBuff, &ActionDoc) != IXML_SUCCESS) {
|
||||||
|
free(ActBuff);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if( ixmlParseBufferEx( ActBuff, &ActionDoc ) != IXML_SUCCESS ) {
|
free(ActBuff);
|
||||||
free( ActBuff );
|
if(ActionDoc == NULL) {
|
||||||
return 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 ActionDoc;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : UpnpMakeAction
|
IXML_Document *UpnpMakeAction(
|
||||||
*
|
const char *ActionName,
|
||||||
* Parameters:
|
const char *ServType,
|
||||||
* IN char * ActionName: Name of the action request or response
|
int NumArg,
|
||||||
* IN char * ServType: Service type
|
const char *Arg,
|
||||||
* 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,
|
|
||||||
... )
|
|
||||||
{
|
{
|
||||||
va_list ArgList;
|
va_list ArgList;
|
||||||
IXML_Document *out = NULL;
|
IXML_Document *out = NULL;
|
||||||
|
|
||||||
va_start( ArgList, Arg );
|
va_start(ArgList, Arg);
|
||||||
out = makeAction( 0, ActionName, ServType, NumArg, Arg, ArgList );
|
out = makeAction(0, ActionName, ServType, NumArg, Arg, ArgList);
|
||||||
va_end( ArgList );
|
va_end(ArgList);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : UpnpMakeActionResponse
|
IXML_Document *UpnpMakeActionResponse(
|
||||||
*
|
const char *ActionName,
|
||||||
* Parameters:
|
const char *ServType,
|
||||||
* IN char * ActionName: Name of the action request or response
|
int NumArg,
|
||||||
* IN char * ServType: Service type
|
const char *Arg,
|
||||||
* 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,
|
|
||||||
... )
|
|
||||||
{
|
{
|
||||||
va_list ArgList;
|
va_list ArgList;
|
||||||
IXML_Document *out = NULL;
|
IXML_Document *out = NULL;
|
||||||
|
|
||||||
va_start( ArgList, Arg );
|
va_start(ArgList, Arg);
|
||||||
out = makeAction( 1, ActionName, ServType, NumArg, Arg, ArgList );
|
out = makeAction(1, ActionName, ServType, NumArg, Arg, ArgList);
|
||||||
va_end( ArgList );
|
va_end(ArgList);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : UpnpAddToActionResponse
|
int UpnpAddToAction(
|
||||||
*
|
IXML_Document **ActionDoc,
|
||||||
* Parameters:
|
const char *ActionName,
|
||||||
* INOUT IXML_Document **ActionResponse: action response document
|
const char *ServType,
|
||||||
* IN char * ActionName: Name of the action request or response
|
const char *ArgName,
|
||||||
* IN char * ServType: Service type
|
const char *ArgValue)
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
return addToAction( 1, ActionResponse, ActionName, ServType, ArgName,
|
return addToAction(0, ActionDoc, ActionName, ServType, ArgName, ArgValue);
|
||||||
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,
|
int UpnpAddToActionResponse(
|
||||||
ArgValue );
|
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
|
IXML_Document *UpnpCreatePropertySet(
|
||||||
*
|
int NumArg,
|
||||||
* Parameters:
|
const char *Arg,
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
|
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"
|
if(ixmlParseBufferEx(BlankDoc, &PropSet) != IXML_SUCCESS) {
|
||||||
"-upnp-org:event-1-0\"></e:propertyset>";
|
return NULL;
|
||||||
IXML_Node *node;
|
}
|
||||||
IXML_Element *Ele;
|
|
||||||
IXML_Element *Ele1;
|
|
||||||
IXML_Node *Txt;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if( ArgName == NULL ) {
|
if (NumArg < 1) {
|
||||||
return UPNP_E_INVALID_PARAM;
|
return PropSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *PropSet == NULL ) {
|
va_start(ArgList, Arg);
|
||||||
rc = ixmlParseBufferEx( BlankDoc, PropSet );
|
ArgName = Arg;
|
||||||
if( rc != IXML_SUCCESS ) {
|
while (Idx++ != NumArg) {
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
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 );
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : UpnpCreatePropertySet
|
int UpnpAddToPropertySet(
|
||||||
*
|
IXML_Document **PropSet,
|
||||||
* Parameters:
|
const char *ArgName,
|
||||||
* IN int NumArg: Number of argument that will go in the propertyset node
|
const char *ArgValue)
|
||||||
* 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,
|
|
||||||
... )
|
|
||||||
{
|
{
|
||||||
va_list ArgList;
|
char BlankDoc[] =
|
||||||
int Idx = 0;
|
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"
|
||||||
char BlankDoc[] = "<e:propertyset xmlns:e=\"urn:schemas-"
|
"</e:propertyset>";
|
||||||
"upnp-org:event-1-0\"></e:propertyset>";
|
IXML_Node *node;
|
||||||
const char *ArgName,
|
IXML_Element *Ele;
|
||||||
*ArgValue;
|
IXML_Element *Ele1;
|
||||||
IXML_Node *node;
|
IXML_Node *Txt;
|
||||||
IXML_Element *Ele;
|
int rc;
|
||||||
IXML_Element *Ele1;
|
|
||||||
IXML_Node *Txt;
|
|
||||||
IXML_Document *PropSet;
|
|
||||||
|
|
||||||
if( ixmlParseBufferEx( BlankDoc, &PropSet ) != IXML_SUCCESS ) {
|
if (ArgName == NULL) {
|
||||||
return NULL;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NumArg < 1 ) {
|
if (*PropSet == NULL) {
|
||||||
return NULL;
|
rc = ixmlParseBufferEx(BlankDoc, PropSet);
|
||||||
}
|
if (rc != IXML_SUCCESS) {
|
||||||
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
va_start( ArgList, Arg );
|
node = ixmlNode_getFirstChild((IXML_Node *)*PropSet);
|
||||||
ArgName = Arg;
|
|
||||||
|
|
||||||
while( Idx++ != NumArg ) {
|
Ele1 = ixmlDocument_createElement(*PropSet, "e:property");
|
||||||
ArgValue = va_arg( ArgList, const char * );
|
Ele = ixmlDocument_createElement(*PropSet, ArgName);
|
||||||
|
|
||||||
if( ArgName != NULL /*&& ArgValue != NULL */ ) {
|
if (ArgValue) {
|
||||||
node = ixmlNode_getFirstChild( ( IXML_Node * ) PropSet );
|
Txt = ixmlDocument_createTextNode(*PropSet, ArgValue);
|
||||||
Ele1 = ixmlDocument_createElement( PropSet, "e:property" );
|
ixmlNode_appendChild((IXML_Node *)Ele, Txt);
|
||||||
Ele = ixmlDocument_createElement( PropSet, ArgName );
|
}
|
||||||
if( ArgValue ) {
|
|
||||||
Txt = ixmlDocument_createTextNode( PropSet, ArgValue );
|
|
||||||
ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );
|
|
||||||
}
|
|
||||||
|
|
||||||
ixmlNode_appendChild( ( IXML_Node * ) Ele1,
|
ixmlNode_appendChild((IXML_Node *)Ele1, (IXML_Node *)Ele);
|
||||||
( IXML_Node * ) Ele );
|
ixmlNode_appendChild(node, (IXML_Node *)Ele1);
|
||||||
ixmlNode_appendChild( node, ( IXML_Node * ) Ele1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
ArgName = va_arg( ArgList, const char * );
|
return UPNP_E_SUCCESS;
|
||||||
|
|
||||||
}
|
|
||||||
va_end( ArgList );
|
|
||||||
return PropSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EXCLUDE_DOM == 0
|
|
||||||
|
#endif /* EXCLUDE_DOM == 0 */
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
200
upnp/src/genlib/client_table/ClientSubscription.c
Normal file
200
upnp/src/genlib/client_table/ClientSubscription.c
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* 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 "ClientSubscription.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> // for calloc(), free()
|
||||||
|
|
||||||
|
|
||||||
|
struct SClientSubscription {
|
||||||
|
int m_renewEventId;
|
||||||
|
UpnpString *m_SID;
|
||||||
|
UpnpString *m_actualSID;
|
||||||
|
UpnpString *m_eventURL;
|
||||||
|
struct SClientSubscription *m_next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GenlibClientSubscription_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GenlibClientSubscription_dup(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
ClientSubscription *q = GenlibClientSubscription_new();
|
||||||
|
|
||||||
|
GenlibClientSubscription_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
if (q != p) {
|
||||||
|
/*struct SClientSubscription *_p = (struct SClientSubscription *)p;*/
|
||||||
|
struct SClientSubscription *_q = (struct SClientSubscription *)q;
|
||||||
|
// Do not copy RenewEventId
|
||||||
|
_q->m_renewEventId = -1;
|
||||||
|
GenlibClientSubscription_set_SID(q, GenlibClientSubscription_get_SID(p));
|
||||||
|
GenlibClientSubscription_set_ActualSID(q, GenlibClientSubscription_get_ActualSID(p));
|
||||||
|
GenlibClientSubscription_set_EventURL(q, GenlibClientSubscription_get_EventURL(p));
|
||||||
|
// Do not copy m_next
|
||||||
|
_q->m_next = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GenlibClientSubscription_get_RenewEventId(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_renewEventId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
|
||||||
|
{
|
||||||
|
((struct SClientSubscription *)p)->m_renewEventId = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *GenlibClientSubscription_get_SID(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *GenlibClientSubscription_get_SID_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(GenlibClientSubscription_get_SID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
|
||||||
|
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_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 *GenlibClientSubscription_get_ActualSID(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_actualSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *GenlibClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(GenlibClientSubscription_get_ActualSID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
|
||||||
|
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_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 *GenlibClientSubscription_get_EventURL(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_eventURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *GenlibClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(GenlibClientSubscription_get_EventURL(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
|
||||||
|
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_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 *GenlibClientSubscription_get_Next(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GenlibClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
|
||||||
|
{
|
||||||
|
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
@@ -1,209 +1,119 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// 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
|
* Purpose: This file defines the functions for clients. It defines
|
||||||
* functions for adding and removing clients to and from the client table,
|
* functions for adding and removing clients to and from the client table,
|
||||||
* adding and accessing subscription and other attributes pertaining to the
|
* adding and accessing subscription and other attributes pertaining to the
|
||||||
* client
|
* client
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
#include "client_table.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;}
|
|
||||||
|
|
||||||
/************************************************************************
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
* 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 );}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub->RenewEventId = -1;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
#include <stdlib.h> // for calloc(), free()
|
||||||
* 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;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* 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;}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
void free_client_subscription(ClientSubscription *sub)
|
||||||
* Function : GetClientSubClientSID
|
{
|
||||||
*
|
upnp_timeout *event;
|
||||||
* Parameters :
|
ThreadPoolJob tempJob;
|
||||||
* client_subscription *head ; Head of the subscription list
|
if (sub) {
|
||||||
* const Upnp_SID sid ; Subscription ID to be matched
|
int renewEventId = GenlibClientSubscription_get_RenewEventId(sub);
|
||||||
*
|
GenlibClientSubscription_strcpy_ActualSID(sub, "");
|
||||||
* Description : Return the client subscription from the client table
|
GenlibClientSubscription_strcpy_EventURL(sub, "");
|
||||||
* that matches const Upnp_SID sid subscrition id value.
|
if (renewEventId != -1) {
|
||||||
*
|
// do not remove timer event of copy
|
||||||
* Return : client_subscription * ; The matching subscription
|
// invalid timer event id
|
||||||
*
|
if (TimerThreadRemove(&gTimerThread, renewEventId, &tempJob) == 0) {
|
||||||
* Note :
|
event = (upnp_timeout *)tempJob.arg;
|
||||||
************************************************************************/
|
free_upnp_timeout(event);
|
||||||
client_subscription *
|
}
|
||||||
GetClientSubClientSID( client_subscription * head,
|
}
|
||||||
const Upnp_SID sid ) {
|
GenlibClientSubscription_set_RenewEventId(sub, -1);
|
||||||
client_subscription * next = head; while( next ) {
|
}
|
||||||
if( !strcmp( next->sid, sid ) )
|
}
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
next = next->next;}
|
|
||||||
}
|
|
||||||
return 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 ) )
|
void freeClientSubList(ClientSubscription *list)
|
||||||
break;
|
{
|
||||||
else
|
ClientSubscription *next;
|
||||||
{
|
while (list) {
|
||||||
next = next->next;}
|
free_client_subscription(list);
|
||||||
}
|
next = GenlibClientSubscription_get_Next(list);
|
||||||
return next;}
|
GenlibClientSubscription_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),
|
||||||
|
GenlibClientSubscription_get_SID_cstr(finger));
|
||||||
|
if (found) {
|
||||||
|
if (previous) {
|
||||||
|
GenlibClientSubscription_set_Next(previous,
|
||||||
|
GenlibClientSubscription_get_Next(finger));
|
||||||
|
} else {
|
||||||
|
*head = GenlibClientSubscription_get_Next(finger);
|
||||||
|
}
|
||||||
|
GenlibClientSubscription_set_Next(finger, NULL);
|
||||||
|
freeClientSubList(finger);
|
||||||
|
finger = NULL;
|
||||||
|
} else {
|
||||||
|
previous = finger;
|
||||||
|
finger = GenlibClientSubscription_get_Next(finger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpString *sid)
|
||||||
|
{
|
||||||
|
ClientSubscription *next = head;
|
||||||
|
int found = 0;
|
||||||
|
while (next) {
|
||||||
|
found = !strcmp(
|
||||||
|
GenlibClientSubscription_get_SID_cstr(next),
|
||||||
|
UpnpString_get_String(sid));
|
||||||
|
if(found) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
next = GenlibClientSubscription_get_Next(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
|
||||||
|
{
|
||||||
|
ClientSubscription *next = head;
|
||||||
|
while (next) {
|
||||||
|
if (!memcmp(
|
||||||
|
GenlibClientSubscription_get_ActualSID_cstr(next),
|
||||||
|
sid->buff, sid->size)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
next = GenlibClientSubscription_get_Next(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
)
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,52 +1,65 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#define _GNU_SOURCE // For strcasestr() in string.h
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include "strintmap.h"
|
#include "strintmap.h"
|
||||||
#include "httpparser.h"
|
#include "httpparser.h"
|
||||||
#include "statcodes.h"
|
#include "statcodes.h"
|
||||||
#include "unixutil.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
|
#define NUM_HTTP_METHODS 9
|
||||||
static str_int_entry Http_Method_Table[NUM_HTTP_METHODS] = {
|
static str_int_entry Http_Method_Table[NUM_HTTP_METHODS] = {
|
||||||
@@ -122,8 +135,8 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
|
|||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE void
|
static UPNP_INLINE void
|
||||||
scanner_init( OUT scanner_t * scanner,
|
scanner_init( OUT scanner_t *scanner,
|
||||||
IN membuffer * bufptr )
|
IN membuffer *bufptr )
|
||||||
{
|
{
|
||||||
scanner->cursor = 0;
|
scanner->cursor = 0;
|
||||||
scanner->msg = bufptr;
|
scanner->msg = bufptr;
|
||||||
@@ -395,12 +408,12 @@ scanner_get_str( IN scanner_t * scanner )
|
|||||||
*
|
*
|
||||||
* Note :
|
* Note :
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
#warning The only use of the function 'scanner_pushback()' in the code is commented out.
|
#pragma message ("The only use of the function 'scanner_pushback()' in the code is commented out.")
|
||||||
#warning 'scanner_pushback()' is a candidate for removal.
|
#pragma message ("'scanner_pushback()' is a candidate for removal.")
|
||||||
#else
|
#else
|
||||||
#pragma message ("The only use of the function 'scanner_pushback()' in the code is commented out.")
|
#warning The only use of the function 'scanner_pushback()' in the code is commented out.
|
||||||
#pragma message ("'scanner_pushback()' is a candidate for removal.")
|
#warning 'scanner_pushback()' is a candidate for removal.
|
||||||
#endif
|
#endif
|
||||||
static UPNP_INLINE void
|
static UPNP_INLINE void
|
||||||
scanner_pushback( INOUT scanner_t * scanner,
|
scanner_pushback( INOUT scanner_t * scanner,
|
||||||
@@ -970,12 +983,12 @@ read_until_crlf( INOUT scanner_t * scanner,
|
|||||||
* PARSE_FAILURE
|
* PARSE_FAILURE
|
||||||
* PARSE_INCOMPLETE
|
* PARSE_INCOMPLETE
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifndef WIN32
|
#ifdef WIN32
|
||||||
#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code.
|
#pragma message("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.
|
#pragma message("'skip_to_end_of_header()' is a candidate for removal.")
|
||||||
#else
|
#else
|
||||||
#pragma message("There are currently no uses of the function 'skip_to_end_of_header()' in the code.")
|
#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code.
|
||||||
#pragma message("'skip_to_end_of_header()' is a candidate for removal.")
|
#warning 'skip_to_end_of_header()' is a candidate for removal.
|
||||||
#endif
|
#endif
|
||||||
static UPNP_INLINE int
|
static UPNP_INLINE int
|
||||||
skip_to_end_of_header( INOUT scanner_t * scanner )
|
skip_to_end_of_header( INOUT scanner_t * scanner )
|
||||||
@@ -1532,7 +1545,9 @@ parser_parse_responseline( INOUT http_parser_t * parser )
|
|||||||
|
|
||||||
if( num_scanned != 3 ||
|
if( num_scanned != 3 ||
|
||||||
hmsg->major_version < 0 ||
|
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
|
// bad response line
|
||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -2496,26 +2511,15 @@ method_to_str( IN http_method_t method )
|
|||||||
return index == -1 ? NULL : Http_Method_Table[index].name;
|
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
|
#ifdef DEBUG
|
||||||
void
|
void print_http_headers(http_message_t *hmsg)
|
||||||
print_http_headers( http_message_t * hmsg )
|
|
||||||
{
|
{
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
// NNS: dlist_node *node;
|
/* NNS: dlist_node *node; */
|
||||||
http_header_t *header;
|
http_header_t *header;
|
||||||
|
|
||||||
// print start line
|
/* print start line */
|
||||||
if( hmsg->is_request ) {
|
if( hmsg->is_request ) {
|
||||||
printf( "method = %d, version = %d.%d, url = %.*s\n",
|
printf( "method = %d, version = %d.%d, url = %.*s\n",
|
||||||
hmsg->method, hmsg->major_version, hmsg->minor_version,
|
hmsg->method, hmsg->major_version, hmsg->minor_version,
|
||||||
@@ -2526,18 +2530,18 @@ print_http_headers( http_message_t * hmsg )
|
|||||||
(int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
(int)hmsg->status_msg.length, hmsg->status_msg.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// print headers
|
/* print headers */
|
||||||
node = ListHead( &hmsg->headers );
|
node = ListHead( &hmsg->headers );
|
||||||
// NNS: node = dlist_first_node( &hmsg->headers );
|
/* NNS: node = dlist_first_node( &hmsg->headers ); */
|
||||||
while( node != NULL ) {
|
while( node != NULL ) {
|
||||||
header = ( http_header_t * ) node->item;
|
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",
|
printf( "hdr name: %.*s, value: %.*s\n",
|
||||||
(int)header->name.length, header->name.buf,
|
(int)header->name.length, header->name.buf,
|
||||||
(int)header->value.length, header->value.buf );
|
(int)header->value.length, header->value.buf );
|
||||||
|
|
||||||
node = ListNext( &hmsg->headers, node );
|
node = ListNext( &hmsg->headers, node );
|
||||||
// NNS: node = dlist_next( &hmsg->headers, node );
|
/* NNS: node = dlist_next( &hmsg->headers, node ); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file defines the functionality making use of the http
|
* Purpose: This file defines the functionality making use of the http
|
||||||
@@ -35,10 +36,28 @@
|
|||||||
* messages
|
* messages
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "httpreadwrite.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "unixutil.h"
|
||||||
|
#include "upnp.h"
|
||||||
|
#include "upnpapi.h"
|
||||||
|
#include "membuffer.h"
|
||||||
|
#include "uri.h"
|
||||||
|
#include "statcodes.h"
|
||||||
|
#include "sock.h"
|
||||||
|
#include "UpnpInet.h"
|
||||||
|
#include "webserver.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPNP_USE_BCBPP
|
#ifndef UPNP_USE_BCBPP
|
||||||
#ifndef UPNP_USE_MSVCPP
|
#ifndef UPNP_USE_MSVCPP
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -46,29 +65,19 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#else
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include "unixutil.h"
|
|
||||||
#include "upnp.h"
|
|
||||||
#include "upnpapi.h"
|
|
||||||
#include "membuffer.h"
|
|
||||||
#include "uri.h"
|
|
||||||
#include "statcodes.h"
|
|
||||||
#include "httpreadwrite.h"
|
|
||||||
#include "sock.h"
|
|
||||||
#include "webserver.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -126,9 +135,9 @@ http_FixUrl( IN uri_type * url,
|
|||||||
* Function: http_FixStrUrl
|
* Function: http_FixStrUrl
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN char* urlstr ; Character string as a URL
|
* IN const char* urlstr; Character string as a URL
|
||||||
* IN int urlstrlen ; Length of the character string
|
* IN int urlstrlen; Length of the character string
|
||||||
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
* OUT uri_type* fixed_url; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Parses URL and then validates URL
|
* Parses URL and then validates URL
|
||||||
@@ -138,7 +147,7 @@ http_FixUrl( IN uri_type * url,
|
|||||||
* UPNP_E_SUCCESS
|
* UPNP_E_SUCCESS
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_FixStrUrl( IN char *urlstr,
|
http_FixStrUrl( IN const char *urlstr,
|
||||||
IN int urlstrlen,
|
IN int urlstrlen,
|
||||||
OUT uri_type * fixed_url )
|
OUT uri_type * fixed_url )
|
||||||
{
|
{
|
||||||
@@ -175,13 +184,13 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
|
|
||||||
http_FixUrl( destination_url, url );
|
http_FixUrl( destination_url, url );
|
||||||
|
|
||||||
connfd = socket( AF_INET, SOCK_STREAM, 0 );
|
connfd = socket( url->hostport.IPaddress.ss_family, SOCK_STREAM, 0 );
|
||||||
if( connfd == -1 ) {
|
if( connfd == -1 ) {
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( connect( connfd, ( struct sockaddr * )&url->hostport.IPv4address,
|
if( connect( connfd, ( struct sockaddr * )&url->hostport.IPaddress,
|
||||||
sizeof( struct sockaddr_in ) ) == -1 ) {
|
sizeof( url->hostport.IPaddress ) ) == -1 ) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__,
|
||||||
"connect error: %d\n", WSAGetLastError());
|
"connect error: %d\n", WSAGetLastError());
|
||||||
@@ -195,8 +204,12 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: http_RecvMessage
|
* \brief Get the data on the socket and take actions based on the read data to
|
||||||
|
* modify the parser objects buffer.
|
||||||
|
*
|
||||||
|
* If an error is reported while parsing the data, the error code is passed in
|
||||||
|
* the http_errr_code parameter.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info; Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
@@ -205,81 +218,96 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
* IN OUT int* timeout_secs; time out
|
* IN OUT int* timeout_secs; time out
|
||||||
* OUT int* http_error_code; HTTP error code returned
|
* OUT int* http_error_code; HTTP error code returned
|
||||||
*
|
*
|
||||||
* Description:
|
* \return
|
||||||
* Get the data on the socket and take actions based on the read data
|
|
||||||
* to modify the parser objects buffer. If an error is reported while
|
|
||||||
* parsing the data, the error code is passed in the http_errr_code
|
|
||||||
* parameter
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* UPNP_E_BAD_HTTPMSG
|
|
||||||
* UPNP_E_SUCCESS
|
* UPNP_E_SUCCESS
|
||||||
************************************************************************/
|
* UPNP_E_BAD_HTTPMSG
|
||||||
int
|
*/
|
||||||
http_RecvMessage( IN SOCKINFO * info,
|
int http_RecvMessage(
|
||||||
OUT http_parser_t * parser,
|
IN SOCKINFO *info,
|
||||||
IN http_method_t request_method,
|
OUT http_parser_t *parser,
|
||||||
IN OUT int *timeout_secs,
|
IN http_method_t request_method,
|
||||||
OUT int *http_error_code )
|
IN OUT int *timeout_secs,
|
||||||
|
OUT int *http_error_code)
|
||||||
{
|
{
|
||||||
parse_status_t status;
|
int ret = UPNP_E_SUCCESS;
|
||||||
int num_read;
|
int line = 0;
|
||||||
xboolean ok_on_close = FALSE;
|
parse_status_t status;
|
||||||
char buf[2 * 1024];
|
int num_read;
|
||||||
|
xboolean ok_on_close = FALSE;
|
||||||
|
char buf[2 * 1024];
|
||||||
|
|
||||||
if( request_method == HTTPMETHOD_UNKNOWN ) {
|
if (request_method == HTTPMETHOD_UNKNOWN) {
|
||||||
parser_request_init( parser );
|
parser_request_init(parser);
|
||||||
} else {
|
} else {
|
||||||
parser_response_init( parser, request_method );
|
parser_response_init(parser, request_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
while( TRUE ) {
|
while (TRUE) {
|
||||||
num_read = sock_read( info, buf, sizeof( buf ), timeout_secs );
|
num_read = sock_read(info, buf, sizeof buf, timeout_secs);
|
||||||
if( num_read > 0 ) {
|
if (num_read > 0) {
|
||||||
// got data
|
// got data
|
||||||
status = parser_append( parser, buf, num_read );
|
status = parser_append(parser, buf, num_read);
|
||||||
|
if (status == PARSE_SUCCESS) {
|
||||||
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
|
parser->msg.msg.buf );
|
||||||
|
print_http_headers( &parser->msg );
|
||||||
|
if (parser->content_length > (unsigned int)g_maxContentLength) {
|
||||||
|
*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
|
||||||
|
line = __LINE__;
|
||||||
|
ret = UPNP_E_OUTOF_BOUNDS;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
line = __LINE__;
|
||||||
|
ret = 0;
|
||||||
|
goto ExitFunction;
|
||||||
|
} else if (status == PARSE_FAILURE) {
|
||||||
|
*http_error_code = parser->http_error_code;
|
||||||
|
line = __LINE__;
|
||||||
|
ret = UPNP_E_BAD_HTTPMSG;
|
||||||
|
goto ExitFunction;
|
||||||
|
} else if (status == PARSE_INCOMPLETE_ENTITY) {
|
||||||
|
// read until close
|
||||||
|
ok_on_close = TRUE;
|
||||||
|
} else if (status == PARSE_CONTINUE_1) {
|
||||||
|
// Web post request.
|
||||||
|
line = __LINE__;
|
||||||
|
ret = PARSE_SUCCESS;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
} else if (num_read == 0) {
|
||||||
|
if (ok_on_close) {
|
||||||
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
|
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
||||||
|
parser->msg.msg.buf );
|
||||||
|
print_http_headers(&parser->msg);
|
||||||
|
line = __LINE__;
|
||||||
|
ret = 0;
|
||||||
|
goto ExitFunction;
|
||||||
|
} else {
|
||||||
|
// partial msg
|
||||||
|
*http_error_code = HTTP_BAD_REQUEST; // or response
|
||||||
|
line = __LINE__;
|
||||||
|
ret = UPNP_E_BAD_HTTPMSG;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*http_error_code = parser->http_error_code;
|
||||||
|
line = __LINE__;
|
||||||
|
ret = num_read;
|
||||||
|
goto ExitFunction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( status == PARSE_SUCCESS ) {
|
ExitFunction:
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
UpnpPrintf(UPNP_ALL, HTTP, __FILE__, line,
|
||||||
parser->msg.msg.buf );
|
"(http_RecvMessage): Error %d, http_error_code = %d.\n",
|
||||||
print_http_headers( &parser->msg );
|
ret,
|
||||||
|
*http_error_code);
|
||||||
|
}
|
||||||
|
|
||||||
if( parser->content_length >
|
return ret;
|
||||||
( unsigned int )g_maxContentLength ) {
|
|
||||||
*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
|
|
||||||
return UPNP_E_OUTOF_BOUNDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else if( status == PARSE_FAILURE ) {
|
|
||||||
*http_error_code = parser->http_error_code;
|
|
||||||
return UPNP_E_BAD_HTTPMSG;
|
|
||||||
} else if( status == PARSE_INCOMPLETE_ENTITY ) {
|
|
||||||
// read until close
|
|
||||||
ok_on_close = TRUE;
|
|
||||||
} else if( status == PARSE_CONTINUE_1 ) //Web post request. murari
|
|
||||||
{
|
|
||||||
return PARSE_SUCCESS;
|
|
||||||
}
|
|
||||||
} else if( num_read == 0 ) {
|
|
||||||
if( ok_on_close ) {
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
"<<< (RECVD) <<<\n%s\n-----------------\n",
|
|
||||||
parser->msg.msg.buf );
|
|
||||||
print_http_headers( &parser->msg );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
// partial msg
|
|
||||||
*http_error_code = HTTP_BAD_REQUEST; // or response
|
|
||||||
return UPNP_E_BAD_HTTPMSG;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*http_error_code = parser->http_error_code;
|
|
||||||
return num_read;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -521,7 +549,7 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
int http_error_code;
|
int http_error_code;
|
||||||
SOCKINFO info;
|
SOCKINFO info;
|
||||||
|
|
||||||
tcp_connection = socket( AF_INET, SOCK_STREAM, 0 );
|
tcp_connection = socket( destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0 );
|
||||||
if( tcp_connection == -1 ) {
|
if( tcp_connection == -1 ) {
|
||||||
parser_response_init( response, req_method );
|
parser_response_init( response, req_method );
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
@@ -535,7 +563,7 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
// connect
|
// connect
|
||||||
ret_code = connect( info.socket,
|
ret_code = connect( info.socket,
|
||||||
( struct sockaddr * )&destination->hostport.
|
( struct sockaddr * )&destination->hostport.
|
||||||
IPv4address, sizeof( struct sockaddr_in ) );
|
IPaddress, sizeof( struct sockaddr_storage ) );
|
||||||
|
|
||||||
if( ret_code == -1 ) {
|
if( ret_code == -1 ) {
|
||||||
sock_destroy( &info, SD_BOTH );
|
sock_destroy( &info, SD_BOTH );
|
||||||
@@ -642,8 +670,9 @@ http_Download( IN const char *url_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n----------END--------\n", request.buf );
|
"HTTP Buffer:\n%s\n" "----------END--------\n",
|
||||||
|
request.buf);
|
||||||
// get doc msg
|
// get doc msg
|
||||||
ret_code =
|
ret_code =
|
||||||
http_RequestAndResponse( &url, request.buf, request.length,
|
http_RequestAndResponse( &url, request.buf, request.length,
|
||||||
@@ -813,9 +842,9 @@ MakePostMessage( const char *url_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n%s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf);
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -1005,7 +1034,7 @@ http_OpenHttpPost( IN const char *url_str,
|
|||||||
|
|
||||||
handle->contentLength = contentLength;
|
handle->contentLength = contentLength;
|
||||||
|
|
||||||
tcp_connection = socket( AF_INET, SOCK_STREAM, 0 );
|
tcp_connection = socket( url.hostport.IPaddress.ss_family, SOCK_STREAM, 0 );
|
||||||
if( tcp_connection == -1 ) {
|
if( tcp_connection == -1 ) {
|
||||||
ret_code = UPNP_E_SOCKET_ERROR;
|
ret_code = UPNP_E_SOCKET_ERROR;
|
||||||
goto errorHandler;
|
goto errorHandler;
|
||||||
@@ -1019,8 +1048,8 @@ http_OpenHttpPost( IN const char *url_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_code = connect( handle->sock_info.socket,
|
ret_code = connect( handle->sock_info.socket,
|
||||||
( struct sockaddr * )&url.hostport.IPv4address,
|
( struct sockaddr * )&url.hostport.IPaddress,
|
||||||
sizeof( struct sockaddr_in ) );
|
sizeof( struct sockaddr_storage ) );
|
||||||
|
|
||||||
if( ret_code == -1 ) {
|
if( ret_code == -1 ) {
|
||||||
sock_destroy( &handle->sock_info, SD_BOTH );
|
sock_destroy( &handle->sock_info, SD_BOTH );
|
||||||
@@ -1132,9 +1161,9 @@ MakeGetMessage( const char *url_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n%s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf);
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -1587,7 +1616,7 @@ http_OpenHttpGetProxy( IN const char *url_str,
|
|||||||
handle->cancel = 0;
|
handle->cancel = 0;
|
||||||
parser_response_init( &handle->response, HTTPMETHOD_GET );
|
parser_response_init( &handle->response, HTTPMETHOD_GET );
|
||||||
|
|
||||||
tcp_connection = socket( AF_INET, SOCK_STREAM, 0 );
|
tcp_connection = socket( peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0 );
|
||||||
if( tcp_connection == -1 ) {
|
if( tcp_connection == -1 ) {
|
||||||
ret_code = UPNP_E_SOCKET_ERROR;
|
ret_code = UPNP_E_SOCKET_ERROR;
|
||||||
goto errorHandler;
|
goto errorHandler;
|
||||||
@@ -1601,8 +1630,8 @@ http_OpenHttpGetProxy( IN const char *url_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_code = connect( handle->sock_info.socket,
|
ret_code = connect( handle->sock_info.socket,
|
||||||
( struct sockaddr * )&peer->hostport.IPv4address,
|
( struct sockaddr * )&peer->hostport.IPaddress,
|
||||||
sizeof( struct sockaddr_in ) );
|
sizeof( struct sockaddr_storage ) );
|
||||||
|
|
||||||
if( ret_code == -1 ) {
|
if( ret_code == -1 ) {
|
||||||
sock_destroy( &handle->sock_info, SD_BOTH );
|
sock_destroy( &handle->sock_info, SD_BOTH );
|
||||||
@@ -2138,9 +2167,9 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
}
|
}
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"HTTP Buffer:\n %s\n" "----------END--------\n",
|
"HTTP Buffer:\n%s\n" "----------END--------\n",
|
||||||
request->buf );
|
request->buf);
|
||||||
|
|
||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
@@ -2236,7 +2265,7 @@ http_OpenHttpGetEx( IN const char *url_str,
|
|||||||
handle->entity_offset = 0;
|
handle->entity_offset = 0;
|
||||||
parser_response_init( &handle->response, HTTPMETHOD_GET );
|
parser_response_init( &handle->response, HTTPMETHOD_GET );
|
||||||
|
|
||||||
tcp_connection = socket( AF_INET, SOCK_STREAM, 0 );
|
tcp_connection = socket( url.hostport.IPaddress.ss_family, SOCK_STREAM, 0 );
|
||||||
if( tcp_connection == -1 ) {
|
if( tcp_connection == -1 ) {
|
||||||
errCode = UPNP_E_SOCKET_ERROR;
|
errCode = UPNP_E_SOCKET_ERROR;
|
||||||
free( handle );
|
free( handle );
|
||||||
@@ -2252,8 +2281,8 @@ http_OpenHttpGetEx( IN const char *url_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
errCode = connect( handle->sock_info.socket,
|
errCode = connect( handle->sock_info.socket,
|
||||||
( struct sockaddr * )&url.hostport.IPv4address,
|
( struct sockaddr * )&url.hostport.IPaddress,
|
||||||
sizeof( struct sockaddr_in ) );
|
sizeof( struct sockaddr_storage ) );
|
||||||
if( errCode == -1 ) {
|
if( errCode == -1 ) {
|
||||||
sock_destroy( &handle->sock_info, SD_BOTH );
|
sock_destroy( &handle->sock_info, SD_BOTH );
|
||||||
errCode = UPNP_E_SOCKET_CONNECT;
|
errCode = UPNP_E_SOCKET_CONNECT;
|
||||||
|
|||||||
@@ -1,63 +1,82 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Purpose: This file defines the Web Server and has functions to carry out
|
* Purpose: This file defines the Web Server and has functions to carry out
|
||||||
* operations of the Web Server.
|
* operations of the Web Server.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#ifndef UPNP_USE_BCBPP
|
#include "webserver.h"
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
#include "FileInfo.h"
|
||||||
#include "util.h"
|
|
||||||
#include "strintmap.h"
|
|
||||||
#include "membuffer.h"
|
|
||||||
#include "httpparser.h"
|
#include "httpparser.h"
|
||||||
#include "httpreadwrite.h"
|
#include "httpreadwrite.h"
|
||||||
|
#include "ithread.h"
|
||||||
|
#include "membuffer.h"
|
||||||
|
#include "ssdplib.h"
|
||||||
#include "statcodes.h"
|
#include "statcodes.h"
|
||||||
#include "webserver.h"
|
#include "strintmap.h"
|
||||||
|
#include "unixutil.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "upnpapi.h"
|
#include "upnpapi.h"
|
||||||
#include "ssdplib.h"
|
#include "util.h"
|
||||||
|
#include "VirtualDir.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef UPNP_USE_BCBPP
|
||||||
|
/* Do not #include <inttypes.h> */
|
||||||
|
/* Do not #include <stdint.h> */
|
||||||
|
#else
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif /* !UPNP_USE_BCBPP */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/* Do not #include <unistd.h> */
|
||||||
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "ithread.h"
|
|
||||||
#include "unixutil.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Response Types
|
Response Types
|
||||||
@@ -279,38 +298,39 @@ search_extension( IN const char *extension,
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* filename,
|
* IN const char* filename,
|
||||||
* OUT DOMString* content_type
|
* OUT UpnpFileInfo *fileInfo
|
||||||
*
|
*
|
||||||
* Description: Based on the extension, clones an XML string based on
|
* Description: Based on the extension, sets the content type of fileInfo
|
||||||
* type and content subtype. If content type and sub type are not
|
* based on type and content subtype. If content type and sub type
|
||||||
* found, unknown types are used
|
* are not found, unknown types are used
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 - On Sucess
|
* 0 - On Sucess
|
||||||
* UPNP_E_OUTOF_MEMORY - on memory allocation failures
|
* UPNP_E_OUTOF_MEMORY - on memory allocation failures
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
UPNP_INLINE int
|
UPNP_INLINE int
|
||||||
get_content_type( IN const char *filename,
|
get_content_type(
|
||||||
OUT DOMString * content_type )
|
IN const char *filename,
|
||||||
|
OUT UpnpFileInfo *fileInfo)
|
||||||
{
|
{
|
||||||
const char *extension;
|
const char *extension;
|
||||||
const char *type,
|
const char *type;
|
||||||
*subtype;
|
const char *subtype;
|
||||||
xboolean ctype_found = FALSE;
|
xboolean ctype_found = FALSE;
|
||||||
char *temp = NULL;
|
char *temp = NULL;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
( *content_type ) = NULL;
|
UpnpFileInfo_set_ContentType(fileInfo, NULL);
|
||||||
|
|
||||||
// get ext
|
// get ext
|
||||||
extension = strrchr( filename, '.' );
|
extension = strrchr( filename, '.' );
|
||||||
if( extension != NULL ) {
|
if (extension != NULL) {
|
||||||
if( search_extension( extension + 1, &type, &subtype ) == 0 ) {
|
if( search_extension( extension + 1, &type, &subtype ) == 0 ) {
|
||||||
ctype_found = TRUE;
|
ctype_found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !ctype_found ) {
|
if (!ctype_found) {
|
||||||
// unknown content type
|
// unknown content type
|
||||||
type = gMediaTypes[APPLICATION_INDEX];
|
type = gMediaTypes[APPLICATION_INDEX];
|
||||||
subtype = "octet-stream";
|
subtype = "octet-stream";
|
||||||
@@ -318,17 +338,14 @@ get_content_type( IN const char *filename,
|
|||||||
|
|
||||||
length = strlen( type ) + strlen( "/" ) + strlen( subtype ) + 1;
|
length = strlen( type ) + strlen( "/" ) + strlen( subtype ) + 1;
|
||||||
temp = ( char * )malloc( length );
|
temp = ( char * )malloc( length );
|
||||||
|
if (!temp) {
|
||||||
if( !temp ) {
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( temp, "%s/%s", type, subtype );
|
sprintf( temp, "%s/%s", type, subtype );
|
||||||
( *content_type ) = ixmlCloneDOMString( temp );
|
UpnpFileInfo_set_ContentType(fileInfo, temp);
|
||||||
|
free(temp);
|
||||||
|
|
||||||
free( temp );
|
if (!UpnpFileInfo_get_ContentType(fileInfo)) {
|
||||||
|
|
||||||
if( !content_type ) {
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,40 +531,33 @@ web_server_set_alias( IN const char *alias_name,
|
|||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: web_server_init
|
int web_server_init()
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* none
|
|
||||||
*
|
|
||||||
* Description: Initilialize the different documents. Initialize the
|
|
||||||
* memory for root directory for web server. Call to initialize global
|
|
||||||
* XML document. Sets bWebServerState to WEB_SERVER_ENABLED
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* 0 - OK
|
|
||||||
* UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
web_server_init( void )
|
|
||||||
{
|
{
|
||||||
int ret_code;
|
int ret = 0;
|
||||||
|
if (bWebServerState == WEB_SERVER_DISABLED) {
|
||||||
|
// decode media list
|
||||||
|
media_list_init();
|
||||||
|
membuffer_init(&gDocumentRootDir);
|
||||||
|
glob_alias_init();
|
||||||
|
pVirtualDirList = NULL;
|
||||||
|
|
||||||
if( bWebServerState == WEB_SERVER_DISABLED ) {
|
// Initialize callbacks
|
||||||
media_list_init(); // decode media list
|
virtualDirCallback.get_info = NULL;
|
||||||
membuffer_init( &gDocumentRootDir );
|
virtualDirCallback.open = NULL;
|
||||||
glob_alias_init();
|
virtualDirCallback.read = NULL;
|
||||||
|
virtualDirCallback.write = NULL;
|
||||||
|
virtualDirCallback.seek = NULL;
|
||||||
|
virtualDirCallback.close = NULL;
|
||||||
|
|
||||||
pVirtualDirList = NULL;
|
if (ithread_mutex_init(&gWebMutex, NULL) == -1) {
|
||||||
|
ret = UPNP_E_OUTOF_MEMORY;
|
||||||
|
} else {
|
||||||
|
bWebServerState = WEB_SERVER_ENABLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret_code = ithread_mutex_init( &gWebMutex, NULL );
|
return ret;
|
||||||
if( ret_code == -1 ) {
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
|
||||||
}
|
|
||||||
bWebServerState = WEB_SERVER_ENABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@@ -586,8 +596,8 @@ web_server_destroy( void )
|
|||||||
* Function: get_file_info
|
* Function: get_file_info
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* filename ; Filename having the description document
|
* IN const char *filename; Filename having the description document
|
||||||
* OUT struct File_Info * info ; File information object having file
|
* OUT UpnpFileInfo *info; File information object having file
|
||||||
* attributes such as filelength, when was the file last
|
* attributes such as filelength, when was the file last
|
||||||
* modified, whether a file or a directory and whether the
|
* modified, whether a file or a directory and whether the
|
||||||
* file or directory is readable.
|
* file or directory is readable.
|
||||||
@@ -600,48 +610,50 @@ web_server_destroy( void )
|
|||||||
* int
|
* int
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static int
|
static int
|
||||||
get_file_info( IN const char *filename,
|
get_file_info(
|
||||||
OUT struct File_Info *info )
|
IN const char *filename,
|
||||||
|
OUT UpnpFileInfo *info)
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
info->content_type = NULL;
|
UpnpFileInfo_set_ContentType(info, NULL);
|
||||||
|
|
||||||
code = stat( filename, &s );
|
code = stat(filename, &s);
|
||||||
if( code == -1 ) {
|
if (code == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( S_ISDIR( s.st_mode ) ) {
|
if (S_ISDIR(s.st_mode)) {
|
||||||
info->is_directory = TRUE;
|
UpnpFileInfo_set_IsDirectory(info, TRUE);
|
||||||
} else if( S_ISREG( s.st_mode ) ) {
|
} else if (S_ISREG(s.st_mode)) {
|
||||||
info->is_directory = FALSE;
|
UpnpFileInfo_set_IsDirectory(info, FALSE);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check readable
|
// check readable
|
||||||
fp = fopen( filename, "r" );
|
fp = fopen(filename, "r");
|
||||||
info->is_readable = ( fp != NULL );
|
UpnpFileInfo_set_IsReadable(info, fp != NULL);
|
||||||
if( fp ) {
|
if (fp) {
|
||||||
fclose( fp );
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
info->file_length = s.st_size;
|
UpnpFileInfo_set_FileLength(info, s.st_size);
|
||||||
info->last_modified = s.st_mtime;
|
UpnpFileInfo_set_LastModified(info, &s.st_mtime);
|
||||||
|
|
||||||
rc = get_content_type( filename, &info->content_type );
|
rc = get_content_type(filename, info);
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
|
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
|
||||||
filename, (long long)info->file_length,
|
filename,
|
||||||
asctime( gmtime( &info->last_modified ) ),
|
(long long)UpnpFileInfo_get_FileLength(info),
|
||||||
info->is_readable );
|
asctime(gmtime(UpnpFileInfo_get_LastModified(info))),
|
||||||
|
UpnpFileInfo_get_IsReadable(info));
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@@ -683,10 +695,10 @@ web_server_set_root_dir( IN const char *root_dir )
|
|||||||
* Function: get_alias
|
* Function: get_alias
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* request_file ; request file passed in to be compared with
|
* IN const char *request_file; request file passed in to be compared with
|
||||||
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
|
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
|
||||||
* stored
|
* stored
|
||||||
* OUT struct File_Info * info ; File information object which will be
|
* OUT UpnpFileInfo *info; File information object which will be
|
||||||
* filled up if the file comparison succeeds
|
* filled up if the file comparison succeeds
|
||||||
*
|
*
|
||||||
* Description: Compare the files names between the one on the XML alias
|
* Description: Compare the files names between the one on the XML alias
|
||||||
@@ -698,22 +710,21 @@ web_server_set_root_dir( IN const char *root_dir )
|
|||||||
* FALSE if request is not an alias
|
* FALSE if request is not an alias
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE xboolean
|
static UPNP_INLINE xboolean
|
||||||
get_alias( IN const char *request_file,
|
get_alias(
|
||||||
OUT struct xml_alias_t *alias,
|
IN const char *request_file,
|
||||||
OUT struct File_Info *info )
|
OUT struct xml_alias_t *alias,
|
||||||
|
OUT UpnpFileInfo *info)
|
||||||
{
|
{
|
||||||
int cmp;
|
int cmp = strcmp(alias->name.buf, request_file);
|
||||||
|
if (cmp == 0) {
|
||||||
|
// fill up info
|
||||||
|
UpnpFileInfo_set_FileLength(info, alias->doc.length);
|
||||||
|
UpnpFileInfo_set_IsDirectory(info, FALSE);
|
||||||
|
UpnpFileInfo_set_IsReadable(info, TRUE);
|
||||||
|
UpnpFileInfo_set_LastModified(info, &alias->last_modified);
|
||||||
|
}
|
||||||
|
|
||||||
cmp = strcmp( alias->name.buf, request_file );
|
return cmp == 0;
|
||||||
if( cmp == 0 ) {
|
|
||||||
// fill up info
|
|
||||||
info->file_length = alias->doc.length;
|
|
||||||
info->is_readable = TRUE;
|
|
||||||
info->is_directory = FALSE;
|
|
||||||
info->last_modified = alias->last_modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmp == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@@ -1197,16 +1208,16 @@ process_request( IN http_message_t * req,
|
|||||||
int err_code;
|
int err_code;
|
||||||
|
|
||||||
char *request_doc;
|
char *request_doc;
|
||||||
struct File_Info finfo;
|
UpnpFileInfo *finfo;
|
||||||
xboolean using_alias;
|
xboolean using_alias;
|
||||||
xboolean using_virtual_dir;
|
xboolean using_virtual_dir;
|
||||||
uri_type *url;
|
uri_type *url;
|
||||||
char *temp_str;
|
char *temp_str;
|
||||||
int resp_major,
|
int resp_major;
|
||||||
resp_minor;
|
int resp_minor;
|
||||||
xboolean alias_grabbed;
|
xboolean alias_grabbed;
|
||||||
size_t dummy;
|
size_t dummy;
|
||||||
struct UpnpVirtualDirCallbacks *pVirtualDirCallback;
|
const char *extra_headers;
|
||||||
|
|
||||||
print_http_headers( req );
|
print_http_headers( req );
|
||||||
|
|
||||||
@@ -1218,7 +1229,7 @@ process_request( IN http_message_t * req,
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
request_doc = NULL;
|
request_doc = NULL;
|
||||||
finfo.content_type = NULL;
|
finfo = UpnpFileInfo_new();
|
||||||
alias_grabbed = FALSE;
|
alias_grabbed = FALSE;
|
||||||
err_code = HTTP_INTERNAL_SERVER_ERROR; // default error
|
err_code = HTTP_INTERNAL_SERVER_ERROR; // default error
|
||||||
using_virtual_dir = FALSE;
|
using_virtual_dir = FALSE;
|
||||||
@@ -1258,53 +1269,46 @@ process_request( IN http_message_t * req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//
|
/* try using alias */
|
||||||
// try using alias
|
if (is_valid_alias(&gAliasDoc)) {
|
||||||
//
|
alias_grab(alias);
|
||||||
if( is_valid_alias( &gAliasDoc ) ) {
|
|
||||||
alias_grab( alias );
|
|
||||||
alias_grabbed = TRUE;
|
alias_grabbed = TRUE;
|
||||||
|
using_alias = get_alias(request_doc, alias, finfo);
|
||||||
using_alias = get_alias( request_doc, alias, &finfo );
|
if (using_alias == TRUE) {
|
||||||
if( using_alias == TRUE ) {
|
UpnpFileInfo_set_ContentType(finfo, "text/xml; charset=\"utf-8\"");
|
||||||
finfo.content_type = ixmlCloneDOMString( "text/xml" );
|
if (UpnpFileInfo_get_ContentType(finfo) == NULL) {
|
||||||
|
|
||||||
if( finfo.content_type == NULL ) {
|
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( using_virtual_dir ) {
|
if (using_virtual_dir) {
|
||||||
if( req->method != HTTPMETHOD_POST ) {
|
if (req->method != HTTPMETHOD_POST) {
|
||||||
// get file info
|
// get file info
|
||||||
pVirtualDirCallback = &virtualDirCallback;
|
if (virtualDirCallback.get_info(filename->buf, finfo) != 0) {
|
||||||
if( pVirtualDirCallback->get_info( filename->buf, &finfo ) !=
|
|
||||||
0 ) {
|
|
||||||
err_code = HTTP_NOT_FOUND;
|
err_code = HTTP_NOT_FOUND;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
// try index.html if req is a dir
|
// try index.html if req is a dir
|
||||||
if( finfo.is_directory ) {
|
if (UpnpFileInfo_get_IsDirectory(finfo)) {
|
||||||
if( filename->buf[filename->length - 1] == '/' ) {
|
if (filename->buf[filename->length - 1] == '/') {
|
||||||
temp_str = "index.html";
|
temp_str = "index.html";
|
||||||
} else {
|
} else {
|
||||||
temp_str = "/index.html";
|
temp_str = "/index.html";
|
||||||
}
|
}
|
||||||
if( membuffer_append_str( filename, temp_str ) != 0 ) {
|
if ( membuffer_append_str(filename, temp_str) != 0) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
// get info
|
// get info
|
||||||
if( ( pVirtualDirCallback->
|
if (virtualDirCallback.get_info(filename->buf, finfo) != UPNP_E_SUCCESS ||
|
||||||
get_info( filename->buf, &finfo ) != UPNP_E_SUCCESS )
|
UpnpFileInfo_get_IsDirectory(finfo)) {
|
||||||
|| finfo.is_directory ) {
|
|
||||||
err_code = HTTP_NOT_FOUND;
|
err_code = HTTP_NOT_FOUND;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not readable
|
// not readable
|
||||||
if( !finfo.is_readable ) {
|
if (!UpnpFileInfo_get_IsReadable(finfo)) {
|
||||||
err_code = HTTP_FORBIDDEN;
|
err_code = HTTP_FORBIDDEN;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
@@ -1314,7 +1318,7 @@ process_request( IN http_message_t * req,
|
|||||||
// goto error_handler;
|
// goto error_handler;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
} else if( !using_alias ) {
|
} else if (!using_alias) {
|
||||||
if( gDocumentRootDir.length == 0 ) {
|
if( gDocumentRootDir.length == 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
@@ -1335,12 +1339,12 @@ process_request( IN http_message_t * req,
|
|||||||
|
|
||||||
if( req->method != HTTPMETHOD_POST ) {
|
if( req->method != HTTPMETHOD_POST ) {
|
||||||
// get info on file
|
// get info on file
|
||||||
if( get_file_info( filename->buf, &finfo ) != 0 ) {
|
if (get_file_info(filename->buf, finfo) != 0) {
|
||||||
err_code = HTTP_NOT_FOUND;
|
err_code = HTTP_NOT_FOUND;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
// try index.html if req is a dir
|
// try index.html if req is a dir
|
||||||
if( finfo.is_directory ) {
|
if (UpnpFileInfo_get_IsDirectory(finfo)) {
|
||||||
if( filename->buf[filename->length - 1] == '/' ) {
|
if( filename->buf[filename->length - 1] == '/' ) {
|
||||||
temp_str = "index.html";
|
temp_str = "index.html";
|
||||||
} else {
|
} else {
|
||||||
@@ -1350,14 +1354,14 @@ process_request( IN http_message_t * req,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
// get info
|
// get info
|
||||||
if( get_file_info( filename->buf, &finfo ) != 0 ||
|
if (get_file_info(filename->buf, finfo) != 0 ||
|
||||||
finfo.is_directory ) {
|
UpnpFileInfo_get_IsDirectory(finfo)) {
|
||||||
err_code = HTTP_NOT_FOUND;
|
err_code = HTTP_NOT_FOUND;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not readable
|
// not readable
|
||||||
if( !finfo.is_readable ) {
|
if (!UpnpFileInfo_get_IsReadable(finfo)) {
|
||||||
err_code = HTTP_FORBIDDEN;
|
err_code = HTTP_FORBIDDEN;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
@@ -1370,12 +1374,12 @@ process_request( IN http_message_t * req,
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
RespInstr->ReadSendSize = finfo.file_length;
|
RespInstr->ReadSendSize = UpnpFileInfo_get_FileLength(finfo);
|
||||||
|
|
||||||
// Check other header field.
|
// Check other header field.
|
||||||
if( ( err_code =
|
err_code =
|
||||||
CheckOtherHTTPHeaders( req, RespInstr,
|
CheckOtherHTTPHeaders(req, RespInstr, UpnpFileInfo_get_FileLength(finfo));
|
||||||
finfo.file_length ) ) != HTTP_OK ) {
|
if ( err_code != HTTP_OK ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,34 +1389,40 @@ process_request( IN http_message_t * req,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extra_headers = UpnpFileInfo_get_ExtraHeaders(finfo);
|
||||||
|
if (!extra_headers) {
|
||||||
|
extra_headers = "";
|
||||||
|
}
|
||||||
|
|
||||||
if( RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
|
if( RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
|
||||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||||
// Transfer-Encoding: chunked
|
// Transfer-Encoding: chunked
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
headers, resp_major, resp_minor,
|
headers, resp_major, resp_minor,
|
||||||
"R" "T" "GKD" "s" "tcS" "XcCc",
|
"R" "T" "GKD" "s" "tcS" "Xc" "sCc",
|
||||||
HTTP_PARTIAL_CONTENT, // status code
|
HTTP_PARTIAL_CONTENT, // status code
|
||||||
finfo.content_type, // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
RespInstr, // range info
|
RespInstr, // range info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
&finfo.last_modified,
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT) != 0 ) {
|
X_USER_AGENT,
|
||||||
|
extra_headers) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
} else if( RespInstr->IsRangeActive && !RespInstr->IsChunkActive ) {
|
} else if( RespInstr->IsRangeActive && !RespInstr->IsChunkActive ) {
|
||||||
|
|
||||||
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
|
||||||
// Transfer-Encoding: chunked
|
// Transfer-Encoding: chunked
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
headers, resp_major, resp_minor,
|
headers, resp_major, resp_minor,
|
||||||
"R" "N" "T" "GD" "s" "tcS" "XcCc",
|
"R" "N" "T" "GD" "s" "tcS" "Xc" "sCc",
|
||||||
HTTP_PARTIAL_CONTENT, // status code
|
HTTP_PARTIAL_CONTENT, // status code
|
||||||
RespInstr->ReadSendSize, // content length
|
RespInstr->ReadSendSize, // content length
|
||||||
finfo.content_type, // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
RespInstr, // range info
|
RespInstr, // range info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
&finfo.last_modified,
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT) != 0 ) {
|
X_USER_AGENT,
|
||||||
|
extra_headers) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1421,12 +1431,13 @@ process_request( IN http_message_t * req,
|
|||||||
// Transfer-Encoding: chunked
|
// Transfer-Encoding: chunked
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
headers, resp_major, resp_minor,
|
headers, resp_major, resp_minor,
|
||||||
"RK" "TD" "s" "tcS" "XcCc",
|
"RK" "TD" "s" "tcS" "Xc" "sCc",
|
||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
finfo.content_type, // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
&finfo.last_modified,
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT) != 0 ) {
|
X_USER_AGENT,
|
||||||
|
extra_headers) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1436,13 +1447,14 @@ process_request( IN http_message_t * req,
|
|||||||
// Transfer-Encoding: chunked
|
// Transfer-Encoding: chunked
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
headers, resp_major, resp_minor,
|
headers, resp_major, resp_minor,
|
||||||
"R" "N" "TD" "s" "tcS" "XcCc",
|
"R" "N" "TD" "s" "tcS" "Xc" "sCc",
|
||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
RespInstr->ReadSendSize, // content length
|
RespInstr->ReadSendSize, // content length
|
||||||
finfo.content_type, // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
&finfo.last_modified,
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT) != 0 ) {
|
X_USER_AGENT,
|
||||||
|
extra_headers) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1450,12 +1462,13 @@ process_request( IN http_message_t * req,
|
|||||||
// Transfer-Encoding: chunked
|
// Transfer-Encoding: chunked
|
||||||
if (http_MakeMessage(
|
if (http_MakeMessage(
|
||||||
headers, resp_major, resp_minor,
|
headers, resp_major, resp_minor,
|
||||||
"R" "TD" "s" "tcS" "XcCc",
|
"R" "TD" "s" "tcS" "b" "Xc" "sCc",
|
||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
finfo.content_type, // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
&finfo.last_modified,
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT) != 0 ) {
|
X_USER_AGENT,
|
||||||
|
extra_headers) != 0 ) {
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1481,11 +1494,11 @@ process_request( IN http_message_t * req,
|
|||||||
|
|
||||||
err_code = UPNP_E_SUCCESS;
|
err_code = UPNP_E_SUCCESS;
|
||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
free( request_doc );
|
free(request_doc);
|
||||||
ixmlFreeDOMString( finfo.content_type );
|
UpnpFileInfo_delete(finfo);
|
||||||
if( err_code != UPNP_E_SUCCESS && alias_grabbed ) {
|
if (err_code != UPNP_E_SUCCESS && alias_grabbed) {
|
||||||
alias_release( alias );
|
alias_release(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err_code;
|
return err_code;
|
||||||
@@ -1510,8 +1523,8 @@ process_request( IN http_message_t * req,
|
|||||||
* HTTP_OK
|
* HTTP_OK
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_RecvPostMessage( http_parser_t * parser,
|
http_RecvPostMessage( http_parser_t *parser,
|
||||||
IN SOCKINFO * info,
|
IN SOCKINFO *info,
|
||||||
char *filename,
|
char *filename,
|
||||||
struct SendInstruction *Instr )
|
struct SendInstruction *Instr )
|
||||||
{
|
{
|
||||||
@@ -1528,12 +1541,10 @@ http_RecvPostMessage( http_parser_t * parser,
|
|||||||
int ret_code = 0;
|
int ret_code = 0;
|
||||||
|
|
||||||
if( Instr && Instr->IsVirtualFile ) {
|
if( Instr && Instr->IsVirtualFile ) {
|
||||||
|
|
||||||
Fp = (virtualDirCallback.open)( filename, UPNP_WRITE );
|
Fp = (virtualDirCallback.open)( filename, UPNP_WRITE );
|
||||||
if( Fp == NULL ) {
|
if( Fp == NULL ) {
|
||||||
return HTTP_INTERNAL_SERVER_ERROR;
|
return HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Fp = fopen( filename, "wb" );
|
Fp = fopen( filename, "wb" );
|
||||||
if( Fp == NULL ) {
|
if( Fp == NULL ) {
|
||||||
|
|||||||
@@ -1,60 +1,58 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/**************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file implements the sockets functionality
|
* Purpose: This file implements the sockets functionality
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "sock.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */
|
||||||
|
#include "upnp.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.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
|
#ifndef MSG_NOSIGNAL
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@@ -62,7 +60,7 @@
|
|||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* OUT SOCKINFO* info ; Socket Information Object
|
* OUT SOCKINFO* info ; Socket Information Object
|
||||||
* IN int sockfd ; Socket Descriptor
|
* IN SOCKET sockfd ; Socket Descriptor
|
||||||
*
|
*
|
||||||
* Description : Assign the passed in socket descriptor to socket
|
* Description : Assign the passed in socket descriptor to socket
|
||||||
* descriptor in the SOCKINFO structure.
|
* descriptor in the SOCKINFO structure.
|
||||||
@@ -76,7 +74,7 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
sock_init( OUT SOCKINFO * info,
|
sock_init( OUT SOCKINFO * info,
|
||||||
IN int sockfd )
|
IN SOCKET sockfd )
|
||||||
{
|
{
|
||||||
assert( info );
|
assert( info );
|
||||||
|
|
||||||
@@ -91,10 +89,9 @@ sock_init( OUT SOCKINFO * info,
|
|||||||
* Function : sock_init_with_ip
|
* Function : sock_init_with_ip
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Parameters :
|
||||||
* OUT SOCKINFO* info ; Socket Information Object
|
* OUT SOCKINFO* info ; Socket Information Object
|
||||||
* IN int sockfd ; Socket Descriptor
|
* IN SOCKET sockfd ; Socket Descriptor
|
||||||
* IN struct in_addr foreign_ip_addr ; Remote IP Address
|
* IN struct sockaddr* foreign_sockaddr; remote socket address.
|
||||||
* IN unsigned short foreign_ip_port ; Remote Port number
|
|
||||||
*
|
*
|
||||||
* Description : Calls the sock_init function and assigns the passed in
|
* Description : Calls the sock_init function and assigns the passed in
|
||||||
* IP address and port to the IP address and port in the SOCKINFO
|
* IP address and port to the IP address and port in the SOCKINFO
|
||||||
@@ -109,9 +106,8 @@ sock_init( OUT SOCKINFO * info,
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
sock_init_with_ip( OUT SOCKINFO * info,
|
sock_init_with_ip( OUT SOCKINFO * info,
|
||||||
IN int sockfd,
|
IN SOCKET sockfd,
|
||||||
IN struct in_addr foreign_ip_addr,
|
IN struct sockaddr* foreign_sockaddr )
|
||||||
IN unsigned short foreign_ip_port )
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -120,8 +116,8 @@ sock_init_with_ip( OUT SOCKINFO * info,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->foreign_ip_addr = foreign_ip_addr;
|
memcpy( &info->foreign_sockaddr, foreign_sockaddr,
|
||||||
info->foreign_ip_port = foreign_ip_port;
|
sizeof( info->foreign_sockaddr) );
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -149,9 +145,11 @@ int
|
|||||||
sock_destroy( INOUT SOCKINFO * info,
|
sock_destroy( INOUT SOCKINFO * info,
|
||||||
int ShutdownMethod )
|
int ShutdownMethod )
|
||||||
{
|
{
|
||||||
shutdown( info->socket, ShutdownMethod );
|
if( info->socket != INVALID_SOCKET ) {
|
||||||
if( UpnpCloseSocket( info->socket ) == -1 ) {
|
shutdown( info->socket, ShutdownMethod );
|
||||||
return UPNP_E_SOCKET_ERROR;
|
if( UpnpCloseSocket( info->socket ) == -1 ) {
|
||||||
|
return UPNP_E_SOCKET_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
@@ -190,7 +188,7 @@ sock_read_write( IN SOCKINFO * info,
|
|||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
int numBytes;
|
int numBytes;
|
||||||
time_t start_time = time( NULL );
|
time_t start_time = time( NULL );
|
||||||
int sockfd = info->socket;
|
SOCKET sockfd = info->socket;
|
||||||
long bytes_sent = 0,
|
long bytes_sent = 0,
|
||||||
byte_left = 0,
|
byte_left = 0,
|
||||||
num_written;
|
num_written;
|
||||||
@@ -202,9 +200,9 @@ sock_read_write( IN SOCKINFO * info,
|
|||||||
FD_ZERO( &readSet );
|
FD_ZERO( &readSet );
|
||||||
FD_ZERO( &writeSet );
|
FD_ZERO( &writeSet );
|
||||||
if( bRead ) {
|
if( bRead ) {
|
||||||
FD_SET( ( unsigned )sockfd, &readSet );
|
FD_SET( sockfd, &readSet );
|
||||||
} else {
|
} else {
|
||||||
FD_SET( ( unsigned )sockfd, &writeSet );
|
FD_SET( sockfd, &writeSet );
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout.tv_sec = *timeoutSecs;
|
timeout.tv_sec = *timeoutSecs;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,34 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file defines the functions for services. It defines
|
* Purpose: This file defines the functions for services. It defines
|
||||||
@@ -116,25 +117,8 @@ RemoveSubscriptionSID( Upnp_SID sid,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : GetSubscriptionSID
|
subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
|
||||||
*
|
|
||||||
* 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 *next = service->subscriptionList;
|
subscription *next = service->subscriptionList;
|
||||||
subscription *previous = NULL;
|
subscription *previous = NULL;
|
||||||
@@ -169,31 +153,15 @@ GetSubscriptionSID( Upnp_SID sid,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : GetNextSubscription
|
subscription *GetNextSubscription(service_info *service, subscription *current)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
subscription *next = NULL;
|
subscription *next = NULL;
|
||||||
subscription *previous = NULL;
|
subscription *previous = NULL;
|
||||||
int notDone = 1;
|
int notDone = 1;
|
||||||
|
|
||||||
//get the current_time
|
// get the current_time
|
||||||
time( ¤t_time );
|
time( ¤t_time );
|
||||||
while( ( notDone ) && ( current ) ) {
|
while( ( notDone ) && ( current ) ) {
|
||||||
previous = current;
|
previous = current;
|
||||||
@@ -218,52 +186,26 @@ GetNextSubscription( service_info * service,
|
|||||||
return next;
|
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;
|
subscription *GetFirstSubscription(service_info *service)
|
||||||
next = GetNextSubscription( service, &temp );
|
{
|
||||||
service->subscriptionList = temp.next;
|
subscription temp;
|
||||||
// service->subscriptionList=next;
|
subscription *next = NULL;
|
||||||
return next;
|
|
||||||
|
temp.next = service->subscriptionList;
|
||||||
|
next = GetNextSubscription(service, &temp);
|
||||||
|
service->subscriptionList = temp.next;
|
||||||
|
// service->subscriptionList = next;
|
||||||
|
|
||||||
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : freeSubscription
|
void freeSubscription(subscription *sub)
|
||||||
*
|
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
if( sub ) {
|
if (sub) {
|
||||||
free_URL_list( &sub->DeliveryURLs );
|
free_URL_list(&sub->DeliveryURLs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file contains functions that operate on memory and
|
* Purpose: This file contains functions that operate on memory and
|
||||||
@@ -491,6 +491,8 @@ membuffer_delete( INOUT membuffer * m,
|
|||||||
|
|
||||||
assert( m != NULL );
|
assert( m != NULL );
|
||||||
|
|
||||||
|
if (!m) return;
|
||||||
|
|
||||||
if( m->length == 0 ) {
|
if( m->length == 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,65 +1,59 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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 "config.h"
|
||||||
|
|
||||||
|
|
||||||
#include "upnp_timeout.h"
|
#include "upnp_timeout.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/************************************************************************
|
#include <stdlib.h> /* for free() */
|
||||||
* Function : free_upnp_timeout
|
|
||||||
*
|
|
||||||
* Parameters :
|
void free_upnp_timeout(upnp_timeout *event)
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
|
if (event) {
|
||||||
if( event ) {
|
if (event->Event) {
|
||||||
if( event->Event )
|
free(event->Event);
|
||||||
free( event->Event );
|
}
|
||||||
free( event );
|
free(event);
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,48 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* 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.
|
* 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
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file contains functions for copying strings based on
|
* Purpose: This file contains functions for copying strings based on
|
||||||
* different options.
|
* different options.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : linecopy
|
* Function : linecopy
|
||||||
*
|
*
|
||||||
|
|||||||
199
upnp/src/inc/ClientSubscription.h
Normal file
199
upnp/src/inc/ClientSubscription.h
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
|
||||||
|
#ifndef CLIENTSUBSCRIPTION_H
|
||||||
|
#define CLIENTSUBSCRIPTION_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "UpnpString.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct s_ClientSubscription ClientSubscription;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructor.
|
||||||
|
*/
|
||||||
|
ClientSubscription *GenlibClientSubscription_new();
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructor.
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_delete(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Copy Constructor.
|
||||||
|
*/
|
||||||
|
ClientSubscription *GenlibClientSubscription_dup(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Assignment operator.
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_assign(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *q,
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
int GenlibClientSubscription_get_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_set_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
/*! [in] . */
|
||||||
|
int n);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *GenlibClientSubscription_get_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const char *GenlibClientSubscription_get_SID_cstr(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_set_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_strcpy_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *GenlibClientSubscription_get_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const char *GenlibClientSubscription_get_ActualSID_cstr(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_set_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_strcpy_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *GenlibClientSubscription_get_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_set_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_strcpy_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
ClientSubscription *GenlibClientSubscription_get_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void GenlibClientSubscription_set_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
ClientSubscription *q);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CLIENTSUBSCRIPTION_H */
|
||||||
|
|
||||||
69
upnp/src/inc/VirtualDir.h
Normal file
69
upnp/src/inc/VirtualDir.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef VIRTUALDIR_H
|
||||||
|
#define VIRTUALDIR_H
|
||||||
|
|
||||||
|
|
||||||
|
/** The \b VirtualDirCallbacks structure contains the pointers to
|
||||||
|
* file-related callback functions a device application can register to
|
||||||
|
* virtualize URLs.
|
||||||
|
*/
|
||||||
|
struct VirtualDirCallbacks
|
||||||
|
{
|
||||||
|
/** Called by the web server to query information on a file. The callback
|
||||||
|
* should return 0 on success or -1 on an error. */
|
||||||
|
VDCallback_GetInfo get_info;
|
||||||
|
|
||||||
|
/** Called by the web server to open a file. The callback should return
|
||||||
|
* a valid handle if the file can be opened. Otherwise, it should return
|
||||||
|
* \c NULL to signify an error. */
|
||||||
|
VDCallback_Open open;
|
||||||
|
|
||||||
|
/** Called by the web server to perform a sequential read from an open
|
||||||
|
* file. The callback should copy \b buflen bytes from the file into
|
||||||
|
* the buffer.
|
||||||
|
* @return An integer representing one of the following:
|
||||||
|
* \li <tt> 0</tt>: The file contains no more data (EOF).
|
||||||
|
* \li <tt> > 0</tt>: A successful read of the number of bytes in the
|
||||||
|
* return code.
|
||||||
|
* \li <tt> < 0</tt>: An error occurred reading the file.
|
||||||
|
*/
|
||||||
|
VDCallback_Read read;
|
||||||
|
|
||||||
|
/** Called by the web server to perform a sequential write to an open
|
||||||
|
* file. The callback should write \b buflen bytes into the file from
|
||||||
|
* the buffer. It should return the actual number of bytes written,
|
||||||
|
* which might be less than \b buflen in the case of a write error.
|
||||||
|
*/
|
||||||
|
VDCallback_Write write;
|
||||||
|
|
||||||
|
/** Called by the web server to move the file pointer, or offset, into
|
||||||
|
* an open file. The \b origin parameter determines where to start
|
||||||
|
* moving the file pointer. A value of \c SEEK_CUR moves the
|
||||||
|
* file pointer relative to where it is. The \b offset parameter can
|
||||||
|
* be either positive (move forward) or negative (move backward).
|
||||||
|
* \c SEEK_END moves relative to the end of the file. A positive
|
||||||
|
* \b offset extends the file. A negative \b offset moves backward
|
||||||
|
* in the file. Finally, \c SEEK_SET moves to an absolute position in
|
||||||
|
* the file. In this case, \b offset must be positive. The callback
|
||||||
|
* should return 0 on a successful seek or a non-zero value on an error.
|
||||||
|
*/
|
||||||
|
VDCallback_Seek seek;
|
||||||
|
|
||||||
|
/** Called by the web server to close a file opened via the \b open
|
||||||
|
* callback. It should return 0 on success, or a non-zero value on an
|
||||||
|
* error.
|
||||||
|
*/
|
||||||
|
VDCallback_Close close;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct virtual_Dir_List
|
||||||
|
{
|
||||||
|
struct virtual_Dir_List *next;
|
||||||
|
char dirName[NAME_SIZE];
|
||||||
|
} virtualDirList;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* VIRTUALDIR_H */
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user