diff --git a/ChangeLog b/ChangeLog index c04f14d..8d2739b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,101 @@ -************************************************************************* +******************************************************************************* +Version 1.4.7 +******************************************************************************* + +2007-05-26 Marcelo Jimenez + * Added support for the Basic Device + (http://www.upnp.org/standardizeddcps/basic.asp) as suggested by + Titus Winters. + +2007-05-25 Marcelo Jimenez + * Fixed the file libupnp.pc.in to generate a correct path for the + include files. + +2007-05-25 Marcelo Jimenez + * Removing the Dbg_Level, InitLog, SetLogFileNames and CloseLog + defines. These were just aliases, no reason to keep them. + +2007-05-25 Marcelo Jimenez + * Changed the comments of the include files that expose the UPnP API + to use only C89 comments and no C99 comments. + +2007-05-24 Nektarios K. Papadopoulos + * Added tvcombo sample that demonstrates coexistence of a device and a + control point in the same application. + +2007-05-24 Nektarios K. Papadopoulos + * SF Tracker FR [ 1570020 ]. + * Enable both device and control point in the same application. Resolve + deadlock in the SSDP processing threads. + * Fix Threadpool expansion condition. + Thanks to Siva Chandran P. for the original patch. + +2007-05-24 Nektarios K. Papadopoulos + * Modified tvdevice (control and picture) service descriptions to make + compatible with WinXP/IE control point. 'in' arguments must appear before + 'out' arguments in argument list. + Thanks to Martin Tremblay for pointing out the solution originally provided + by MORIOKA Yasuhiro. + +2007-05-21 Marcelo Jimenez + * More MSVC fixes, using XINLINE instead of inline, MSVC has troubles + with inline. Thanks to David Maass for reporting. + * Changed XINLINE to UPNP_INLINE. + +2007-05-21 Marcelo Jimenez + * Added the file build/inc/msvc/inttypes.h. This file is for use with + MSVC only, because it does not provide C99 compatibility. + +2007-05-18 Marcelo Jimenez + * Removed all uses of the DEVICEONLY(x) macro. + +2007-05-17 Marcelo Jimenez + * Removed all uses of the DBGONLY(x) macro. A static inline empty + function now is used and the compiler takes care of optimizing it out. + +2007-05-17 Marcelo Jimenez + * Fixed a bug in UpnpPrintf, function could call va_start() and return + befor calling va_end(). + +2007-05-15 Marcelo Jimenez + * EXPORT_SPEC missing on some declarations in ixml/inc/ixml.h. + Thanks to David Maass. + +2007-05-15 Marcelo Jimenez + * sizeof is unsigned, so %zu is more adequate than %zd. + +2007-05-15 Marcelo Jimenez + * Using an invented printf directive PRIzu that on MSVC + expands to "lu", and on normal C99 compilers expands to "zu". + +2007-05-15 Marcelo Jimenez + * Rewrote raw_find_str. Now it no longer uses strcasestr(), but it + transforms the first input buffer into lowercase. + +2007-05-08 Marcelo Jimenez + * Fix for debug printf format strings. size_t are not expected + in a string format like "%.*s". + +2007-05-08 Marcelo Jimenez + * Added inttypes.h as a header requirement in configure.ac. + +2007-05-11 Marcelo Jimenez + * Moved upnp_tv_ctrlpt and upnp_tv_device executables from folder + upnp to folder upnp/sample. Moved folder upnp/sample/tvdevice/web + to folder upnp/sample/web. This way, if someone compiles the + tarball and executes upnp_tv_device from its creation directory, + there will be no error -108 for not finding directory web. + +******************************************************************************* Version 1.4.6 -************************************************************************* +******************************************************************************* 2007-04-19 Marcelo Jimenez * Fix for freebsd host_os in configure.ac. -************************************************************************* +******************************************************************************* Version 1.4.5 -************************************************************************* +******************************************************************************* 2007-04-19 Marcelo Jimenez * Case insensitive comparison in raw_find_str() (httpparser.c) as @@ -33,9 +121,9 @@ Version 1.4.5 (int instead of size_t) in combination with format "b" and "Q". The attached patch should fix this. -************************************************************************* +******************************************************************************* Version 1.4.4 -************************************************************************* +******************************************************************************* 2007-04-06 Marcelo Jimenez * SF Tracker [ 1695399 ] Typo in util.h @@ -70,9 +158,9 @@ Version 1.4.4 Please note, that I enabled some extra debugging lines that were commented, in order to get more information. See attached files. -************************************************************************* +******************************************************************************* Version 1.4.3 -************************************************************************* +******************************************************************************* 2007-03-13 Marcelo Jimenez * SF Tracker [ 1663004 ] Compile on Cygwin @@ -107,9 +195,9 @@ Version 1.4.3 * Fixed nasty segmentation fault bug on membuffer.c. -************************************************************************* +******************************************************************************* Version 1.4.2 -************************************************************************* +******************************************************************************* 2007-02-09 Marcelo Jimenez @@ -211,9 +299,9 @@ Version 1.4.2 * support for large files (>2 GBytes) added -************************************************************************* +******************************************************************************* Version 1.4.1 -************************************************************************* +******************************************************************************* 2006-07-07 Oxy @@ -244,9 +332,9 @@ Version 1.4.1 * Patch to fix memory leaks and reasons for crashes added (thanks to loigu) -************************************************************************* +******************************************************************************* Version 1.4.0 -************************************************************************* +******************************************************************************* 2006-05-26 Oxy @@ -272,18 +360,18 @@ Version 1.4.0 * Bugfix for M-Search packet -************************************************************************* +******************************************************************************* FORK FROM DEAD libupnp -************************************************************************* +******************************************************************************* -2006-04-29 Rémi Turboult +2006-04-29 R�mi Turboult * THANKS: new file with list of contributors * upnp/src/gena/gena_device.c (respond_ok): add 'Content-Length: 0' in subscription response. Patch by Chaos (Bug # 1455367). -2006-04-08 Rémi Turboult +2006-04-08 R�mi Turboult * upnp/doc/UPnP_Programming_Guide.pdf: replace this document with the one in libupnp-doc-1.2.1 because current CVS version @@ -294,20 +382,20 @@ FORK FROM DEAD libupnp * changes applied to several files to work under Sparc Solaris, temporarily requiring a define SPARC_SOLARIS -2006-04-03 Rémi Turboult +2006-04-03 R�mi Turboult * upnp/Makefile.am: install upnp samples in $(docdir)/examples -2006-03-28 Rémi Turboult +2006-03-28 R�mi Turboult * configure.ac: add --with-docdir option to choose where documentation is installed (or -without-docdir to not install the documentation) -2006-03-27 Rémi Turboult +2006-03-27 R�mi Turboult * ixml/test: add simple test suite for xml parser -2006-03-26 Rémi Turboult +2006-03-26 R�mi Turboult * ixml/src/ixmlparser.c (Parser_processCDSect): fix bug which prevents CDATA sections which contain a 0 (zero) to be parsed (instead the @@ -318,18 +406,18 @@ FORK FROM DEAD libupnp option, and move samples compilation from check_PROGRAMS to noinst_PROGRAMS -2006-03-25 Rémi Turboult +2006-03-25 R�mi Turboult * upnp/src/genlib/miniserver/miniserver.c (get_miniserver_sockets): fix bug if new socket created has fd 0 (can only occur when stdin has been closed). Patch by Oskar Liljeblad 2004-07-02 : http://sourceforge.net/mailarchive/message.php?msg_id=8870528 -2006-03-21 Rémi Turboult +2006-03-21 R�mi Turboult * upnp/test/test_init.c: add some version checks and exit if failure -2006-03-05 Rémi Turboult +2006-03-05 R�mi Turboult * libupnp version 1.3.1 @@ -344,11 +432,11 @@ FORK FROM DEAD libupnp dependencies between upnp and ixml / threadutil, so that programs linking against upnp only still work. -2006-03-04 Rémi Turboult +2006-03-04 R�mi Turboult * libupnp version 1.3.0 -2006-03-03 Rémi Turboult +2006-03-03 R�mi Turboult * upnp/src/genlib/net/http/httpreadwrite.c (get_sdk_info): use package version string from configure to set sdk info @@ -356,7 +444,7 @@ FORK FROM DEAD libupnp * upnp/Makefile.am: add sample/tvdevice/web/ files in EXTRA_DIST + do not distribute generated upnpconfig.h file. -2006-02-28 Rémi Turboult +2006-02-28 R�mi Turboult * upnp/src/inc/config.h, configure.ac: use only new defines UPNP_HAVE_xx instead of INCLUDE_yyy_APIS and INTERNAL_WEB_SERVER @@ -365,7 +453,7 @@ FORK FROM DEAD libupnp the librarie LDFLAGS in order to export only the symbols defined in the API -2006-02-27 Rémi Turboult +2006-02-27 R�mi Turboult * configure.ac: add libtool versions for the 3 libraries @@ -373,7 +461,7 @@ FORK FROM DEAD libupnp * threadutil/src/ThreadPool.c (SetSeed): add missing 'static' -2006-02-26 Rémi Turboult +2006-02-26 R�mi Turboult * threadutil/inc/iasnprintf.h: add gcc __printf__ format attribute to "iasnprintf" @@ -394,11 +482,11 @@ FORK FROM DEAD libupnp the configuration of the installed libraries (generates installed file ) -2006-02-22 Rémi Turboult +2006-02-22 R�mi Turboult * upnp/ : add missing include of config.h in some .c files -2006-02-21 Rémi Turboult +2006-02-21 R�mi Turboult * upnp/inc/upnp.h: move some definitions which should not be exported into "upnp/src/inc/util.h" @@ -406,12 +494,12 @@ FORK FROM DEAD libupnp * import all modifications below from libupnp in djmount 0.51 into official libupnp -2006-01-17 Rémi Turboult +2006-01-17 R�mi Turboult * threadutil/Makefile.am (libthreadutil_la_SOURCES): remove extraneous file -2006-01-15 Rémi Turboult +2006-01-15 R�mi Turboult * configure.ac: add checks for large-file support @@ -431,53 +519,53 @@ FORK FROM DEAD libupnp * ixml/src/node.c (ixmlNode_getNodeType): fix compilation warning on const return type -2006-01-12 Rémi Turboult +2006-01-12 R�mi Turboult * upnp/src/inc/readwrite.h : suppress unused C++ header file -2006-01-11 Rémi Turboult +2006-01-11 R�mi Turboult * upnp/inc/config.h, upnp/src/inc/upnpapi.h, upnp/src/inc/httpreadwrite.h: remove internal configuration variable MINIMUM_DELAY (no clear purpose) -2005-12-05 Rémi Turboult +2005-12-05 R�mi Turboult * upnp/inc/upnp.h: re-declare obsolete method UpnpSetContentLength, for binary compatibility with previous libupnp version. * upnp/src/api/upnpapi.c: correct type of g_maxContentLength to size_t -2005-11-01 Rémi Turboult +2005-11-01 R�mi Turboult * autoconfiscate library : replace all makefiles by Makefile.am for automake support, + preliminary autoconf support (generated config.h not yet used in source files) -2005-10-18 Rémi Turboult +2005-10-18 R�mi Turboult * upnp/src/makefile: fix location of DEBUG STATIC libupnp library * upnp/sample/tvctrlpt/linux/Makefile, upnp/sample/tvdevice/linux/Makefile: fix STATIC library support -2005-10-16 Rémi Turboult +2005-10-16 R�mi Turboult * threadutil/src/Makefile (clean): remove built library -2005-08-28 Rémi Turboult +2005-08-28 R�mi Turboult * ixml/src/ixml.h, ixml/src/ixml.c (ixmlRelaxParser) : new function * ixml/src/ixmlparser.h, ixml/src/ixmlparser.c (Parser_setErrorChar) : new function -2005-08-02 Rémi Turboult +2005-08-02 R�mi Turboult * ixml/src/Makefile: correct bug for static library being incorrectly stripped when building non-debug -2005-06-09 Rémi Turboult +2005-06-09 R�mi Turboult * ixml/src/element.c (ixmlElement_removeAttributeNode): remove some compilation warning @@ -488,7 +576,7 @@ FORK FROM DEAD libupnp * upnp/inc/upnptools.h, upnp/src/api/upnptools.c : add missing const's in public API -2005-05-28 Rémi Turboult +2005-05-28 R�mi Turboult * upnp/inc/config.h: suppress HTTP_READ_BYTES (unused) and replace by DEFAULT_SOAP_CONTENT_LENGTH (previously in upnpapi.h) @@ -509,7 +597,7 @@ FORK FROM DEAD libupnp * upnp/src/genlib/net/http/httpreadwrite.c : corrected an incorrect sprintf format -2005-05-27 Rémi Turboult +2005-05-27 R�mi Turboult * upnp/makefile, upnp/src/makefile, ixml/Makefile, ixml/src/Makefile, @@ -517,7 +605,7 @@ FORK FROM DEAD libupnp implement STATIC library support (from patch at http://sourceforge.net/tracker/?group_id=7189&atid=307189 ) -2005-05-26 Rémi Turboult +2005-05-26 R�mi Turboult * upnp/src/api/upnpapi.c, upnp/src/soap/soap_device.c, upnp/src/soap/makefile : diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..462421d --- /dev/null +++ b/Doxyfile @@ -0,0 +1,1257 @@ +# Doxyfile 1.5.2 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = libUPnP + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.4.7 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs/doxygen + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# 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 +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# 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 +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./upnp ./ixml ./threadutil + +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = */.svn */.deps */.libs */test + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# 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 +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# 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. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen will always +# show the root nodes and its direct children regardless of this setting. + +DOT_GRAPH_MAX_NODES = 50 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/Makefile.am b/Makefile.am index 87543cc..0e5970c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,15 +1,19 @@ -# $Id: Makefile.am,v 1.5 2006/04/29 20:12:50 r3mi Exp $ + # # Top-level "Makefile.am" for libupnp # -# Copyright (C) 2005 Rémi Turboult +# Copyright (C) 2005 R�mi Turboult # ACLOCAL_AMFLAGS = -I m4 DISTCHECK_CONFIGURE_FLAGS = --enable-debug --enable-samples -SUBDIRS = ixml threadutil upnp docs/dist +SUBDIRS = \ + ixml \ + threadutil \ + upnp \ + docs/dist EXTRA_DIST = \ @@ -23,7 +27,8 @@ EXTRA_DIST = \ build/libupnp.dsw \ build/inc/autoconfig.h \ build/inc/config.h \ - build/inc/upnpconfig.h + build/inc/upnpconfig.h \ + build/msvc/inttypes.h # This variable must have 'exec' in its name, in order to be installed @@ -31,11 +36,12 @@ EXTRA_DIST = \ pkgconfigexecdir = $(libdir)/pkgconfig pkgconfigexec_DATA = libupnp.pc + $(pkgconfigexec_DATA): config.status if WITH_DOCUMENTATION - doc_DATA = LICENSE README NEWS TODO THANKS + doc_DATA = LICENSE README NEWS TODO THANKS endif diff --git a/README b/README index eede54d..50905f9 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Portable SDK for UPnP* Devices (libupnp) Copyright (c) 2000-2003 Intel Corporation - All Rights Reserved. -Copyright (c) 2005-2006 Rémi Turboult +Copyright (c) 2005-2006 R�mi Turboult Copyright (c) 2006 Michel Pfeiffer and others See LICENSE for details. diff --git a/THANKS b/THANKS index 9b1d835..f58a535 100644 --- a/THANKS +++ b/THANKS @@ -30,4 +30,5 @@ exempt of errors. - Paul Vixie - Siva Chandran - Timothy Redaelli +- Titus Winters diff --git a/build/inc/autoconfig.h b/build/inc/autoconfig.h index f461e4c..39e85b9 100644 --- a/build/inc/autoconfig.h +++ b/build/inc/autoconfig.h @@ -1,4 +1,4 @@ -/* autoconfig.h. Generated by configure. */ +/* autoconfig.h. Generated from autoconfig.h.in by configure. */ /* autoconfig.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 to compile debug code */ @@ -19,15 +19,18 @@ /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #define HAVE_FSEEKO 1 +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 +/* Define to 1 if you have the `compat' library (-lcompat). */ +/* #undef HAVE_LIBCOMPAT */ + /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 -/* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 - /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 @@ -92,19 +95,19 @@ #define PACKAGE "libupnp" /* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "virtual_worlds@gmx.de" +#define PACKAGE_BUGREPORT "mroberto@users.sourceforge.net" /* Define to the full name of this package. */ #define PACKAGE_NAME "libupnp" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libupnp 1.4.0" +#define PACKAGE_STRING "libupnp 1.4.7" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libupnp" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.4.0" +#define PACKAGE_VERSION "1.4.7" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ @@ -135,27 +138,30 @@ #define UPNP_VERSION_MINOR 4 /* see upnpconfig.h */ -#define UPNP_VERSION_PATCH 0 +#define UPNP_VERSION_PATCH 7 /* see upnpconfig.h */ -#define UPNP_VERSION_STRING "1.4.0" +#define UPNP_VERSION_STRING "1.4.7" /* Version number of package */ -#define VERSION "1.4.0" +#define VERSION "1.4.7" -/* Number of bits in a file offset, on hosts where this is settable. */ +/* File Offset size */ #define _FILE_OFFSET_BITS 64 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ /* #undef _LARGEFILE_SOURCE */ -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ +/* Large files support */ +#define _LARGE_FILE_SOURCE /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ -/* Define to `unsigned' if does not define. */ +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `unsigned int' if does not define. */ /* #undef size_t */ /* Substitute for socklen_t */ diff --git a/build/inc/config.h b/build/inc/config.h index f6a21e3..aaa6ee6 100644 --- a/build/inc/config.h +++ b/build/inc/config.h @@ -34,7 +34,6 @@ #include "autoconfig.h" -#define MAX_JOBS_TOTAL 10 /** @name Compile time configuration options * The Linux SDK for UPnP Devices contains some compile-time parameters @@ -96,6 +95,17 @@ #define MAX_THREADS 12 //@} +/** @name MAX_JOBS_TOTAL + * The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs + * that can be queued. If this limit is reached further jobs will be thrown + * to avoid memory exhaustion. The default value 100. + * (Added by Axis.) + */ + +//@{ +#define MAX_JOBS_TOTAL 100 +//@} + /** @name DEFAULT_SOAP_CONTENT_LENGTH * SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes. * This prevents devices that have a misbehaving web server to send @@ -294,68 +304,40 @@ -/** @name DBGONLY - The {\bf DBGONLY} macro allows code to be marked so that it - is only included in the DEBUG build and not the release. To - use this macro, put the code inside of the parentheses: - - {\tt DBGONLY(int i;)} - - This will cause a declaration of the integer {\tt i} only - in the debug build. - */ - -//@{ -#ifdef DEBUG - #define DBGONLY(x) x -#else - #define DBGONLY(x) -#endif -//@} - - - -#undef EXCLUDE_WEB_SERVER -#undef EXCLUDE_MINISERVER +#undef EXCLUDE_WEB_SERVER +#undef EXCLUDE_MINISERVER #ifdef INTERNAL_WEB_SERVER - #define EXCLUDE_WEB_SERVER 0 - #define EXCLUDE_MINISERVER 0 +# define EXCLUDE_WEB_SERVER 0 +# define EXCLUDE_MINISERVER 0 #else - #define EXCLUDE_WEB_SERVER 1 - #define EXCLUDE_MINISERVER 1 +# define EXCLUDE_WEB_SERVER 1 +# define EXCLUDE_MINISERVER 1 #endif #if EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1 - #undef EXCLUDE_MINISERVER - #define EXCLUDE_MINISERVER 1 - #if INTERNAL_WEB_SERVER - # error "conflicting settings: use configure --disable-webserver" - #endif +# undef EXCLUDE_MINISERVER +# define EXCLUDE_MINISERVER 1 +# if INTERNAL_WEB_SERVER +# error "conflicting settings: use configure --disable-webserver" +# endif #endif #if EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0 - #undef EXCLUDE_MINISERVER - #define EXCLUDE_MINISERVER 0 - #if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER - #error "conflicting settings : use configure --enable-webserver" - #endif +# undef EXCLUDE_MINISERVER +# define EXCLUDE_MINISERVER 0 +# if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER +# error "conflicting settings : use configure --enable-webserver" +# endif #endif #ifdef INCLUDE_CLIENT_APIS - #define CLIENTONLY(x) x -#else - #define CLIENTONLY(x) -#endif - -#ifdef INCLUDE_DEVICE_APIS - #define DEVICEONLY(x) x -#else - #define DEVICEONLY(x) +# define CLIENTONLY(x) x +#else +# define CLIENTONLY(x) #endif //@} #endif - diff --git a/build/inc/upnpconfig.h b/build/inc/upnpconfig.h index ec5dacf..202b225 100644 --- a/build/inc/upnpconfig.h +++ b/build/inc/upnpconfig.h @@ -1,46 +1,46 @@ -/* upnp/inc/upnpconfig.h. Generated by configure. */ +/* upnp/inc/upnpconfig.h. Generated from upnpconfig.h.in by configure. */ // -*- C -*- /////////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006 Rémi Turboult -// All rights reserved. +// Copyright (c) 2006 R�mi Turboult +// All rights reserved. // -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: +// 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 +// * 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 +// +// 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 +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// #ifndef UPNP_CONFIG_H -#define UPNP_CONFIG_H +#define UPNP_CONFIG_H /*************************************************************************** - * Library version - ***************************************************************************/ + * Library version + ***************************************************************************/ /** The library version (string) e.g. "1.3.0" */ -#define UPNP_VERSION_STRING "1.4.0" +#define UPNP_VERSION_STRING "1.4.7" /** Major version of the library */ #define UPNP_VERSION_MAJOR 1 @@ -49,7 +49,7 @@ #define UPNP_VERSION_MINOR 4 /** Patch version of the library */ -#define UPNP_VERSION_PATCH 0 +#define UPNP_VERSION_PATCH 7 /** The library version (numeric) e.g. 10300 means version 1.3.0 */ #define UPNP_VERSION \ @@ -59,25 +59,25 @@ /*************************************************************************** * Library optional features - ***************************************************************************/ + ***************************************************************************/ /* - * The following defines can be tested in order to know which + * The following defines can be tested in order to know which * optional features have been included in the installed library. */ -/** 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) : file is available */ -#undef UPNP_HAVE_DEBUG +/* #undef UPNP_HAVE_DEBUG */ -/** 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 * (i.e. configure --enable-client) */ #define UPNP_HAVE_CLIENT 1 -/** Defined to 1 if the library has been compiled with device API enabled +/** Defined to 1 if the library has been compiled with device API enabled * (i.e. configure --enable-device) */ #define UPNP_HAVE_DEVICE 1 diff --git a/build/libupnp.dsp b/build/libupnp.dsp index b73fb47..2e1a0c0 100644 --- a/build/libupnp.dsp +++ b/build/libupnp.dsp @@ -5,17 +5,17 @@ # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=libupnp - Win32 Debug -!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE -!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE Dies ist kein g�ltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f�hren Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "libupnp.mak". !MESSAGE -!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE Sie k�nnen beim Ausf�hren von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "libupnp.mak" CFG="libupnp - Win32 Debug" !MESSAGE -!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE F�r die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "libupnp - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE "libupnp - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") diff --git a/build/msvc/inttypes.h b/build/msvc/inttypes.h new file mode 100644 index 0000000..1c2baa8 --- /dev/null +++ b/build/msvc/inttypes.h @@ -0,0 +1,301 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/configure.ac b/configure.ac index cdbd1ea..3acb68b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,15 @@ # -*- Autoconf -*- -# $Id: configure.ac,v 1.11 2006/04/09 13:59:44 r3mi Exp $ # # Top-level configure.ac file for libupnp # # Process this file with autoconf to produce a configure script. # -# (C) Copyright 2005-2006 Rémi Turboult +# (C) Copyright 2005-2006 R�mi Turboult # AC_PREREQ(2.60) -AC_INIT([libupnp], [1.4.6], [mroberto@users.sourceforge.net]) +AC_INIT([libupnp], [1.4.7], [mroberto@users.sourceforge.net]) # *Independently* of the above libupnp package version, the libtool version # of the 3 libraries need to be updated whenever there is a change released : # "current:revision:age" (this is NOT the same as the package version), where: @@ -213,6 +212,7 @@ AC_CHECK_HEADERS( [ \ arpa/inet.h \ fcntl.h \ + inttypes.h \ limits.h \ netdb.h \ netinet/in.h \ @@ -260,6 +260,7 @@ AC_CONFIG_FILES([ threadutil/Makefile upnp/Makefile upnp/doc/Makefile + upnp/sample/Makefile docs/dist/Makefile libupnp.pc ]) diff --git a/ixml/inc/ixml.h b/ixml/inc/ixml.h index 4ce354f..c7a549e 100644 --- a/ixml/inc/ixml.h +++ b/ixml/inc/ixml.h @@ -1,59 +1,61 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef _IXML_H_ #define _IXML_H_ + #include #include -//#include #include + #ifdef WIN32 - #ifndef UPNP_STATIC_LIB - #ifdef LIBUPNP_EXPORTS - // set up declspec for dll export to make functions visible to library users - #define EXPORT_SPEC __declspec(dllexport) - #else - #define EXPORT_SPEC __declspec(dllimport) - #endif - #else - #define EXPORT_SPEC - #endif + #ifndef UPNP_STATIC_LIB + #ifdef LIBUPNP_EXPORTS + /* set up declspec for dll export to make functions visible to library users */ + #define EXPORT_SPEC __declspec(dllexport) + #else + #define EXPORT_SPEC __declspec(dllimport) + #endif + #else + #define EXPORT_SPEC + #endif #else - #define EXPORT_SPEC + #define EXPORT_SPEC #endif typedef int BOOL; + #define DOMString char * @@ -88,7 +90,7 @@ typedef int BOOL; * etc., refer to section 1.1 of the DOM2-Core recommendation. */ -//@{ +/*! @{ */ /*================================================================ * @@ -121,7 +123,7 @@ typedef enum * *=================================================================*/ typedef enum -{ // see DOM spec +{ /* see DOM spec */ IXML_INDEX_SIZE_ERR = 1, IXML_DOMSTRING_SIZE_ERR = 2, IXML_HIERARCHY_REQUEST_ERR = 3, @@ -240,7 +242,7 @@ extern "C" { * its functionality. For more information, refer to DOM2-Core page 34. */ -//@{ +/*! @{ */ /** Returns the name of the {\bf Node}, depending on what type of * {\bf Node} it is, in a read-only string. Refer to the table in the @@ -634,7 +636,7 @@ ixmlNode_free(IXML_Node *nodeptr /** The {\bf Node} to free. */ ); -//@} +/*! @} */ /*================================================================ * @@ -649,7 +651,7 @@ ixmlNode_free(IXML_Node *nodeptr * allowable attributes and values for a particular element. For more * information, refer to the {\it Interface Attr} section in the DOM2-Core. */ -//@{ +/*! @{ */ /** Frees an {\bf Attr} node. @@ -662,7 +664,7 @@ ixmlAttr_free(IXML_Attr *attrNode /** The {\bf Attr} node to free. */ ); -//@} +/*! @} */ /*================================================================ @@ -680,7 +682,7 @@ ixmlAttr_free(IXML_Attr *attrNode * information, refer to the {\it Interface CDATASection} section in the * DOM2-Core. */ -//@{ +/*! @{ */ /** Initializes a {\bf CDATASection} node. @@ -704,7 +706,7 @@ ixmlCDATASection_free(IXML_CDATASection *nodeptr /** The {\bf CDATASection} node to free. */ ); -//@} +/*! @} */ /*================================================================ * @@ -719,7 +721,7 @@ ixmlCDATASection_free(IXML_CDATASection *nodeptr * primary interface to the elements of the document. For more information, * refer to the {\it Interface Document} section in the DOM2Core. */ -//@{ +/*! @{ */ /** Initializes a {\bf Document} node. * @@ -947,7 +949,7 @@ ixmlDocument_getElementsByTagName(IXML_Document *doc, /** The tag name to find. */ ); -// introduced in DOM level 2 +/* introduced in DOM level 2 */ /** Creates a new {\bf Element} node in the given qualified name and * namespace URI. @@ -1128,7 +1130,7 @@ ixmlDocument_importNode(IXML_Document* doc, /** A pointer to a new {\bf Node} owned by {\bf doc}. */ ); -//@} +/*! @} */ /*================================================================ * @@ -1144,7 +1146,7 @@ ixmlDocument_importNode(IXML_Document* doc, * extends the {\bf Node} interface and adds more operations to manipulate * attributes. */ -//@{ +/*! @{ */ /** Initializes a {\bf IXML_Element} node. * @@ -1314,7 +1316,7 @@ ixmlElement_getElementsByTagName(IXML_Element* element, search. */ ); -// introduced in DOM 2 +/* introduced in DOM 2 */ /** Retrieves an attribute value using the local name and namespace URI. * @@ -1493,7 +1495,7 @@ ixmlElement_free(IXML_Element* element /** The {\bf Element} to free. */ ); -//@} +/*! @} */ /*================================================================ * @@ -1508,7 +1510,7 @@ ixmlElement_free(IXML_Element* element * no particular order. The {\bf Node} interface uses a {\bf NamedNodeMap} * to maintain the attributes of a node. */ -//@{ +/*! @{ */ /** Returns the number of items contained in this {\bf NamedNodeMap}. * @@ -1579,7 +1581,7 @@ ixmlNamedNodeMap_item(IXML_NamedNodeMap *nnMap, /** The index into the map to remove. */ ); -// introduced in DOM level 2 +/* introduced in DOM level 2 */ /** Retrieves a {\bf Node} from a {\bf NamedNodeMap} specified by * namespace URI and local name. @@ -1646,7 +1648,7 @@ ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap /** The {\bf NamedNodeMap to free}. */ ); -//@} +/*! @} */ /*================================================================ * @@ -1661,7 +1663,7 @@ ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap * the nodes contained in a {\bf NodeList}. The DOM2-Core refers to * this as being {\it live}. */ -//@{ +/*! @{ */ /** Retrieves a {\bf Node} from a {\bf NodeList} specified by a * numerical index. @@ -1701,8 +1703,8 @@ ixmlNodeList_free(IXML_NodeList *nList /** The {\bf NodeList} to free. */ ); -//@} Interface NodeList -//@} DOM Interfaces +/*! @} */ /* Interface NodeList */ +/*! @} */ /* DOM Interfaces */ /**@name IXML API * The IXML API contains utility functions that are not part of the standard @@ -1710,7 +1712,7 @@ ixmlNodeList_free(IXML_NodeList *nList * file or buffer, create an XML file from a DOM structure, and manipulate * DOMString objects. */ -//@{ +/*! @{ */ /*================================================================ * @@ -1738,7 +1740,7 @@ ixmlNodeList_free(IXML_NodeList *nList * of the DOM tree or {\tt NULL} on an error. */ -DOMString +EXPORT_SPEC DOMString ixmlPrintDocument(IXML_Document *doc); /** Renders a {\bf Node} and all sub-elements into an XML text @@ -1756,7 +1758,7 @@ ixmlPrintDocument(IXML_Document *doc); * of the DOM tree or {\tt NULL} on an error. */ -DOMString +EXPORT_SPEC DOMString ixmlPrintNode(IXML_Node *doc /** The root of the {\bf Node} tree to render to XML text. */ ); @@ -1777,7 +1779,7 @@ ixmlPrintNode(IXML_Node *doc * of the DOM tree or {\tt NULL} on an error. */ -DOMString +EXPORT_SPEC DOMString ixmlDocumenttoString(IXML_Document *doc); /** Renders a {\bf Node} and all sub-elements into an XML text @@ -1809,7 +1811,7 @@ ixmlNodetoString(IXML_Node *doc * characters are replaced by the {\bf errorChar}, and invalid "&" entities * are left untranslated. The parsing is then allowed to continue. */ -void +EXPORT_SPEC void ixmlRelaxParser(char errorChar); @@ -1913,6 +1915,7 @@ ixmlFreeDOMString(DOMString buf } #endif -//@} IXML API +/*! @} */ /* IXML API */ + +#endif /* _IXML_H_ */ -#endif // _IXML_H_ diff --git a/ixml/src/inc/ixmlmembuf.h b/ixml/src/inc/ixmlmembuf.h index cd99c25..ad81ad0 100644 --- a/ixml/src/inc/ixmlmembuf.h +++ b/ixml/src/inc/ixmlmembuf.h @@ -39,7 +39,7 @@ #define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) ) #ifndef WIN32 - #define XINLINE inline + #define UPNP_INLINE inline #endif #define MEMBUF_DEF_SIZE_INC 20 diff --git a/libupnp.pc.in b/libupnp.pc.in index 6de54b6..85f1ae8 100644 --- a/libupnp.pc.in +++ b/libupnp.pc.in @@ -7,6 +7,6 @@ Name: libupnp Description: Linux SDK for UPnP Devices Version: @VERSION@ Libs: @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml -Cflags: @PTHREAD_CFLAGS@ -I${includedir} +Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp diff --git a/libupnp.spec b/libupnp.spec index 5393123..db1db3f 100644 --- a/libupnp.spec +++ b/libupnp.spec @@ -1,4 +1,4 @@ -Version: 1.4.2 +Version: 1.4.7 Summary: Universal Plug and Play (UPnP) SDK Name: libupnp Release: 1%{?dist} @@ -77,6 +77,9 @@ make install DESTDIR=$RPM_BUILD_ROOT rm -rf %{buildroot} %changelog +* Mon Nov 19 2007 Marcelo Jimenez - 1.4.7-1 +- Update to version 1.4.7 + * Fri Feb 02 2007 Eric Tanguy - 1.4.2-1 - Update to version 1.4.2 diff --git a/svnignore b/svnignore new file mode 100644 index 0000000..d771250 --- /dev/null +++ b/svnignore @@ -0,0 +1,14 @@ +.deps +.dirstamp +.libs +.*.swp +*~ +Makefile +Makefile.in +aclocal.m4 +autoconfig.h* +autom4te.cache +config* +libtool +libupnp.pc +stamp-h* diff --git a/threadutil/inc/FreeList.h b/threadutil/inc/FreeList.h index dd56135..e389e65 100644 --- a/threadutil/inc/FreeList.h +++ b/threadutil/inc/FreeList.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef FREE_LIST_H #define FREE_LIST_H @@ -36,9 +36,6 @@ extern "C" { #endif -//#include - - #include "ithread.h" #include @@ -52,7 +49,7 @@ extern "C" { *****************************************************************************/ typedef struct FREELISTNODE { - struct FREELISTNODE*next; //pointer to next free node + struct FREELISTNODE *next; } FreeListNode; @@ -65,12 +62,10 @@ typedef struct FREELISTNODE *****************************************************************************/ typedef struct FREELIST { - FreeListNode *head; //head of free list - size_t element_size; //size of elements in free - //list - int maxFreeListLength; //max size of free structures - //to keep - int freeListLength; //current size of free list + FreeListNode *head; + size_t element_size; + int maxFreeListLength; + int freeListLength; }FreeList; @@ -141,4 +136,5 @@ int FreeListDestroy (FreeList *free_list); } #endif -#endif // FREE_LIST_H +#endif /* FREE_LIST_H */ + diff --git a/threadutil/inc/LinkedList.h b/threadutil/inc/LinkedList.h index 2572723..240f975 100644 --- a/threadutil/inc/LinkedList.h +++ b/threadutil/inc/LinkedList.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef LINKED_LIST_H #define LINKED_LIST_H @@ -70,9 +70,9 @@ typedef int (*cmp_routine)(void *itemA,void *itemB); *****************************************************************************/ typedef struct LISTNODE { - struct LISTNODE *prev; //previous node - struct LISTNODE *next; //next node - void *item; //item + struct LISTNODE *prev; + struct LISTNODE *next; + void *item; } ListNode; /**************************************************************************** @@ -96,12 +96,12 @@ typedef struct LISTNODE *****************************************************************************/ typedef struct LINKEDLIST { - ListNode head; //head, first item is stored at: head->next - ListNode tail; //tail, last item is stored at: tail->prev - long size; //size of list - FreeList freeNodeList; //free list to use - free_function free_func; //free function to use - cmp_routine cmp_func; //compare function to use + ListNode head; /* head, first item is stored at: head->next */ + ListNode tail; /* tail, last item is stored at: tail->prev */ + long size; /* size of list */ + FreeList freeNodeList; /* free list to use */ + free_function free_func; /* free function to use */ + cmp_routine cmp_func; /* compare function to use */ } LinkedList; /**************************************************************************** @@ -327,4 +327,5 @@ int ListSize(LinkedList* list); } #endif -#endif //LINKED_LIST_H +#endif /* LINKED_LIST_H */ + diff --git a/threadutil/inc/ThreadPool.h b/threadutil/inc/ThreadPool.h index 166d6f1..91a0726 100644 --- a/threadutil/inc/ThreadPool.h +++ b/threadutil/inc/ThreadPool.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef THREADPOOL_H #define THREADPOOL_H @@ -36,17 +36,17 @@ extern "C" { #endif -//Size of job free list +/* Size of job free list */ #define JOBFREELISTSIZE 100 #define INFINITE_THREADS -1 #define EMAXTHREADS (-8 & 1<<29) -//Invalid Policy +/* Invalid Policy */ #define INVALID_POLICY (-9 & 1<<29) -//Invalid JOB Id +/* Invalid JOB Id */ #define INVALID_JOB_ID (-2 & 1<<29) typedef enum duration {SHORT_TERM,PERSISTENT} Duration; @@ -55,40 +55,31 @@ typedef enum priority {LOW_PRIORITY, MED_PRIORITY, HIGH_PRIORITY} ThreadPriority; -#define DEFAULT_PRIORITY MED_PRIORITY //default priority used by TPJobInit -#define DEFAULT_MIN_THREADS 1 //default minimum used by TPAttrInit -#define DEFAULT_MAX_THREADS 10 //default max used by TPAttrInit -#define DEFAULT_JOBS_PER_THREAD 10 //default jobs per thread used by TPAttrInit -#define DEFAULT_STARVATION_TIME 500 //default starvation time used by TPAttrInit -#define DEFAULT_IDLE_TIME 10 * 1000 //default idle time used by TPAttrInit -#define DEFAULT_FREE_ROUTINE NULL //default free routine used TPJobInit -#define DEFAULT_MAX_JOBS_TOTAL 100 //default max jobs used TPAttrInit +#define DEFAULT_PRIORITY MED_PRIORITY /* default priority used by TPJobInit */ +#define DEFAULT_MIN_THREADS 1 /* default minimum used by TPAttrInit */ +#define DEFAULT_MAX_THREADS 10 /* default max used by TPAttrInit */ +#define DEFAULT_JOBS_PER_THREAD 10 /* default jobs per thread used by TPAttrInit */ +#define DEFAULT_STARVATION_TIME 500 /* default starvation time used by TPAttrInit */ +#define DEFAULT_IDLE_TIME 10 * 1000 /* default idle time used by TPAttrInit */ +#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */ +#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */ -#define STATS 1 //always include stats because code change is minimal +#define STATS 1 /* always include stats because code change is minimal */ -//Statistics -#ifdef WIN32 // todo: check why STATSONLY fails during compilation - #undef STATS +/* Statistics */ +#ifdef WIN32 /* TODO: check why STATSONLY fails during compilation */ + #undef STATS #endif #ifdef STATS - #define STATSONLY(x) x + #define STATSONLY(x) x #else - #define STATSONLY(x) + #define STATSONLY(x) #endif #ifdef _DEBUG - #define DEBUG 1 -#endif - -//DEBUGGING -#ifndef WIN32 - #ifdef DEBUG - #define DBGONLY(x) x - #else - #define DBGONLY(x) - #endif + #define DEBUG 1 #endif #include "LinkedList.h" @@ -101,7 +92,7 @@ typedef enum priority {LOW_PRIORITY, #define EXPORT typedef int PolicyType; #define DEFAULT_POLICY SCHED_OTHER -#define DEFAULT_SCHED_PARAM 0 //default priority +#define DEFAULT_SCHED_PARAM 0 /* default priority */ /**************************************************************************** * Name: free_routine @@ -120,25 +111,25 @@ typedef void (*free_routine)(void *arg); *****************************************************************************/ typedef struct THREADPOOLATTR { - int minThreads; // minThreads, ThreadPool will always maintain at least - // this many threads + int minThreads; /* minThreads, ThreadPool will always maintain at least + this many threads */ - int maxThreads; // maxThreads, ThreadPool will never have more than this - // number of threads + int maxThreads; /* maxThreads, ThreadPool will never have more than this + number of threads */ - int maxIdleTime; // maxIdleTime (in milliseconds) - // this is the maximum time a thread will remain idle - // before dying + int maxIdleTime; /* maxIdleTime (in milliseconds) + this is the maximum time a thread will remain idle + before dying */ - int jobsPerThread; // jobs per thread to maintain + int jobsPerThread; /* jobs per thread to maintain */ - int maxJobsTotal; // maximum number of jobs that can be queued totally. + int maxJobsTotal; /* maximum number of jobs that can be queued totally. */ - int starvationTime; // the time a low priority or med priority - // job waits before getting bumped - // up a priority (in milliseconds) + int starvationTime; /* the time a low priority or med priority + job waits before getting bumped + up a priority (in milliseconds) */ - PolicyType schedPolicy; // scheduling policy to use + PolicyType schedPolicy; /* scheduling policy to use */ } ThreadPoolAttr; @@ -150,12 +141,12 @@ typedef struct THREADPOOLATTR *****************************************************************************/ typedef struct THREADPOOLJOB { - start_routine func; //function - void *arg; //arg - free_routine free_func; //free function - struct timeb requestTime; //time of request - int priority; //priority of request - int jobId; //id + start_routine func; + void *arg; + free_routine free_func; + struct timeb requestTime; + int priority; + int jobId; } ThreadPoolJob; /**************************************************************************** @@ -165,32 +156,32 @@ typedef struct THREADPOOLJOB * Structure to hold statistics *****************************************************************************/ -STATSONLY( +#ifdef STATS typedef struct TPOOLSTATS { - double totalTimeHQ; //total time spent by all jobs in high priority Q - int totalJobsHQ; //total jobs in HQ run so far - double avgWaitHQ; //average wait in HQ - double totalTimeMQ; //total time spent by all jobs in med priority Q - int totalJobsMQ; //total jobs in MQ run so far - double avgWaitMQ; //average wait in MQ - double totalTimeLQ; //total time spent by all jobs in low priority Q - int totalJobsLQ; //total jobs in LQ run so far - double avgWaitLQ; //average wait in LQ - double totalWorkTime; //total time spent working for all threads - double totalIdleTime; //total time spent idle for all threads - int workerThreads; //number of current workerThreads - int idleThreads; //number of current idle threads - int persistentThreads; //number of persistent threads - int totalThreads; //total number of current threads - int maxThreads; //max threads so far - int currentJobsHQ; // current jobs in Q - int currentJobsLQ; //current jobs in Q - int currentJobsMQ; //current jobs in Q + double totalTimeHQ; + int totalJobsHQ; + double avgWaitHQ; + double totalTimeMQ; + int totalJobsMQ; + double avgWaitMQ; + double totalTimeLQ; + int totalJobsLQ; + double avgWaitLQ; + double totalWorkTime; + double totalIdleTime; + int workerThreads; + int idleThreads; + int persistentThreads; + int totalThreads; + int maxThreads; + int currentJobsHQ; + int currentJobsLQ; + int currentJobsMQ; }ThreadPoolStats; -) +#endif /**************************************************************************** @@ -215,24 +206,26 @@ typedef struct TPOOLSTATS typedef struct THREADPOOL { - ithread_mutex_t mutex; //mutex to protect job qs - ithread_cond_t condition; //condition variable to signal Q - ithread_cond_t start_and_shutdown; //condition variable for start - //and stop - int lastJobId; //ids for jobs - int shutdown; //whether or not we are shutting down - int totalThreads; //total number of threads - int persistentThreads; //number of persistent threads - FreeList jobFreeList; //free list of jobs - LinkedList lowJobQ; //low priority job Q - LinkedList medJobQ; //med priority job Q - LinkedList highJobQ; //high priority job Q - ThreadPoolJob *persistentJob; //persistent job + ithread_mutex_t mutex; /* mutex to protect job qs */ + ithread_cond_t condition; /* condition variable to signal Q */ + ithread_cond_t start_and_shutdown; /* condition variable for start + and stop */ + int lastJobId; /* ids for jobs */ + int shutdown; /* whether or not we are shutting down */ + int totalThreads; /* total number of threads */ + int persistentThreads; /* number of persistent threads */ + FreeList jobFreeList; /* free list of jobs */ + LinkedList lowJobQ; /* low priority job Q */ + LinkedList medJobQ; /* med priority job Q */ + LinkedList highJobQ; /* high priority job Q */ + ThreadPoolJob *persistentJob; /* persistent job */ - ThreadPoolAttr attr; //thread pool attributes + ThreadPoolAttr attr; /* thread pool attributes */ - //statistics - STATSONLY(ThreadPoolStats stats;) +#ifdef STATS + /* statistics */ + ThreadPoolStats stats; +#endif } ThreadPool; @@ -550,12 +543,15 @@ int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal); * Returns: * Always returns 0. *****************************************************************************/ -STATSONLY( EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);); +#ifdef STATS + EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats); -STATSONLY(EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);); + EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats); +#endif #ifdef __cplusplus } #endif -#endif //ThreadPool +#endif /* ThreadPool */ + diff --git a/threadutil/inc/TimerThread.h b/threadutil/inc/TimerThread.h index 1659de8..6eb03e2 100644 --- a/threadutil/inc/TimerThread.h +++ b/threadutil/inc/TimerThread.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef TIMERTHREAD_H #define TIMERTHREAD_H @@ -43,9 +43,9 @@ extern "C" { #define INVALID_EVENT_ID (-10 & 1<<29) -//Timeout Types -//absolute means in seconds from Jan 1, 1970 -//relative means in seconds from current time +/* Timeout Types */ +/* absolute means in seconds from Jan 1, 1970 */ +/* relative means in seconds from current time */ typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType; @@ -63,13 +63,13 @@ typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType; *****************************************************************************/ typedef struct TIMERTHREAD { - ithread_mutex_t mutex; //mutex to protect eventQ - ithread_cond_t condition; //condition variable - int lastEventId; //last event id - LinkedList eventQ; //event q - int shutdown; //whether or not we are shutdown - FreeList freeEvents; //FreeList for events - ThreadPool *tp; //ThreadPool to use + ithread_mutex_t mutex; + ithread_cond_t condition; + int lastEventId; + LinkedList eventQ; + int shutdown; + FreeList freeEvents; + ThreadPool *tp; } TimerThread; @@ -85,9 +85,9 @@ typedef struct TIMERTHREAD typedef struct TIMEREVENT { ThreadPoolJob job; - time_t eventTime; //absolute time for event in seconds since Jan 1, 1970 - Duration persistent; //long term or short term job - int id; //id of job + time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */ + Duration persistent; /* long term or short term job */ + int id; } TimerEvent; @@ -188,4 +188,5 @@ int TimerThreadShutdown(TimerThread *timer); } #endif -#endif //TIMER_THREAD_H +#endif /* TIMER_THREAD_H */ + diff --git a/threadutil/inc/iasnprintf.h b/threadutil/inc/iasnprintf.h index b4f1331..041fea8 100644 --- a/threadutil/inc/iasnprintf.h +++ b/threadutil/inc/iasnprintf.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #include diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index 5024443..90d69f3 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef ITHREADH #define ITHREADH @@ -36,15 +36,9 @@ extern "C" { #endif -#ifdef DEBUG -#define DEBUG_ONLY(x) x -#else -#define DEBUG_ONLY(x) -#endif - #include #ifndef WIN32 - #include + #include #endif #ifdef __FreeBSD__ @@ -548,23 +542,23 @@ extern "C" { #define imillisleep(x) usleep(1000*x) #ifdef WIN32 - #ifndef UPNP_STATIC_LIB - #ifdef LIBUPNP_EXPORTS - // set up declspec for dll export to make functions visible to library users - #define EXPORT_SPEC __declspec(dllexport) - #else - #define EXPORT_SPEC __declspec(dllimport) - #endif - #else - #define EXPORT_SPEC - #endif + #ifndef UPNP_STATIC_LIB + #ifdef LIBUPNP_EXPORTS + /* set up declspec for dll export to make functions visible to library users */ + #define EXPORT_SPEC __declspec(dllexport) + #else + #define EXPORT_SPEC __declspec(dllimport) + #endif + #else + #define EXPORT_SPEC + #endif #else - #define EXPORT_SPEC + #define EXPORT_SPEC #endif #ifndef PTHREAD_MUTEX_RECURSIVE -//NK: Added for satisfying the gcc compiler +/* NK: Added for satisfying the gcc compiler */ EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind); #endif @@ -572,4 +566,5 @@ EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind } #endif -#endif //ITHREADH +#endif /* ITHREADH */ + diff --git a/threadutil/src/ThreadPool.c b/threadutil/src/ThreadPool.c index d8e737c..3a78b72 100644 --- a/threadutil/src/ThreadPool.c +++ b/threadutil/src/ThreadPool.c @@ -131,7 +131,7 @@ SetPriority( ThreadPriority priority ) int midPriority = 0; struct sched_param newPriority; - pthread_getschedparam( ithread_self( ), ¤tPolicy, + pthread_getschedparam( ithread_self(), ¤tPolicy, &newPriority ); minPriority = sched_get_priority_min( currentPolicy ); maxPriority = sched_get_priority_max( currentPolicy ); @@ -153,7 +153,7 @@ SetPriority( ThreadPriority priority ) newPriority.sched_priority = actPriority; - return pthread_setschedparam( ithread_self( ), currentPolicy, + return pthread_setschedparam( ithread_self(), currentPolicy, &newPriority ); } @@ -220,10 +220,8 @@ BumpPriority( ThreadPool * tp ) //starvation time //bump priority (add to higher priority Q) - STATSONLY( tp->stats.totalJobsMQ++; - ); - STATSONLY( tp->stats.totalTimeMQ += diffTime; - ); + STATSONLY( tp->stats.totalJobsMQ++; ) + STATSONLY( tp->stats.totalTimeMQ += diffTime; ) ListDelNode( &tp->medJobQ, tp->medJobQ.head.next, 0 ); ListAddTail( &tp->highJobQ, tempJob ); @@ -241,10 +239,8 @@ BumpPriority( ThreadPool * tp ) //starvation time //bump priority (add to higher priority Q) - STATSONLY( tp->stats.totalJobsLQ++; - ); - STATSONLY( tp->stats.totalTimeLQ += diffTime; - ); + STATSONLY( tp->stats.totalJobsLQ++; ) + STATSONLY( tp->stats.totalTimeLQ += diffTime; ) ListDelNode( &tp->lowJobQ, tp->lowJobQ.head.next, 0 ); ListAddTail( &tp->medJobQ, tempJob ); @@ -293,14 +289,26 @@ SetRelTimeout( struct timespec *time, * ThreadPoolStats *stats must be valid non null stats structure *****************************************************************************/ #ifdef STATS -static void StatsInit( ThreadPoolStats * stats ) { - assert( stats != NULL ); stats->totalIdleTime = 0; stats->totalJobsHQ = 0; stats->totalJobsLQ = 0; stats->totalJobsMQ = 0; stats->totalTimeHQ = 0; stats->totalTimeMQ = 0; stats->totalTimeLQ = 0; stats->totalWorkTime = 0; stats->totalIdleTime = 0; stats->avgWaitHQ = 0; //average wait in HQ - stats->avgWaitMQ = 0; //average wait in MQ +static void StatsInit( ThreadPoolStats * stats ) +{ + assert( stats != NULL ); + stats->totalIdleTime = 0; + stats->totalJobsHQ = 0; + stats->totalJobsLQ = 0; + stats->totalJobsMQ = 0; + stats->totalTimeHQ = 0; + stats->totalTimeMQ = 0; + stats->totalTimeLQ = 0; + stats->totalWorkTime = 0; + stats->totalIdleTime = 0; + stats->avgWaitHQ = 0; + stats->avgWaitMQ = 0; stats->avgWaitLQ = 0; stats->workerThreads = 0; stats->idleThreads = 0; stats->persistentThreads = 0; - stats->maxThreads = 0; stats->totalThreads = 0;} + stats->maxThreads = 0; stats->totalThreads = 0; +} #endif /**************************************************************************** @@ -346,16 +354,16 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: * Parameters: * *****************************************************************************/ - static void SetSeed( ) { + static void SetSeed() { struct timeb t; ftime( &t ); #if defined(WIN32) - srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ).p ); + srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id().p ); #elif defined(__FreeBSD__) - srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ) ); + srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id() ); #else - srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) ); + srand( ( unsigned int )t.millitm + ithread_get_current_thread_id() ); #endif } @@ -375,8 +383,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: *****************************************************************************/ static void *WorkerThread( void *arg ) { - STATSONLY( time_t start = 0; - ) + STATSONLY( time_t start = 0; ) ThreadPoolJob *job = NULL; ListNode *head = NULL; @@ -400,10 +407,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); - SetSeed( ); + SetSeed(); - STATSONLY( time( &start ); - ); + STATSONLY( time( &start ); ) while( 1 ) { @@ -418,12 +424,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: retCode = 0; - STATSONLY( tp->stats.idleThreads++; - ); - STATSONLY( tp->stats.totalWorkTime += ( time( NULL ) - start ); - ); //work time - STATSONLY( time( &start ); - ); //idle time + STATSONLY( tp->stats.idleThreads++; ) + STATSONLY( tp->stats.totalWorkTime += ( time( NULL ) - start ); ) //work time + STATSONLY( time( &start ); ) // idle time if( persistent == 1 ) { //Persistent thread @@ -431,8 +434,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: tp->persistentThreads--; } - STATSONLY( if( persistent == 0 ) - tp->stats.workerThreads--; ); + STATSONLY( if( persistent == 0 ) tp->stats.workerThreads--; ) //Check for a job or shutdown while( ( tp->lowJobQ.size == 0 ) @@ -453,7 +455,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: && ( ( tp->totalThreads ) > tp->attr.maxThreads ) ) ) { - STATSONLY( tp->stats.idleThreads-- ); + STATSONLY( tp->stats.idleThreads--; ) tp->totalThreads--; ithread_cond_broadcast( &tp->start_and_shutdown ); @@ -475,12 +477,9 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: } - STATSONLY( tp->stats.idleThreads--; - ); - STATSONLY( tp->stats.totalIdleTime += ( time( NULL ) - start ); - ); //idle time - STATSONLY( time( &start ); - ); //work time + STATSONLY( tp->stats.idleThreads--; ) + STATSONLY( tp->stats.totalIdleTime += ( time( NULL ) - start ); ) // idle time + STATSONLY( time( &start ); ) // work time //bump priority of starved jobs BumpPriority( tp ); @@ -512,34 +511,33 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: ithread_cond_broadcast( &tp->start_and_shutdown ); } else { - STATSONLY( tp->stats.workerThreads++ ); + STATSONLY( tp->stats.workerThreads++; ) persistent = 0; //Pick the highest priority job if( tp->highJobQ.size > 0 ) { head = ListHead( &tp->highJobQ ); job = ( ThreadPoolJob * ) head->item; - STATSONLY( CalcWaitTime - ( tp, HIGH_PRIORITY, job ) ); + STATSONLY( CalcWaitTime( tp, HIGH_PRIORITY, job ); ) ListDelNode( &tp->highJobQ, head, 0 ); } else if( tp->medJobQ.size > 0 ) { head = ListHead( &tp->medJobQ ); job = ( ThreadPoolJob * ) head->item; - STATSONLY( CalcWaitTime( tp, MED_PRIORITY, job ) ); + STATSONLY( CalcWaitTime( tp, MED_PRIORITY, job ); ) ListDelNode( &tp->medJobQ, head, 0 ); } else if( tp->lowJobQ.size > 0 ) { head = ListHead( &tp->lowJobQ ); job = ( ThreadPoolJob * ) head->item; - STATSONLY( CalcWaitTime( tp, LOW_PRIORITY, job ) ); + STATSONLY( CalcWaitTime( tp, LOW_PRIORITY, job ); ) ListDelNode( &tp->lowJobQ, head, 0 ); } else { // Should never get here assert( 0 ); - STATSONLY( tp->stats.workerThreads-- ); + STATSONLY( tp->stats.workerThreads--; ) tp->totalThreads--; ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); @@ -644,9 +642,11 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: } - STATSONLY( if( tp->stats.maxThreads < tp->totalThreads ) { - tp->stats.maxThreads = tp->totalThreads;} - ) +#ifdef STATS + if( tp->stats.maxThreads < tp->totalThreads ) { + tp->stats.maxThreads = tp->totalThreads; + } +#endif return rc; } @@ -674,7 +674,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: threads = tp->totalThreads - tp->persistentThreads; while( ( threads == 0 ) - || ( ( jobs / threads ) > tp->attr.jobsPerThread ) ) { + || ( ( jobs / threads ) >= tp->attr.jobsPerThread ) ) { if( CreateWorker( tp ) != 0 ) return; @@ -766,7 +766,7 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: JOBFREELISTSIZE ); assert( retCode == 0 ); - STATSONLY( StatsInit( &tp->stats ) ); + STATSONLY( StatsInit( &tp->stats ); ) retCode += ListInit( &tp->highJobQ, CmpThreadPoolJob, NULL ); assert( retCode == 0 ); diff --git a/upnp/Makefile.am b/upnp/Makefile.am index 1a7cdc0..daa8a95 100644 --- a/upnp/Makefile.am +++ b/upnp/Makefile.am @@ -1,163 +1,154 @@ -# $Id: Makefile.am,v 1.10 2006/04/08 15:22:22 r3mi Exp $ + # # "Makefile.am" for "libupnp/upnp" # -# Copyright (C) 2005 Rémi Turboult +# Copyright (C) 2005 R�mi Turboult # -SUBDIRS = doc +SUBDIRS = doc . sample -AM_CPPFLAGS = -I$(srcdir)/inc \ - -I$(top_srcdir)/threadutil/inc \ - -I$(top_srcdir)/ixml/inc +AM_CPPFLAGS = \ + -I$(srcdir)/inc \ + -I$(top_srcdir)/threadutil/inc \ + -I$(top_srcdir)/ixml/inc -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS = $(PTHREAD_CFLAGS) -AM_LDFLAGS = $(PTHREAD_LIBS) +AM_LDFLAGS = $(PTHREAD_LIBS) -LDADD = libupnp.la \ - $(top_builddir)/threadutil/libthreadutil.la \ - $(top_builddir)/ixml/libixml.la +LDADD = \ + libupnp.la \ + $(top_builddir)/threadutil/libthreadutil.la \ + $(top_builddir)/ixml/libixml.la -upnpincludedir = $(includedir)/upnp -upnpinclude_HEADERS = inc/upnp.h +upnpincludedir = $(includedir)/upnp +upnpinclude_HEADERS = inc/upnp.h nodist_upnpinclude_HEADERS = inc/upnpconfig.h if ENABLE_TOOLS -upnpinclude_HEADERS += inc/upnptools.h +upnpinclude_HEADERS += inc/upnptools.h endif if ENABLE_DEBUG -upnpinclude_HEADERS += inc/upnpdebug.h +upnpinclude_HEADERS += inc/upnpdebug.h endif -lib_LTLIBRARIES = libupnp.la -libupnp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/inc -libupnp_la_LDFLAGS = -version-info $(LT_VERSION_UPNP) \ - -export-symbols-regex '^Upnp.*' \ - $(top_builddir)/threadutil/libthreadutil.la \ - $(top_builddir)/ixml/libixml.la +lib_LTLIBRARIES = libupnp.la -libupnp_la_SOURCES = \ - src/inc/config.h \ - src/inc/client_table.h src/inc/global.h \ - src/inc/md5.h src/inc/ssdplib.h \ - src/inc/unixutil.h src/inc/urlconfig.h \ - src/inc/gmtdate.h src/inc/membuffer.h \ - src/inc/server.h src/inc/statcodes.h \ - src/inc/upnpapi.h src/inc/utilall.h \ - src/inc/gena_ctrlpt.h src/inc/http_client.h \ - src/inc/miniserver.h src/inc/service_table.h \ - src/inc/statuscodes.h src/inc/upnpclosesocket.h \ - src/inc/util.h src/inc/gena_device.h \ - src/inc/httpparser.h src/inc/netall.h \ - src/inc/soaplib.h src/inc/strintmap.h \ - src/inc/upnp_timeout.h src/inc/uuid.h \ - src/inc/gena.h src/inc/httpreadwrite.h \ - src/inc/parsetools.h src/inc/sock.h \ - src/inc/sysdep.h src/inc/uri.h \ - src/inc/webserver.h +libupnp_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/inc + +libupnp_la_LDFLAGS = \ + -version-info $(LT_VERSION_UPNP) \ + -export-symbols-regex '^Upnp.*' \ + $(top_builddir)/threadutil/libthreadutil.la \ + $(top_builddir)/ixml/libixml.la + +libupnp_la_SOURCES = \ + src/inc/config.h \ + src/inc/client_table.h \ + src/inc/gena.h \ + src/inc/gena_ctrlpt.h \ + src/inc/gena_device.h \ + src/inc/global.h \ + src/inc/gmtdate.h \ + src/inc/http_client.h \ + src/inc/httpparser.h \ + src/inc/httpreadwrite.h \ + src/inc/md5.h \ + src/inc/membuffer.h \ + src/inc/miniserver.h \ + src/inc/netall.h \ + src/inc/parsetools.h \ + src/inc/server.h \ + src/inc/service_table.h \ + src/inc/soaplib.h \ + src/inc/sock.h \ + src/inc/statcodes.h \ + src/inc/statuscodes.h \ + src/inc/strintmap.h \ + src/inc/ssdplib.h \ + src/inc/sysdep.h \ + src/inc/unixutil.h \ + src/inc/upnpapi.h \ + src/inc/upnpclosesocket.h \ + src/inc/upnp_timeout.h \ + src/inc/uri.h \ + src/inc/urlconfig.h \ + src/inc/util.h \ + src/inc/utilall.h \ + src/inc/uuid.h \ + src/inc/webserver.h # ssdp -libupnp_la_SOURCES += src/ssdp/ssdp_device.c src/ssdp/ssdp_ctrlpt.c \ - src/ssdp/ssdp_server.c +libupnp_la_SOURCES += \ + src/ssdp/ssdp_device.c \ + src/ssdp/ssdp_ctrlpt.c \ + src/ssdp/ssdp_server.c # soap -libupnp_la_SOURCES += src/soap/soap_device.c src/soap/soap_ctrlpt.c \ - src/soap/soap_common.c +libupnp_la_SOURCES += \ + src/soap/soap_device.c \ + src/soap/soap_ctrlpt.c \ + src/soap/soap_common.c # genlib -libupnp_la_SOURCES += \ - src/genlib/miniserver/miniserver.c \ - src/genlib/service_table/service_table.c \ - src/genlib/util/membuffer.c \ - src/genlib/util/strintmap.c \ - src/genlib/util/upnp_timeout.c \ - src/genlib/util/util.c \ - src/genlib/client_table/client_table.c \ - src/genlib/net/sock.c \ - src/genlib/net/http/httpparser.c \ - src/genlib/net/http/httpreadwrite.c \ - src/genlib/net/http/statcodes.c \ - src/genlib/net/http/webserver.c \ - src/genlib/net/http/parsetools.c \ - src/genlib/net/uri/uri.c +libupnp_la_SOURCES += \ + src/genlib/miniserver/miniserver.c \ + src/genlib/service_table/service_table.c \ + src/genlib/util/membuffer.c \ + src/genlib/util/strintmap.c \ + src/genlib/util/upnp_timeout.c \ + src/genlib/util/util.c \ + src/genlib/client_table/client_table.c \ + src/genlib/net/sock.c \ + src/genlib/net/http/httpparser.c \ + src/genlib/net/http/httpreadwrite.c \ + src/genlib/net/http/statcodes.c \ + src/genlib/net/http/webserver.c \ + src/genlib/net/http/parsetools.c \ + src/genlib/net/uri/uri.c # gena -libupnp_la_SOURCES += src/gena/gena_device.c src/gena/gena_ctrlpt.c \ - src/gena/gena_callback2.c +libupnp_la_SOURCES += \ + src/gena/gena_device.c \ + src/gena/gena_ctrlpt.c \ + src/gena/gena_callback2.c # api -libupnp_la_SOURCES += src/api/upnpapi.c +libupnp_la_SOURCES += src/api/upnpapi.c if ENABLE_TOOLS - libupnp_la_SOURCES += src/api/upnptools.c +libupnp_la_SOURCES += src/api/upnptools.c endif if ENABLE_DEBUG - libupnp_la_SOURCES += src/api/upnpdebug.c +libupnp_la_SOURCES += src/api/upnpdebug.c endif + # uuid -libupnp_la_SOURCES += src/uuid/md5.c src/uuid/sysdep.c src/uuid/uuid.c +libupnp_la_SOURCES += \ + src/uuid/md5.c \ + src/uuid/sysdep.c \ + src/uuid/uuid.c + # urlconfig -libupnp_la_SOURCES += src/urlconfig/urlconfig.c - - -# samples -noinst_PROGRAMS = -if ENABLE_SAMPLES -if ENABLE_CLIENT - noinst_PROGRAMS += upnp_tv_ctrlpt - upnp_tv_ctrlpt_CPPFLAGS = $(AM_CPPFLAGS) \ - -I$(srcdir)/sample/common/ \ - -I$(srcdir)/sample/tvctrlpt -endif -if ENABLE_DEVICE - noinst_PROGRAMS += upnp_tv_device - upnp_tv_device_CPPFLAGS = $(AM_CPPFLAGS) \ - -I$(srcdir)/sample/common/ \ - -I$(srcdir)/sample/tvdevice -endif -endif -upnp_tv_device_SOURCES = \ - sample/common/sample_util.c \ - sample/common/sample_util.h \ - sample/tvdevice/upnp_tv_device.c \ - sample/tvdevice/upnp_tv_device.h \ - sample/tvdevice/linux/upnp_tv_device_main.c -upnp_tv_ctrlpt_SOURCES = \ - sample/common/sample_util.c \ - sample/common/sample_util.h \ - sample/tvctrlpt/upnp_tv_ctrlpt.c \ - sample/tvctrlpt/upnp_tv_ctrlpt.h \ - sample/tvctrlpt/linux/upnp_tv_ctrlpt_main.c - -if WITH_DOCUMENTATION - examplesdir = $(docdir)/examples - examples_DATA = $(upnp_tv_ctrlpt_SOURCES) $(upnp_tv_device_SOURCES) -endif +libupnp_la_SOURCES += src/urlconfig/urlconfig.c # check / distcheck tests -check_PROGRAMS = test_init -TESTS = test_init - -test_init_SOURCES = test/test_init.c +check_PROGRAMS = test_init +TESTS = test_init +test_init_SOURCES = test/test_init.c -EXTRA_DIST = LICENSE \ - sample/tvdevice/web/tvcontrolSCPD.xml \ - sample/tvdevice/web/tvdevicedesc.xml \ - sample/tvdevice/web/tvdevicepres.html \ - sample/tvdevice/web/tvpictureSCPD.xml \ - src/inc/inet_pton.h \ - src/inet_pton.c \ - src/win_dll.c - - - -CLEANFILES = IUpnpErrFile.txt IUpnpInfoFile.txt - +EXTRA_DIST = \ + LICENSE \ + src/inc/inet_pton.h \ + src/inet_pton.c \ + src/win_dll.c +CLEANFILES = \ + IUpnpErrFile.txt \ + IUpnpInfoFile.txt diff --git a/upnp/doc/Makefile.am b/upnp/doc/Makefile.am index 7b6c743..cf2a91f 100644 --- a/upnp/doc/Makefile.am +++ b/upnp/doc/Makefile.am @@ -2,7 +2,7 @@ # # "Makefile.am" for "libunp/upnp/doc" # -# (C) Copyright 2005 Rémi Turboult +# (C) Copyright 2005 R�mi Turboult # ########################################################################## # diff --git a/upnp/doc/UPnP_Programming_Guide.pdf b/upnp/doc/UPnP_Programming_Guide.pdf index 7d4502b..03a7355 100644 Binary files a/upnp/doc/UPnP_Programming_Guide.pdf and b/upnp/doc/UPnP_Programming_Guide.pdf differ diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index dad9258..d47944e 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -1,101 +1,124 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef UPNP_H #define UPNP_H /** @name The API */ -//@{ +/*! @{ */ + #if defined MYLIB_LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 != 64 - #if defined __GNUC__ - #warning libupnp requires largefile mode - use AC_SYS_LARGEFILE - #else - #error libupnp requires largefile mode - use AC_SYS_LARGEFILE - #endif + #if defined __GNUC__ + #warning libupnp requires largefile mode - use AC_SYS_LARGEFILE + #else + #error libupnp requires largefile mode - use AC_SYS_LARGEFILE + #endif #endif + #include #ifdef __FreeBSD__ -#include + #include #endif #include "ixml.h" #include "upnpconfig.h" -#if UPNP_HAVE_DEBUG -# include "upnpdebug.h" -#endif + #ifdef WIN32 - #ifndef UPNP_STATIC_LIB - #ifdef LIBUPNP_EXPORTS - // set up declspec for dll export to make functions visible to library users - #define EXPORT_SPEC __declspec(dllexport) - #else - #define EXPORT_SPEC __declspec(dllimport) - #endif - #else - #define EXPORT_SPEC - #endif - #ifdef UPNP_USE_MSVCPP // define some things the M$ VC++ doesn't knows - typedef __int64 int64_t; - #endif - #ifdef UPNP_USE_BCBPP // define some things Borland Builder doesn't knows - typedef __int64 int64_t; - #endif + #ifndef UPNP_STATIC_LIB + #ifdef LIBUPNP_EXPORTS + /* set up declspec for dll export to make functions visible to library users */ + #define EXPORT_SPEC __declspec(dllexport) + #else + #define EXPORT_SPEC __declspec(dllimport) + #endif + #else + #define EXPORT_SPEC + #endif + #ifdef UPNP_USE_MSVCPP + /* define some things the M$ VC++ doesn't know */ + #define UPNP_INLINE + typedef __int64 int64_t; + #define PRId64 "I64d" + #define PRIzu "lu" + #endif + #ifdef UPNP_USE_BCBPP + /* define some things Borland Builder doesn't know */ + #define UPNP_INLINE inline + typedef __int64 int64_t; +#warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here + #define PRId64 "I64d" + #define PRIzu "zu" + #endif #else - #define EXPORT_SPEC + #define EXPORT_SPEC + #define UPNP_INLINE inline + /* Invented this macro so that we can live a little longer with MSVC lack of C99. */ + #define PRIzu "zu" #endif -#ifndef WIN32 - #define UpnpCloseSocket close -#else - #define UpnpCloseSocket closesocket - #define fseeko fseek -#endif -#define UPNP_SOCKETERROR -1 -#define UPNP_INVALID_SOCKET -1 -#ifndef WIN32 - #define SOCKET int -#endif +/* + * Defining this macro here gives some interesting information about unused + * functions in the code. Of course, this should never go uncommented on a + * release. + */ +/*#define inline*/ + #ifndef WIN32 - #include + #define UpnpCloseSocket close #else - #include - #include + #define UpnpCloseSocket closesocket + #define fseeko fseek #endif +#define UPNP_SOCKETERROR -1 +#define UPNP_INVALID_SOCKET -1 +#ifndef WIN32 + #define SOCKET int +#endif + + +#ifndef WIN32 + #include +#else + #include + #include +#endif + #include + #define NUM_HANDLE 200 #define LINE_SIZE 180 #define NAME_SIZE 256 @@ -104,7 +127,6 @@ #define SERL_NUMR_SIZE 64 #define MODL_DESC_SIZE 64 #define UPNP_INFINITE -1 - #define UPNP_USING_CHUNKED -3 #define UPNP_UNTIL_CLOSE -4 @@ -116,7 +138,7 @@ * code means. Refer to the documentation for each function for a * description of what an error code means in that context. */ -//@{ +/*! @{ */ /** @name UPNP_E_SUCCESS [0] * {\tt UPNP_E_SUCCESS} signifies that the operation completed successfully. @@ -124,35 +146,35 @@ * the operation was successfully transmitted on the network. The result of * the entire operation comes as part of the callback for that operation. */ -//@{ +/*! @{ */ #define UPNP_E_SUCCESS 0 -//@} +/*! @} */ /** @name UPNP_E_INVALID_HANDLE [-100] * {\tt UPNP_E_INVALID_HANDLE} signifies that the handle passed to a * function is not a recognized as a valid handle. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_HANDLE -100 -//@} +/*! @} */ /** @name UPNP_E_INVALID_PARAM [-101] * {\tt UPNP_E_INVALID_PARAM} signifies that one or more of the parameters * passed to the function is not valid. Refer to the documentation for each * function for more information on the valid ranges of the parameters. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_PARAM -101 -//@} +/*! @} */ /** @name UPNP_E_OUTOF_HANDLE [-102] * {\tt UPNP_E_OUTOF_HANDLE} signifies that the SDK does not have any * more space for additional handles. The SDK allocates space for only * a few handles in order to conserve memory. */ -//@{ +/*! @{ */ #define UPNP_E_OUTOF_HANDLE -102 -//@} +/*! @} */ #define UPNP_E_OUTOF_CONTEXT -103 @@ -161,9 +183,9 @@ * currently available to complete the operation. Most operations require * some free memory in order to complete their work. */ -//@{ +/*! @{ */ #define UPNP_E_OUTOF_MEMORY -104 -//@} +/*! @} */ /** @name UPNP_E_INIT [-105] * {\tt UPNP_E_INIT} signifies that the SDK has already been @@ -171,9 +193,9 @@ * Any additional initialization attempts simply return this error with * no other ill effects. */ -//@{ +/*! @{ */ #define UPNP_E_INIT -105 -//@} +/*! @} */ #define UPNP_E_BUFFER_TOO_SMALL -106 @@ -182,9 +204,9 @@ * to {\bf UpnpRegisterRootDevice} or {\bf UpnpRegisterRootDevice2} is an * invalid description document. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_DESC -107 -//@} +/*! @} */ /** @name UPNP_E_INVALID_URL [-108] * {\tt UPNP_E_INVALID_URL} signifies that a URL passed into the function @@ -192,9 +214,9 @@ * URL itself might be malformed (e.g. have invalid characters in it) or * the host might be unreachable. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_URL -108 -//@} +/*! @} */ #define UPNP_E_INVALID_SID -109 #define UPNP_E_INVALID_DEVICE -110 @@ -205,18 +227,18 @@ * {\bf UpnpAcceptSubscriptionExt} to signify that the device ID/service * ID pair does not refer to a valid service. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_SERVICE -111 -//@} +/*! @} */ /** @name UPNP_E_BAD_RESPONSE [-113] * {\tt UPNP_E_BAD_RESPONSE} signifies that the response received from the * remote side of a connection is not correct for the protocol. This applies * to the GENA, SOAP, and HTTP protocols. */ -//@{ +/*! @{ */ #define UPNP_E_BAD_RESPONSE -113 -//@} +/*! @} */ #define UPNP_E_BAD_REQUEST -114 @@ -225,26 +247,26 @@ * invalid. This can be because the DOM document passed to the function was * malformed or the action message is not correct for the given action. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_ACTION -115 -//@} +/*! @} */ /** @name UPNP_E_FINISH [-116] * {\tt UPNP_E_FINISH} signifies that {\bf UpnpInit} has not been called, or * that {\bf UpnpFinish} has already been called. None of the API functions * operate until {\bf UpnpInit} successfully completes. */ -//@{ +/*! @{ */ #define UPNP_E_FINISH -116 -//@} +/*! @} */ /** @name UPNP_E_INIT_FAILED [-117] * {\tt UPNP_E_INIT_FAILED} signifies that {\bf UpnpInit} cannot complete. * The typical reason is failure to allocate sufficient resources. */ -//@{ +/*! @{ */ #define UPNP_E_INIT_FAILED -117 -//@} +/*! @} */ /** @name UPNP_E_URL_TOO_BIG [-118] * {\tt UPNP_E_URL_TOO_BIG} signifies that the URL passed into a function @@ -260,18 +282,18 @@ * message (e.g. {\bf UpnpSubscribe}), GENA event notifications (e.g. {\bf * UpnpNotify}), and HTTP transfers (e.g. {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_BAD_HTTPMSG -119 -//@} +/*! @} */ /** @name UPNP_E_ALREADY_REGISTERED [-120] * {\tt UPNP_E_ALREADY_REGISTERED} signifies that a client or a device is * already registered. The SDK currently has a limit of one registered * client and one registered device per process. */ -//@{ +/*! @{ */ #define UPNP_E_ALREADY_REGISTERED -120 -//@} +/*! @} */ /** @name UPNP_E_NETWORK_ERROR [-200] * {\tt UPNP_E_NETWORK_ERROR} signifies that a network error occurred. It @@ -280,9 +302,9 @@ * failed to read the local IP address or had problems configuring one of * the sockets. */ -//@{ +/*! @{ */ #define UPNP_E_NETWORK_ERROR -200 -//@} +/*! @} */ /** @name UPNP_E_SOCKET_WRITE [-201] * {\tt UPNP_E_SOCKET_WRITE} signifies an error writing to a socket. This @@ -291,9 +313,9 @@ * control (e.g. {\bf UpnpSendAction}), eventing (e.g. {\bf UpnpNotify}), * and HTTP functions (e.g. {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_SOCKET_WRITE -201 -//@} +/*! @} */ /** @name UPNP_E_SOCKET_READ [-202] * {\tt UPNP_E_SOCKET_READ} signifies an error reading from a socket. This @@ -302,9 +324,9 @@ * control (e.g. {\bf UpnpSendAction}), eventing (e.g. {\bf UpnpNotify}), * and HTTP functions (e.g. {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_SOCKET_READ -202 -//@} +/*! @} */ /** @name UPNP_E_SOCKET_BIND [-203] * {\tt UPNP_E_SOCKET_BIND} signifies that the SDK had a problem binding @@ -314,9 +336,9 @@ * (e.g. {\bf UpnpNotify}), and HTTP functions (e.g. * {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_SOCKET_BIND -203 -//@} +/*! @} */ /** @name UPNP_E_SOCKET_CONNECT [-204] * {\tt UPNP_E_SOCKET_CONNECT} signifies that the SDK had a problem @@ -326,9 +348,9 @@ * (e.g. {\bf UpnpNotify}), and HTTP functions (e.g. * {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_SOCKET_CONNECT -204 -//@} +/*! @} */ /** @name UPNP_E_OUTOF_SOCKET [-205] * {\tt UPNP_E_OUTOF_SOCKET} signifies that the SDK cannot create any @@ -338,36 +360,36 @@ * (e.g. {\bf UpnpNotify}), and HTTP functions (e.g. * {\bf UpnpDownloadXmlDoc}). */ -//@{ +/*! @{ */ #define UPNP_E_OUTOF_SOCKET -205 -//@} +/*! @} */ /** @name UPNP_E_LISTEN [-206] * {\tt UPNP_E_LISTEN} signifies that the SDK had a problem setting the * socket to listen for incoming connections. This error only happens during * initialization (i.e. {\bf UpnpInit}). */ -//@{ +/*! @{ */ #define UPNP_E_LISTEN -206 -//@} +/*! @} */ /** @name UPNP_E_TIMEDOUT [-207] * {\tt UPNP_E_TIMEDOUT} signifies that too much time elapsed before the * required number of bytes were sent or received over a socket. This error * can be returned by any function that performs network operations. */ -//@{ +/*! @{ */ #define UPNP_E_TIMEDOUT -207 -//@} +/*! @} */ /** @name UPNP_E_SOCKET_ERROR [-208] * {\tt UPNP_E_SOCKET_ERROR} is the generic socket error code for * conditions not covered by other error codes. This error can be returned * by any function that performs network operations. */ -//@{ +/*! @{ */ #define UPNP_E_SOCKET_ERROR -208 -//@} +/*! @} */ #define UPNP_E_FILE_WRITE_ERROR -209 @@ -376,9 +398,9 @@ * error can be returned by any function that allows for external * cancelation. */ -//@{ +/*! @{ */ #define UPNP_E_CANCELED -210 -//@} +/*! @} */ #define UPNP_E_EVENT_PROTOCOL -300 @@ -386,58 +408,58 @@ * {\tt UPNP_E_SUBSCRIBE_UNACCEPTED} signifies that a subscription * request was rejected from the remote side. */ -//@{ +/*! @{ */ #define UPNP_E_SUBSCRIBE_UNACCEPTED -301 -//@} +/*! @} */ /** @name UPNP_E_UNSUBSCRIBE_UNACCAPTED [-302] * {\tt UPNP_E_UNSUBSCRIBE_UNACCEPTED} signifies that an unsubscribe * request was rejected from the remote side. */ -//@{ +/*! @{ */ #define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302 -//@} +/*! @} */ /** @name UPNP_E_NOTIFY_UNACCEPTED [-303] * {\tt UPNP_E_NOTIFY_UNACCEPTED} signifies that the remote host did not * accept the notify sent from the local device. */ -//@{ +/*! @{ */ #define UPNP_E_NOTIFY_UNACCEPTED -303 -//@} +/*! @} */ /** @name UPNP_E_INVALID_ARGUMENT [-501] * {\tt UPNP_E_INVALID_ARGUMENT} signifies that one or more of the parameters * passed to a function is invalid. Refer to the individual function * descriptions for the acceptable ranges for parameters. */ -//@{ +/*! @{ */ #define UPNP_E_INVALID_ARGUMENT -501 -//@} +/*! @} */ /** @name UPNP_E_FILE_NOT_FOUND [-502] * {\tt UPNP_E_FILE_NOT_FOUND} signifies that the filename passed * to one of the device registration functions was not found or was not * accessible. */ -//@{ +/*! @{ */ #define UPNP_E_FILE_NOT_FOUND -502 -//@} +/*! @} */ /** @name UPNP_E_FILE_READ_ERROR [-503] * {\tt UPNP_E_FILE_READ_ERROR} signifies an error when reading a file. */ -//@{ +/*! @{ */ #define UPNP_E_FILE_READ_ERROR -503 -//@} +/*! @} */ /** @name UPNP_E_EXT_NOT_XML [-504] * {\tt UPNP_E_EXT_NOT_XML} signifies that the file name of the description * document passed to {\bf UpnpRegisterRootDevice2} does not end in ".xml". */ -//@{ +/*! @{ */ #define UPNP_E_EXT_NOT_XML -504 -//@} +/*! @} */ #define UPNP_E_NO_WEB_SERVER -505 #define UPNP_E_OUTOF_BOUNDS -506 @@ -446,26 +468,26 @@ * {\tt UPNP_E_NOT_FOUND} signifies that the response to a SOAP request * did not contain the required XML constructs. */ -//@{ +/*! @{ */ #define UPNP_E_NOT_FOUND -507 -//@} +/*! @} */ /** @name UPNP_E_INTERNAL_ERROR [-911] * {\tt UPNP_E_INTERNAL_ERROR} is the generic error code for internal * conditions not covered by other error codes. */ -//@{ +/*! @{ */ #define UPNP_E_INTERNAL_ERROR -911 -//@} +/*! @} */ -// SOAP-related error codes +/* SOAP-related error codes */ #define UPNP_SOAP_E_INVALID_ACTION 401 #define UPNP_SOAP_E_INVALID_ARGS 402 #define UPNP_SOAP_E_OUT_OF_SYNC 403 #define UPNP_SOAP_E_INVALID_VAR 404 #define UPNP_SOAP_E_ACTION_FAILED 501 -//@} +/*! @} */ #ifndef OUT #define OUT @@ -479,10 +501,12 @@ #define INOUT #endif +#include "upnpdebug.h" + enum UpnpOpenFileMode{UPNP_READ, UPNP_WRITE}; -/// @name Constants, Structures, and Types -//@{ +/*! @name Constants, Structures, and Types */ +/*! @{ */ /** Returned when a control point application registers with {\bf * UpnpRegisterClient}. Client handles can only be used with @@ -505,9 +529,9 @@ typedef int UpnpDevice_Handle; enum Upnp_EventType_e { - // - // Control callbacks - // + /* + * Control callbacks + */ /** Received by a device when a control point issues a control * request. The {\bf Event} parameter contains a pointer to a {\bf @@ -535,9 +559,9 @@ enum Upnp_EventType_e { UPNP_CONTROL_GET_VAR_COMPLETE, - // - // Discovery callbacks - // + /* + * Discovery callbacks + */ /** Received by a control point when a new device or service is available. * The {\bf Event} parameter contains a pointer to a {\bf @@ -566,9 +590,9 @@ enum Upnp_EventType_e { UPNP_DISCOVERY_SEARCH_TIMEOUT, - // - // Eventing callbacks - // + /* + * Eventing callbacks + */ /** Received by a device when a subscription arrives. * The {\bf Event} parameter contains a pointer to a {\bf @@ -799,10 +823,10 @@ struct Upnp_Event }; -// -// This typedef is required by Doc++ to parse the last entry of the -// Upnp_Discovery structure correctly. -// +/* + * This typedef is required by Doc++ to parse the last entry of the + * Upnp_Discovery structure correctly. + */ typedef struct sockaddr_in SOCKADDRIN; @@ -1047,14 +1071,14 @@ typedef int (*Upnp_FunPtr) ( IN void *Cookie ); -//@} // Constants, Structures, and Types +/*! @} */ /* Constants, Structures, and Types */ #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif /* __cplusplus */ -///@name Initialization and Registration -//@{ +/*! @name Initialization and Registration */ +/*! @{ */ /** Initializes the Linux SDK for UPnP Devices. This function must be called * before any other API function can be called. It should be called * only once. Subsequent calls to this API return a {\tt UPNP_E_INIT} @@ -1365,18 +1389,18 @@ EXPORT_SPEC int UpnpSetMaxContentLength( for incoming SOAP actions, in bytes. */ ); -//@} // Initialization and Registration +/*! @} */ /* Initialization and Registration */ -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// // -// D I S C O V E R Y // -// // -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// +/****************************************************************************** + ****************************************************************************** + * * + * D I S C O V E R Y * + * * + ****************************************************************************** + ******************************************************************************/ -///@name Discovery -//@{ +/*! @name Discovery */ +/*! @{ */ /** {\bf UpnpSearchAsync} searches for devices matching the given * search target. The function returns immediately and the SDK @@ -1435,18 +1459,18 @@ EXPORT_SPEC int UpnpSendAdvertisement( the announcements. */ ); -//@} // Discovery +/*! @} */ /* Discovery */ -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// // -// C O N T R O L // -// // -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// +/****************************************************************************** + ****************************************************************************** + * * + * C O N T R O L * + * * + ****************************************************************************** + ******************************************************************************/ -///@name Control -//@{ +/*! @name Control */ +/*! @{ */ /** {\bf UpnpGetServiceVarStatus} queries the state of a state * variable of a service on another device. This is a synchronous call. @@ -1669,18 +1693,18 @@ EXPORT_SPEC int UpnpSendActionExAsync( passed to the callback when invoked. */ ); -//@} // Control +/*! @} */ /* Control */ -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// // -// E V E N T I N G // -// // -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// +/****************************************************************************** + ****************************************************************************** + * * + * E V E N T I N G * + * * + ****************************************************************************** + ******************************************************************************/ -///@name Eventing -//@{ +/*! @name Eventing */ +/*! @{ */ /** {\bf UpnpAcceptSubscription} accepts a subscription request and sends * out the current state of the eventable variables for a service. @@ -2183,19 +2207,19 @@ EXPORT_SPEC int UpnpUnSubscribeAsync( callback function when invoked. */ ); -//@} // Eventing +/*! @} */ /* Eventing */ -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// // -// C L I E N T - A P I // -// // -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// +/****************************************************************************** + ****************************************************************************** + * * + * C L I E N T - A P I * + * * + ****************************************************************************** + ******************************************************************************/ -///@name Control Point HTTP API -//@{ +/*! @name Control Point HTTP API */ +/*! @{ */ /** {\bf UpnpDownloadUrlItem} downloads a file specified in a URL. * The SDK allocates the memory for {\bf outBuf} and the @@ -2588,18 +2612,18 @@ EXPORT_SPEC int UpnpDownloadXmlDoc( XML document. */ ); -//@} // Control Point HTTP API +/*! @} */ /* Control Point HTTP API */ -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// // -// W E B S E R V E R A P I // -// // -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// +/****************************************************************************** + ****************************************************************************** + * * + * W E B S E R V E R A P I * + * * + ****************************************************************************** + ******************************************************************************/ -///@name Web Server API -//@{ +/*! @name Web Server API */ +/*! @{ */ /** {\bf UpnpSetWebServerRootDir} sets the document root directory for * the internal web server. This directory is considered the @@ -2715,12 +2739,13 @@ EXPORT_SPEC void UpnpFree( IN void *item /* The item to free. */ ); -//@} // Web Server API +/*! @} */ /* Web Server API */ #ifdef __cplusplus } -#endif // __cplusplus +#endif /* __cplusplus */ -//@} The API +/*! @} */ /* The API */ #endif + diff --git a/upnp/inc/upnpconfig.h.in b/upnp/inc/upnpconfig.h.in index 309f763..091be6a 100644 --- a/upnp/inc/upnpconfig.h.in +++ b/upnp/inc/upnpconfig.h.in @@ -1,34 +1,34 @@ -// -*- C -*- -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2006 Rémi Turboult -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/* -*- C -*- */ +/******************************************************************************* + * + * Copyright (c) 2006 R�mi Turboult + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef UPNP_CONFIG_H #define UPNP_CONFIG_H @@ -91,6 +91,5 @@ #undef UPNP_HAVE_TOOLS -#endif // UPNP_CONFIG_H - +#endif /* UPNP_CONFIG_H */ diff --git a/upnp/inc/upnpdebug.h b/upnp/inc/upnpdebug.h index 1efbbca..c0a9b39 100644 --- a/upnp/inc/upnpdebug.h +++ b/upnp/inc/upnpdebug.h @@ -1,43 +1,41 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// Copyright (c) 2006 Rémi Turboult -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * Copyright (c) 2006 R�mi Turboult + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ #ifndef UPNP_DEBUG_H #define UPNP_DEBUG_H +#include "upnp.h" #include "upnpconfig.h" -// Function declarations only if debug compiled into the library -#if UPNP_HAVE_DEBUG - #include #ifdef __cplusplus @@ -49,7 +47,7 @@ extern "C" { The UPnP SDK contains other features to aid in debugging. */ -//@{ +/*! @{ */ /** @name Upnp_LogLevel * The user has the option to select 4 different types of debugging levels, @@ -70,18 +68,25 @@ extern "C" { * \end{itemize} */ -typedef enum Upnp_Module {SSDP,SOAP,GENA,TPOOL,MSERV,DOM,API, HTTP} Dbg_Module; -//@{ +typedef enum Upnp_Module { + SSDP, + SOAP, + GENA, + TPOOL, + MSERV, + DOM, + API, + HTTP +} Dbg_Module; + +/*! @{ */ typedef enum Upnp_LogLevel_e { UPNP_CRITICAL, UPNP_PACKET, UPNP_INFO, UPNP_ALL } Upnp_LogLevel; -//@} - -// for backward compatibility -#define Dbg_Level Upnp_LogLevel +/*! @} */ /** @@ -92,32 +97,38 @@ typedef enum Upnp_LogLevel_e { /*************************************************************************** - * Function : UpnpInitLog - * - * Parameters: void - * - * Description: + * Function : UpnpInitLog + * + * Parameters: void + * + * Description: * This functions initializes the log files + * * Returns: int * -1 : If fails * UPNP_E_SUCCESS : if success ***************************************************************************/ +#ifdef DEBUG int UpnpInitLog(); - -// for backward compatibility -#define InitLog UpnpInitLog +#else +static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; } +#endif /*************************************************************************** * Function : UpnpSetLogLevel * - * Parameters: void + * Parameters: Upnp_LogLevel log_level * * Description: * This functions set the log level (see {\tt Upnp_LogLevel} * Returns: void ***************************************************************************/ -void UpnpSetLogLevel (Upnp_LogLevel); +#ifdef DEBUG +void UpnpSetLogLevel(Upnp_LogLevel log_level); +#else +static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {} +#endif /*************************************************************************** @@ -129,10 +140,11 @@ void UpnpSetLogLevel (Upnp_LogLevel); * This functions closes the log files * Returns: void ***************************************************************************/ +#ifdef DEBUG void UpnpCloseLog(); - -// for backward compatibility -#define CloseLog UpnpCloseLog +#else +static UPNP_INLINE void UpnpCloseLog() {} +#endif /*************************************************************************** @@ -149,17 +161,22 @@ void UpnpCloseLog(); * per the requested banner * Returns: void ***************************************************************************/ -void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName); - -// for backward compatibility -#define SetLogFileNames UpnpSetLogFileNames +#ifdef DEBUG +void UpnpSetLogFileNames( + const char *ErrFileName, + const char *InfoFileName); +#else +static UPNP_INLINE void UpnpSetLogFileNames( + const char *ErrFileName, + const char *InfoFileName) {} +#endif /*************************************************************************** * Function : UpnpGetDebugFile * * Parameters: - * IN Dbg_Level DLevel: The level of the debug logging. It will decide + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide * whether debug statement will go to standard output, * or any of the log files. * IN Dbg_Module Module: debug will go in the name of this module @@ -171,17 +188,47 @@ void UpnpSetLogFileNames (const char* ErrFileName, const char* InfoFileName); * NULL : if the module is turn off for debug * else returns the right file descriptor ***************************************************************************/ -FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module); +#ifdef DEBUG +FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module); +#else +static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module) +{ + return NULL; +} +#endif -// for backward compatibility -#define GetDebugFile UpnpGetDebugFile + +/*************************************************************************** + * Function : DebugAtThisLevel + * + * Parameters: + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide + * whether debug statement will go to standard output, + * or any of the log files. + * IN Dbg_Module Module: debug will go in the name of this module + * + * Description: + * This functions returns true if debug output should be done in this + * module. + * + * Returns: int + ***************************************************************************/ +#ifdef DEBUG +int DebugAtThisLevel( + IN Upnp_LogLevel DLevel, + IN Dbg_Module Module); +#else +static UPNP_INLINE int DebugAtThisLevel( + IN Upnp_LogLevel DLevel, + IN Dbg_Module Module) { return 0; } +#endif /*************************************************************************** * Function : UpnpPrintf * * Parameters: - * IN Dbg_Level DLevel: The level of the debug logging. It will decide + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide * whether debug statement will go to standard output, * or any of the log files. * IN Dbg_Module Module: debug will go in the name of this module @@ -198,6 +245,7 @@ FILE* UpnpGetDebugFile (Upnp_LogLevel level, Dbg_Module module); * debug statement is coming * Returns: void ***************************************************************************/ +#ifdef DEBUG void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, const char* DbgFileName, int DbgLineNo, const char* FmtStr, @@ -206,6 +254,15 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, __attribute__((format (__printf__, 5, 6))) #endif ; +#else +static UPNP_INLINE void UpnpPrintf( + Upnp_LogLevel DLevel, + Dbg_Module Module, + const char* DbgFileName, + int DbgLineNo, + const char* FmtStr, + ...) {} +#endif /*************************************************************************** @@ -222,8 +279,19 @@ void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, * per the requested banner * Returns: void ***************************************************************************/ -void UpnpDisplayBanner (FILE *fd, - const char** lines, size_t size, int starlength); +#ifdef DEBUG +void UpnpDisplayBanner( + FILE *fd, + const char **lines, + size_t size, + int starlength); +#else +static UPNP_INLINE void UpnpDisplayBanner( + FILE *fd, + const char **lines, + size_t size, + int starlength) {} +#endif /*************************************************************************** @@ -240,19 +308,23 @@ void UpnpDisplayBanner (FILE *fd, * debug statement is coming to the log file * Returns: void ***************************************************************************/ -void UpnpDisplayFileAndLine (FILE *fd, const char *DbgFileName, int DbgLineNo); - - -//@} +#ifdef DEBUG +void UpnpDisplayFileAndLine( + FILE *fd, + const char *DbgFileName, + int DbgLineNo); +#else +static UPNP_INLINE void UpnpDisplayFileAndLine( + FILE *fd, + const char *DbgFileName, + int DbgLineNo) {} +#endif +/*! @} */ #ifdef __cplusplus } #endif -#endif // UPNP_HAVE_DEBUG - -#endif // UPNP_DEBUG_H - - +#endif /* UPNP_DEBUG_H */ diff --git a/upnp/inc/upnptools.h b/upnp/inc/upnptools.h index 2d785d7..4b51758 100644 --- a/upnp/inc/upnptools.h +++ b/upnp/inc/upnptools.h @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ /** @name Optional Tool APIs * The Linux SDK for UPnP Devices contains some additional, optional @@ -36,14 +36,14 @@ * size in the SDK. Refer to the README for details. */ -//@{ +/*! @{ */ #ifndef UPNP_TOOLS_H #define UPNP_TOOLS_H #include "upnp.h" -// Function declarations only if tools compiled into the library +/* Function declarations only if tools compiled into the library */ #if UPNP_HAVE_TOOLS #ifdef __cplusplus @@ -217,14 +217,13 @@ EXPORT_SPEC const char * UpnpGetErrorMessage( int errorcode /** The SDK error code to convert. */ ); -//@} +/*! @} */ #ifdef __cplusplus } #endif -#endif // UPNP_HAVE_TOOLS - -#endif // UPNP_TOOLS_H +#endif /* UPNP_HAVE_TOOLS */ +#endif /* UPNP_TOOLS_H */ diff --git a/upnp/sample/Makefile.am b/upnp/sample/Makefile.am new file mode 100644 index 0000000..75fad68 --- /dev/null +++ b/upnp/sample/Makefile.am @@ -0,0 +1,86 @@ +# +# "Makefile.am" for "libupnp/upnp/sample" +# +# Copyright (C) 2007 Marcelo Roberto Jimenez +# + +AM_CPPFLAGS = \ + -I$(top_srcdir)/upnp/inc \ + -I$(top_srcdir)/threadutil/inc \ + -I$(top_srcdir)/ixml/inc + +AM_CFLAGS = $(PTHREAD_CFLAGS) + +AM_LDFLAGS = $(PTHREAD_LIBS) + +LDADD = \ + $(top_builddir)/upnp/libupnp.la \ + $(top_builddir)/threadutil/libthreadutil.la \ + $(top_builddir)/ixml/libixml.la + + +# samples +noinst_PROGRAMS = +if ENABLE_SAMPLES +if ENABLE_CLIENT +noinst_PROGRAMS += upnp_tv_ctrlpt +upnp_tv_ctrlpt_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(srcdir)/common/ \ + -I$(srcdir)/tvctrlpt +if ENABLE_DEVICE +noinst_PROGRAMS += upnp_tv_combo +upnp_tv_combo_CPPFLAGS = $(AM_CPPFLAGS) \ + -I$(srcdir)/common/ \ + -I$(srcdir)/tvcombo +endif +endif +if ENABLE_DEVICE +noinst_PROGRAMS += upnp_tv_device +upnp_tv_device_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(srcdir)/common/ \ + -I$(srcdir)/tvdevice +endif +endif + + +upnp_tv_device_SOURCES = \ + common/sample_util.c \ + common/sample_util.h \ + tvdevice/upnp_tv_device.c \ + tvdevice/upnp_tv_device.h \ + tvdevice/linux/upnp_tv_device_main.c + + +upnp_tv_ctrlpt_SOURCES = \ + common/sample_util.c \ + common/sample_util.h \ + tvctrlpt/upnp_tv_ctrlpt.c \ + tvctrlpt/upnp_tv_ctrlpt.h \ + tvctrlpt/linux/upnp_tv_ctrlpt_main.c + +upnp_tv_combo_SOURCES = \ + common/sample_util.c \ + common/sample_util.h \ + tvcombo/upnp_tv_ctrlpt.c \ + tvcombo/upnp_tv_ctrlpt.h \ + tvcombo/upnp_tv_device.c \ + tvcombo/upnp_tv_device.h \ + tvcombo/linux/upnp_tv_combo_main.c + + +if WITH_DOCUMENTATION +examplesdir = $(docdir)/examples +examples_DATA = \ + $(upnp_tv_ctrlpt_SOURCES) \ + $(upnp_tv_device_SOURCES) +endif + + +EXTRA_DIST = \ + tvdevice/web/tvcontrolSCPD.xml \ + tvdevice/web/tvdevicedesc.xml \ + tvdevice/web/tvdevicepres.html \ + tvdevice/web/tvpictureSCPD.xml + diff --git a/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c new file mode 100644 index 0000000..956a819 --- /dev/null +++ b/upnp/sample/tvcombo/linux/upnp_tv_combo_main.c @@ -0,0 +1,489 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2000-2003 Intel Corporation +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither name of Intel Corporation nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + + +#include "sample_util.h" +#include "upnp_tv_ctrlpt.h" +#include "upnp_tv_device.h" + + +#include +#include + +/* + Tags for valid commands issued at the command prompt + */ +enum cmdloop_tvcmds { + PRTHELP = 0, PRTFULLHELP, POWON, POWOFF, + SETCHAN, SETVOL, SETCOL, SETTINT, SETCONT, SETBRT, + CTRLACTION, PICTACTION, CTRLGETVAR, PICTGETVAR, + PRTDEV, LSTDEV, REFRESH, EXITCMD +}; + +/* + Data structure for parsing commands from the command line + */ +struct cmdloop_commands { + char *str; // the string + int cmdnum; // the command + int numargs; // the number of arguments + char *args; // the args +} cmdloop_commands; + +/* + Mappings between command text names, command tag, + and required command arguments for command line + commands + */ +static struct cmdloop_commands cmdloop_cmdlist[] = { + {"Help", PRTHELP, 1, ""}, + {"HelpFull", PRTFULLHELP, 1, ""}, + {"ListDev", LSTDEV, 1, ""}, + {"Refresh", REFRESH, 1, ""}, + {"PrintDev", PRTDEV, 2, ""}, + {"PowerOn", POWON, 2, ""}, + {"PowerOff", POWOFF, 2, ""}, + {"SetChannel", SETCHAN, 3, " "}, + {"SetVolume", SETVOL, 3, " "}, + {"SetColor", SETCOL, 3, " "}, + {"SetTint", SETTINT, 3, " "}, + {"SetContrast", SETCONT, 3, " "}, + {"SetBrightness", SETBRT, 3, " "}, + {"CtrlAction", CTRLACTION, 2, " "}, + {"PictAction", PICTACTION, 2, " "}, + {"CtrlGetVar", CTRLGETVAR, 2, " "}, + {"PictGetVar", PICTGETVAR, 2, " "}, + {"Exit", EXITCMD, 1, ""} +}; + +void +linux_print( const char *string ) +{ + puts( string ); +} + +/******************************************************************************** + * TvCtrlPointPrintHelp + * + * Description: + * Print help info for this application. + ********************************************************************************/ +void +TvCtrlPointPrintShortHelp( void ) +{ + SampleUtil_Print( "Commands:" ); + SampleUtil_Print( " Help" ); + SampleUtil_Print( " HelpFull" ); + SampleUtil_Print( " ListDev" ); + SampleUtil_Print( " Refresh" ); + SampleUtil_Print( " PrintDev " ); + SampleUtil_Print( " PowerOn " ); + SampleUtil_Print( " PowerOff " ); + SampleUtil_Print( " SetChannel " ); + SampleUtil_Print( " SetVolume " ); + SampleUtil_Print( " SetColor " ); + SampleUtil_Print( " SetTint " ); + SampleUtil_Print( " SetContrast " ); + SampleUtil_Print( " SetBrightness " ); + SampleUtil_Print( " CtrlAction " ); + SampleUtil_Print( " PictAction " ); + SampleUtil_Print( " CtrlGetVar " ); + SampleUtil_Print( " PictGetVar " ); + SampleUtil_Print( " Exit" ); +} + +void +TvCtrlPointPrintLongHelp( void ) +{ + SampleUtil_Print( "" ); + SampleUtil_Print( "******************************" ); + SampleUtil_Print( "* TV Control Point Help Info *" ); + SampleUtil_Print( "******************************" ); + SampleUtil_Print( "" ); + SampleUtil_Print( "This sample control point application automatically searches" ); + SampleUtil_Print( "for and subscribes to the services of television device emulator" ); + SampleUtil_Print( "devices. While registers a tv device itself." ); + SampleUtil_Print( "" ); + SampleUtil_Print( "Commands:" ); + SampleUtil_Print( " Help" ); + SampleUtil_Print( " Print this help info." ); + SampleUtil_Print( " ListDev" ); + SampleUtil_Print( " Print the current list of TV Device Emulators that this" ); + SampleUtil_Print( " control point is aware of. Each device is preceded by a" ); + SampleUtil_Print( " device number which corresponds to the devnum argument of" ); + SampleUtil_Print( " commands listed below." ); + SampleUtil_Print( " Refresh" ); + SampleUtil_Print( " Delete all of the devices from the device list and issue new" ); + SampleUtil_Print( " search request to rebuild the list from scratch." ); + SampleUtil_Print( " PrintDev " ); + SampleUtil_Print( " Print the state table for the device ." ); + SampleUtil_Print( " e.g., 'PrintDev 1' prints the state table for the first" ); + SampleUtil_Print( " device in the device list." ); + SampleUtil_Print( " PowerOn " ); + SampleUtil_Print( " Sends the PowerOn action to the Control Service of" ); + SampleUtil_Print( " device ." ); + SampleUtil_Print( " PowerOff " ); + SampleUtil_Print( " Sends the PowerOff action to the Control Service of" ); + SampleUtil_Print( " device ." ); + SampleUtil_Print( " SetChannel " ); + SampleUtil_Print( " Sends the SetChannel action to the Control Service of" ); + SampleUtil_Print( " device , requesting the channel to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " SetVolume " ); + SampleUtil_Print( " Sends the SetVolume action to the Control Service of" ); + SampleUtil_Print( " device , requesting the volume to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " SetColor " ); + SampleUtil_Print( " Sends the SetColor action to the Control Service of" ); + SampleUtil_Print( " device , requesting the color to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " SetTint " ); + SampleUtil_Print( " Sends the SetTint action to the Control Service of" ); + SampleUtil_Print( " device , requesting the tint to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " SetContrast " ); + SampleUtil_Print( " Sends the SetContrast action to the Control Service of" ); + SampleUtil_Print( " device , requesting the contrast to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " SetBrightness " ); + SampleUtil_Print( " Sends the SetBrightness action to the Control Service of" ); + SampleUtil_Print( " device , requesting the brightness to be changed" ); + SampleUtil_Print( " to ." ); + SampleUtil_Print( " CtrlAction " ); + SampleUtil_Print( " Sends an action request specified by the string " ); + SampleUtil_Print( " to the Control Service of device . This command" ); + SampleUtil_Print( " only works for actions that have no arguments." ); + SampleUtil_Print( " (e.g., \"CtrlAction 1 IncreaseChannel\")" ); + SampleUtil_Print( " PictAction " ); + SampleUtil_Print( " Sends an action request specified by the string " ); + SampleUtil_Print( " to the Picture Service of device . This command" ); + SampleUtil_Print( " only works for actions that have no arguments." ); + SampleUtil_Print( " (e.g., \"PictAction 1 DecreaseContrast\")" ); + SampleUtil_Print( " CtrlGetVar " ); + SampleUtil_Print( " Requests the value of a variable specified by the string " ); + SampleUtil_Print( " from the Control Service of device ." ); + SampleUtil_Print( " (e.g., \"CtrlGetVar 1 Volume\")" ); + SampleUtil_Print( " PictGetVar " ); + SampleUtil_Print( " Requests the value of a variable specified by the string " ); + SampleUtil_Print( " from the Picture Service of device ." ); + SampleUtil_Print( " (e.g., \"PictGetVar 1 Tint\")" ); + SampleUtil_Print( " Exit" ); + SampleUtil_Print( " Exits the control point application." ); +} + +/******************************************************************************** + * TvCtrlPointPrintCommands + * + * Description: + * Print the list of valid command line commands to the user + * + * Parameters: + * None + * + ********************************************************************************/ +void +TvCtrlPointPrintCommands() +{ + int i; + int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands ); + + SampleUtil_Print( "Valid Commands:" ); + for( i = 0; i < numofcmds; i++ ) { + SampleUtil_Print( " %-14s %s", cmdloop_cmdlist[i].str, + cmdloop_cmdlist[i].args ); + } + SampleUtil_Print( "" ); +} + +/******************************************************************************** + * TvCtrlPointCommandLoop + * + * Description: + * Function that receives commands from the user at the command prompt + * during the lifetime of the control point, and calls the appropriate + * functions for those commands. + * + * Parameters: + * None + * + ********************************************************************************/ +void * +TvCtrlPointCommandLoop( void *args ) +{ + char cmdline[100]; + + while( 1 ) { + SampleUtil_Print( "\n>> " ); + fgets( cmdline, 100, stdin ); + TvCtrlPointProcessCommand( cmdline ); + } + + return NULL; +} + +int +TvCtrlPointProcessCommand( char *cmdline ) +{ + char cmd[100]; + char strarg[100]; + int arg_val_err = -99999; + int arg1 = arg_val_err; + int arg2 = arg_val_err; + int cmdnum = -1; + int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands ); + int cmdfound = 0; + int i, + rc; + int invalidargs = 0; + int validargs; + + validargs = sscanf( cmdline, "%s %d %d", cmd, &arg1, &arg2 ); + + for( i = 0; i < numofcmds; i++ ) { + if( strcasecmp( cmd, cmdloop_cmdlist[i].str ) == 0 ) { + cmdnum = cmdloop_cmdlist[i].cmdnum; + cmdfound++; + if( validargs != cmdloop_cmdlist[i].numargs ) + invalidargs++; + break; + } + } + + if( !cmdfound ) { + SampleUtil_Print( "Command not found; try 'Help'" ); + return TV_SUCCESS; + } + + if( invalidargs ) { + SampleUtil_Print( "Invalid arguments; try 'Help'" ); + return TV_SUCCESS; + } + + switch ( cmdnum ) { + case PRTHELP: + TvCtrlPointPrintShortHelp(); + break; + + case PRTFULLHELP: + TvCtrlPointPrintLongHelp(); + break; + + case POWON: + TvCtrlPointSendPowerOn( arg1 ); + break; + + case POWOFF: + TvCtrlPointSendPowerOff( arg1 ); + break; + + case SETCHAN: + TvCtrlPointSendSetChannel( arg1, arg2 ); + break; + + case SETVOL: + TvCtrlPointSendSetVolume( arg1, arg2 ); + break; + + case SETCOL: + TvCtrlPointSendSetColor( arg1, arg2 ); + break; + + case SETTINT: + TvCtrlPointSendSetTint( arg1, arg2 ); + break; + + case SETCONT: + TvCtrlPointSendSetContrast( arg1, arg2 ); + break; + + case SETBRT: + TvCtrlPointSendSetBrightness( arg1, arg2 ); + break; + + case CTRLACTION: + /* + re-parse commandline since second arg is string + */ + validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); + if( 3 == validargs ) + TvCtrlPointSendAction( TV_SERVICE_CONTROL, arg1, strarg, + NULL, NULL, 0 ); + else + invalidargs++; + break; + + case PICTACTION: + /* + re-parse commandline since second arg is string + */ + validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); + if( 3 == validargs ) + TvCtrlPointSendAction( TV_SERVICE_PICTURE, arg1, strarg, + NULL, NULL, 0 ); + else + invalidargs++; + break; + + case CTRLGETVAR: + /* + re-parse commandline since second arg is string + */ + validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); + if( 3 == validargs ) + TvCtrlPointGetVar( TV_SERVICE_CONTROL, arg1, strarg ); + else + invalidargs++; + break; + + case PICTGETVAR: + /* + re-parse commandline since second arg is string + */ + validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); + if( 3 == validargs ) + TvCtrlPointGetVar( TV_SERVICE_PICTURE, arg1, strarg ); + else + invalidargs++; + break; + + case PRTDEV: + TvCtrlPointPrintDevice( arg1 ); + break; + + case LSTDEV: + TvCtrlPointPrintList(); + break; + + case REFRESH: + TvCtrlPointRefresh(); + break; + + case EXITCMD: + rc = TvCtrlPointStop(); + exit( rc ); + break; + + default: + SampleUtil_Print( "Command not implemented; see 'Help'" ); + break; + } + + if( invalidargs ) + SampleUtil_Print( "Invalid args in command; see 'Help'" ); + + return TV_SUCCESS; +} + +int +device_main( int argc, char **argv ) +{ + + unsigned int portTemp = 0; + char *ip_address = NULL, + *desc_doc_name = NULL, + *web_dir_path = NULL; + unsigned int port = 0; + + int i = 0; + + SampleUtil_Initialize( linux_print ); + + // Parse options + for( i = 1; i < argc; i++ ) { + if( strcmp( argv[i], "-ip" ) == 0 ) { + ip_address = argv[++i]; + } else if( strcmp( argv[i], "-port" ) == 0 ) { + sscanf( argv[++i], "%u", &portTemp ); + } else if( strcmp( argv[i], "-desc" ) == 0 ) { + desc_doc_name = argv[++i]; + } else if( strcmp( argv[i], "-webdir" ) == 0 ) { + web_dir_path = argv[++i]; + } else if( strcmp( argv[i], "-help" ) == 0 ) { + SampleUtil_Print( "Usage: %s -ip ipaddress -port port" + " -desc desc_doc_name -webdir web_dir_path" + " -help (this message)\n", argv[0] ); + SampleUtil_Print( "\tipaddress: IP address of the device" + " (must match desc. doc)\n" ); + SampleUtil_Print( "\t\te.g.: 192.168.0.4\n" ); + SampleUtil_Print( "\tport: Port number to use for " + "receiving UPnP messages (must match desc. doc)\n" ); + SampleUtil_Print( "\t\te.g.: 5431\n" ); + SampleUtil_Print + ( "\tdesc_doc_name: name of device description document\n" ); + SampleUtil_Print( "\t\te.g.: tvcombodesc.xml\n" ); + SampleUtil_Print + ( "\tweb_dir_path: Filesystem path where web files " + "related to the device are stored\n" ); + SampleUtil_Print( "\t\te.g.: /upnp/sample/web\n" ); + return 1; + } + } + + port = ( unsigned short )portTemp; + + return TvDeviceStart( + ip_address, port, desc_doc_name, web_dir_path, linux_print ); +} + +int +main( int argc, char **argv ) +{ + int rc; + ithread_t cmdloop_thread; + int sig; + sigset_t sigs_to_catch; + int code; + + device_main(argc, argv); + rc = TvCtrlPointStart( linux_print, NULL ); + if( rc != TV_SUCCESS ) { + SampleUtil_Print( "Error starting UPnP TV Control Point" ); + return rc; + } + // start a command loop thread + code = + ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, + NULL ); + + /* + Catch Ctrl-C and properly shutdown + */ + sigemptyset( &sigs_to_catch ); + sigaddset( &sigs_to_catch, SIGINT ); + sigwait( &sigs_to_catch, &sig ); + + SampleUtil_Print( "Shutting down on signal %d...", sig ); + TvDeviceStop(); + rc = TvCtrlPointStop(); + + return rc; +} + diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.c b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c new file mode 100644 index 0000000..45ceee5 --- /dev/null +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.c @@ -0,0 +1,1409 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2000-2003 Intel Corporation +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither name of Intel Corporation nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + +#include "upnp_tv_ctrlpt.h" + +/* + Mutex for protecting the global device list + in a multi-threaded, asynchronous environment. + All functions should lock this mutex before reading + or writing the device list. + */ +ithread_mutex_t DeviceListMutex; + +UpnpClient_Handle ctrlpt_handle = -1; + +char TvDeviceType[] = "urn:schemas-upnp-org:device:tvdevice:1"; +char *TvServiceType[] = { + "urn:schemas-upnp-org:service:tvcontrol:1", + "urn:schemas-upnp-org:service:tvpicture:1" +}; +char *TvServiceName[] = { "Control", "Picture" }; + +/* + Global arrays for storing variable names and counts for + TvControl and TvPicture services + */ +char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = { + {"Power", "Channel", "Volume", ""}, + {"Color", "Tint", "Contrast", "Brightness"} +}; +char TvVarCount[TV_SERVICE_SERVCOUNT] = + { TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT }; + +/* + Timeout to request during subscriptions + */ +int default_timeout = 1801; + +/* + The first node in the global device list, or NULL if empty + */ +struct TvDeviceNode *GlobalDeviceList = NULL; + +/******************************************************************************** + * TvCtrlPointDeleteNode + * + * Description: + * Delete a device node from the global device list. Note that this + * function is NOT thread safe, and should be called from another + * function that has already locked the global device list. + * + * Parameters: + * node -- The device node + * + ********************************************************************************/ +int +TvCtrlPointDeleteNode( struct TvDeviceNode *node ) +{ + int rc, + service, + var; + + if( NULL == node ) { + SampleUtil_Print( "ERROR: TvCtrlPointDeleteNode: Node is empty" ); + return TV_ERROR; + } + + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + /* + If we have a valid control SID, then unsubscribe + */ + if( strcmp( node->device.TvService[service].SID, "" ) != 0 ) { + rc = UpnpUnSubscribe( ctrlpt_handle, + node->device.TvService[service].SID ); + if( UPNP_E_SUCCESS == rc ) { + SampleUtil_Print + ( "Unsubscribed from Tv %s EventURL with SID=%s", + TvServiceName[service], + node->device.TvService[service].SID ); + } else { + SampleUtil_Print + ( "Error unsubscribing to Tv %s EventURL -- %d", + TvServiceName[service], rc ); + } + } + + for( var = 0; var < TvVarCount[service]; var++ ) { + if( node->device.TvService[service].VariableStrVal[var] ) { + free( node->device.TvService[service]. + VariableStrVal[var] ); + } + } + } + + //Notify New Device Added + SampleUtil_StateUpdate( NULL, NULL, node->device.UDN, DEVICE_REMOVED ); + free( node ); + node = NULL; + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointRemoveDevice + * + * Description: + * Remove a device from the global device list. + * + * Parameters: + * UDN -- The Unique Device Name for the device to remove + * + ********************************************************************************/ +int +TvCtrlPointRemoveDevice( char *UDN ) +{ + struct TvDeviceNode *curdevnode, + *prevdevnode; + + ithread_mutex_lock( &DeviceListMutex ); + + curdevnode = GlobalDeviceList; + if( !curdevnode ) { + SampleUtil_Print + ( "WARNING: TvCtrlPointRemoveDevice: Device list empty" ); + } else { + if( 0 == strcmp( curdevnode->device.UDN, UDN ) ) { + GlobalDeviceList = curdevnode->next; + TvCtrlPointDeleteNode( curdevnode ); + } else { + prevdevnode = curdevnode; + curdevnode = curdevnode->next; + + while( curdevnode ) { + if( strcmp( curdevnode->device.UDN, UDN ) == 0 ) { + prevdevnode->next = curdevnode->next; + TvCtrlPointDeleteNode( curdevnode ); + break; + } + + prevdevnode = curdevnode; + curdevnode = curdevnode->next; + } + } + } + + ithread_mutex_unlock( &DeviceListMutex ); + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointRemoveAll + * + * Description: + * Remove all devices from the global device list. + * + * Parameters: + * None + * + ********************************************************************************/ +int +TvCtrlPointRemoveAll( void ) +{ + struct TvDeviceNode *curdevnode, + *next; + + ithread_mutex_lock( &DeviceListMutex ); + + curdevnode = GlobalDeviceList; + GlobalDeviceList = NULL; + + while( curdevnode ) { + next = curdevnode->next; + TvCtrlPointDeleteNode( curdevnode ); + curdevnode = next; + } + + ithread_mutex_unlock( &DeviceListMutex ); + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointRefresh + * + * Description: + * Clear the current global device list and issue new search + * requests to build it up again from scratch. + * + * Parameters: + * None + * + ********************************************************************************/ +int +TvCtrlPointRefresh( void ) +{ + int rc; + + TvCtrlPointRemoveAll( ); + + /* + Search for all devices of type tvdevice version 1, + waiting for up to 5 seconds for the response + */ + rc = UpnpSearchAsync( ctrlpt_handle, 5, TvDeviceType, NULL ); + if( UPNP_E_SUCCESS != rc ) { + SampleUtil_Print( "Error sending search request%d", rc ); + return TV_ERROR; + } + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointGetVar + * + * Description: + * Send a GetVar request to the specified service of a device. + * + * Parameters: + * service -- The service + * devnum -- The number of the device (order in the list, + * starting with 1) + * varname -- The name of the variable to request. + * + ********************************************************************************/ +int +TvCtrlPointGetVar( int service, + int devnum, + char *varname ) +{ + struct TvDeviceNode *devnode; + int rc; + + ithread_mutex_lock( &DeviceListMutex ); + + rc = TvCtrlPointGetDevice( devnum, &devnode ); + + if( TV_SUCCESS == rc ) { + rc = UpnpGetServiceVarStatusAsync( ctrlpt_handle, + devnode->device. + TvService[service].ControlURL, + varname, + TvCtrlPointCallbackEventHandler, + NULL ); + if( rc != UPNP_E_SUCCESS ) { + SampleUtil_Print + ( "Error in UpnpGetServiceVarStatusAsync -- %d", rc ); + rc = TV_ERROR; + } + } + + ithread_mutex_unlock( &DeviceListMutex ); + + return rc; +} + +int +TvCtrlPointGetPower( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_CONTROL, devnum, "Power" ); +} + +int +TvCtrlPointGetChannel( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_CONTROL, devnum, "Channel" ); +} + +int +TvCtrlPointGetVolume( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_CONTROL, devnum, "Volume" ); +} + +int +TvCtrlPointGetColor( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_PICTURE, devnum, "Color" ); +} + +int +TvCtrlPointGetTint( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_PICTURE, devnum, "Tint" ); +} + +int +TvCtrlPointGetContrast( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_PICTURE, devnum, "Contrast" ); +} + +int +TvCtrlPointGetBrightness( int devnum ) +{ + return TvCtrlPointGetVar( TV_SERVICE_PICTURE, devnum, "Brightness" ); +} + +/******************************************************************************** + * TvCtrlPointSendAction + * + * Description: + * Send an Action request to the specified service of a device. + * + * Parameters: + * service -- The service + * devnum -- The number of the device (order in the list, + * starting with 1) + * actionname -- The name of the action. + * param_name -- An array of parameter names + * param_val -- The corresponding parameter values + * param_count -- The number of parameters + * + ********************************************************************************/ +int +TvCtrlPointSendAction( int service, + int devnum, + char *actionname, + char **param_name, + char **param_val, + int param_count ) +{ + struct TvDeviceNode *devnode; + IXML_Document *actionNode = NULL; + int rc = TV_SUCCESS; + int param; + + ithread_mutex_lock( &DeviceListMutex ); + + rc = TvCtrlPointGetDevice( devnum, &devnode ); + if( TV_SUCCESS == rc ) { + if( 0 == param_count ) { + actionNode = + UpnpMakeAction( actionname, TvServiceType[service], 0, + NULL ); + } else { + for( param = 0; param < param_count; param++ ) { + if( UpnpAddToAction + ( &actionNode, actionname, TvServiceType[service], + param_name[param], + param_val[param] ) != UPNP_E_SUCCESS ) { + SampleUtil_Print + ( "ERROR: TvCtrlPointSendAction: Trying to add action param" ); + //return -1; // TBD - BAD! leaves mutex locked + } + } + } + + rc = UpnpSendActionAsync( ctrlpt_handle, + devnode->device.TvService[service]. + ControlURL, TvServiceType[service], + NULL, actionNode, + TvCtrlPointCallbackEventHandler, NULL ); + + if( rc != UPNP_E_SUCCESS ) { + SampleUtil_Print( "Error in UpnpSendActionAsync -- %d", rc ); + rc = TV_ERROR; + } + } + + ithread_mutex_unlock( &DeviceListMutex ); + + if( actionNode ) + ixmlDocument_free( actionNode ); + + return rc; +} + +/******************************************************************************** + * TvCtrlPointSendActionNumericArg + * + * Description:Send an action with one argument to a device in the global device list. + * + * Parameters: + * devnum -- The number of the device (order in the list, starting with 1) + * service -- TV_SERVICE_CONTROL or TV_SERVICE_PICTURE + * actionName -- The device action, i.e., "SetChannel" + * paramName -- The name of the parameter that is being passed + * paramValue -- Actual value of the parameter being passed + * + ********************************************************************************/ +int +TvCtrlPointSendActionNumericArg( int devnum, + int service, + char *actionName, + char *paramName, + int paramValue ) +{ + char param_val_a[50]; + char *param_val = param_val_a; + + sprintf( param_val_a, "%d", paramValue ); + + return TvCtrlPointSendAction( service, devnum, actionName, ¶mName, + ¶m_val, 1 ); +} + +int +TvCtrlPointSendPowerOn( int devnum ) +{ + return TvCtrlPointSendAction( TV_SERVICE_CONTROL, devnum, "PowerOn", + NULL, NULL, 0 ); +} + +int +TvCtrlPointSendPowerOff( int devnum ) +{ + return TvCtrlPointSendAction( TV_SERVICE_CONTROL, devnum, "PowerOff", + NULL, NULL, 0 ); +} + +int +TvCtrlPointSendSetChannel( int devnum, + int channel ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_CONTROL, + "SetChannel", "Channel", + channel ); +} + +int +TvCtrlPointSendSetVolume( int devnum, + int volume ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_CONTROL, + "SetVolume", "Volume", + volume ); +} + +int +TvCtrlPointSendSetColor( int devnum, + int color ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_PICTURE, + "SetColor", "Color", color ); +} + +int +TvCtrlPointSendSetTint( int devnum, + int tint ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_PICTURE, + "SetTint", "Tint", tint ); +} + +int +TvCtrlPointSendSetContrast( int devnum, + int contrast ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_PICTURE, + "SetContrast", "Contrast", + contrast ); +} + +int +TvCtrlPointSendSetBrightness( int devnum, + int brightness ) +{ + return TvCtrlPointSendActionNumericArg( devnum, TV_SERVICE_PICTURE, + "SetBrightness", "Brightness", + brightness ); +} + +/******************************************************************************** + * TvCtrlPointGetDevice + * + * Description: + * Given a list number, returns the pointer to the device + * node at that position in the global device list. Note + * that this function is not thread safe. It must be called + * from a function that has locked the global device list. + * + * Parameters: + * devnum -- The number of the device (order in the list, + * starting with 1) + * devnode -- The output device node pointer + * + ********************************************************************************/ +int +TvCtrlPointGetDevice( int devnum, + struct TvDeviceNode **devnode ) +{ + int count = devnum; + struct TvDeviceNode *tmpdevnode = NULL; + + if( count ) + tmpdevnode = GlobalDeviceList; + + while( --count && tmpdevnode ) { + tmpdevnode = tmpdevnode->next; + } + + if( !tmpdevnode ) { + SampleUtil_Print( "Error finding TvDevice number -- %d", devnum ); + return TV_ERROR; + } + + *devnode = tmpdevnode; + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointPrintList + * + * Description: + * Print the universal device names for each device in the global device list + * + * Parameters: + * None + * + ********************************************************************************/ +int +TvCtrlPointPrintList( ) +{ + struct TvDeviceNode *tmpdevnode; + int i = 0; + + ithread_mutex_lock( &DeviceListMutex ); + + SampleUtil_Print( "TvCtrlPointPrintList:" ); + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + SampleUtil_Print( " %3d -- %s", ++i, tmpdevnode->device.UDN ); + tmpdevnode = tmpdevnode->next; + } + SampleUtil_Print( "" ); + ithread_mutex_unlock( &DeviceListMutex ); + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointPrintDevice + * + * Description: + * Print the identifiers and state table for a device from + * the global device list. + * + * Parameters: + * devnum -- The number of the device (order in the list, + * starting with 1) + * + ********************************************************************************/ +int +TvCtrlPointPrintDevice( int devnum ) +{ + struct TvDeviceNode *tmpdevnode; + int i = 0, + service, + var; + char spacer[15]; + + if( devnum <= 0 ) { + SampleUtil_Print + ( "Error in TvCtrlPointPrintDevice: invalid devnum = %d", + devnum ); + return TV_ERROR; + } + + ithread_mutex_lock( &DeviceListMutex ); + + SampleUtil_Print( "TvCtrlPointPrintDevice:" ); + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + i++; + if( i == devnum ) + break; + tmpdevnode = tmpdevnode->next; + } + + if( !tmpdevnode ) { + SampleUtil_Print + ( "Error in TvCtrlPointPrintDevice: invalid devnum = %d -- actual device count = %d", + devnum, i ); + } else { + SampleUtil_Print( " TvDevice -- %d", devnum ); + SampleUtil_Print( " | " ); + SampleUtil_Print( " +- UDN = %s", + tmpdevnode->device.UDN ); + SampleUtil_Print( " +- DescDocURL = %s", + tmpdevnode->device.DescDocURL ); + SampleUtil_Print( " +- FriendlyName = %s", + tmpdevnode->device.FriendlyName ); + SampleUtil_Print( " +- PresURL = %s", + tmpdevnode->device.PresURL ); + SampleUtil_Print( " +- Adver. TimeOut = %d", + tmpdevnode->device.AdvrTimeOut ); + + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + if( service < TV_SERVICE_SERVCOUNT - 1 ) + sprintf( spacer, " | " ); + else + sprintf( spacer, " " ); + SampleUtil_Print( " | " ); + SampleUtil_Print( " +- Tv %s Service", + TvServiceName[service] ); + SampleUtil_Print( "%s+- ServiceId = %s", spacer, + tmpdevnode->device.TvService[service]. + ServiceId ); + SampleUtil_Print( "%s+- ServiceType = %s", spacer, + tmpdevnode->device.TvService[service]. + ServiceType ); + SampleUtil_Print( "%s+- EventURL = %s", spacer, + tmpdevnode->device.TvService[service]. + EventURL ); + SampleUtil_Print( "%s+- ControlURL = %s", spacer, + tmpdevnode->device.TvService[service]. + ControlURL ); + SampleUtil_Print( "%s+- SID = %s", spacer, + tmpdevnode->device.TvService[service].SID ); + SampleUtil_Print( "%s+- ServiceStateTable", spacer ); + + for( var = 0; var < TvVarCount[service]; var++ ) { + SampleUtil_Print( "%s +- %-10s = %s", spacer, + TvVarName[service][var], + tmpdevnode->device.TvService[service]. + VariableStrVal[var] ); + } + } + } + + SampleUtil_Print( "" ); + ithread_mutex_unlock( &DeviceListMutex ); + + return TV_SUCCESS; +} + +/******************************************************************************** + * TvCtrlPointAddDevice + * + * Description: + * If the device is not already included in the global device list, + * add it. Otherwise, update its advertisement expiration timeout. + * + * Parameters: + * DescDoc -- The description document for the device + * location -- The location of the description document URL + * expires -- The expiration time for this advertisement + * + ********************************************************************************/ +void +TvCtrlPointAddDevice( IXML_Document * DescDoc, + char *location, + int expires ) +{ + char *deviceType = NULL; + char *friendlyName = NULL; + char presURL[200]; + char *baseURL = NULL; + char *relURL = NULL; + char *UDN = NULL; + char *serviceId[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; + char *eventURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; + char *controlURL[TV_SERVICE_SERVCOUNT] = { NULL, NULL }; + Upnp_SID eventSID[TV_SERVICE_SERVCOUNT]; + int TimeOut[TV_SERVICE_SERVCOUNT] = + { default_timeout, default_timeout }; + struct TvDeviceNode *deviceNode; + struct TvDeviceNode *tmpdevnode; + int ret = 1; + int found = 0; + int service, + var; + + ithread_mutex_lock( &DeviceListMutex ); + + /* + Read key elements from description document + */ + UDN = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" ); + deviceType = SampleUtil_GetFirstDocumentItem( DescDoc, "deviceType" ); + friendlyName = + SampleUtil_GetFirstDocumentItem( DescDoc, "friendlyName" ); + baseURL = SampleUtil_GetFirstDocumentItem( DescDoc, "URLBase" ); + relURL = SampleUtil_GetFirstDocumentItem( DescDoc, "presentationURL" ); + + ret = + UpnpResolveURL( ( baseURL ? baseURL : location ), relURL, + presURL ); + + if( UPNP_E_SUCCESS != ret ) + SampleUtil_Print( "Error generating presURL from %s + %s", baseURL, + relURL ); + + if( strcmp( deviceType, TvDeviceType ) == 0 ) { + SampleUtil_Print( "Found Tv device" ); + + // Check if this device is already in the list + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + if( strcmp( tmpdevnode->device.UDN, UDN ) == 0 ) { + found = 1; + break; + } + tmpdevnode = tmpdevnode->next; + } + + if( found ) { + // The device is already there, so just update + // the advertisement timeout field + tmpdevnode->device.AdvrTimeOut = expires; + } else { + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + if( SampleUtil_FindAndParseService + ( DescDoc, location, TvServiceType[service], + &serviceId[service], &eventURL[service], + &controlURL[service] ) ) { + SampleUtil_Print( "Subscribing to EventURL %s...", + eventURL[service] ); + + ret = + UpnpSubscribe( ctrlpt_handle, eventURL[service], + &TimeOut[service], + eventSID[service] ); + + if( ret == UPNP_E_SUCCESS ) { + SampleUtil_Print + ( "Subscribed to EventURL with SID=%s", + eventSID[service] ); + } else { + SampleUtil_Print + ( "Error Subscribing to EventURL -- %d", ret ); + strcpy( eventSID[service], "" ); + } + } else { + SampleUtil_Print( "Error: Could not find Service: %s", + TvServiceType[service] ); + } + } + + /* + Create a new device node + */ + deviceNode = + ( struct TvDeviceNode * ) + malloc( sizeof( struct TvDeviceNode ) ); + strcpy( deviceNode->device.UDN, UDN ); + strcpy( deviceNode->device.DescDocURL, location ); + strcpy( deviceNode->device.FriendlyName, friendlyName ); + strcpy( deviceNode->device.PresURL, presURL ); + deviceNode->device.AdvrTimeOut = expires; + + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + strcpy( deviceNode->device.TvService[service].ServiceId, + serviceId[service] ); + strcpy( deviceNode->device.TvService[service].ServiceType, + TvServiceType[service] ); + strcpy( deviceNode->device.TvService[service].ControlURL, + controlURL[service] ); + strcpy( deviceNode->device.TvService[service].EventURL, + eventURL[service] ); + strcpy( deviceNode->device.TvService[service].SID, + eventSID[service] ); + + for( var = 0; var < TvVarCount[service]; var++ ) { + deviceNode->device.TvService[service]. + VariableStrVal[var] = + ( char * )malloc( TV_MAX_VAL_LEN ); + strcpy( deviceNode->device.TvService[service]. + VariableStrVal[var], "" ); + } + } + + deviceNode->next = NULL; + + // Insert the new device node in the list + if( ( tmpdevnode = GlobalDeviceList ) ) { + + while( tmpdevnode ) { + if( tmpdevnode->next ) { + tmpdevnode = tmpdevnode->next; + } else { + tmpdevnode->next = deviceNode; + break; + } + } + } else { + GlobalDeviceList = deviceNode; + } + + //Notify New Device Added + SampleUtil_StateUpdate( NULL, NULL, deviceNode->device.UDN, + DEVICE_ADDED ); + } + } + + ithread_mutex_unlock( &DeviceListMutex ); + + if( deviceType ) + free( deviceType ); + if( friendlyName ) + free( friendlyName ); + if( UDN ) + free( UDN ); + if( baseURL ) + free( baseURL ); + if( relURL ) + free( relURL ); + + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + if( serviceId[service] ) + free( serviceId[service] ); + if( controlURL[service] ) + free( controlURL[service] ); + if( eventURL[service] ) + free( eventURL[service] ); + } +} + +/******************************************************************************** + * TvStateUpdate + * + * Description: + * Update a Tv state table. Called when an event is + * received. Note: this function is NOT thread save. It must be + * called from another function that has locked the global device list. + * + * Parameters: + * UDN -- The UDN of the parent device. + * Service -- The service state table to update + * ChangedVariables -- DOM document representing the XML received + * with the event + * State -- pointer to the state table for the Tv service + * to update + * + ********************************************************************************/ +void +TvStateUpdate( char *UDN, + int Service, + IXML_Document * ChangedVariables, + char **State ) +{ + IXML_NodeList *properties, + *variables; + IXML_Element *property, + *variable; + int length, + length1; + int i, + j; + char *tmpstate = NULL; + + SampleUtil_Print( "Tv State Update (service %d): ", Service ); + + /* + Find all of the e:property tags in the document + */ + properties = + ixmlDocument_getElementsByTagName( ChangedVariables, + "e:property" ); + if( NULL != properties ) { + length = ixmlNodeList_length( properties ); + for( i = 0; i < length; i++ ) { /* Loop through each property change found */ + property = + ( IXML_Element * ) ixmlNodeList_item( properties, i ); + + /* + For each variable name in the state table, check if this + is a corresponding property change + */ + for( j = 0; j < TvVarCount[Service]; j++ ) { + variables = + ixmlElement_getElementsByTagName( property, + TvVarName[Service] + [j] ); + + /* + If a match is found, extract the value, and update the state table + */ + if( variables ) { + length1 = ixmlNodeList_length( variables ); + if( length1 ) { + variable = + ( IXML_Element * ) + ixmlNodeList_item( variables, 0 ); + tmpstate = SampleUtil_GetElementValue( variable ); + + if( tmpstate ) { + strcpy( State[j], tmpstate ); + SampleUtil_Print + ( " Variable Name: %s New Value:'%s'", + TvVarName[Service][j], State[j] ); + } + + if( tmpstate ) + free( tmpstate ); + tmpstate = NULL; + } + + ixmlNodeList_free( variables ); + variables = NULL; + } + } + + } + ixmlNodeList_free( properties ); + } +} + +/******************************************************************************** + * TvCtrlPointHandleEvent + * + * Description: + * Handle a UPnP event that was received. Process the event and update + * the appropriate service state table. + * + * Parameters: + * sid -- The subscription id for the event + * eventkey -- The eventkey number for the event + * changes -- The DOM document representing the changes + * + ********************************************************************************/ +void +TvCtrlPointHandleEvent( Upnp_SID sid, + int evntkey, + IXML_Document * changes ) +{ + struct TvDeviceNode *tmpdevnode; + int service; + + ithread_mutex_lock( &DeviceListMutex ); + + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) == + 0 ) { + SampleUtil_Print( "Received Tv %s Event: %d for SID %s", + TvServiceName[service], evntkey, sid ); + + TvStateUpdate( tmpdevnode->device.UDN, service, changes, + ( char ** )&tmpdevnode->device. + TvService[service].VariableStrVal ); + break; + } + } + tmpdevnode = tmpdevnode->next; + } + + ithread_mutex_unlock( &DeviceListMutex ); +} + +/******************************************************************************** + * TvCtrlPointHandleSubscribeUpdate + * + * Description: + * Handle a UPnP subscription update that was received. Find the + * service the update belongs to, and update its subscription + * timeout. + * + * Parameters: + * eventURL -- The event URL for the subscription + * sid -- The subscription id for the subscription + * timeout -- The new timeout for the subscription + * + ********************************************************************************/ +void +TvCtrlPointHandleSubscribeUpdate( char *eventURL, + Upnp_SID sid, + int timeout ) +{ + struct TvDeviceNode *tmpdevnode; + int service; + + ithread_mutex_lock( &DeviceListMutex ); + + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + + if( strcmp + ( tmpdevnode->device.TvService[service].EventURL, + eventURL ) == 0 ) { + SampleUtil_Print + ( "Received Tv %s Event Renewal for eventURL %s", + TvServiceName[service], eventURL ); + strcpy( tmpdevnode->device.TvService[service].SID, sid ); + break; + } + } + + tmpdevnode = tmpdevnode->next; + } + + ithread_mutex_unlock( &DeviceListMutex ); +} + +void +TvCtrlPointHandleGetVar( char *controlURL, + char *varName, + DOMString varValue ) +{ + + struct TvDeviceNode *tmpdevnode; + int service; + + ithread_mutex_lock( &DeviceListMutex ); + + tmpdevnode = GlobalDeviceList; + while( tmpdevnode ) { + for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) { + if( strcmp + ( tmpdevnode->device.TvService[service].ControlURL, + controlURL ) == 0 ) { + SampleUtil_StateUpdate( varName, varValue, + tmpdevnode->device.UDN, + GET_VAR_COMPLETE ); + break; + } + } + tmpdevnode = tmpdevnode->next; + } + + ithread_mutex_unlock( &DeviceListMutex ); +} + +/******************************************************************************** + * TvCtrlPointCallbackEventHandler + * + * Description: + * The callback handler registered with the SDK while registering + * the control point. Detects the type of callback, and passes the + * request on to the appropriate function. + * + * Parameters: + * EventType -- The type of callback event + * Event -- Data structure containing event data + * Cookie -- Optional data specified during callback registration + * + ********************************************************************************/ +int +TvCtrlPointCallbackEventHandler( Upnp_EventType EventType, + void *Event, + void *Cookie ) +{ + SampleUtil_PrintEvent( EventType, Event ); + + switch ( EventType ) { + /* + SSDP Stuff + */ + case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: + case UPNP_DISCOVERY_SEARCH_RESULT: + { + struct Upnp_Discovery *d_event = + ( struct Upnp_Discovery * )Event; + IXML_Document *DescDoc = NULL; + int ret; + + if( d_event->ErrCode != UPNP_E_SUCCESS ) { + SampleUtil_Print( "Error in Discovery Callback -- %d", + d_event->ErrCode ); + } + + if( ( ret = + UpnpDownloadXmlDoc( d_event->Location, + &DescDoc ) ) != + UPNP_E_SUCCESS ) { + SampleUtil_Print + ( "Error obtaining device description from %s -- error = %d", + d_event->Location, ret ); + } else { + TvCtrlPointAddDevice( DescDoc, d_event->Location, + d_event->Expires ); + } + + if( DescDoc ) + ixmlDocument_free( DescDoc ); + + TvCtrlPointPrintList( ); + break; + } + + case UPNP_DISCOVERY_SEARCH_TIMEOUT: + /* + Nothing to do here... + */ + break; + + case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: + { + struct Upnp_Discovery *d_event = + ( struct Upnp_Discovery * )Event; + + if( 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; +} + +/******************************************************************************** + * TvCtrlPointVerifyTimeouts + * + * Description: + * Checks the advertisement each device + * in the global device list. If an advertisement expires, + * the device is removed from the list. If an advertisement is about to + * expire, a search request is sent for that device. + * + * Parameters: + * incr -- The increment to subtract from the timeouts each time the + * function is called. + * + ********************************************************************************/ +void +TvCtrlPointVerifyTimeouts( int incr ) +{ + struct TvDeviceNode *prevdevnode, + *curdevnode; + int ret; + + ithread_mutex_lock( &DeviceListMutex ); + + prevdevnode = NULL; + curdevnode = GlobalDeviceList; + + while( curdevnode ) { + curdevnode->device.AdvrTimeOut -= incr; + //SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); + + if( curdevnode->device.AdvrTimeOut <= 0 ) { + /* + This advertisement has expired, so we should remove the device + from the list + */ + + if( GlobalDeviceList == curdevnode ) + GlobalDeviceList = curdevnode->next; + else + prevdevnode->next = curdevnode->next; + TvCtrlPointDeleteNode( curdevnode ); + if( prevdevnode ) + curdevnode = prevdevnode->next; + else + curdevnode = GlobalDeviceList; + } else { + + if( curdevnode->device.AdvrTimeOut < 2 * incr ) { + /* + This advertisement is about to expire, so send + out a search request for this device UDN to + try to renew + */ + ret = UpnpSearchAsync( ctrlpt_handle, incr, + curdevnode->device.UDN, NULL ); + if( ret != UPNP_E_SUCCESS ) + SampleUtil_Print + ( "Error sending search request for Device UDN: %s -- err = %d", + curdevnode->device.UDN, ret ); + } + + prevdevnode = curdevnode; + curdevnode = curdevnode->next; + } + + } + ithread_mutex_unlock( &DeviceListMutex ); + +} + +/******************************************************************************** + * TvCtrlPointTimerLoop + * + * Description: + * Function that runs in its own thread and monitors advertisement + * and subscription timeouts for devices in the global device list. + * + * Parameters: + * None + * + ********************************************************************************/ +void * +TvCtrlPointTimerLoop( void *args ) +{ + int incr = 30; // how often to verify the timeouts, in seconds + + while( 1 ) { + isleep( incr ); + TvCtrlPointVerifyTimeouts( incr ); + } + + return NULL; +} + +/******************************************************************************** + * TvCtrlPointStart + * + * Description: + * Call this function to initialize the UPnP library and start the TV Control + * Point. This function creates a timer thread and provides a callback + * handler to process any UPnP events that are received. + * + * Parameters: + * None + * + * Returns: + * TV_SUCCESS if everything went well, else TV_ERROR + * + ********************************************************************************/ +int +TvCtrlPointStart( print_string printFunctionPtr, + state_update updateFunctionPtr ) +{ + ithread_t timer_thread; + int rc; + short int port = 0; + char *ip_address = NULL; + + SampleUtil_Initialize( printFunctionPtr ); + SampleUtil_RegisterUpdateFunction( updateFunctionPtr ); + + ithread_mutex_init( &DeviceListMutex, 0 ); + + SampleUtil_Print( "Intializing UPnP with ipaddress=%s port=%d", + ip_address, port ); + rc = UpnpInit( ip_address, port ); + if( UPNP_E_SUCCESS != rc ) { + SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc ); + //UpnpFinish( ); + //return TV_ERROR; + } + + if( NULL == ip_address ) + ip_address = UpnpGetServerIpAddress( ); + if( 0 == port ) + port = UpnpGetServerPort( ); + + SampleUtil_Print( "UPnP Initialized (%s:%d)", ip_address, port ); + + SampleUtil_Print( "Registering Control Point" ); + rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler, + &ctrlpt_handle, &ctrlpt_handle ); + if( UPNP_E_SUCCESS != rc ) { + SampleUtil_Print( "Error registering CP: %d", rc ); + UpnpFinish( ); + return TV_ERROR; + } + + SampleUtil_Print( "Control Point Registered" ); + + TvCtrlPointRefresh( ); + + // start a timer thread + ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL ); + + return TV_SUCCESS; +} + +int +TvCtrlPointStop( void ) +{ + TvCtrlPointRemoveAll( ); + UpnpUnRegisterClient( ctrlpt_handle ); + UpnpFinish( ); + SampleUtil_Finish( ); + + return TV_SUCCESS; +} diff --git a/upnp/sample/tvcombo/upnp_tv_ctrlpt.h b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h new file mode 100644 index 0000000..b47f5c6 --- /dev/null +++ b/upnp/sample/tvcombo/upnp_tv_ctrlpt.h @@ -0,0 +1,158 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2000-2003 Intel Corporation +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither name of Intel Corporation nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef UPNP_TV_CTRLPT_H +#define UPNP_TV_CTRLPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "ithread.h" +#include +#include +#include +#include +#include + +#include "upnp.h" +#include "upnptools.h" +#include "sample_util.h" + +#define TV_SERVICE_SERVCOUNT 2 +#define TV_SERVICE_CONTROL 0 +#define TV_SERVICE_PICTURE 1 + +#define TV_CONTROL_VARCOUNT 3 +#define TV_CONTROL_POWER 0 +#define TV_CONTROL_CHANNEL 1 +#define TV_CONTROL_VOLUME 2 + +#define TV_PICTURE_VARCOUNT 4 +#define TV_PICTURE_COLOR 0 +#define TV_PICTURE_TINT 1 +#define TV_PICTURE_CONTRAST 2 +#define TV_PICTURE_BRIGHTNESS 3 + +#define TV_MAX_VAL_LEN 5 + +#define TV_SUCCESS 0 +#define TV_ERROR (-1) +#define TV_WARNING 1 + +/* This should be the maximum VARCOUNT from above */ +#define TV_MAXVARS TV_PICTURE_VARCOUNT + +extern char TvDeviceType[]; +extern char *TvServiceType[]; +extern char *TvServiceName[]; +extern char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS]; +extern char TvVarCount[]; + +struct tv_service { + char ServiceId[NAME_SIZE]; + char ServiceType[NAME_SIZE]; + char *VariableStrVal[TV_MAXVARS]; + char EventURL[NAME_SIZE]; + char ControlURL[NAME_SIZE]; + char SID[NAME_SIZE]; +}; + +extern struct TvDeviceNode *GlobalDeviceList; + +struct TvDevice { + char UDN[250]; + char DescDocURL[250]; + char FriendlyName[250]; + char PresURL[250]; + int AdvrTimeOut; + struct tv_service TvService[TV_SERVICE_SERVCOUNT]; +}; + +struct TvDeviceNode { + struct TvDevice device; + struct TvDeviceNode *next; +}; + +extern ithread_mutex_t DeviceListMutex; + +extern UpnpClient_Handle ctrlpt_handle; + +void TvCtrlPointPrintHelp( void ); +int TvCtrlPointDeleteNode(struct TvDeviceNode*); +int TvCtrlPointRemoveDevice(char*); +int TvCtrlPointRemoveAll( void ); +int TvCtrlPointRefresh( void ); + + +int TvCtrlPointSendAction(int, int, char *, char **, char **, int); +int TvCtrlPointSendActionNumericArg(int devnum, int service, char *actionName, char *paramName, int paramValue); +int TvCtrlPointSendPowerOn(int devnum); +int TvCtrlPointSendPowerOff(int devnum); +int TvCtrlPointSendSetChannel(int, int); +int TvCtrlPointSendSetVolume(int, int); +int TvCtrlPointSendSetColor(int, int); +int TvCtrlPointSendSetTint(int, int); +int TvCtrlPointSendSetContrast(int, int); +int TvCtrlPointSendSetBrightness(int, int); + +int TvCtrlPointGetVar(int, int, char*); +int TvCtrlPointGetPower(int devnum); +int TvCtrlPointGetChannel(int); +int TvCtrlPointGetVolume(int); +int TvCtrlPointGetColor(int); +int TvCtrlPointGetTint(int); +int TvCtrlPointGetContrast(int); +int TvCtrlPointGetBrightness(int); + +int TvCtrlPointGetDevice(int, struct TvDeviceNode **); +int TvCtrlPointPrintList( void ); +int TvCtrlPointPrintDevice(int); +void TvCtrlPointAddDevice (IXML_Document *, char *, int); +void TvCtrlPointHandleGetVar(char *,char *,DOMString); +void TvStateUpdate(char*,int, IXML_Document * , char **); +void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *); +void TvCtrlPointHandleSubscribeUpdate(char *, Upnp_SID, int); +int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *); +void TvCtrlPointVerifyTimeouts(int); +void TvCtrlPointPrintCommands( void ); +void* TvCtrlPointCommandLoop( void* ); +int TvCtrlPointStart( print_string printFunctionPtr, state_update updateFunctionPtr ); +int TvCtrlPointStop( void ); +int TvCtrlPointProcessCommand( char *cmdline ); + +#ifdef __cplusplus +}; +#endif + +#endif //UPNP_TV_CTRLPT_H diff --git a/upnp/sample/tvcombo/upnp_tv_device.c b/upnp/sample/tvcombo/upnp_tv_device.c new file mode 100644 index 0000000..ad459b6 --- /dev/null +++ b/upnp/sample/tvcombo/upnp_tv_device.c @@ -0,0 +1,2031 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2000-2003 Intel Corporation +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither name of Intel Corporation nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + +#include "upnp_tv_device.h" + +#define DEFAULT_WEB_DIR "./web" + +#define DESC_URL_SIZE 200 + +/* + Device type for tv device + */ +extern char TvDeviceType[]; + +/* + Service types for tv services + */ +extern char *TvServiceType[]; + +/* + Global arrays for storing Tv Control Service + variable names, values, and defaults + */ +char *tvc_varname[] = { "Power", "Channel", "Volume" }; +char tvc_varval[TV_CONTROL_VARCOUNT][TV_MAX_VAL_LEN]; +char *tvc_varval_def[] = { "1", "1", "5" }; + +/* + Global arrays for storing Tv Picture Service + variable names, values, and defaults + */ +char *tvp_varname[] = { "Color", "Tint", "Contrast", "Brightness" }; +char tvp_varval[TV_PICTURE_VARCOUNT][TV_MAX_VAL_LEN]; +char *tvp_varval_def[] = { "5", "5", "5", "5" }; + +/* + The amount of time (in seconds) before advertisements + will expire + */ +int default_advr_expire = 100; + +/* + Global structure for storing the state table for this device + */ +struct TvService tv_service_table[2]; + +/* + Device handle supplied by UPnP SDK + */ +UpnpDevice_Handle device_handle = -1; + +/* + Mutex for protecting the global state table data + in a multi-threaded, asynchronous environment. + All functions should lock this mutex before reading + or writing the state table data. + */ +ithread_mutex_t TVDevMutex; + +//Color constants +#define MAX_COLOR 10 +#define MIN_COLOR 1 + +//Brightness constants +#define MAX_BRIGHTNESS 10 +#define MIN_BRIGHTNESS 1 + +//Power constants +#define POWER_ON 1 +#define POWER_OFF 0 + +//Tint constants +#define MAX_TINT 10 +#define MIN_TINT 1 + +//Volume constants +#define MAX_VOLUME 10 +#define MIN_VOLUME 1 + +//Contrast constants +#define MAX_CONTRAST 10 +#define MIN_CONTRAST 1 + +//Channel constants +#define MAX_CHANNEL 100 +#define MIN_CHANNEL 1 + +/****************************************************************************** + * SetServiceTable + * + * Description: + * Initializes the service table for the specified service. + * Note that + * knowledge of the service description is + * assumed. + * Parameters: + * int serviceType - one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE + * const char * UDN - UDN of device containing service + * const char * serviceId - serviceId of service + * const char * serviceTypeS - service type (as specified in Description + * Document) + * struct TvService *out - service containing table to be set. + * + *****************************************************************************/ +int +SetServiceTable( IN int serviceType, + IN const char *UDN, + IN const char *serviceId, + IN const char *serviceTypeS, + INOUT struct TvService *out ) +{ + unsigned int i = 0; + + strcpy( out->UDN, UDN ); + strcpy( out->ServiceId, serviceId ); + strcpy( out->ServiceType, serviceTypeS ); + + switch ( serviceType ) { + case TV_SERVICE_CONTROL: + out->VariableCount = TV_CONTROL_VARCOUNT; + for( i = 0; + i < tv_service_table[TV_SERVICE_CONTROL].VariableCount; + i++ ) { + tv_service_table[TV_SERVICE_CONTROL].VariableName[i] + = tvc_varname[i]; + tv_service_table[TV_SERVICE_CONTROL].VariableStrVal[i] + = tvc_varval[i]; + strcpy( tv_service_table[TV_SERVICE_CONTROL]. + VariableStrVal[i], tvc_varval_def[i] ); + } + + break; + case TV_SERVICE_PICTURE: + out->VariableCount = TV_PICTURE_VARCOUNT; + + for( i = 0; + i < tv_service_table[TV_SERVICE_PICTURE].VariableCount; + i++ ) { + tv_service_table[TV_SERVICE_PICTURE].VariableName[i] = + tvp_varname[i]; + tv_service_table[TV_SERVICE_PICTURE].VariableStrVal[i] = + tvp_varval[i]; + strcpy( tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[i], tvp_varval_def[i] ); + } + + break; + default: + assert( 0 ); + } + + return SetActionTable( serviceType, out ); + +} + +/****************************************************************************** + * SetActionTable + * + * Description: + * Initializes the action table for the specified service. + * Note that + * knowledge of the service description is + * assumed. Action names are hardcoded. + * Parameters: + * int serviceType - one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE + * struct TvService *out - service containing action table to set. + * + *****************************************************************************/ +int +SetActionTable( IN int serviceType, + INOUT struct TvService *out ) +{ + if( serviceType == TV_SERVICE_CONTROL ) { + out->ActionNames[0] = "PowerOn"; + out->actions[0] = TvDevicePowerOn; + out->ActionNames[1] = "PowerOff"; + out->actions[1] = TvDevicePowerOff; + out->ActionNames[2] = "SetChannel"; + out->actions[2] = TvDeviceSetChannel; + out->ActionNames[3] = "IncreaseChannel"; + out->actions[3] = TvDeviceIncreaseChannel; + out->ActionNames[4] = "DecreaseChannel"; + out->actions[4] = TvDeviceDecreaseChannel; + out->ActionNames[5] = "SetVolume"; + out->actions[5] = TvDeviceSetVolume; + out->ActionNames[6] = "IncreaseVolume"; + out->actions[6] = TvDeviceIncreaseVolume; + out->ActionNames[7] = "DecreaseVolume"; + out->actions[7] = TvDeviceDecreaseVolume; + out->ActionNames[8] = NULL; + return 1; + } else if( serviceType == TV_SERVICE_PICTURE ) { + out->ActionNames[0] = "SetColor"; + out->ActionNames[1] = "IncreaseColor"; + out->ActionNames[2] = "DecreaseColor"; + out->actions[0] = TvDeviceSetColor; + out->actions[1] = TvDeviceIncreaseColor; + out->actions[2] = TvDeviceDecreaseColor; + out->ActionNames[3] = "SetTint"; + out->ActionNames[4] = "IncreaseTint"; + out->ActionNames[5] = "DecreaseTint"; + out->actions[3] = TvDeviceSetTint; + out->actions[4] = TvDeviceIncreaseTint; + out->actions[5] = TvDeviceDecreaseTint; + + out->ActionNames[6] = "SetBrightness"; + out->ActionNames[7] = "IncreaseBrightness"; + out->ActionNames[8] = "DecreaseBrightness"; + out->actions[6] = TvDeviceSetBrightness; + out->actions[7] = TvDeviceIncreaseBrightness; + out->actions[8] = TvDeviceDecreaseBrightness; + + out->ActionNames[9] = "SetContrast"; + out->ActionNames[10] = "IncreaseContrast"; + out->ActionNames[11] = "DecreaseContrast"; + + out->actions[9] = TvDeviceSetContrast; + out->actions[10] = TvDeviceIncreaseContrast; + out->actions[11] = TvDeviceDecreaseContrast; + return 1; + } + + return 0; + +} + +/****************************************************************************** + * TvDeviceStateTableInit + * + * Description: + * Initialize the device state table for + * this TvDevice, pulling identifier info + * from the description Document. Note that + * knowledge of the service description is + * assumed. State table variables and default + * values are currently hardcoded in this file + * rather than being read from service description + * documents. + * + * Parameters: + * DescDocURL -- The description document URL + * + *****************************************************************************/ +int +TvDeviceStateTableInit( IN char *DescDocURL ) +{ + IXML_Document *DescDoc = NULL; + int ret = UPNP_E_SUCCESS; + char *servid_ctrl = NULL, + *evnturl_ctrl = NULL, + *ctrlurl_ctrl = NULL; + char *servid_pict = NULL, + *evnturl_pict = NULL, + *ctrlurl_pict = NULL; + char *udn = NULL; + + //Download description document + if( UpnpDownloadXmlDoc( DescDocURL, &DescDoc ) != UPNP_E_SUCCESS ) { + SampleUtil_Print( "TvDeviceStateTableInit -- Error Parsing %s\n", + DescDocURL ); + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + + udn = SampleUtil_GetFirstDocumentItem( DescDoc, "UDN" ); + + /* + Find the Tv Control Service identifiers + */ + if( !SampleUtil_FindAndParseService( DescDoc, DescDocURL, + TvServiceType[TV_SERVICE_CONTROL], + &servid_ctrl, &evnturl_ctrl, + &ctrlurl_ctrl ) ) { + SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find" + " Service: %s\n", + TvServiceType[TV_SERVICE_CONTROL] ); + + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + + //set control service table + SetServiceTable( TV_SERVICE_CONTROL, udn, servid_ctrl, + TvServiceType[TV_SERVICE_CONTROL], + &tv_service_table[TV_SERVICE_CONTROL] ); + + /* + Find the Tv Picture Service identifiers + */ + if( !SampleUtil_FindAndParseService( DescDoc, DescDocURL, + TvServiceType[TV_SERVICE_PICTURE], + &servid_pict, &evnturl_pict, + &ctrlurl_pict ) ) { + SampleUtil_Print( "TvDeviceStateTableInit -- Error: Could not find" + " Service: %s\n", + TvServiceType[TV_SERVICE_PICTURE] ); + + ret = UPNP_E_INVALID_DESC; + goto error_handler; + } + //set picture service table + SetServiceTable( TV_SERVICE_PICTURE, udn, servid_pict, + TvServiceType[TV_SERVICE_PICTURE], + &tv_service_table[TV_SERVICE_PICTURE] ); + + error_handler: + + //clean up + if( udn ) + free( udn ); + if( servid_ctrl ) + free( servid_ctrl ); + if( evnturl_ctrl ) + free( evnturl_ctrl ); + if( ctrlurl_ctrl ) + free( ctrlurl_ctrl ); + if( servid_pict ) + free( servid_pict ); + if( evnturl_pict ) + free( evnturl_pict ); + if( ctrlurl_pict ) + free( ctrlurl_pict ); + if( DescDoc ) + ixmlDocument_free( DescDoc ); + + return ( ret ); +} + +/****************************************************************************** + * TvDeviceHandleSubscriptionRequest + * + * Description: + * Called during a subscription request callback. If the + * subscription request is for this device and either its + * control service or picture service, then accept it. + * + * Parameters: + * sr_event -- The subscription request event structure + * + *****************************************************************************/ +int +TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request + *sr_event ) +{ + unsigned int i = 0; //,j=0; + + // IXML_Document *PropSet=NULL; + + //lock state mutex + ithread_mutex_lock( &TVDevMutex ); + + for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) { + if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) && + ( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId ) + == 0 ) ) { + + /* + PropSet = NULL; + + for (j=0; j< tv_service_table[i].VariableCount; j++) + { + //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 + 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 + * + * Description: + * Called during a get variable request callback. If the + * request is for this device and either its control service + * or picture service, then respond with the variable value. + * + * Parameters: + * cgv_event -- The control get variable request event structure + * + *****************************************************************************/ +int +TvDeviceHandleGetVarRequest( INOUT struct Upnp_State_Var_Request + *cgv_event ) +{ + unsigned int i = 0, + j = 0; + int getvar_succeeded = 0; + + cgv_event->CurrentVal = NULL; + + ithread_mutex_lock( &TVDevMutex ); + + for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) { + //check udn and service id + if( ( strcmp( cgv_event->DevUDN, tv_service_table[i].UDN ) == 0 ) + && + ( strcmp( cgv_event->ServiceID, tv_service_table[i].ServiceId ) + == 0 ) ) { + //check variable name + for( j = 0; j < tv_service_table[i].VariableCount; j++ ) { + if( strcmp( cgv_event->StateVarName, + tv_service_table[i].VariableName[j] ) == 0 ) { + getvar_succeeded = 1; + cgv_event->CurrentVal = + ixmlCloneDOMString( tv_service_table[i]. + VariableStrVal[j] ); + break; + } + } + } + } + + if( getvar_succeeded ) { + cgv_event->ErrCode = UPNP_E_SUCCESS; + } else { + SampleUtil_Print + ( "Error in UPNP_CONTROL_GET_VAR_REQUEST callback:\n" ); + SampleUtil_Print( " Unknown variable name = %s\n", + cgv_event->StateVarName ); + cgv_event->ErrCode = 404; + strcpy( cgv_event->ErrStr, "Invalid Variable" ); + } + + ithread_mutex_unlock( &TVDevMutex ); + + return ( cgv_event->ErrCode == UPNP_E_SUCCESS ); +} + +/****************************************************************************** + * TvDeviceHandleActionRequest + * + * Description: + * Called during an action request callback. If the + * request is for this device and either its control service + * or picture service, then perform the action and respond. + * + * Parameters: + * ca_event -- The control action request event structure + * + *****************************************************************************/ +int +TvDeviceHandleActionRequest( INOUT struct Upnp_Action_Request *ca_event ) +{ + + /* + Defaults if action not found + */ + int action_found = 0; + int i = 0; + int service = -1; + int retCode = 0; + char *errorString = NULL; + + ca_event->ErrCode = 0; + ca_event->ActionResult = NULL; + + if( ( strcmp( ca_event->DevUDN, + tv_service_table[TV_SERVICE_CONTROL].UDN ) == 0 ) && + ( strcmp + ( ca_event->ServiceID, + tv_service_table[TV_SERVICE_CONTROL].ServiceId ) == 0 ) ) { + /* + Request for action in the TvDevice Control Service + */ + service = TV_SERVICE_CONTROL; + } else if( ( strcmp( ca_event->DevUDN, + tv_service_table[TV_SERVICE_PICTURE].UDN ) == 0 ) + && + ( strcmp + ( ca_event->ServiceID, + tv_service_table[TV_SERVICE_PICTURE].ServiceId ) == + 0 ) ) { + /* + Request for action in the TvDevice Picture Service + */ + service = TV_SERVICE_PICTURE; + } + //Find and call appropriate procedure based on action name + //Each action name has an associated procedure stored in the + //service table. These are set at initialization. + + for( i = 0; ( ( i < TV_MAXACTIONS ) && + ( tv_service_table[service].ActionNames[i] != NULL ) ); + i++ ) { + + if( !strcmp( ca_event->ActionName, + tv_service_table[service].ActionNames[i] ) ) { + + if( ( !strcmp( tv_service_table[TV_SERVICE_CONTROL]. + 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 { + errorString = "Power is Off"; + retCode = UPNP_E_INTERNAL_ERROR; + } + action_found = 1; + break; + } + } + + if( !action_found ) { + ca_event->ActionResult = NULL; + strcpy( ca_event->ErrStr, "Invalid Action" ); + ca_event->ErrCode = 401; + } else { + if( retCode == UPNP_E_SUCCESS ) { + ca_event->ErrCode = UPNP_E_SUCCESS; + } else { + //copy the error string + strcpy( ca_event->ErrStr, errorString ); + switch ( retCode ) { + case UPNP_E_INVALID_PARAM: + { + ca_event->ErrCode = 402; + break; + } + case UPNP_E_INTERNAL_ERROR: + default: + { + ca_event->ErrCode = 501; + break; + } + + } + } + } + + return ( ca_event->ErrCode ); +} + +/****************************************************************************** + * TvDeviceSetServiceTableVar + * + * Description: + * Update the TvDevice service state table, and notify all subscribed + * control points of the updated state. Note that since this function + * blocks on the mutex TVDevMutex, to avoid a hang this function should + * not be called within any other function that currently has this mutex + * locked. + * + * Parameters: + * service -- The service number (TV_SERVICE_CONTROL or TV_SERVICE_PICTURE) + * variable -- The variable number (TV_CONTROL_POWER, TV_CONTROL_CHANNEL, + * TV_CONTROL_VOLUME, TV_PICTURE_COLOR, TV_PICTURE_TINT, + * TV_PICTURE_CONTRAST, or TV_PICTURE_BRIGHTNESS) + * value -- The string representation of the new value + * + *****************************************************************************/ +int +TvDeviceSetServiceTableVar( IN unsigned int service, + IN unsigned int variable, + IN char *value ) +{ + //IXML_Document *PropSet= NULL; + + if( ( service >= TV_SERVICE_SERVCOUNT ) + || ( variable >= tv_service_table[service].VariableCount ) + || ( strlen( value ) >= TV_MAX_VAL_LEN ) ) { + return ( 0 ); + } + + ithread_mutex_lock( &TVDevMutex ); + + strcpy( tv_service_table[service].VariableStrVal[variable], value ); + + /* + //Using utility api + PropSet= UpnpCreatePropertySet(1,tv_service_table[service]. + VariableName[variable], + tv_service_table[service]. + VariableStrVal[variable]); + + UpnpNotifyExt(device_handle, tv_service_table[service].UDN, + tv_service_table[service].ServiceId,PropSet); + + //Free created property set + Document_free(PropSet); + */ + + UpnpNotify( device_handle, + tv_service_table[service].UDN, + tv_service_table[service].ServiceId, + ( const char ** )&tv_service_table[service]. + VariableName[variable], + ( const char ** )&tv_service_table[service]. + VariableStrVal[variable], 1 ); + + ithread_mutex_unlock( &TVDevMutex ); + + return ( 1 ); + +} + +/****************************************************************************** + * TvDeviceSetPower + * + * Description: + * Turn the power on/off, update the TvDevice control service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * on -- If 1, turn power on. If 0, turn power off. + * + *****************************************************************************/ +int +TvDeviceSetPower( IN int on ) +{ + char value[TV_MAX_VAL_LEN]; + int ret = 0; + + if( on != POWER_ON && on != POWER_OFF ) { + SampleUtil_Print( "error: can't set power to value %d\n", on ); + return ( 0 ); + } + + /* + Vendor-specific code to turn the power on/off goes here + */ + + sprintf( value, "%d", on ); + ret = TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, TV_CONTROL_POWER, + value ); + + return ( ret ); +} + +/****************************************************************************** + * TvDevicePowerOn + * + * Description: + * Turn the power on. + * + * Parameters: + * + * IXML_Document * in - document of action request + * IXML_Document **out - action result + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDevicePowerOn( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( TvDeviceSetPower( POWER_ON ) ) { + //create a response + + if( UpnpAddToActionResponse( out, "PowerOn", + TvServiceType[TV_SERVICE_CONTROL], + "Power", "1" ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * TvDevicePowerOff + * + * Description: + * Turn the power off. + * + * Parameters: + * + * IXML_Document * in - document of action request + * IXML_Document **out - action result + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDevicePowerOff( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + ( *out ) = NULL; + ( *errorString ) = NULL; + if( TvDeviceSetPower( POWER_OFF ) ) { + //create a response + + if( UpnpAddToActionResponse( out, "PowerOff", + TvServiceType[TV_SERVICE_CONTROL], + "Power", "0" ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + + return UPNP_E_SUCCESS; + } + + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; +} + +/****************************************************************************** + * TvDeviceSetChannel + * + * Description: + * Change the channel, update the TvDevice control service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceSetChannel( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + + int channel = 0; + + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Channel" ) ) ) { + ( *errorString ) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + + channel = atoi( value ); + + if( channel < MIN_CHANNEL || channel > MAX_CHANNEL ) { + + free( value ); + SampleUtil_Print( "error: can't change to channel %d\n", channel ); + ( *errorString ) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, + TV_CONTROL_CHANNEL, value ) ) { + if( UpnpAddToActionResponse( out, "SetChannel", + TvServiceType[TV_SERVICE_CONTROL], + "NewChannel", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementChannel + * + * Description: + * Increment the channel. Read the current channel from the state + * table, add the increment, and then change the channel. + * + * Parameters: + * incr -- The increment by which to change the channel. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +IncrementChannel( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curchannel, + newchannel; + + char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseChannel"; + } else { + actionName = "DecreaseChannel"; + } + + ithread_mutex_lock( &TVDevMutex ); + curchannel = atoi( tv_service_table[TV_SERVICE_CONTROL]. + VariableStrVal[TV_CONTROL_CHANNEL] ); + ithread_mutex_unlock( &TVDevMutex ); + + newchannel = curchannel + incr; + + if( newchannel < MIN_CHANNEL || newchannel > MAX_CHANNEL ) { + SampleUtil_Print( "error: can't change to channel %d\n", + newchannel ); + ( *errorString ) = "Invalid Channel"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newchannel ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, + TV_CONTROL_CHANNEL, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_CONTROL], + "Channel", value ) != UPNP_E_SUCCESS ) + { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } +} + +/****************************************************************************** + * TvDeviceDecreaseChannel + * + * Description: + * Decrease the channel. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceDecreaseChannel( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + return IncrementChannel( -1, in, out, errorString ); + +} + +/****************************************************************************** + * TvDeviceIncreaseChannel + * + * Description: + * Increase the channel. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceIncreaseChannel( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + return IncrementChannel( 1, in, out, errorString ); + +} + +/****************************************************************************** + * TvDeviceSetVolume + * + * Description: + * Change the volume, update the TvDevice control service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceSetVolume( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + + int volume = 0; + + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Volume" ) ) ) { + ( *errorString ) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + + volume = atoi( value ); + + if( volume < MIN_VOLUME || volume > MAX_VOLUME ) { + SampleUtil_Print( "error: can't change to volume %d\n", volume ); + ( *errorString ) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the volume goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, + TV_CONTROL_VOLUME, value ) ) { + if( UpnpAddToActionResponse( out, "SetVolume", + TvServiceType[TV_SERVICE_CONTROL], + "NewVolume", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementVolume + * + * Description: + * Increment the volume. Read the current volume from the state + * table, add the increment, and then change the volume. + * + * Parameters: + * incr -- The increment by which to change the volume. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +IncrementVolume( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curvolume, + newvolume; + char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseVolume"; + } else { + actionName = "DecreaseVolume"; + } + + ithread_mutex_lock( &TVDevMutex ); + curvolume = atoi( tv_service_table[TV_SERVICE_CONTROL]. + VariableStrVal[TV_CONTROL_VOLUME] ); + ithread_mutex_unlock( &TVDevMutex ); + + newvolume = curvolume + incr; + + if( newvolume < MIN_VOLUME || newvolume > MAX_VOLUME ) { + SampleUtil_Print( "error: can't change to volume %d\n", + newvolume ); + ( *errorString ) = "Invalid Volume"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newvolume ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL, + TV_CONTROL_VOLUME, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_CONTROL], + "Volume", value ) != UPNP_E_SUCCESS ) + { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * TvDeviceIncrVolume + * + * Description: + * Increase the volume. + * + * Parameters: + * + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +TvDeviceIncreaseVolume( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementVolume( 1, in, out, errorString ); + +} + +/****************************************************************************** + * TvDeviceDecreaseVolume + * + * Description: + * Decrease the volume. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceDecreaseVolume( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementVolume( -1, in, out, errorString ); + +} + +/****************************************************************************** + * TvDeviceSetColor + * + * Description: + * Change the color, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceSetColor( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + + int color = 0; + + ( *out ) = NULL; + ( *errorString ) = NULL; + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Color" ) ) ) { + ( *errorString ) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + + color = atoi( value ); + + if( color < MIN_COLOR || color > MAX_COLOR ) { + SampleUtil_Print( "error: can't change to color %d\n", color ); + ( *errorString ) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the volume goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_COLOR, value ) ) { + if( UpnpAddToActionResponse( out, "SetColor", + TvServiceType[TV_SERVICE_PICTURE], + "NewColor", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementColor + * + * Description: + * Increment the color. Read the current color from the state + * table, add the increment, and then change the color. + * + * Parameters: + * incr -- The increment by which to change the color. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ + +int +IncrementColor( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curcolor, + newcolor; + + char *actionName; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseColor"; + } else { + actionName = "DecreaseColor"; + } + + ithread_mutex_lock( &TVDevMutex ); + curcolor = atoi( tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[TV_PICTURE_COLOR] ); + ithread_mutex_unlock( &TVDevMutex ); + + newcolor = curcolor + incr; + + if( newcolor < MIN_COLOR || newcolor > MAX_COLOR ) { + SampleUtil_Print( "error: can't change to color %d\n", newcolor ); + ( *errorString ) = "Invalid Color"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newcolor ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_COLOR, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Color", value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } +} + +/****************************************************************************** + * TvDeviceDecreaseColor + * + * Description: + * Decrease the color. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +TvDeviceDecreaseColor( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementColor( -1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceIncreaseColor + * + * Description: + * Increase the color. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +TvDeviceIncreaseColor( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementColor( 1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceSetTint + * + * Description: + * Change the tint, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceSetTint( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + + int tint = -1; + + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Tint" ) ) ) { + ( *errorString ) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + + tint = atoi( value ); + + if( tint < MIN_TINT || tint > MAX_TINT ) { + SampleUtil_Print( "error: can't change to tint %d\n", tint ); + ( *errorString ) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the volume goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_TINT, value ) ) { + if( UpnpAddToActionResponse( out, "SetTint", + TvServiceType[TV_SERVICE_PICTURE], + "NewTint", value ) != UPNP_E_SUCCESS ) + { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementTint + * + * Description: + * Increment the tint. Read the current tint from the state + * table, add the increment, and then change the tint. + * + * Parameters: + * incr -- The increment by which to change the tint. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +IncrementTint( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curtint, + newtint; + + char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseTint"; + } else { + actionName = "DecreaseTint"; + } + + ithread_mutex_lock( &TVDevMutex ); + curtint = atoi( tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[TV_PICTURE_TINT] ); + ithread_mutex_unlock( &TVDevMutex ); + + newtint = curtint + incr; + + if( newtint < MIN_TINT || newtint > MAX_TINT ) { + SampleUtil_Print( "error: can't change to tint %d\n", newtint ); + ( *errorString ) = "Invalid Tint"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newtint ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_TINT, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Tint", value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * TvDeviceIncreaseTint + * + * Description: + * Increase tint. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceIncreaseTint( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementTint( 1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceDecreaseTint + * + * Description: + * Decrease tint. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceDecreaseTint( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementTint( -1, in, out, errorString ); +} + +/***************************************************************************** + * TvDeviceSetContrast + * + * Description: + * Change the contrast, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + ****************************************************************************/ +int +TvDeviceSetContrast( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + int contrast = -1; + + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Contrast" ) ) ) { + ( *errorString ) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + + contrast = atoi( value ); + + if( contrast < MIN_CONTRAST || contrast > MAX_CONTRAST ) { + SampleUtil_Print( "error: can't change to contrast %d\n", + contrast ); + ( *errorString ) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the volume goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_CONTRAST, value ) ) { + if( UpnpAddToActionResponse( out, "SetContrast", + TvServiceType[TV_SERVICE_PICTURE], + "NewContrast", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementContrast + * + * Description: + * Increment the contrast. Read the current contrast from the state + * table, add the increment, and then change the contrast. + * + * Parameters: + * incr -- The increment by which to change the contrast. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +IncrementContrast( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curcontrast, + newcontrast; + + char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseContrast"; + } else { + actionName = "DecreaseContrast"; + } + + ithread_mutex_lock( &TVDevMutex ); + curcontrast = atoi( tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[TV_PICTURE_CONTRAST] ); + ithread_mutex_unlock( &TVDevMutex ); + + newcontrast = curcontrast + incr; + + if( newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST ) { + SampleUtil_Print( "error: can't change to contrast %d\n", + newcontrast ); + ( *errorString ) = "Invalid Contrast"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newcontrast ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_CONTRAST, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Contrast", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } +} + +/****************************************************************************** + * TvDeviceIncreaseContrast + * + * Description: + * + * Increase the contrast. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceIncreaseContrast( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + return IncrementContrast( 1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceDecreaseContrast + * + * Description: + * Decrease the contrast. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceDecreaseContrast( IXML_Document * in, + IXML_Document ** out, + char **errorString ) +{ + return IncrementContrast( -1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceSetBrightness + * + * Description: + * Change the brightness, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * brightness -- The brightness value to change to. + * + *****************************************************************************/ +int +TvDeviceSetBrightness( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + + char *value = NULL; + int brightness = -1; + + ( *out ) = NULL; + ( *errorString ) = NULL; + + if( !( value = SampleUtil_GetFirstDocumentItem( in, "Brightness" ) ) ) { + ( *errorString ) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + + brightness = atoi( value ); + + if( brightness < MIN_BRIGHTNESS || brightness > MAX_BRIGHTNESS ) { + SampleUtil_Print( "error: can't change to brightness %d\n", + brightness ); + ( *errorString ) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the volume goes here + */ + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_BRIGHTNESS, value ) ) { + if( UpnpAddToActionResponse( out, "SetBrightness", + TvServiceType[TV_SERVICE_PICTURE], + "NewBrightness", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + free( value ); + return UPNP_E_INTERNAL_ERROR; + } + free( value ); + return UPNP_E_SUCCESS; + } else { + free( value ); + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + +} + +/****************************************************************************** + * IncrementBrightness + * + * Description: + * Increment the brightness. Read the current brightness from the state + * table, add the increment, and then change the brightness. + * + * Parameters: + * incr -- The increment by which to change the brightness. + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int +IncrementBrightness( IN int incr, + IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + int curbrightness, + newbrightness; + char *actionName = NULL; + char value[TV_MAX_VAL_LEN]; + + if( incr > 0 ) { + actionName = "IncreaseBrightness"; + } else { + actionName = "DecreaseBrightness"; + } + + ithread_mutex_lock( &TVDevMutex ); + curbrightness = atoi( tv_service_table[TV_SERVICE_PICTURE]. + VariableStrVal[TV_PICTURE_BRIGHTNESS] ); + ithread_mutex_unlock( &TVDevMutex ); + + newbrightness = curbrightness + incr; + + if( newbrightness < MIN_BRIGHTNESS || newbrightness > MAX_BRIGHTNESS ) { + SampleUtil_Print( "error: can't change to brightness %d\n", + newbrightness ); + ( *errorString ) = "Invalid Brightness"; + return UPNP_E_INVALID_PARAM; + } + + /* + Vendor-specific code to set the channel goes here + */ + + sprintf( value, "%d", newbrightness ); + + if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE, + TV_PICTURE_BRIGHTNESS, value ) ) { + if( UpnpAddToActionResponse( out, actionName, + TvServiceType[TV_SERVICE_PICTURE], + "Brightness", + value ) != UPNP_E_SUCCESS ) { + ( *out ) = NULL; + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } + return UPNP_E_SUCCESS; + } else { + ( *errorString ) = "Internal Error"; + return UPNP_E_INTERNAL_ERROR; + } +} + +/****************************************************************************** + * TvDeviceIncreaseBrightness + * + * Description: + * Increase brightness. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceIncreaseBrightness( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + return IncrementBrightness( 1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceDecreaseBrightness + * + * Description: + * Decrease brightnesss. + * + * Parameters: + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int +TvDeviceDecreaseBrightness( IN IXML_Document * in, + OUT IXML_Document ** out, + OUT char **errorString ) +{ + return IncrementBrightness( -1, in, out, errorString ); +} + +/****************************************************************************** + * TvDeviceCallbackEventHandler + * + * Description: + * The callback handler registered with the SDK while registering + * root device. Dispatches the request to the appropriate procedure + * based on the value of EventType. The four requests handled by the + * device are: + * 1) Event Subscription requests. + * 2) Get Variable requests. + * 3) Action requests. + * + * Parameters: + * + * EventType -- The type of callback event + * Event -- Data structure containing event data + * Cookie -- Optional data specified during callback registration + * + *****************************************************************************/ +int +TvDeviceCallbackEventHandler( Upnp_EventType EventType, + void *Event, + void *Cookie ) +{ + + switch ( EventType ) { + + case UPNP_EVENT_SUBSCRIPTION_REQUEST: + + TvDeviceHandleSubscriptionRequest( ( struct + Upnp_Subscription_Request + * )Event ); + break; + + case UPNP_CONTROL_GET_VAR_REQUEST: + TvDeviceHandleGetVarRequest( ( struct Upnp_State_Var_Request + * )Event ); + break; + + case UPNP_CONTROL_ACTION_REQUEST: + TvDeviceHandleActionRequest( ( struct Upnp_Action_Request * ) + Event ); + break; + + /* + ignore these cases, since this is not a control point + */ + case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: + case UPNP_DISCOVERY_SEARCH_RESULT: + case UPNP_DISCOVERY_SEARCH_TIMEOUT: + case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: + case UPNP_CONTROL_ACTION_COMPLETE: + case UPNP_CONTROL_GET_VAR_COMPLETE: + case UPNP_EVENT_RECEIVED: + case UPNP_EVENT_RENEWAL_COMPLETE: + case UPNP_EVENT_SUBSCRIBE_COMPLETE: + case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: + break; + + default: + SampleUtil_Print + ( "Error in TvDeviceCallbackEventHandler: unknown event type %d\n", + EventType ); + } + + /* + Print a summary of the event received + */ + SampleUtil_PrintEvent( EventType, Event ); + + return ( 0 ); +} + +/****************************************************************************** + * TvDeviceStop + * + * Description: + * Stops the device. Uninitializes the sdk. + * + * Parameters: + * + *****************************************************************************/ +int +TvDeviceStop( ) +{ + UpnpUnRegisterRootDevice( device_handle ); + UpnpFinish( ); + SampleUtil_Finish( ); + ithread_mutex_destroy( &TVDevMutex ); + return UPNP_E_SUCCESS; +} + +/****************************************************************************** + * TvDeviceStart + * + * Description: + * Initializes the UPnP Sdk, registers the device, and sends out + * advertisements. + * + * Parameters: + * + * ip_address - ip address to initialize the sdk (may be NULL) + * if null, then the first non null loopback address is used. + * port - port number to initialize the sdk (may be 0) + * if zero, then a random number is used. + * desc_doc_name - name of description document. + * may be NULL. Default is tvcombodesc.xml + * web_dir_path - path of web directory. + * may be NULL. Default is ./web (for Linux) or ../tvdevice/web + * for windows. + * pfun - print function to use. + * + *****************************************************************************/ +int +TvDeviceStart( char *ip_address, + unsigned short port, + char *desc_doc_name, + char *web_dir_path, + print_string pfun ) +{ + int ret = UPNP_E_SUCCESS; + + char desc_doc_url[DESC_URL_SIZE]; + + ithread_mutex_init( &TVDevMutex, NULL ); + + SampleUtil_Initialize( pfun ); + + SampleUtil_Print + ( "Initializing UPnP Sdk with \n \t ipaddress = %s port = %d\n", + ip_address, port ); + + if( ( ret = UpnpInit( ip_address, port ) ) != UPNP_E_SUCCESS ) { + SampleUtil_Print( "Error with UpnpInit -- %d\n", ret ); + UpnpFinish( ); + return ret; + } + + if( ip_address == NULL ) { + ip_address = UpnpGetServerIpAddress( ); + } + + if( port == 0 ) { + port = UpnpGetServerPort( ); + } + + SampleUtil_Print( "UPnP Initialized\n \t ipaddress= %s port = %d\n", + ip_address, port ); + + if( desc_doc_name == NULL ) + desc_doc_name = "tvcombodesc.xml"; + + if( web_dir_path == NULL ) + web_dir_path = DEFAULT_WEB_DIR; + + snprintf( desc_doc_url, DESC_URL_SIZE, "http://%s:%d/%s", ip_address, + port, desc_doc_name ); + + SampleUtil_Print( "Specifying the webserver root directory -- %s\n", + web_dir_path ); + if( ( ret = + UpnpSetWebServerRootDir( web_dir_path ) ) != UPNP_E_SUCCESS ) { + SampleUtil_Print + ( "Error specifying webserver root directory -- %s: %d\n", + web_dir_path, ret ); + UpnpFinish( ); + return ret; + } + + SampleUtil_Print + ( "Registering the RootDevice\n\t with desc_doc_url: %s\n", + desc_doc_url ); + + if( ( ret = UpnpRegisterRootDevice( desc_doc_url, + TvDeviceCallbackEventHandler, + &device_handle, &device_handle ) ) + != UPNP_E_SUCCESS ) { + SampleUtil_Print( "Error registering the rootdevice : %d\n", ret ); + UpnpFinish( ); + return ret; + } else { + SampleUtil_Print( "RootDevice Registered\n" ); + + SampleUtil_Print( "Initializing State Table\n" ); + TvDeviceStateTableInit( desc_doc_url ); + SampleUtil_Print( "State Table Initialized\n" ); + + if( ( ret = + UpnpSendAdvertisement( device_handle, default_advr_expire ) ) + != UPNP_E_SUCCESS ) { + SampleUtil_Print( "Error sending advertisements : %d\n", ret ); + UpnpFinish( ); + return ret; + } + + SampleUtil_Print( "Advertisements Sent\n" ); + } + return UPNP_E_SUCCESS; +} diff --git a/upnp/sample/tvcombo/upnp_tv_device.h b/upnp/sample/tvcombo/upnp_tv_device.h new file mode 100644 index 0000000..c797409 --- /dev/null +++ b/upnp/sample/tvcombo/upnp_tv_device.h @@ -0,0 +1,638 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2000-2003 Intel Corporation +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither name of Intel Corporation nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef UPNP_TV_DEVICE_H +#define UPNP_TV_DEVICE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ithread.h" +#include +#include +#include +#include "upnp.h" +#include "sample_util.h" + +//Color constants +#define MAX_COLOR 10 +#define MIN_COLOR 1 + +//Brightness constants +#define MAX_BRIGHTNESS 10 +#define MIN_BRIGHTNESS 1 + +//Power constants +#define POWER_ON 1 +#define POWER_OFF 0 + +//Tint constants +#define MAX_TINT 10 +#define MIN_TINT 1 + +//Volume constants +#define MAX_VOLUME 10 +#define MIN_VOLUME 1 + +//Contrast constants +#define MAX_CONTRAST 10 +#define MIN_CONTRAST 1 + +//Channel constants +#define MAX_CHANNEL 100 +#define MIN_CHANNEL 1 + +//Number of services. +#define TV_SERVICE_SERVCOUNT 2 + +//Index of control service +#define TV_SERVICE_CONTROL 0 + +//Index of picture service +#define TV_SERVICE_PICTURE 1 + +//Number of control variables +#define TV_CONTROL_VARCOUNT 3 + +//Index of power variable +#define TV_CONTROL_POWER 0 + +//Index of channel variable +#define TV_CONTROL_CHANNEL 1 + +//Index of volume variable +#define TV_CONTROL_VOLUME 2 + +//Number of picture variables +#define TV_PICTURE_VARCOUNT 4 + +//Index of color variable +#define TV_PICTURE_COLOR 0 + +//Index of tint variable +#define TV_PICTURE_TINT 1 + +//Index of contrast variable +#define TV_PICTURE_CONTRAST 2 + +//Index of brightness variable +#define TV_PICTURE_BRIGHTNESS 3 + +//Max value length +#define TV_MAX_VAL_LEN 5 + +//Max actions +#define TV_MAXACTIONS 12 + +/* This should be the maximum VARCOUNT from above */ +#define TV_MAXVARS TV_PICTURE_VARCOUNT + + +extern char TvDeviceType[]; + +extern char *TvServiceType[]; + + + +/****************************************************************************** + * upnp_action + * + * Description: + * Prototype for all actions. For each action that a service + * implements, there is a corresponding function with this prototype. + * Pointers to these functions, along with action names, are stored + * in the service table. When an action request comes in the action + * name is matched, and the appropriate function is called. + * Each function returns UPNP_E_SUCCESS, on success, and a nonzero + * error code on failure. + * + * Parameters: + * + * IXML_Document * request - document of action request + * IXML_Document **out - action result + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ + +typedef int (*upnp_action) (IXML_Document *request, IXML_Document **out, + char **errorString); + +/* Structure for storing Tv Service + identifiers and state table */ +struct TvService { + + char UDN[NAME_SIZE]; /* Universally Unique Device Name */ + char ServiceId[NAME_SIZE]; + char ServiceType[NAME_SIZE]; + char *VariableName[TV_MAXVARS]; + char *VariableStrVal[TV_MAXVARS]; + char *ActionNames[TV_MAXACTIONS]; + upnp_action actions[TV_MAXACTIONS]; + unsigned int VariableCount; +}; + +//Array of service structures +extern struct TvService tv_service_table[]; + +//Device handle returned from sdk +extern UpnpDevice_Handle device_handle; + + +/* Mutex for protecting the global state table data + in a multi-threaded, asynchronous environment. + All functions should lock this mutex before reading + or writing the state table data. */ +extern ithread_mutex_t TVDevMutex; + + + +/****************************************************************************** + * SetActionTable + * + * Description: + * Initializes the action table for the specified service. + * Note that + * knowledge of the service description is + * assumed. Action names are hardcoded. + * Parameters: + * int serviceType - one of TV_SERVICE_CONTROL or, TV_SERVICE_PICTURE + * struct TvService *out - service containing action table to set. + * + *****************************************************************************/ +int SetActionTable(int serviceType, struct TvService * out); + +/****************************************************************************** + * TvDeviceStateTableInit + * + * Description: + * Initialize the device state table for + * this TvDevice, pulling identifier info + * from the description Document. Note that + * knowledge of the service description is + * assumed. State table variables and default + * values are currently hardcoded in this file + * rather than being read from service description + * documents. + * + * Parameters: + * DescDocURL -- The description document URL + * + *****************************************************************************/ +int TvDeviceStateTableInit(char*); + + +/****************************************************************************** + * TvDeviceHandleSubscriptionRequest + * + * Description: + * Called during a subscription request callback. If the + * subscription request is for this device and either its + * control service or picture service, then accept it. + * + * Parameters: + * sr_event -- The subscription request event structure + * + *****************************************************************************/ +int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *); + +/****************************************************************************** + * TvDeviceHandleGetVarRequest + * + * Description: + * Called during a get variable request callback. If the + * request is for this device and either its control service + * or picture service, then respond with the variable value. + * + * Parameters: + * cgv_event -- The control get variable request event structure + * + *****************************************************************************/ +int TvDeviceHandleGetVarRequest(struct Upnp_State_Var_Request *); + +/****************************************************************************** + * TvDeviceHandleActionRequest + * + * Description: + * Called during an action request callback. If the + * request is for this device and either its control service + * or picture service, then perform the action and respond. + * + * Parameters: + * ca_event -- The control action request event structure + * + *****************************************************************************/ +int TvDeviceHandleActionRequest(struct Upnp_Action_Request *); + +/****************************************************************************** + * TvDeviceCallbackEventHandler + * + * Description: + * The callback handler registered with the SDK while registering + * root device. Dispatches the request to the appropriate procedure + * based on the value of EventType. The four requests handled by the + * device are: + * 1) Event Subscription requests. + * 2) Get Variable requests. + * 3) Action requests. + * + * Parameters: + * + * EventType -- The type of callback event + * Event -- Data structure containing event data + * Cookie -- Optional data specified during callback registration + * + *****************************************************************************/ +int TvDeviceCallbackEventHandler(Upnp_EventType, void*, void*); + +/****************************************************************************** + * TvDeviceSetServiceTableVar + * + * Description: + * Update the TvDevice service state table, and notify all subscribed + * control points of the updated state. Note that since this function + * blocks on the mutex TVDevMutex, to avoid a hang this function should + * not be called within any other function that currently has this mutex + * locked. + * + * Parameters: + * service -- The service number (TV_SERVICE_CONTROL or TV_SERVICE_PICTURE) + * variable -- The variable number (TV_CONTROL_POWER, TV_CONTROL_CHANNEL, + * TV_CONTROL_VOLUME, TV_PICTURE_COLOR, TV_PICTURE_TINT, + * TV_PICTURE_CONTRAST, or TV_PICTURE_BRIGHTNESS) + * value -- The string representation of the new value + * + *****************************************************************************/ +int TvDeviceSetServiceTableVar(unsigned int, unsigned int, char*); + +//Control Service Actions + +/****************************************************************************** + * TvDevicePowerOn + * + * Description: + * Turn the power on. + * + * Parameters: + * + * IXML_Document * in - document of action request + * IXML_Document **out - action result + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDevicePowerOn(IN IXML_Document * in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDevicePowerOff + * + * Description: + * Turn the power off. + * + * Parameters: + * + * IXML_Document * in - document of action request + * IXML_Document **out - action result + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDevicePowerOff(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceSetChannel + * + * Description: + * Change the channel, update the TvDevice control service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceSetChannel(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceIncreaseChannel + * + * Description: + * Increase the channel. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceIncreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); +/****************************************************************************** + * TvDeviceDecreaseChannel + * + * Description: + * Decrease the channel. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceDecreaseChannel(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); +/****************************************************************************** + * TvDeviceSetVolume + * + * Description: + * Change the volume, update the TvDevice control service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceSetVolume(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceIncreaseVolume + * + * Description: + * Increase the volume. + * + * Parameters: + * + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int TvDeviceIncreaseVolume(IN IXML_Document *in, OUT IXML_Document**out, + OUT char **errorString); + + +/****************************************************************************** + * TvDeviceDecreaseVolume + * + * Description: + * Decrease the volume. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceDecreaseVolume(IN IXML_Document *in, OUT IXML_Document**out, + OUT char **errorString); + + +//Picture Service Actions + +/****************************************************************************** + * TvDeviceSetColor + * + * Description: + * Change the color, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceSetColor(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + + +/****************************************************************************** + * TvDeviceIncreaseColor + * + * Description: + * Increase the color. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int TvDeviceIncreaseColor(IN IXML_Document * in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceDecreaseColor + * + * Description: + * Decrease the color. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + *****************************************************************************/ +int TvDeviceDecreaseColor(IN IXML_Document * in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceSetTint + * + * Description: + * Change the tint, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceSetTint(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceIncreaseTint + * + * Description: + * Increase tint. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceIncreaseTint(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceDecreaseTint + * + * Description: + * Decrease tint. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceDecreaseTint(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/***************************************************************************** + * TvDeviceSetContrast + * + * Description: + * Change the contrast, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + ****************************************************************************/ +int TvDeviceSetContrast(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceIncreaseContrast + * + * Description: + * + * Increase the contrast. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceIncreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); +/****************************************************************************** + * TvDeviceDecreaseContrast + * + * Description: + * Decrease the contrast. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceDecreaseContrast(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceSetBrightness + * + * Description: + * Change the brightness, update the TvDevice picture service + * state table, and notify all subscribed control points of the + * updated state. + * + * Parameters: + * brightness -- The brightness value to change to. + * + *****************************************************************************/ +int TvDeviceSetBrightness(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceIncreaseBrightness + * + * Description: + * Increase brightness. + * + * Parameters: + * + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceIncreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +/****************************************************************************** + * TvDeviceDecreaseBrightness + * + * Description: + * Decrease brightnesss. + * + * Parameters: + * IXML_Document * in - action request document + * IXML_Document **out - action result document + * char **errorString - errorString (in case action was unsuccessful) + * + *****************************************************************************/ +int TvDeviceDecreaseBrightness(IN IXML_Document *in, OUT IXML_Document **out, + OUT char **errorString); + +int TvDeviceStart(char * ip_address, unsigned short port,char * desc_doc_name, + char *web_dir_path, print_string pfun); +int TvDeviceStop(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/upnp/sample/web/tvcombodesc.xml b/upnp/sample/web/tvcombodesc.xml new file mode 100644 index 0000000..3ffe57c --- /dev/null +++ b/upnp/sample/web/tvcombodesc.xml @@ -0,0 +1,37 @@ + + + + 1 + 0 + + + urn:schemas-upnp-org:device:tvdevice:1 + UPnP Television Emulator + TV Manufacturer Name + http://www.manufacturer.com + UPnP Television Device Emulator 1.0 + TVEmulator + 1.0 + http://www.manufacturer.com/TVEmulator/ + 123456789001 + uuid:Upnp-TVEmulator-1_0-1234567890002 + 123456789 + + + urn:schemas-upnp-org:service:tvcontrol:1 + urn:upnp-org:serviceId:tvcontrol1 + /upnp/control/tvcontrol1 + /upnp/event/tvcontrol1 + /tvcontrolSCPD.xml + + + urn:schemas-upnp-org:service:tvpicture:1 + urn:upnp-org:serviceId:tvpicture1 + /upnp/control/tvpicture1 + /upnp/event/tvpicture1 + /tvpictureSCPD.xml + + + /tvdevicepres.html + + diff --git a/upnp/sample/tvdevice/web/tvcontrolSCPD.xml b/upnp/sample/web/tvcontrolSCPD.xml similarity index 99% rename from upnp/sample/tvdevice/web/tvcontrolSCPD.xml rename to upnp/sample/web/tvcontrolSCPD.xml index f556a59..3dd7221 100644 --- a/upnp/sample/tvdevice/web/tvcontrolSCPD.xml +++ b/upnp/sample/web/tvcontrolSCPD.xml @@ -7,7 +7,6 @@ - @@ -38,6 +37,12 @@ SetChannel + + Channel + Channel + in + + NewChannel @@ -45,11 +50,6 @@ out - - Channel - Channel - in - @@ -80,6 +80,11 @@ SetVolume + + Volume + Volume + in + NewVolume @@ -87,11 +92,6 @@ Volume out - - Volume - Volume - in - @@ -124,9 +124,6 @@ - - - diff --git a/upnp/sample/tvdevice/web/tvdevicedesc.xml b/upnp/sample/web/tvdevicedesc.xml similarity index 100% rename from upnp/sample/tvdevice/web/tvdevicedesc.xml rename to upnp/sample/web/tvdevicedesc.xml diff --git a/upnp/sample/tvdevice/web/tvdevicepres.html b/upnp/sample/web/tvdevicepres.html similarity index 100% rename from upnp/sample/tvdevice/web/tvdevicepres.html rename to upnp/sample/web/tvdevicepres.html diff --git a/upnp/sample/tvdevice/web/tvpictureSCPD.xml b/upnp/sample/web/tvpictureSCPD.xml similarity index 95% rename from upnp/sample/tvdevice/web/tvpictureSCPD.xml rename to upnp/sample/web/tvpictureSCPD.xml index 8388fd7..5903513 100644 --- a/upnp/sample/tvdevice/web/tvpictureSCPD.xml +++ b/upnp/sample/web/tvpictureSCPD.xml @@ -12,6 +12,12 @@ SetColor + + Color + Color + in + + NewColor @@ -19,11 +25,6 @@ out - - Color - Color - in - @@ -54,19 +55,19 @@ SetTint - + + Tint + Tint + in + + NewTint Tint out - - Tint - Tint - in - - + @@ -96,18 +97,18 @@ SetContrast - + + Contrast + Contrast + in + + NewContrast Contrast out - - Contrast - Contrast - in - - + @@ -137,19 +138,17 @@ SetBrightness - + + Brightness + Brightness + in + NewBrightness Brightness out - - - Brightness - Brightness - in - @@ -182,7 +181,6 @@ - diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 6c20928..ecc72fb 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -29,7 +29,7 @@ // /////////////////////////////////////////////////////////////////////////// -//File upnpapi.c + #include "config.h" #include #include @@ -37,22 +37,22 @@ #include #include #ifndef WIN32 - #include - #include - #include + #include + #include + #include - #ifndef SPARC_SOLARIS -// #include - #include - #else - #include - #include - #include - #endif + #ifndef SPARC_SOLARIS +// #include + #include + #else + #include + #include + #include + #endif - #include - #include - #include + #include + #include + #include #endif #include "upnpapi.h" #include "httpreadwrite.h" @@ -63,36 +63,32 @@ #include "httpreadwrite.h" -//************************************ -//Needed for GENA +// Needed for GENA #include "gena.h" #include "service_table.h" #include "miniserver.h" -//******************************************* -/* - ********************* */ #ifdef INTERNAL_WEB_SERVER -#include "webserver.h" -#include "urlconfig.h" + #include "webserver.h" + #include "urlconfig.h" #endif // INTERNAL_WEB_SERVER -/* - ****************** */ -//Mutex to synchronize the subscription handling at the client side -CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; - ) - //Mutex to synchronize handles ( root device or control point handle) - ithread_mutex_t GlobalHndMutex; +// Mutex to synchronize the subscription handling at the client side +CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; ) -//Mutex to synchronize the uuid creation process - ithread_mutex_t gUUIDMutex; +//Mutex to synchronize handles ( root device or control point handle) + ithread_mutex_t GlobalHndMutex; - TimerThread gTimerThread; +// Mutex to synchronize the uuid creation process + ithread_mutex_t gUUIDMutex; - ThreadPool gRecvThreadPool; + TimerThread gTimerThread; - ThreadPool gSendThreadPool; + ThreadPool gRecvThreadPool; + + ThreadPool gSendThreadPool; + + ThreadPool gMiniServerThreadPool; //Flag to indicate the state of web server WebServerState bWebServerState = WEB_SERVER_DISABLED; @@ -200,13 +196,12 @@ int UpnpInit( IN const char *HostIP, srand( time( NULL ) ); // needed by SSDP or other parts - DBGONLY( if( InitLog( ) != UPNP_E_SUCCESS ) - return UPNP_E_INIT_FAILED; ); + if( UpnpInitLog() != UPNP_E_SUCCESS ) { + return UPNP_E_INIT_FAILED; + } - DBGONLY( UpnpPrintf - ( UPNP_INFO, API, __FILE__, __LINE__, "Inside UpnpInit \n" ); - ) - //initialize mutex + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "Inside UpnpInit \n" ); + // initialize mutex #ifdef __CYGWIN__ /* On Cygwin, pthread_mutex_init() fails without this memset. */ /* TODO: Fix Cygwin so we don't need this memset(). */ @@ -219,30 +214,30 @@ int UpnpInit( IN const char *HostIP, if( ithread_mutex_init( &gUUIDMutex, NULL ) != 0 ) { return UPNP_E_INIT_FAILED; } - //initialize subscribe mutex - CLIENTONLY( if - ( ithread_mutex_init( &GlobalClientSubscribeMutex, NULL ) - != 0 ) { - return UPNP_E_INIT_FAILED;} - ) + // initialize subscribe mutex +#ifdef INCLUDE_CLIENT_APIS + if ( ithread_mutex_init( &GlobalClientSubscribeMutex, NULL ) != 0 ) { + return UPNP_E_INIT_FAILED; + } +#endif - HandleLock( ); + HandleLock(); if( HostIP != NULL ) strcpy( LOCAL_HOST, HostIP ); else { if( getlocalhostname( LOCAL_HOST ) != UPNP_E_SUCCESS ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INIT_FAILED; } } if( UpnpSdkInit != 0 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INIT; } - InitHandleList( ); - HandleUnlock( ); + InitHandleList(); + HandleUnlock(); TPAttrInit( &attr ); TPAttrSetMaxThreads( &attr, MAX_THREADS ); @@ -253,11 +248,17 @@ int UpnpInit( IN const char *HostIP, if( ThreadPoolInit( &gSendThreadPool, &attr ) != UPNP_E_SUCCESS ) { UpnpSdkInit = 0; - UpnpFinish( ); + UpnpFinish(); return UPNP_E_INIT_FAILED; } if( ThreadPoolInit( &gRecvThreadPool, &attr ) != UPNP_E_SUCCESS ) { + UpnpSdkInit = 0; + UpnpFinish(); + return UPNP_E_INIT_FAILED; + } + + if( ThreadPoolInit( &gMiniServerThreadPool, &attr ) != UPNP_E_SUCCESS ) { UpnpSdkInit = 0; UpnpFinish( ); return UPNP_E_INIT_FAILED; @@ -265,8 +266,7 @@ int UpnpInit( IN const char *HostIP, UpnpSdkInit = 1; #if EXCLUDE_SOAP == 0 - DEVICEONLY( SetSoapCallback( soap_device_callback ); - ); + SetSoapCallback( soap_device_callback ); #endif #if EXCLUDE_GENA == 0 SetGenaCallback( genaCallback ); @@ -276,15 +276,14 @@ int UpnpInit( IN const char *HostIP, &gSendThreadPool ) ) != UPNP_E_SUCCESS ) { UpnpSdkInit = 0; - UpnpFinish( ); + UpnpFinish(); return retVal; } #if EXCLUDE_MINISERVER == 0 if( ( retVal = StartMiniServer( DestPort ) ) <= 0 ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "Miniserver failed to start" ); - ) - UpnpFinish( ); + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "Miniserver failed to start" ); + UpnpFinish(); UpnpSdkInit = 0; if( retVal != -1 ) return retVal; @@ -298,25 +297,23 @@ int UpnpInit( IN const char *HostIP, #if EXCLUDE_WEB_SERVER == 0 if( ( retVal = UpnpEnableWebserver( WEB_SERVER_ENABLED ) ) != UPNP_E_SUCCESS ) { - UpnpFinish( ); + UpnpFinish(); UpnpSdkInit = 0; return retVal; } #endif - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Host Ip: %s Host Port: %d\n", LOCAL_HOST, - LOCAL_PORT ) ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Host Ip: %s Host Port: %d\n", LOCAL_HOST, + LOCAL_PORT ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, API, __FILE__, __LINE__, "Exiting UpnpInit \n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "Exiting UpnpInit \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /***************** end of UpnpInit ******************/ -DBGONLY( +#ifdef DEBUG static void PrintThreadPoolStats (const char* DbgFileName, int DbgLineNo, const char* msg, const ThreadPoolStats* const stats) @@ -337,7 +334,8 @@ PrintThreadPoolStats (const char* DbgFileName, int DbgLineNo, stats->avgWaitHQ, stats->avgWaitMQ, stats->avgWaitLQ, stats->maxThreads, stats->totalWorkTime, stats->totalIdleTime ); -}) +} +#endif /**************************************************************************** @@ -358,39 +356,46 @@ PrintThreadPoolStats (const char* DbgFileName, int DbgLineNo, * UPNP_E_SUCCESS on success, nonzero on failure. *****************************************************************************/ int -UpnpFinish( ) +UpnpFinish() { - DEVICEONLY( UpnpDevice_Handle device_handle; - ) - CLIENTONLY( UpnpClient_Handle client_handle; - ) +#ifdef INCLUDE_DEVICE_APIS + UpnpDevice_Handle device_handle; +#endif +#ifdef INCLUDE_CLIENT_APIS + UpnpClient_Handle client_handle; +#endif struct Handle_Info *temp; - DBGONLY( ThreadPoolStats stats; - ) +#ifdef DEBUG + ThreadPoolStats stats; +#endif #ifdef WIN32 // WSACleanup( ); #endif - if( UpnpSdkInit != 1 ) + if( UpnpSdkInit != 1 ) { return UPNP_E_FINISH; + } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Inside UpnpFinish : UpnpSdkInit is :%d:\n", - UpnpSdkInit ); if( UpnpSdkInit == 1 ) { - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpFinish : UpnpSdkInit is ONE\n" );} - ThreadPoolGetStats( &gRecvThreadPool, &stats ); - PrintThreadPoolStats (__FILE__, __LINE__, - "Recv Thread Pool", &stats); - ThreadPoolGetStats( &gSendThreadPool, &stats ); - PrintThreadPoolStats (__FILE__, __LINE__, - "Send Thread Pool", &stats); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Inside UpnpFinish : UpnpSdkInit is :%d:\n", + UpnpSdkInit ); +#ifdef DEBUG + if( UpnpSdkInit == 1 ) { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpFinish : UpnpSdkInit is ONE\n" ); + } + ThreadPoolGetStats( &gRecvThreadPool, &stats ); + PrintThreadPoolStats (__FILE__, __LINE__, + "Recv Thread Pool", &stats); + ThreadPoolGetStats( &gSendThreadPool, &stats ); + PrintThreadPoolStats (__FILE__, __LINE__, + "Send Thread Pool", &stats); +#endif #ifdef INCLUDE_DEVICE_APIS - if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE ) - UpnpUnRegisterRootDevice( device_handle ); + if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE ) + UpnpUnRegisterRootDevice( device_handle ); #endif #ifdef INCLUDE_CLIENT_APIS @@ -400,33 +405,41 @@ UpnpFinish( ) TimerThreadShutdown( &gTimerThread ); - StopMiniServer( ); + StopMiniServer(); #if EXCLUDE_WEB_SERVER == 0 - web_server_destroy( ); + web_server_destroy(); #endif +#ifdef DEBUG ThreadPoolShutdown( &gSendThreadPool ); ThreadPoolShutdown( &gRecvThreadPool ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Exiting UpnpFinish : UpnpSdkInit is :%d:\n", + UpnpSdkInit ); + ThreadPoolGetStats( &gRecvThreadPool, &stats ); + PrintThreadPoolStats( __FILE__, __LINE__, + "Recv Thread Pool", &stats); + ThreadPoolGetStats( &gSendThreadPool, &stats ); + PrintThreadPoolStats(__FILE__, __LINE__, + "Send Thread Pool", &stats); + UpnpCloseLog(); +#endif - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "Exiting UpnpFinish : UpnpSdkInit is :%d:\n", UpnpSdkInit ); ThreadPoolGetStats( &gRecvThreadPool, &stats ); PrintThreadPoolStats ( __FILE__, __LINE__, "Recv Thread Pool", &stats); ThreadPoolGetStats( &gSendThreadPool, &stats ); PrintThreadPoolStats (__FILE__, __LINE__, "Send Thread Pool", &stats); ) // DBGONLY - DBGONLY( CloseLog( ); - ); - - CLIENTONLY( ithread_mutex_destroy( &GlobalClientSubscribeMutex ); - ) - - ithread_mutex_destroy( &GlobalHndMutex ); +#ifdef INCLUDE_CLIENT_APIS + ithread_mutex_destroy( &GlobalClientSubscribeMutex ); +#endif + ithread_mutex_destroy( &GlobalHndMutex ); ithread_mutex_destroy( &gUUIDMutex ); // remove all virtual dirs - UpnpRemoveAllVirtualDirs( ); - //leuk_he allow static linking: - #ifdef WIN32 - #ifdef PTW32_STATIC_LIB - pthread_win32_thread_detach_np (); - #endif - #endif + UpnpRemoveAllVirtualDirs(); + // leuk_he allow static linking: +#ifdef WIN32 +#ifdef PTW32_STATIC_LIB + pthread_win32_thread_detach_np (); +#endif +#endif UpnpSdkInit = 0; @@ -512,9 +525,9 @@ UpnpAddRootDevice( IN const char *DescURL, return retVal; } - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) { - HandleUnlock( ); + HandleUnlock(); ixmlDocument_free( temp ); return UPNP_E_INVALID_HANDLE; } @@ -522,20 +535,18 @@ UpnpAddRootDevice( IN const char *DescURL, if( addServiceTable ( ( IXML_Node * ) temp, &HInfo->ServiceTable, DescURL ) ) { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpAddRootDevice: GENA Service Table \n" ); - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Here are the known services: \n" ); - printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpAddRootDevice: GENA Service Table \n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Here are the known services: \n" ); + printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); } else { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "\nUpnpAddRootDevice: No Eventing Support Found \n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "\nUpnpAddRootDevice: No Eventing Support Found \n" ); } ixmlDocument_free( temp ); - HandleUnlock( ); + HandleUnlock(); return UPNP_E_SUCCESS; } @@ -579,39 +590,37 @@ UpnpRegisterRootDevice( IN const char *DescUrl, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Inside UpnpRegisterRootDevice \n" ); - ) - HandleLock( ); - + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Inside UpnpRegisterRootDevice\n" ); + + HandleLock(); if( UpnpSdkDeviceRegistered ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_ALREADY_REGISTERED; } if( Hnd == NULL || Fun == NULL || DescUrl == NULL || strlen( DescUrl ) == 0 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - if( ( *Hnd = GetFreeHandle( ) ) == UPNP_E_OUTOF_HANDLE ) { - HandleUnlock( ); + if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) { + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) ); if( HInfo == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HandleTable[*Hnd] = HInfo; - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Root device URL is %s\n", DescUrl ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Root device URL is %s\n", DescUrl ); - HInfo->aliasInstalled = 0; + HInfo->aliasInstalled = 0; HInfo->HType = HND_DEVICE; strcpy( HInfo->DescURL, DescUrl ); HInfo->Callback = Fun; @@ -620,11 +629,9 @@ UpnpRegisterRootDevice( IN const char *DescUrl, HInfo->DeviceList = NULL; HInfo->ServiceList = NULL; HInfo->DescDocument = NULL; - CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); - ); - CLIENTONLY( HInfo->ClientSubList = NULL; - ) - HInfo->MaxSubscriptions = UPNP_INFINITE; + CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); ) + CLIENTONLY( HInfo->ClientSubList = NULL; ) + HInfo->MaxSubscriptions = UPNP_INFINITE; HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE; if( ( retVal = @@ -632,79 +639,59 @@ UpnpRegisterRootDevice( IN const char *DescUrl, != UPNP_E_SUCCESS ) { CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); FreeHandle( *Hnd ); - HandleUnlock( ); + HandleUnlock(); return retVal; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: Valid Description\n" ); - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: DescURL : %s\n", - HInfo->DescURL ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: Valid Description\n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: DescURL : %s\n", + HInfo->DescURL ); - HInfo->DeviceList = + HInfo->DeviceList = ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" ); - if( HInfo->DeviceList == NULL ) { + if( !HInfo->DeviceList ) { CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); ixmlDocument_free( HInfo->DescDocument ); FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: No devices found for RootDevice\n" ); - ) - return UPNP_E_INVALID_DESC; + HandleUnlock(); + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: No devices found for RootDevice\n" ); + return UPNP_E_INVALID_DESC; } - HInfo->ServiceList = - ixmlDocument_getElementsByTagName( HInfo->DescDocument, - "serviceList" ); - if( HInfo->ServiceList == NULL ) { - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); - ixmlNodeList_free( HInfo->DeviceList ); - ixmlDocument_free( HInfo->DescDocument ); - FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: No services found for RootDevice\n" ); - ) - return UPNP_E_INVALID_DESC; + HInfo->ServiceList = ixmlDocument_getElementsByTagName( + HInfo->DescDocument, "serviceList" ); + if( !HInfo->ServiceList ) { + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: No services found for RootDevice\n" ); } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: Gena Check\n" ); - ) - //******************************* - //GENA SET UP - //******************************* - if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument, - &HInfo->ServiceTable, HInfo->DescURL ) ) { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice: GENA Service Table \n" ); - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Here are the known services: \n" ); - printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: Gena Check\n" ); + //******************************* + // GENA SET UP + //******************************* + if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument, + &HInfo->ServiceTable, HInfo->DescURL ) ) { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice: GENA Service Table \n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Here are the known services: \n" ); + printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); } else { - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); - FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "\nUpnpRegisterRootDevice: Errors retrieving service table \n" ); - ) - return UPNP_E_INVALID_DESC; + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "\nUpnpRegisterRootDevice2: Empty service table\n" ); } UpnpSdkDeviceRegistered = 1; - HandleUnlock( ); + HandleUnlock(); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Exiting RegisterRootDevice Successfully\n" ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Exiting RegisterRootDevice Successfully\n" ); - ) - - return UPNP_E_SUCCESS; - -} /****************** End of UpnpRegisterRootDevice *********************/ + return UPNP_E_SUCCESS; +} #endif // INCLUDE_DEVICE_APIS @@ -744,31 +731,29 @@ UpnpRemoveRootDevice( IN const char *DescURL, return retVal; } - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) { - HandleUnlock( ); + HandleUnlock(); ixmlDocument_free( temp ); return UPNP_E_INVALID_HANDLE; } if( removeServiceTable( ( IXML_Node * ) temp, &HInfo->ServiceTable ) ) { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpRemoveRootDevice: GENA Service Table \n" ); - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Here are the known services: \n" ); - printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpRemoveRootDevice: GENA Service Table \n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Here are the known services: \n" ); + printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); } else { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "\nUpnpRemoveRootDevice: No Services Removed\n" ); - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Here are the known services: \n" ); - printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "\nUpnpRemoveRootDevice: No Services Removed\n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Here are the known services: \n" ); + printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); } - HandleUnlock( ); + HandleUnlock(); ixmlDocument_free( temp ); return UPNP_E_SUCCESS; @@ -806,27 +791,26 @@ UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd ) return UPNP_E_FINISH; } - HandleLock( ); + HandleLock(); if( !UpnpSdkDeviceRegistered ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Inside UpnpUnRegisterRootDevice \n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Inside UpnpUnRegisterRootDevice \n" ); #if EXCLUDE_GENA == 0 - if( genaUnregisterDevice( Hnd ) != UPNP_E_SUCCESS ) + if( genaUnregisterDevice( Hnd ) != UPNP_E_SUCCESS ) return UPNP_E_INVALID_HANDLE; #endif - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); #if EXCLUDE_SSDP == 0 retVal = AdvertiseAndReply( -1, Hnd, 0, ( struct sockaddr_in * )NULL, @@ -834,9 +818,9 @@ UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd ) ( char * )NULL, HInfo->MaxAge ); #endif - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } //info = (struct Handle_Info *) HandleTable[Hnd]; @@ -844,7 +828,7 @@ UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd ) ixmlNodeList_free( HInfo->ServiceList ); ixmlDocument_free( HInfo->DescDocument ); - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); + CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); ) #ifdef INTERNAL_WEB_SERVER if( HInfo->aliasInstalled ) { @@ -854,13 +838,12 @@ UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd ) FreeHandle( Hnd ); UpnpSdkDeviceRegistered = 0; - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Exiting UpnpUnRegisterRootDevice \n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Exiting UpnpUnRegisterRootDevice \n" ); - return retVal; + return retVal; } /****************** End of UpnpUnRegisterRootDevice *********************/ @@ -1162,34 +1145,31 @@ UpnpRegisterRootDevice2( IN Upnp_DescType descriptionType, struct Handle_Info *HInfo; int retVal = 0; char *description = ( char * )description_const; - if( UpnpSdkInit != 1 ) { return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Inside UpnpRegisterRootDevice2 \n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Inside UpnpRegisterRootDevice2\n" ); - if( Hnd == NULL || Fun == NULL ) { + if( Hnd == NULL || Fun == NULL ) { return UPNP_E_INVALID_PARAM; } - HandleLock( ); - + HandleLock(); if( UpnpSdkDeviceRegistered ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_ALREADY_REGISTERED; } - if( ( *Hnd = GetFreeHandle( ) ) == UPNP_E_OUTOF_HANDLE ) { - HandleUnlock( ); + if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) { + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) ); if( HInfo == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HandleTable[*Hnd] = HInfo; @@ -1197,99 +1177,82 @@ UpnpRegisterRootDevice2( IN Upnp_DescType descriptionType, // prevent accidental removal of a non-existent alias HInfo->aliasInstalled = 0; - retVal = GetDescDocumentAndURL( descriptionType, description, - bufferLen, config_baseURL, - &HInfo->DescDocument, HInfo->DescURL ); - //HInfo->DescAlias ); + retVal = GetDescDocumentAndURL( + descriptionType, description, bufferLen, + config_baseURL, &HInfo->DescDocument, HInfo->DescURL ); if( retVal != UPNP_E_SUCCESS ) { FreeHandle( *Hnd ); - HandleUnlock( ); + HandleUnlock(); return retVal; } HInfo->aliasInstalled = ( config_baseURL != 0 ); - HInfo->HType = HND_DEVICE; + HInfo->Callback = Fun; HInfo->Cookie = ( void * )Cookie; HInfo->MaxAge = DEFAULT_MAXAGE; HInfo->DeviceList = NULL; HInfo->ServiceList = NULL; - CLIENTONLY( HInfo->ClientSubList = NULL; - ) - CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); - ); + + CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); ) + CLIENTONLY( HInfo->ClientSubList = NULL; ) HInfo->MaxSubscriptions = UPNP_INFINITE; HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE; - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: Valid Description\n" ); - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: DescURL : %s\n", - HInfo->DescURL ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: Valid Description\n" ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: DescURL : %s\n", + HInfo->DescURL ); - HInfo->DeviceList = + HInfo->DeviceList = ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" ); - if( HInfo->DeviceList == NULL ) { - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); + if( !HInfo->DeviceList ) { + CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); ) ixmlDocument_free( HInfo->DescDocument ); FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: No devices found for RootDevice\n" ); - ) - return UPNP_E_INVALID_DESC; + HandleUnlock(); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: No devices found for RootDevice\n" ); + return UPNP_E_INVALID_DESC; } - HInfo->ServiceList = - ixmlDocument_getElementsByTagName( HInfo->DescDocument, - "serviceList" ); - - if( HInfo->ServiceList == NULL ) { - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); - ixmlNodeList_free( HInfo->DeviceList ); - ixmlDocument_free( HInfo->DescDocument ); - FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: No services found for RootDevice\n" ); - ) - return UPNP_E_INVALID_DESC; + HInfo->ServiceList = ixmlDocument_getElementsByTagName( + HInfo->DescDocument, "serviceList" ); + if( !HInfo->ServiceList ) { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: No services found for RootDevice\n" ); } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: Gena Check\n" ); - ) - //******************************* - //GENA SET UP - //******************************* - if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument, - &HInfo->ServiceTable, HInfo->DescURL ) ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "UpnpRegisterRootDevice2: GENA Service Table \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: Gena Check\n" ); + //******************************* + // GENA SET UP + //******************************* + if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument, + &HInfo->ServiceTable, HInfo->DescURL ) ) { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "UpnpRegisterRootDevice2: GENA Service Table\n" ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Here are the known services: \n" ); + printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API ); } else { - CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) ); - FreeHandle( *Hnd ); - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "\nUpnpRegisterRootDevice: Errors retrieving service table \n" ); - ) - return UPNP_E_INVALID_DESC; + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "\nUpnpRegisterRootDevice2: Empty service table\n" ); } + UpnpSdkDeviceRegistered = 1; - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting RegisterRootDevice2 Successfully\n" ); - ) - return UPNP_E_SUCCESS; + HandleUnlock(); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting RegisterRootDevice2 Successfully\n" ); -} /****************** End of UpnpRegisterRootDevice2 *********************/ + return UPNP_E_SUCCESS; +} -#endif //INCLUDE_DEVICE_APIS +#endif // INCLUDE_DEVICE_APIS #ifdef INCLUDE_CLIENT_APIS @@ -1322,60 +1285,52 @@ UpnpRegisterClient( IN Upnp_FunPtr Fun, if( UpnpSdkInit != 1 ) { return UPNP_E_FINISH; } - - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpRegisterClient \n" ); - ) - - if( Fun == NULL || Hnd == NULL ) { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpRegisterClient \n" ); + if( Fun == NULL || Hnd == NULL ) { return UPNP_E_INVALID_PARAM; } - HandleLock( ); + HandleLock(); if( UpnpSdkClientRegistered ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_ALREADY_REGISTERED; } - - if( ( *Hnd = GetFreeHandle( ) ) == UPNP_E_OUTOF_HANDLE ) { - HandleUnlock( ); + if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) { + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) ); if( HInfo == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } HInfo->HType = HND_CLIENT; HInfo->Callback = Fun; HInfo->Cookie = ( void * )Cookie; - DEVICEONLY( HInfo->MaxAge = 0; - ) HInfo->ClientSubList = NULL; ListInit( &HInfo->SsdpSearchList, NULL, NULL ); - DEVICEONLY( HInfo->MaxSubscriptions = UPNP_INFINITE; - ) - DEVICEONLY( HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE; - ) - - HandleTable[*Hnd] = HInfo; +#ifdef INCLUDE_DEVICE_APIS + HInfo->MaxAge = 0; + HInfo->MaxSubscriptions = UPNP_INFINITE; + HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE; +#endif + HandleTable[*Hnd] = HInfo; UpnpSdkClientRegistered = 1; - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpRegisterClient \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpRegisterClient \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpRegisterClient *********************/ #endif // INCLUDE_CLIENT_APIS -#ifdef INCLUDE_CLIENT_APIS /**************************************************************************** * Function: UpnpUnRegisterClient @@ -1392,6 +1347,7 @@ UpnpRegisterClient( IN Upnp_FunPtr Fun, * Return Values: * UPNP_E_SUCCESS on success, nonzero on failure. *****************************************************************************/ +#ifdef INCLUDE_CLIENT_APIS int UpnpUnRegisterClient( IN UpnpClient_Handle Hnd ) { @@ -1403,23 +1359,22 @@ UpnpUnRegisterClient( IN UpnpClient_Handle Hnd ) return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpUnRegisterClient \n" ); - ) - HandleLock( ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpUnRegisterClient \n" ); + HandleLock(); if( !UpnpSdkClientRegistered ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); #if EXCLUDE_GENA == 0 if( genaUnregisterClient( Hnd ) != UPNP_E_SUCCESS ) return UPNP_E_INVALID_HANDLE; #endif - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } //clean up search list @@ -1437,11 +1392,10 @@ UpnpUnRegisterClient( IN UpnpClient_Handle Hnd ) ListDestroy( &HInfo->SsdpSearchList, 0 ); FreeHandle( Hnd ); UpnpSdkClientRegistered = 0; - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpUnRegisterClient \n" ); - ) - return UPNP_E_SUCCESS; + HandleUnlock(); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpUnRegisterClient \n" ); + return UPNP_E_SUCCESS; } /****************** End of UpnpUnRegisterClient *********************/ #endif // INCLUDE_CLIENT_APIS @@ -1483,19 +1437,18 @@ UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSendAdvertisement \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSendAdvertisement \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( Exp < 1 ) Exp = DEFAULT_MAXAGE; SInfo->MaxAge = Exp; - HandleUnlock( ); + HandleUnlock(); retVal = AdvertiseAndReply( 1, Hnd, 0, ( struct sockaddr_in * )NULL, ( char * )NULL, ( char * )NULL, ( char * )NULL, Exp ); @@ -1515,9 +1468,9 @@ UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd, adEvent->handle = Hnd; adEvent->Event = ptrMx; - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); free( adEvent ); free( ptrMx ); return UPNP_E_INVALID_HANDLE; @@ -1532,7 +1485,7 @@ UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd, REL_SEC, &job, SHORT_TERM, &( adEvent->eventId ) ) ) != UPNP_E_SUCCESS ) { - HandleUnlock( ); + HandleUnlock(); free( adEvent ); free( ptrMx ); return retVal; @@ -1546,18 +1499,18 @@ UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd, REL_SEC, &job, SHORT_TERM, &( adEvent->eventId ) ) ) != UPNP_E_SUCCESS ) { - HandleUnlock( ); + HandleUnlock(); free( adEvent ); free( ptrMx ); return retVal; } #endif - HandleUnlock( ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSendAdvertisement \n" ); ) + HandleUnlock(); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSendAdvertisement \n" ); - return retVal; + return retVal; } /****************** End of UpnpSendAdvertisement *********************/ #endif // INCLUDE_DEVICE_APIS @@ -1595,33 +1548,31 @@ UpnpSearchAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSearchAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSearchAsync \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( Mx < 1 ) Mx = DEFAULT_MX; if( Target == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); SearchByTarget( Mx, Target, ( void * )Cookie_const ); //HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSearchAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSearchAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpSearchAsync *********************/ #endif // INCLUDE_CLIENT_APIS @@ -1659,25 +1610,23 @@ UpnpSetMaxSubscriptions( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSetMaxSubscriptions \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSetMaxSubscriptions \n" ); - HandleLock( ); + HandleLock(); if( ( ( MaxSubscriptions != UPNP_INFINITE ) && ( MaxSubscriptions < 0 ) ) || ( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } SInfo->MaxSubscriptions = MaxSubscriptions; - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSetMaxSubscriptions \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSetMaxSubscriptions \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /***************** End of UpnpSetMaxSubscriptions ********************/ #endif // INCLUDE_DEVICE_APIS @@ -1710,27 +1659,25 @@ UpnpSetMaxSubscriptionTimeOut( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSetMaxSubscriptionTimeOut \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSetMaxSubscriptionTimeOut \n" ); - HandleLock( ); + HandleLock(); if( ( ( MaxSubscriptionTimeOut != UPNP_INFINITE ) && ( MaxSubscriptionTimeOut < 0 ) ) || ( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } SInfo->MaxSubscriptionTimeOut = MaxSubscriptionTimeOut; - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSetMaxSubscriptionTimeOut \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSetMaxSubscriptionTimeOut \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpSetMaxSubscriptionTimeOut ******************/ #endif // INCLUDE_DEVICE_APIS @@ -1777,25 +1724,24 @@ UpnpSubscribeAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSubscribeAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSubscribeAsync \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( EvtUrl == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( TimeOut != UPNP_INFINITE && TimeOut < 1 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( Fun == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } @@ -1803,10 +1749,10 @@ UpnpSubscribeAsync( IN UpnpClient_Handle Hnd, ( struct UpnpNonblockParam * ) malloc( sizeof( struct UpnpNonblockParam ) ); if( Param == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } - HandleUnlock( ); + HandleUnlock(); Param->FunName = SUBSCRIBE; Param->Handle = Hnd; @@ -1820,11 +1766,10 @@ UpnpSubscribeAsync( IN UpnpClient_Handle Hnd, TPJobSetPriority( &job, MED_PRIORITY ); ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSubscribeAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSubscribeAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpSubscribeAsync *********************/ #endif // INCLUDE_CLIENT_APIS @@ -1864,35 +1809,33 @@ UpnpSubscribe( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSubscribe \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSubscribe \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( EvtUrl == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( TimeOut == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); RetVal = genaSubscribe( Hnd, EvtUrl, TimeOut, SubsId ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSubscribe \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSubscribe \n" ); - return RetVal; + return RetVal; } /****************** End of UpnpSubscribe *********************/ #endif // INCLUDE_CLIENT_APIS @@ -1926,27 +1869,25 @@ UpnpUnSubscribe( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpUnSubscribe \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpUnSubscribe \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); RetVal = genaUnSubscribe( Hnd, SubsId ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpUnSubscribe \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpUnSubscribe \n" ); - return RetVal; + return RetVal; } /****************** End of UpnpUnSubscribe *********************/ #endif // INCLUDE_CLIENT_APIS @@ -1987,25 +1928,24 @@ UpnpUnSubscribeAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpUnSubscribeAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpUnSubscribeAsync \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( Fun == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); Param = ( struct UpnpNonblockParam * ) malloc( sizeof( struct UpnpNonblockParam ) ); @@ -2022,11 +1962,10 @@ UpnpUnSubscribeAsync( IN UpnpClient_Handle Hnd, TPJobSetPriority( &job, MED_PRIORITY ); ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpUnSubscribeAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpUnSubscribeAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpUnSubscribeAsync *********************/ #endif // INCLUDE_CLIENT_APIS @@ -2063,31 +2002,29 @@ UpnpRenewSubscription( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpRenewSubscription \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpRenewSubscription \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( TimeOut == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); RetVal = genaRenewSubscription( Hnd, SubsId, TimeOut ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpRenewSubscription \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpRenewSubscription \n" ); - return RetVal; + return RetVal; } /****************** End of UpnpRenewSubscription *********************/ #endif // INCLUDE_CLIENT_APIS @@ -2131,27 +2068,26 @@ UpnpRenewSubscriptionAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpRenewSubscriptionAsync \n" ); - ) - HandleLock( ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpRenewSubscriptionAsync \n" ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( TimeOut != UPNP_INFINITE && TimeOut < 1 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( Fun == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); Param = ( struct UpnpNonblockParam * ) @@ -2172,11 +2108,10 @@ UpnpRenewSubscriptionAsync( IN UpnpClient_Handle Hnd, TPJobSetPriority( &job, MED_PRIORITY ); ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpRenewSubscriptionAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpRenewSubscriptionAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpRenewSubscriptionAsync *******************/ #endif // INCLUDE_CLIENT_APIS @@ -2227,37 +2162,35 @@ UpnpNotify( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpNotify \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpNotify \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( DevID == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( ServName == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( VarName == NULL || NewVal == NULL || cVariables < 0 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); retVal = genaNotifyAll( Hnd, DevID, ServName, VarName, NewVal, cVariables ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpNotify \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpNotify \n" ); - return retVal; + return retVal; } /****************** End of UpnpNotify *********************/ @@ -2300,32 +2233,30 @@ UpnpNotifyExt( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpNotify \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpNotify \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( DevID == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( ServName == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); retVal = genaNotifyAllExt( Hnd, DevID, ServName, PropSet ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpNotify \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpNotify \n" ); - return retVal; + return retVal; } /****************** End of UpnpNotify *********************/ @@ -2379,41 +2310,39 @@ UpnpAcceptSubscription( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpAcceptSubscription \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpAcceptSubscription \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( DevID == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( ServName == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( VarName == NULL || NewVal == NULL || cVariables < 0 ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); retVal = genaInitNotify( Hnd, DevID, ServName, VarName, NewVal, cVariables, SubsId ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpAcceptSubscription \n" ); - ) - return retVal; + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpAcceptSubscription \n" ); + return retVal; } /***************** End of UpnpAcceptSubscription *********************/ @@ -2457,41 +2386,39 @@ UpnpAcceptSubscriptionExt( IN UpnpDevice_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpAcceptSubscription \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpAcceptSubscription \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( DevID == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( ServName == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( SubsId == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } if( PropSet == NULL ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - HandleUnlock( ); + HandleUnlock(); retVal = genaInitNotifyExt( Hnd, DevID, ServName, PropSet, SubsId ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpAcceptSubscription \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpAcceptSubscription \n" ); - return retVal; + return retVal; } /****************** End of UpnpAcceptSubscription *********************/ @@ -2551,19 +2478,19 @@ UpnpSendAction( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSendAction \n" ); - ) - if(DevUDN_const !=NULL) - DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"non NULL DevUDN is ignored\n");); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSendAction \n" ); + if(DevUDN_const !=NULL) { + UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"non NULL DevUDN is ignored\n"); + } DevUDN_const = NULL; - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -2577,11 +2504,10 @@ UpnpSendAction( IN UpnpClient_Handle Hnd, retVal = SoapSendAction( ActionURL, ServiceType, Action, RespNodePtr ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSendAction \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSendAction \n" ); - return retVal; + return retVal; } /****************** End of UpnpSendAction *********************/ @@ -2634,22 +2560,21 @@ UpnpSendActionEx( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSendActionEx \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSendActionEx \n" ); - if( Header == NULL ) { + if( Header == NULL ) { retVal = UpnpSendAction( Hnd, ActionURL_const, ServiceType_const, DevUDN_const, Action, RespNodePtr ); return retVal; } - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -2661,11 +2586,10 @@ UpnpSendActionEx( IN UpnpClient_Handle Hnd, retVal = SoapSendActionEx( ActionURL, ServiceType, Header, Action, RespNodePtr ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSendAction \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSendAction \n" ); - return retVal; + return retVal; } /****************** End of UpnpSendActionEx *********************/ @@ -2718,16 +2642,15 @@ UpnpSendActionAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSendActionAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSendActionAsync \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -2774,11 +2697,10 @@ UpnpSendActionAsync( IN UpnpClient_Handle Hnd, TPJobSetPriority( &job, MED_PRIORITY ); ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSendActionAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSendActionAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpSendActionAsync *********************/ @@ -2833,23 +2755,22 @@ UpnpSendActionExAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpSendActionExAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpSendActionExAsync \n" ); - if( Header == NULL ) { + if( Header == NULL ) { retVal = UpnpSendActionAsync( Hnd, ActionURL_const, ServiceType_const, DevUDN_const, Act, Fun, Cookie_const ); return retVal; } - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -2912,11 +2833,10 @@ UpnpSendActionExAsync( IN UpnpClient_Handle Hnd, TPJobSetPriority( &job, MED_PRIORITY ); ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpSendActionAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpSendActionAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpSendActionExAsync *********************/ @@ -2956,16 +2876,15 @@ UpnpGetServiceVarStatusAsync( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpGetServiceVarStatusAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpGetServiceVarStatusAsync \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -2994,11 +2913,10 @@ UpnpGetServiceVarStatusAsync( IN UpnpClient_Handle Hnd, ThreadPoolAdd( &gSendThreadPool, &job, NULL ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpGetServiceVarStatusAsync \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpGetServiceVarStatusAsync \n" ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /****************** End of UpnpGetServiceVarStatusAsync ****************/ @@ -3038,17 +2956,16 @@ UpnpGetServiceVarStatus( IN UpnpClient_Handle Hnd, return UPNP_E_FINISH; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpGetServiceVarStatus \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpGetServiceVarStatus \n" ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } - HandleUnlock( ); + HandleUnlock(); if( ActionURL == NULL ) { return UPNP_E_INVALID_PARAM; @@ -3060,11 +2977,10 @@ UpnpGetServiceVarStatus( IN UpnpClient_Handle Hnd, retVal = SoapGetServiceVarStatus( ActionURL, VarName, &StVarPtr ); *StVar = StVarPtr; - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpGetServiceVarStatus \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpGetServiceVarStatus \n" ); - return retVal; + return retVal; } /****************** End of UpnpGetServiceVarStatus *********************/ #endif // INCLUDE_CLIENT_APIS @@ -3339,16 +3255,13 @@ UpnpDownloadXmlDoc( const char *url, ret_code = UpnpDownloadUrlItem( url, &xml_buf, content_type ); if( ret_code != UPNP_E_SUCCESS ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "retCode: %d\n", ret_code ); - ) - return ret_code; + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "retCode: %d\n", ret_code ); + return ret_code; } if( strncasecmp( content_type, "text/xml", strlen( "text/xml" ) ) ) { - DBGONLY( - UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "Not text/xml\n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, "Not text/xml\n" ); // Linksys WRT54G router returns // "CONTENT-TYPE: application/octet-stream". // Let's be nice to Linksys and try to parse document anyway. @@ -3364,16 +3277,16 @@ UpnpDownloadXmlDoc( const char *url, free( xml_buf ); if( ret_code != IXML_SUCCESS ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "Invalid desc\n" ); - ) - if( ret_code == IXML_INSUFFICIENT_MEMORY ) { + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "Invalid desc\n" ); + if( ret_code == IXML_INSUFFICIENT_MEMORY ) { return UPNP_E_OUTOF_MEMORY; } else { return UPNP_E_INVALID_DESC; } } else { - DBGONLY( xml_buf = ixmlPrintNode( ( IXML_Node * ) * xmlDoc ); +#ifdef DEBUG + xml_buf = ixmlPrintNode( ( IXML_Node * ) * xmlDoc ); UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, "Printing the Parsed xml document \n %s\n", xml_buf ); @@ -3381,7 +3294,8 @@ UpnpDownloadXmlDoc( const char *url, "****************** END OF Parsed XML Doc *****************\n" ); ixmlFreeDOMString( xml_buf ); UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpDownloadXmlDoc\n" ); ) + "Exiting UpnpDownloadXmlDoc\n" ); +#endif return UPNP_E_SUCCESS; } @@ -3393,7 +3307,6 @@ UpnpDownloadXmlDoc( const char *url, // //---------------------------------------------------------------------------- -#ifdef INCLUDE_CLIENT_APIS /************************************************************************** * Function: UpnpThreadDistribution @@ -3406,106 +3319,93 @@ UpnpDownloadXmlDoc( const char *url, * Return Values: VOID * ***************************************************************************/ +#ifdef INCLUDE_CLIENT_APIS void UpnpThreadDistribution( struct UpnpNonblockParam *Param ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpThreadDistribution \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpThreadDistribution \n" ); - switch ( Param->FunName ) { + switch ( Param->FunName ) { #if EXCLUDE_GENA == 0 - CLIENTONLY( case SUBSCRIBE: -{ -struct Upnp_Event_Subscribe Evt; -Evt.ErrCode = genaSubscribe( Param->Handle, Param->Url, - ( int * )&( Param->TimeOut ), - ( char * )Evt.Sid ); -strcpy( Evt.PublisherUrl, Param->Url ); Evt.TimeOut = Param->TimeOut; -Param->Fun( UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie ); -free( Param ); break;} - case UNSUBSCRIBE: - { - struct Upnp_Event_Subscribe Evt; - Evt.ErrCode = - genaUnSubscribe( Param->Handle, - Param->SubsId ); - strcpy( ( char * )Evt.Sid, Param->SubsId ); - strcpy( Evt.PublisherUrl, "" ); - Evt.TimeOut = 0; - Param->Fun( UPNP_EVENT_UNSUBSCRIBE_COMPLETE, - &Evt, Param->Cookie ); - free( Param ); break;} - case RENEW: - { - struct Upnp_Event_Subscribe Evt; - Evt.ErrCode = - genaRenewSubscription( Param->Handle, - Param->SubsId, - &( Param->TimeOut ) ); - Evt.TimeOut = Param->TimeOut; - strcpy( ( char * )Evt.Sid, Param->SubsId ); - Param->Fun( UPNP_EVENT_RENEWAL_COMPLETE, &Evt, - Param->Cookie ); free( Param ); - break;} - ) -#endif + case SUBSCRIBE: { + struct Upnp_Event_Subscribe Evt; + Evt.ErrCode = genaSubscribe( + Param->Handle, Param->Url, + ( int * )&( Param->TimeOut ), + ( char * )Evt.Sid ); + strcpy( Evt.PublisherUrl, Param->Url ); + Evt.TimeOut = Param->TimeOut; + Param->Fun( UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie ); + free( Param ); + break; + } + case UNSUBSCRIBE: { + struct Upnp_Event_Subscribe Evt; + Evt.ErrCode = + genaUnSubscribe( Param->Handle, + Param->SubsId ); + strcpy( ( char * )Evt.Sid, Param->SubsId ); + strcpy( Evt.PublisherUrl, "" ); + Evt.TimeOut = 0; + Param->Fun( UPNP_EVENT_UNSUBSCRIBE_COMPLETE, + &Evt, Param->Cookie ); + free( Param ); + break; + } + case RENEW: { + struct Upnp_Event_Subscribe Evt; + Evt.ErrCode = + genaRenewSubscription( Param->Handle, + Param->SubsId, + &( Param->TimeOut ) ); + Evt.TimeOut = Param->TimeOut; + strcpy( ( char * )Evt.Sid, Param->SubsId ); + Param->Fun( UPNP_EVENT_RENEWAL_COMPLETE, &Evt, + Param->Cookie ); + free( Param ); + break; + } +#endif // EXCLUDE_GENA == 0 #if EXCLUDE_SOAP == 0 - case ACTION: - { - struct Upnp_Action_Complete Evt; - - Evt.ActionResult = NULL; -#ifdef INCLUDE_CLIENT_APIS - + case ACTION: { + struct Upnp_Action_Complete Evt; + Evt.ActionResult = NULL; Evt.ErrCode = SoapSendAction( Param->Url, Param->ServiceType, Param->Act, &Evt.ActionResult ); -#endif - Evt.ActionRequest = Param->Act; strcpy( Evt.CtrlUrl, Param->Url ); - Param->Fun( UPNP_CONTROL_ACTION_COMPLETE, &Evt, Param->Cookie ); - ixmlDocument_free( Evt.ActionRequest ); ixmlDocument_free( Evt.ActionResult ); free( Param ); break; - } - case STATUS: - { + } + case STATUS: { struct Upnp_State_Var_Complete Evt; - -#ifdef INCLUDE_CLIENT_APIS - - Evt.ErrCode = SoapGetServiceVarStatus( Param->Url, - Param->VarName, - &( Evt. - CurrentVal ) ); -#endif + Evt.ErrCode = SoapGetServiceVarStatus( + Param->Url, Param->VarName, &( Evt.CurrentVal ) ); strcpy( Evt.StateVarName, Param->VarName ); strcpy( Evt.CtrlUrl, Param->Url ); - Param->Fun( UPNP_CONTROL_GET_VAR_COMPLETE, &Evt, Param->Cookie ); free( Evt.CurrentVal ); free( Param ); break; } -#endif //EXCLUDE_SOAP +#endif // EXCLUDE_SOAP == 0 default: break; - } // end of switch(Param->FunName) + } // end of switch(Param->FunName) - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpThreadDistribution \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting UpnpThreadDistribution \n" ); } /****************** End of UpnpThreadDistribution *********************/ -#endif +#endif // INCLUDE_CLIENT_APIS /************************************************************************** * Function: GetCallBackFn @@ -3537,7 +3437,7 @@ GetCallBackFn( UpnpClient_Handle Hnd ) * ***************************************************************************/ void -InitHandleList( ) +InitHandleList() { int i; @@ -3558,7 +3458,7 @@ InitHandleList( ) * ***************************************************************************/ int -GetFreeHandle( ) +GetFreeHandle() { int i = 1; @@ -3662,28 +3562,22 @@ GetHandleInfo( UpnpClient_Handle Hnd, struct Handle_Info ** HndInfo ) { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "GetHandleInfo: Handle is %d\n", Hnd ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "GetHandleInfo: Handle is %d\n", Hnd ); - if( Hnd < 1 || Hnd >= NUM_HANDLE ) { - - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "GetHandleInfo : Handle out of range\n" ); - ) - return UPNP_E_INVALID_HANDLE; + if( Hnd < 1 || Hnd >= NUM_HANDLE ) { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "GetHandleInfo : Handle out of range\n" ); + return UPNP_E_INVALID_HANDLE; } if( HandleTable[Hnd] != NULL ) { - *HndInfo = ( struct Handle_Info * )HandleTable[Hnd]; return ( ( struct Handle_Info * )*HndInfo )->HType; } + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "GetHandleInfo : exiting\n" ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "GetHandleInfo : exiting\n" ); - ) - - return UPNP_E_INVALID_HANDLE; + return UPNP_E_INVALID_HANDLE; } /****************** End of GetHandleInfo *********************/ @@ -3703,10 +3597,9 @@ int FreeHandle( int Upnp_Handle ) { if( Upnp_Handle < 1 || Upnp_Handle >= NUM_HANDLE ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "FreeHandleInfo : Handle out of range\n" ); - ) - return UPNP_E_INVALID_HANDLE; + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "FreeHandleInfo : Handle out of range\n" ); + return UPNP_E_INVALID_HANDLE; } if( HandleTable[Upnp_Handle] == NULL ) { @@ -3736,17 +3629,17 @@ int PrintHandleInfo( IN UpnpClient_Handle Hnd ) struct Handle_Info * HndInfo; if (HandleTable[Hnd] != NULL) { HndInfo = HandleTable[Hnd]; - DBGONLY( +#ifdef DEBUG UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "Printing information for Handle_%d\n", Hnd); UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "HType_%d\n", HndInfo->HType); - DEVICEONLY( +#ifdef INCLUDE_DEVICE_APIS if(HndInfo->HType != HND_CLIENT) UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, "DescURL_%s\n", HndInfo->DescURL ); - ) - ) +#endif +#endif } else { return UPNP_E_INVALID_HANDLE; } @@ -3775,12 +3668,10 @@ void printNodes( IXML_Node * tmpRoot, int depth ) NodeType = ixmlNode_getNodeType(ChildNode1); NodeValue = ixmlNode_getNodeValue(ChildNode1); NodeName = ixmlNode_getNodeName(ChildNode1); - DBGONLY( - UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, - "DEPTH-%2d-IXML_Node Type %d, " - "IXML_Node Name: %s, IXML_Node Value: %s\n", - depth, NodeType, NodeName, NodeValue); - ) + UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, + "DEPTH-%2d-IXML_Node Type %d, " + "IXML_Node Name: %s, IXML_Node Value: %s\n", + depth, NodeType, NodeName, NodeValue); } } @@ -3839,10 +3730,9 @@ void printNodes( IXML_Node * tmpRoot, int depth ) // Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. if( ( LocalSock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Can't create addrlist socket\n" ); - ) - return UPNP_E_INIT; + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Can't create addrlist socket\n" ); + return UPNP_E_INIT; } // Get the interface configuration information... ifConf.ifc_len = sizeof szBuffer; @@ -3850,11 +3740,10 @@ void printNodes( IXML_Node * tmpRoot, int depth ) nResult = ioctl( LocalSock, SIOCGIFCONF, &ifConf ); if( nResult < 0 ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "DiscoverInterfaces: SIOCGIFCONF returned error\n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "DiscoverInterfaces: SIOCGIFCONF returned error\n" ); - return UPNP_E_INIT; + return UPNP_E_INIT; } // Cycle through the list of interfaces looking for IP addresses. @@ -3866,11 +3755,9 @@ void printNodes( IXML_Node * tmpRoot, int depth ) // See if this is the sort of interface we want to deal with. strcpy( ifReq.ifr_name, pifReq->ifr_name ); if( ioctl( LocalSock, SIOCGIFFLAGS, &ifReq ) < 0 ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Can't get interface flags for %s:\n", - ifReq.ifr_name ); - ) - + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Can't get interface flags for %s:\n", + ifReq.ifr_name ); } // Skip loopback, point-to-point and down interfaces, // except don't skip down interfaces @@ -3899,11 +3786,10 @@ void printNodes( IXML_Node * tmpRoot, int depth ) strncpy( out, inet_ntoa( LocalAddr.sin_addr ), LINE_SIZE ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside getlocalhostname : after strncpy %s\n", - out ); - ) - return UPNP_E_SUCCESS; + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside getlocalhostname : after strncpy %s\n", + out ); + return UPNP_E_SUCCESS; #endif } @@ -4128,7 +4014,7 @@ UpnpRemoveVirtualDir( IN const char *dirName ) * ***************************************************************************/ void -UpnpRemoveAllVirtualDirs( ) +UpnpRemoveAllVirtualDirs() { virtualDirList *pCur; @@ -4176,7 +4062,7 @@ UpnpEnableWebserver( IN int enable ) switch ( enable ) { #ifdef INTERNAL_WEB_SERVER case TRUE: - if( ( retVal = web_server_init( ) ) != UPNP_E_SUCCESS ) { + if( ( retVal = web_server_init() ) != UPNP_E_SUCCESS ) { return retVal; } bWebServerState = WEB_SERVER_ENABLED; @@ -4184,7 +4070,7 @@ UpnpEnableWebserver( IN int enable ) break; case FALSE: - web_server_destroy( ); + web_server_destroy(); bWebServerState = WEB_SERVER_DISABLED; SetHTTPGetCallback( NULL ); break; @@ -4209,7 +4095,7 @@ UpnpEnableWebserver( IN int enable ) * 0, if webserver disabled ***************************************************************************/ int -UpnpIsWebserverEnabled( ) +UpnpIsWebserverEnabled() { if( UpnpSdkInit != 1 ) { return 0; @@ -4300,7 +4186,7 @@ UpnpSetContentLength( IN UpnpClient_Handle Hnd, break; } - HandleLock( ); + HandleLock(); errCode = GetHandleInfo( Hnd, &HInfo ); @@ -4318,7 +4204,7 @@ UpnpSetContentLength( IN UpnpClient_Handle Hnd, } while( 0 ); - HandleUnlock( ); + HandleUnlock(); return errCode; } diff --git a/upnp/src/api/upnpdebug.c b/upnp/src/api/upnpdebug.c index 593c4d2..6748fa7 100644 --- a/upnp/src/api/upnpdebug.c +++ b/upnp/src/api/upnpdebug.c @@ -88,18 +88,19 @@ UpnpSetLogFileNames ( IN const char *ErrFileName, /*************************************************************************** - * Function : UpnpInitLog - * - * Parameters: void - * - * Description: + * Function : UpnpInitLog + * + * Parameters: void + * + * Description: * This functions initializes the log files + * * Returns: int * -1 : If fails * UPNP_E_SUCCESS : if success ***************************************************************************/ int -UpnpInitLog( ) +UpnpInitLog() { ithread_mutex_init( &GlobalDebugMutex, NULL ); @@ -116,7 +117,7 @@ UpnpInitLog( ) /*************************************************************************** * Function : UpnpSetLogLevel * - * Parameters: void + * Parameters: Upnp_LogLevel log_level * * Description: * This functions set the log level (see {\tt Upnp_LogLevel} @@ -139,7 +140,7 @@ UpnpSetLogLevel (Upnp_LogLevel log_level) * Returns: void ***************************************************************************/ void -UpnpCloseLog( ) +UpnpCloseLog() { if( DEBUG_TARGET == 1 ) { fflush( ErrFileHnd ); @@ -152,11 +153,47 @@ UpnpCloseLog( ) } +/*************************************************************************** + * Function : DebugAtThisLevel + * + * Parameters: + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide + * whether debug statement will go to standard output, + * or any of the log files. + * IN Dbg_Module Module: debug will go in the name of this module + * + * Description: + * This functions returns true if debug output should be done in this + * module. + * + * Returns: int + ***************************************************************************/ +#ifdef DEBUG +int DebugAtThisLevel( + IN Upnp_LogLevel DLevel, + IN Dbg_Module Module) +{ + int ret = g_log_level >= DLevel; + ret &= + DEBUG_ALL || + (Module == SSDP && DEBUG_SSDP ) || + (Module == SOAP && DEBUG_SOAP ) || + (Module == GENA && DEBUG_GENA ) || + (Module == TPOOL && DEBUG_TPOOL) || + (Module == MSERV && DEBUG_MSERV) || + (Module == DOM && DEBUG_DOM ) || + (Module == HTTP && DEBUG_HTTP ); + + return ret; +} +#endif + + /*************************************************************************** * Function : UpnpPrintf * * Parameters: - * IN Dbg_Level DLevel: The level of the debug logging. It will decide + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide * whether debug statement will go to standard output, * or any of the log files. * IN Dbg_Module Module: debug will go in the name of this module @@ -173,71 +210,53 @@ UpnpCloseLog( ) * statement is coming * Returns: void ***************************************************************************/ -DBGONLY( void UpnpPrintf( IN Upnp_LogLevel DLevel, - IN Dbg_Module Module, - IN const char *DbgFileName, - IN int DbgLineNo, - IN const char *FmtStr, - ... ) { - - va_list ArgList; - va_start( ArgList, FmtStr ); - if( g_log_level < DLevel ) return; if( DEBUG_ALL == 0 ) { - switch ( Module ) { -case SSDP: - if( DEBUG_SSDP == 1 ) break; - else -return; case SOAP: - if( DEBUG_SOAP == 1 ) break; - else -return; case GENA: - if( DEBUG_GENA == 1 ) break; - else -return; case TPOOL: - if( DEBUG_TPOOL == 1 ) break; - else -return; case MSERV: - if( DEBUG_MSERV == 1 ) break; - else -return; case DOM: - if( DEBUG_DOM == 1 ) break; - else -return; case HTTP: - if( DEBUG_HTTP == 1 ) break; - else -return; case API: - if( DEBUG_API == 1 ) break; - else -return; default: - return;} - } - - ithread_mutex_lock( &GlobalDebugMutex ); if( DEBUG_TARGET == 0 ) { - if( DbgFileName ) { - UpnpDisplayFileAndLine( stdout, DbgFileName, DbgLineNo );} - vfprintf( stdout, FmtStr, ArgList ); fflush( stdout );} - else - { - if( DLevel == 0 ) { - if( DbgFileName ) { - UpnpDisplayFileAndLine( ErrFileHnd, DbgFileName, DbgLineNo );} - vfprintf( ErrFileHnd, FmtStr, ArgList ); fflush( ErrFileHnd );} - else - { - if( DbgFileName ) { - UpnpDisplayFileAndLine( InfoFileHnd, DbgFileName, DbgLineNo );} - vfprintf( InfoFileHnd, FmtStr, ArgList ); fflush( InfoFileHnd );} - } - va_end( ArgList ); ithread_mutex_unlock( &GlobalDebugMutex );} - - ) +#ifdef DEBUG +void UpnpPrintf( + IN Upnp_LogLevel DLevel, + IN Dbg_Module Module, + IN const char *DbgFileName, + IN int DbgLineNo, + IN const char *FmtStr, + ... ) +{ + va_list ArgList; + + if (!DebugAtThisLevel(DLevel, Module)) { + return; + } + + ithread_mutex_lock(&GlobalDebugMutex); + va_start(ArgList, FmtStr); + if (!DEBUG_TARGET) { + if( DbgFileName ) { + UpnpDisplayFileAndLine(stdout, DbgFileName, DbgLineNo); + } + vfprintf(stdout, FmtStr, ArgList); + fflush(stdout); + } else if (DLevel == 0) { + if (DbgFileName) { + UpnpDisplayFileAndLine(ErrFileHnd, DbgFileName, DbgLineNo); + } + vfprintf(ErrFileHnd, FmtStr, ArgList); + fflush(ErrFileHnd); + } else { + if (DbgFileName) { + UpnpDisplayFileAndLine(InfoFileHnd, DbgFileName, DbgLineNo); + } + vfprintf(InfoFileHnd, FmtStr, ArgList); + fflush(InfoFileHnd); + } + va_end(ArgList); + ithread_mutex_unlock(&GlobalDebugMutex); +} +#endif /*************************************************************************** * Function : UpnpGetDebugFile * * Parameters: - * IN Dbg_Level DLevel: The level of the debug logging. It will decide + * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide * whether debug statement will go to standard output, * or any of the log files. * IN Dbg_Module Module: debug will go in the name of this module @@ -249,46 +268,26 @@ return; default: * NULL : if the module is turn off for debug * else returns the right file descriptor ***************************************************************************/ - DBGONLY( FILE * GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module ) { - if( g_log_level < DLevel ) return NULL; if( DEBUG_ALL == 0 ) { - switch ( Module ) { -case SSDP: - if( DEBUG_SSDP == 1 ) break; - else -return NULL; case SOAP: - if( DEBUG_SOAP == 1 ) break; - else -return NULL; case GENA: - if( DEBUG_GENA == 1 ) break; - else -return NULL; case TPOOL: - if( DEBUG_TPOOL == 1 ) break; - else -return NULL; case MSERV: - if( DEBUG_MSERV == 1 ) break; - else -return NULL; case DOM: - if( DEBUG_DOM == 1 ) break; - else -return NULL; case API: - if( DEBUG_API == 1 ) break; - else -return NULL; default: - return NULL;} - } +#ifdef DEBUG +FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module ) +{ + FILE *ret; - if( DEBUG_TARGET == 0 ) { - return stdout;} - else - { - if( DLevel == 0 ) { - return ErrFileHnd;} - else - { - return InfoFileHnd;} - } - } - ) + if (!DebugAtThisLevel(DLevel, Module)) { + ret = NULL; + } + + if (!DEBUG_TARGET) { + ret = stdout; + } else if (DLevel == 0) { + ret = ErrFileHnd; + } else { + ret = InfoFileHnd; + } + + return ret; +} +#endif /*************************************************************************** @@ -305,17 +304,26 @@ return NULL; default: * debug statement is coming to the log file * Returns: void ***************************************************************************/ - DBGONLY( void UpnpDisplayFileAndLine( IN FILE * fd, - IN const char *DbgFileName, - IN int DbgLineNo ) { - int starlength = 66; - const char *lines[2]; - char FileAndLine[500]; lines[0] = "DEBUG"; if( DbgFileName ) { - sprintf( FileAndLine, "FILE: %s, LINE: %d", DbgFileName, - DbgLineNo ); lines[1] = FileAndLine;} - - UpnpDisplayBanner( fd, lines, 2, starlength ); fflush( fd );} - ) +#ifdef DEBUG +void UpnpDisplayFileAndLine( + IN FILE * fd, + IN const char *DbgFileName, + IN int DbgLineNo) +{ + int starlength = 66; + const char *lines[2]; + char FileAndLine[500]; + lines[0] = "DEBUG"; + if (DbgFileName) { + sprintf(FileAndLine, + "FILE: %s, LINE: %d", + DbgFileName, DbgLineNo); + lines[1] = FileAndLine; + } + UpnpDisplayBanner(fd, lines, 2, starlength); + fflush(fd); +} +#endif /*************************************************************************** @@ -332,47 +340,58 @@ return NULL; default: * per the requested banner * Returns: void ***************************************************************************/ - DBGONLY( void UpnpDisplayBanner( IN FILE * fd, - IN const char **lines, - IN size_t size, - IN int starLength ) { - char *stars = ( char * )malloc( starLength + 1 ); - const char *line = NULL; - int leftMarginLength = starLength / 2 + 1; - int rightMarginLength = starLength / 2 + 1; - char *leftMargin = ( char * )malloc( leftMarginLength ); - char *rightMargin = ( char * )malloc( rightMarginLength ); - int i = 0; - int LineSize = 0; - char *currentLine = ( char * )malloc( starLength + 1 ); - memset( stars, '*', starLength ); - stars[starLength] = 0; - memset( leftMargin, 0, leftMarginLength ); - memset( rightMargin, 0, rightMarginLength ); - fprintf( fd, "\n%s\n", stars ); for( i = 0; i < size; i++ ) { - LineSize = strlen( lines[i] ); - line = lines[i]; while( LineSize > ( starLength - 2 ) ) { - memcpy( currentLine, line, ( starLength - 2 ) ); - currentLine[( starLength - 2 )] = 0; - fprintf( fd, "*%s*\n", currentLine ); - LineSize -= ( starLength - 2 ); line += ( starLength - 2 );} +#ifdef DEBUG +void UpnpDisplayBanner( + IN FILE * fd, + IN const char **lines, + IN size_t size, + IN int starLength) +{ + int leftMarginLength = starLength / 2 + 1; + int rightMarginLength = starLength / 2 + 1; + int i = 0; + int LineSize = 0; + int starLengthMinus2 = starLength - 2; - if( LineSize % 2 == 0 ) { - leftMarginLength = rightMarginLength = - ( ( starLength - 2 ) - LineSize ) / 2;} - else - { - leftMarginLength = ( ( starLength - 2 ) - LineSize ) / 2; - rightMarginLength = - ( ( starLength - 2 ) - LineSize ) / 2 + 1;} + char *leftMargin = ( char * )malloc( leftMarginLength ); + char *rightMargin = ( char * )malloc( rightMarginLength ); + char *stars = ( char * )malloc( starLength + 1 ); + char *currentLine = ( char * )malloc( starLength + 1 ); + const char *line = NULL; - memset( leftMargin, ' ', leftMarginLength ); - memset( rightMargin, ' ', rightMarginLength ); - leftMargin[leftMarginLength] = 0; - rightMargin[rightMarginLength] = 0; - fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );} + memset( stars, '*', starLength ); + stars[starLength] = 0; + memset( leftMargin, 0, leftMarginLength ); + memset( rightMargin, 0, rightMarginLength ); + fprintf( fd, "\n%s\n", stars ); + for( i = 0; i < size; i++ ) { + LineSize = strlen( lines[i] ); + line = lines[i]; + while( LineSize > starLengthMinus2 ) { + memcpy( currentLine, line, starLengthMinus2 ); + currentLine[starLengthMinus2] = 0; + fprintf( fd, "*%s*\n", currentLine ); + LineSize -= starLengthMinus2; + line += starLengthMinus2; + } + leftMarginLength = (starLengthMinus2 - LineSize)/2; + if( LineSize % 2 == 0 ) { + rightMarginLength = leftMarginLength; + } else { + rightMarginLength = leftMarginLength + 1; + } + memset( leftMargin, ' ', leftMarginLength ); + memset( rightMargin, ' ', rightMarginLength ); + leftMargin[leftMarginLength] = 0; + rightMargin[rightMarginLength] = 0; + fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin ); + } + fprintf( fd, "%s\n\n", stars ); - fprintf( fd, "%s\n\n", stars ); - free( leftMargin ); - free( rightMargin ); free( stars ); free( currentLine );} - ) + free( currentLine ); + free( stars ); + free( rightMargin ); + free( leftMargin ); +} +#endif + diff --git a/upnp/src/gena/gena_callback2.c b/upnp/src/gena/gena_callback2.c index 4ecc152..231c5b5 100644 --- a/upnp/src/gena/gena_callback2.c +++ b/upnp/src/gena/gena_callback2.c @@ -93,37 +93,35 @@ genaCallback( IN http_parser_t * parser, xboolean found_function = FALSE; if( request->method == HTTPMETHOD_SUBSCRIBE ) { - DEVICEONLY( found_function = TRUE; - if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) - { - // renew subscription - gena_process_subscription_renewal_request - ( info, request );} - else - { - // subscribe - gena_process_subscription_request( info, request );} +#ifdef INCLUDE_DEVICE_APIS + found_function = TRUE; + if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL ) { + // renew subscription + gena_process_subscription_renewal_request + ( info, request ); + } else { + // subscribe + gena_process_subscription_request( info, request ); + } + UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, + "got subscription request\n" ); + } else if( request->method == HTTPMETHOD_UNSUBSCRIBE ) { + found_function = TRUE; + // unsubscribe + gena_process_unsubscribe_request( info, request ); +#endif + } else if( request->method == HTTPMETHOD_NOTIFY ) { +#ifdef INCLUDE_CLIENT_APIS + found_function = TRUE; + // notify + gena_process_notification_event( info, request ); +#endif + } - DBGONLY( UpnpPrintf - ( UPNP_ALL, GENA, __FILE__, __LINE__, - "got subscription request\n" ); ) - ) - } - else - if( request->method == HTTPMETHOD_UNSUBSCRIBE ) { - DEVICEONLY( found_function = TRUE; - // unsubscribe - gena_process_unsubscribe_request( info, - request ); ) - } else if( request->method == HTTPMETHOD_NOTIFY ) { - CLIENTONLY( found_function = TRUE; - // notify - gena_process_notification_event( info, request ); ) - } - - if( !found_function ) { + if( !found_function ) { // handle missing functions of device or ctrl pt error_respond( info, HTTP_NOT_IMPLEMENTED, request ); - } } +} #endif // EXCLUDE_GENA + diff --git a/upnp/src/gena/gena_ctrlpt.c b/upnp/src/gena/gena_ctrlpt.c index b949db3..67ea063 100644 --- a/upnp/src/gena/gena_ctrlpt.c +++ b/upnp/src/gena/gena_ctrlpt.c @@ -72,14 +72,14 @@ GenaAutoRenewSubscription( IN void *input ) int eventType = 0; if( AUTO_RENEW_TIME == 0 ) { - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA SUB EXPIRED" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA SUB EXPIRED" ); sub_struct->ErrCode = UPNP_E_SUCCESS; send_callback = 1; eventType = UPNP_EVENT_SUBSCRIPTION_EXPIRED; } else { - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA AUTO RENEW" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA AUTO RENEW" ); if( ( ( sub_struct->ErrCode = genaRenewSubscription( event->handle, sub_struct-> Sid, @@ -93,17 +93,17 @@ GenaAutoRenewSubscription( IN void *input ) } } if( send_callback ) { - HandleLock( ); + HandleLock(); if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); free_upnp_timeout( event ); return; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "HANDLE IS VALID" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "HANDLE IS VALID" ); callback_fun = handle_info->Callback; cookie = handle_info->Cookie; - HandleUnlock( ); + HandleUnlock(); //make callback callback_fun( eventType, event->Event, cookie ); @@ -397,9 +397,9 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle ) http_parser_t response; while( TRUE ) { - HandleLock( ); + HandleLock(); if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } @@ -417,7 +417,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle ) RemoveClientSubClientSID( &handle_info->ClientSubList, sub_copy.sid ); - HandleUnlock( ); + HandleUnlock(); return_code = gena_unsubscribe( sub_copy.EventURL, sub_copy.ActualSID, &response ); @@ -429,7 +429,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle ) } freeClientSubList( handle_info->ClientSubList ); - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -449,6 +449,7 @@ genaUnregisterClient( IN UpnpClient_Handle client_handle ) * return UPNP_E_SUCCESS if service response is OK else * returns appropriate error ***************************************************************************/ +#ifdef INCLUDE_CLIENT_APIS int genaUnSubscribe( IN UpnpClient_Handle client_handle, IN const Upnp_SID in_sid ) @@ -459,25 +460,25 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle, client_subscription sub_copy; http_parser_t response; - HandleLock( ); + HandleLock(); // validate handle and sid if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } if( ( sub = GetClientSubClientSID( handle_info->ClientSubList, in_sid ) ) == NULL ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SID; } return_code = copy_client_subscription( sub, &sub_copy ); - HandleUnlock( ); + HandleUnlock(); return_code = gena_unsubscribe( sub_copy.EventURL, sub_copy.ActualSID, &response ); @@ -488,19 +489,20 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle, free_client_subscription( &sub_copy ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid ); - HandleUnlock( ); + HandleUnlock(); return return_code; } +#endif /************************************************************************ * Function : genaSubscribe @@ -524,6 +526,7 @@ genaUnSubscribe( IN UpnpClient_Handle client_handle, * return UPNP_E_SUCCESS if service response is OK else * returns appropriate error ***************************************************************************/ +#ifdef INCLUDE_CLIENT_APIS int genaSubscribe( IN UpnpClient_Handle client_handle, IN char *PublisherURL, @@ -538,28 +541,28 @@ genaSubscribe( IN UpnpClient_Handle client_handle, struct Handle_Info *handle_info; char *EventURL = NULL; - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA SUBSCRIBE BEGIN" ) ); - HandleLock( ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA SUBSCRIBE BEGIN" ); + HandleLock(); memset( out_sid, 0, sizeof( Upnp_SID ) ); // validate handle if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } - HandleUnlock( ); + HandleUnlock(); // subscribe - SubscribeLock( ); + SubscribeLock(); return_code = gena_subscribe( PublisherURL, TimeOut, NULL, &ActualSID ); - HandleLock( ); + HandleLock(); if( return_code != UPNP_E_SUCCESS ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__, - "SUBSCRIBE FAILED in transfer error code: %d returned\n", - return_code ) ); + UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__, + "SUBSCRIBE FAILED in transfer error code: %d returned\n", + return_code ); goto error_handler; } @@ -605,10 +608,11 @@ genaSubscribe( IN UpnpClient_Handle client_handle, free( EventURL ); free( newSubscription ); } - HandleUnlock( ); - SubscribeUnlock( ); + HandleUnlock(); + SubscribeUnlock(); return return_code; } +#endif /************************************************************************ * Function : genaRenewSubscription @@ -643,17 +647,17 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, char *ActualSID; ThreadPoolJob tempJob; - HandleLock( ); + HandleLock(); // validate handle and sid if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } if( ( sub = GetClientSubClientSID( handle_info->ClientSubList, in_sid ) ) == NULL ) { - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SID; } // remove old events @@ -663,13 +667,13 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, free_upnp_timeout( ( upnp_timeout * ) tempJob.arg ); } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "REMOVED AUTO RENEW EVENT" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "REMOVED AUTO RENEW EVENT" ); sub->RenewEventId = -1; return_code = copy_client_subscription( sub, &sub_copy ); - HandleUnlock( ); + HandleUnlock(); if( return_code != HTTP_SUCCESS ) { return return_code; @@ -677,10 +681,10 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, return_code = gena_subscribe( sub_copy.EventURL, TimeOut, sub_copy.ActualSID, &ActualSID ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( client_handle, &handle_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); if( return_code == UPNP_E_SUCCESS ) { free( ActualSID ); } @@ -693,7 +697,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, // network failure (remove client sub) RemoveClientSubClientSID( &handle_info->ClientSubList, in_sid ); free_client_subscription( &sub_copy ); - HandleUnlock( ); + HandleUnlock(); return return_code; } // get subscription @@ -701,7 +705,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, in_sid ) ) == NULL ) { free( ActualSID ); free_client_subscription( &sub_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SID; } // store actual sid @@ -714,7 +718,7 @@ genaRenewSubscription( IN UpnpClient_Handle client_handle, RemoveClientSubClientSID( &handle_info->ClientSubList, sub->sid ); } free_client_subscription( &sub_copy ); - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -795,12 +799,12 @@ gena_process_notification_event( IN SOCKINFO * info, return; } - HandleLock( ); + HandleLock(); // get client info if( GetClientHandleInfo( &client_handle, &handle_info ) != HND_CLIENT ) { error_respond( info, HTTP_PRECONDITION_FAILED, event ); - HandleUnlock( ); + HandleUnlock(); ixmlDocument_free( ChangedVars ); return; @@ -813,20 +817,20 @@ gena_process_notification_event( IN SOCKINFO * info, // (if we are in the middle) // this is to avoid mistakenly rejecting the first event if we // receive it before the subscription response - HandleUnlock( ); + HandleUnlock(); // try and get Subscription Lock // (in case we are in the process of subscribing) - SubscribeLock( ); + SubscribeLock(); // get HandleLock again - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &client_handle, &handle_info ) != HND_CLIENT ) { error_respond( info, HTTP_PRECONDITION_FAILED, event ); - SubscribeUnlock( ); - HandleUnlock( ); + SubscribeUnlock(); + HandleUnlock(); ixmlDocument_free( ChangedVars ); return; @@ -836,17 +840,17 @@ gena_process_notification_event( IN SOCKINFO * info, GetClientSubActualSID( handle_info->ClientSubList, &sid ) ) == NULL ) { error_respond( info, HTTP_PRECONDITION_FAILED, event ); - SubscribeUnlock( ); - HandleUnlock( ); + SubscribeUnlock(); + HandleUnlock(); ixmlDocument_free( ChangedVars ); return; } - SubscribeUnlock( ); + SubscribeUnlock(); } else { error_respond( info, HTTP_PRECONDITION_FAILED, event ); - HandleUnlock( ); + HandleUnlock(); ixmlDocument_free( ChangedVars ); return; @@ -864,7 +868,7 @@ gena_process_notification_event( IN SOCKINFO * info, callback = handle_info->Callback; cookie = handle_info->Cookie; - HandleUnlock( ); + HandleUnlock(); // make callback with event struct // In future, should find a way of mainting diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c index ec2511a..33594ac 100644 --- a/upnp/src/gena/gena_device.c +++ b/upnp/src/gena/gena_device.c @@ -62,19 +62,19 @@ genaUnregisterDevice( IN UpnpDevice_Handle device_handle ) { struct Handle_Info *handle_info; - HandleLock( ); + HandleLock(); if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__, - "genaUnregisterDevice : BAD Handle : %d\n", - device_handle ) ); + UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__, + "genaUnregisterDevice : BAD Handle : %d\n", + device_handle ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } freeServiceTable( &handle_info->ServiceTable ); - HandleUnlock( ); + HandleUnlock(); return UPNP_E_SUCCESS; } @@ -188,7 +188,7 @@ free_notify_struct( IN notify_thread_struct * input ) * * Note : called by genaNotify ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int notify_send_and_recv( IN uri_type * destination_url, IN membuffer * mid_msg, IN char *propertySet, @@ -203,12 +203,12 @@ notify_send_and_recv( IN uri_type * destination_url, SOCKINFO info; // connect - DBGONLY( UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, - "gena notify to: %.*s\n", - destination_url->hostport.text.size, - destination_url->hostport.text.buff ); ) + UpnpPrintf( UPNP_ALL, GENA, __FILE__, __LINE__, + "gena notify to: %.*s\n", + (int)destination_url->hostport.text.size, + destination_url->hostport.text.buff ); - conn_fd = http_Connect( destination_url, &url ); + conn_fd = http_Connect( destination_url, &url ); if( conn_fd < 0 ) { return conn_fd; // return UPNP error } @@ -365,12 +365,12 @@ genaNotifyThread( IN void *input ) struct Handle_Info *handle_info; ThreadPoolJob job; - HandleLock( ); + HandleLock(); //validate context if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) { free_notify_struct( in ); - HandleUnlock( ); + HandleUnlock(); return; } @@ -380,7 +380,7 @@ genaNotifyThread( IN void *input ) || ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL ) || ( ( copy_subscription( sub, &sub_copy ) != HTTP_SUCCESS ) ) ) { free_notify_struct( in ); - HandleUnlock( ); + HandleUnlock(); return; } //If the event is out of order push it back to the job queue @@ -392,22 +392,22 @@ genaNotifyThread( IN void *input ) ThreadPoolAdd( &gSendThreadPool, &job, NULL ); freeSubscription( &sub_copy ); - HandleUnlock( ); + HandleUnlock(); return; } - HandleUnlock( ); + HandleUnlock(); //send the notify return_code = genaNotify( in->headers, in->propertySet, &sub_copy ); freeSubscription( &sub_copy ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( in->device_handle, &handle_info ) != HND_DEVICE ) { free_notify_struct( in ); - HandleUnlock( ); + HandleUnlock(); return; } //validate context @@ -416,7 +416,7 @@ genaNotifyThread( IN void *input ) || ( !service->active ) || ( ( sub = GetSubscriptionSID( in->sid, service ) ) == NULL ) ) { free_notify_struct( in ); - HandleUnlock( ); + HandleUnlock(); return; } @@ -430,7 +430,7 @@ genaNotifyThread( IN void *input ) } free_notify_struct( in ); - HandleUnlock( ); + HandleUnlock(); } /**************************************************************************** @@ -477,8 +477,8 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, notify_thread_struct *thread_struct = NULL; - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA BEGIN INITIAL NOTIFY " ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN INITIAL NOTIFY " ); reference_count = ( int * )malloc( sizeof( int ) ); @@ -504,13 +504,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, strcpy( UDN_copy, UDN ); strcpy( servId_copy, servId ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } @@ -519,26 +519,25 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SERVICE; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ", - UDN, servId ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ", + UDN, servId ); if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) || ( sub->active ) ) { free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SID; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ", - sid ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ", sid ); sub->active = 1; @@ -549,13 +548,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return return_code; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n", - propertySet ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n", + propertySet ); headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + @@ -569,12 +568,12 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( servId_copy ); free( reference_count ); - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: " - "%zd\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", + "%"PRIzu"\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", strlen( propertySet ) + 1 ); //schedule thread for initial notification @@ -621,7 +620,7 @@ genaInitNotify( IN UpnpDevice_Handle device_handle, free( headers ); } - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -668,8 +667,8 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, notify_thread_struct *thread_struct = NULL; - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA BEGIN INITIAL NOTIFY EXT" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN INITIAL NOTIFY EXT" ); reference_count = ( int * )malloc( sizeof( int ) ); if( reference_count == NULL ) { @@ -694,13 +693,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, strcpy( UDN_copy, UDN ); strcpy( servId_copy, servId ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_HANDLE; } @@ -709,24 +708,23 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SERVICE; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n", - UDN, servId ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n", + UDN, servId ); if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) || ( sub->active ) ) { free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return GENA_E_BAD_SID; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", - sid ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", sid ); sub->active = 1; @@ -735,13 +733,13 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( reference_count ); free( servId_copy ); - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_PARAM; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENERATED PROPERY SET IN INIT EXT NOTIFY: %s", - propertySet ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN INIT EXT NOTIFY: %s", + propertySet ); headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + @@ -754,7 +752,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, free( servId_copy ); free( reference_count ); ixmlFreeDOMString( propertySet ); - HandleUnlock( ); + HandleUnlock(); return UPNP_E_OUTOF_MEMORY; } @@ -804,7 +802,7 @@ genaInitNotifyExt( IN UpnpDevice_Handle device_handle, free( thread_struct ); free( headers ); } - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -899,7 +897,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle, "%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", (long) strlen( propertySet ) + 1 ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) return_code = GENA_E_BAD_HANDLE; @@ -959,7 +957,7 @@ genaNotifyAllExt( IN UpnpDevice_Handle device_handle, free( servId_copy ); } - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -1061,7 +1059,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle, " upnp:event\r\nNTS: upnp:propchange\r\n", (long) strlen( propertySet ) + 1 ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { return_code = GENA_E_BAD_HANDLE; @@ -1123,7 +1121,7 @@ genaNotifyAll( IN UpnpDevice_Handle device_handle, free( UDN_copy ); free( servId_copy ); } - HandleUnlock( ); + HandleUnlock(); return return_code; } @@ -1317,8 +1315,8 @@ gena_process_subscription_request( IN SOCKINFO * info, memptr callback_hdr; memptr timeout_hdr; - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "Subscription Request Received:\n" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "Subscription Request Received:\n" ); if( httpmsg_find_hdr( request, HDR_NT, &nt_hdr ) == NULL ) { error_respond( info, HTTP_BAD_REQUEST, request ); @@ -1347,18 +1345,17 @@ gena_process_subscription_request( IN SOCKINFO * info, return; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "SubscriptionRequest for event URL path: %s\n", - event_url_path ); - ) + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "SubscriptionRequest for event URL path: %s\n", + event_url_path ); - HandleLock( ); + HandleLock(); // CURRENTLY, ONLY ONE DEVICE if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) { free( event_url_path ); error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); - HandleUnlock( ); + HandleUnlock(); return; } service = FindServiceEventURLPath( &handle_info->ServiceTable, @@ -1367,28 +1364,28 @@ gena_process_subscription_request( IN SOCKINFO * info, if( service == NULL || !service->active ) { error_respond( info, HTTP_NOT_FOUND, request ); - HandleUnlock( ); + HandleUnlock(); return; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "Subscription Request: Number of Subscriptions already %d\n " - "Max Subscriptions allowed: %d\n", - service->TotalSubscriptions, - handle_info->MaxSubscriptions ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "Subscription Request: Number of Subscriptions already %d\n " + "Max Subscriptions allowed: %d\n", + service->TotalSubscriptions, + handle_info->MaxSubscriptions ); // too many subscriptions if( handle_info->MaxSubscriptions != -1 && service->TotalSubscriptions >= handle_info->MaxSubscriptions ) { error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); - HandleUnlock( ); + HandleUnlock(); return; } // generate new subscription sub = ( subscription * ) malloc( sizeof( subscription ) ); if( sub == NULL ) { error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); - HandleUnlock( ); + HandleUnlock(); return; } sub->eventKey = 0; @@ -1405,13 +1402,13 @@ gena_process_subscription_request( IN SOCKINFO * info, &sub->DeliveryURLs ) ) == 0 ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); freeSubscriptionList( sub ); - HandleUnlock( ); + HandleUnlock(); return; } if( return_code == UPNP_E_OUTOF_MEMORY ) { error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); freeSubscriptionList( sub ); - HandleUnlock( ); + HandleUnlock(); return; } // set the timeout @@ -1447,7 +1444,7 @@ gena_process_subscription_request( IN SOCKINFO * info, // respond OK if( respond_ok( info, time_out, sub, request ) != UPNP_E_SUCCESS ) { freeSubscriptionList( sub ); - HandleUnlock( ); + HandleUnlock(); return; } //add to subscription list @@ -1464,7 +1461,7 @@ gena_process_subscription_request( IN SOCKINFO * info, callback_fun = handle_info->Callback; cookie = handle_info->Cookie; - HandleUnlock( ); + HandleUnlock(); //make call back with request struct //in the future should find a way of mainting @@ -1527,7 +1524,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info, return; } - HandleLock( ); + HandleLock(); // CURRENTLY, ONLY SUPPORT ONE DEVICE if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) { @@ -1544,22 +1541,21 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info, !service->active || ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); - HandleUnlock( ); + HandleUnlock(); return; } - DBGONLY( UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "Renew request: Number of subscriptions already: %d\n " - "Max Subscriptions allowed:%d\n", - service->TotalSubscriptions, - handle_info->MaxSubscriptions ); - ) - // too many subscriptions - if( handle_info->MaxSubscriptions != -1 && + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "Renew request: Number of subscriptions already: %d\n " + "Max Subscriptions allowed:%d\n", + service->TotalSubscriptions, + handle_info->MaxSubscriptions ); + // too many subscriptions + if( handle_info->MaxSubscriptions != -1 && service->TotalSubscriptions > handle_info->MaxSubscriptions ) { error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); RemoveSubscriptionSID( sub->sid, service ); - HandleUnlock( ); + HandleUnlock(); return; } // set the timeout @@ -1598,7 +1594,7 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info, RemoveSubscriptionSID( sub->sid, service ); } - HandleUnlock( ); + HandleUnlock(); } /**************************************************************************** @@ -1651,13 +1647,13 @@ gena_process_unsubscribe_request( IN SOCKINFO * info, return; } - HandleLock( ); + HandleLock(); // CURRENTLY, ONLY SUPPORT ONE DEVICE if( GetDeviceHandleInfo( &device_handle, &handle_info ) != HND_DEVICE ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); membuffer_destroy( &event_url_path ); - HandleUnlock( ); + HandleUnlock(); return; } service = FindServiceEventURLPath( &handle_info->ServiceTable, @@ -1670,14 +1666,14 @@ gena_process_unsubscribe_request( IN SOCKINFO * info, //CheckSubscriptionSID(sid, service) == NULL ) { error_respond( info, HTTP_PRECONDITION_FAILED, request ); - HandleUnlock( ); + HandleUnlock(); return; } RemoveSubscriptionSID( sid, service ); error_respond( info, HTTP_OK, request ); // success - HandleUnlock( ); + HandleUnlock(); } #endif // INCLUDE_DEVICE_APIS diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 433a85b..d2c00e1 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -106,16 +106,16 @@ SetHTTPGetCallback( MiniServerCallback callback ) } /************************************************************************ -* Function : SetSoapCallback +* Function : SetSoapCallback * -* Parameters : -* MiniServerCallback callback ; - SOAP Callback to be invoked +* Parameters : +* MiniServerCallback callback ; - SOAP Callback to be invoked * -* Description : Set SOAP Callback +* Description : Set SOAP Callback * -* Return : void +* Return : void * -* Note : +* Note : ************************************************************************/ void SetSoapCallback( MiniServerCallback callback ) @@ -174,11 +174,9 @@ dispatch_request( IN SOCKINFO * info, case HTTPMETHOD_NOTIFY: case HTTPMETHOD_SUBSCRIBE: case HTTPMETHOD_UNSUBSCRIBE: - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "miniserver %d: got GENA msg\n", info->socket ); - ) - callback = gGenaCallback; + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "miniserver %d: got GENA msg\n", info->socket ); + callback = gGenaCallback; break; //HTTP server call @@ -217,7 +215,7 @@ dispatch_request( IN SOCKINFO * info, * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void handle_error( IN SOCKINFO * info, int http_error_code, int major, @@ -275,12 +273,10 @@ handle_request( void *args ) struct mserv_request_t *request = ( struct mserv_request_t * )args; int connfd = request->connfd; - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "miniserver %d: READING\n", connfd ); - ) - //parser_request_init( &parser ); ////LEAK_FIX_MK - hmsg = &parser.msg; + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "miniserver %d: READING\n", connfd ); + //parser_request_init( &parser ); ////LEAK_FIX_MK + hmsg = &parser.msg; if( sock_init_with_ip( &info, connfd, request->foreign_ip_addr, request->foreign_ip_port ) != UPNP_E_SUCCESS ) { @@ -295,12 +291,10 @@ handle_request( void *args ) goto error_handler; } - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "miniserver %d: PROCESSING...\n", connfd ); - ) - // dispatch - http_error_code = dispatch_request( &info, &parser ); + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "miniserver %d: PROCESSING...\n", connfd ); + // dispatch + http_error_code = dispatch_request( &info, &parser ); if( http_error_code != 0 ) { goto error_handler; } @@ -316,11 +310,9 @@ handle_request( void *args ) handle_error( &info, http_error_code, major, minor ); } - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "miniserver %d: COMPLETE\n", connfd ); - ) - sock_destroy( &info, SD_BOTH ); //should shutdown completely + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "miniserver %d: COMPLETE\n", connfd ); + sock_destroy( &info, SD_BOTH ); //should shutdown completely httpmsg_destroy( hmsg ); free( request ); @@ -341,7 +333,7 @@ handle_request( void *args ) * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void schedule_request_job( IN int connfd, IN struct sockaddr_in *clientAddr ) { @@ -352,11 +344,9 @@ schedule_request_job( IN int connfd, ( struct mserv_request_t * ) malloc( sizeof( struct mserv_request_t ) ); if( request == NULL ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "mserv %d: out of memory\n", connfd ); - ) - shutdown( request->connfd, SD_BOTH ); + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "mserv %d: out of memory\n", connfd ); + shutdown( request->connfd, SD_BOTH ); UpnpCloseSocket( connfd ); return; } @@ -369,11 +359,9 @@ schedule_request_job( IN int connfd, TPJobSetFreeFunction( &job, free_handle_request_arg ); TPJobSetPriority( &job, MED_PRIORITY ); - if( ThreadPoolAdd( &gRecvThreadPool, &job, NULL ) != 0 ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "mserv %d: cannot schedule request\n", connfd ); - ) + if( ThreadPoolAdd( &gMiniServerThreadPool, &job, NULL ) != 0 ) { + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "mserv %d: cannot schedule request\n", connfd ); free( request ); shutdown( connfd, SD_BOTH ); UpnpCloseSocket( connfd ); @@ -446,11 +434,9 @@ RunMiniServer( MiniServerSockArray * miniSock ) if( select( maxMiniSock, &rdSet, NULL, &expSet, NULL ) == UPNP_SOCKETERROR ) { - DBGONLY( UpnpPrintf - ( UPNP_CRITICAL, SSDP, __FILE__, __LINE__, - "Error in select call !!!\n" ); - ) - continue; + UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__, + "Error in select call !!!\n" ); + continue; } else { if( FD_ISSET( miniServSock, &rdSet ) ) { @@ -459,12 +445,10 @@ RunMiniServer( MiniServerSockArray * miniSock ) ( struct sockaddr * )&clientAddr, &clientLen ); if( connectHnd == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "miniserver: Error" - " in accepting connection\n" ); - ) - continue; + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "miniserver: Error" + " in accepting connection\n" ); + continue; } schedule_request_job( connectHnd, &clientAddr ); } @@ -489,24 +473,19 @@ RunMiniServer( MiniServerSockArray * miniSock ) &clientLen ); if( byteReceived > 0 ) { requestBuf[byteReceived] = '\0'; - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "Received response !!! %s From host %s \n", - requestBuf, - inet_ntoa( clientAddr.sin_addr ) ); - ) - DBGONLY( UpnpPrintf - ( UPNP_PACKET, MSERV, __FILE__, __LINE__, - "Received multicast packet: \n %s\n", - requestBuf ); - ) + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "Received response !!! %s From host %s \n", + requestBuf, inet_ntoa( clientAddr.sin_addr ) ); + UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__, + "Received multicast packet: \n %s\n", + requestBuf ); - if( NULL != strstr( requestBuf, "ShutDown" ) ) + if( NULL != strstr( requestBuf, "ShutDown" ) ) { break; + } } } } - } shutdown( miniServSock, SD_BOTH ); @@ -555,12 +534,10 @@ get_port( int sockfd ) } port = ntohs( sockinfo.sin_port ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, MSERV, __FILE__, __LINE__, - "sockfd = %d, .... port = %d\n", sockfd, port ); - ) + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "sockfd = %d, .... port = %d\n", sockfd, port ); - return port; + return port; } /************************************************************************ @@ -623,16 +600,10 @@ get_miniserver_sockets( MiniServerSockArray * out, //THIS MAY CAUSE TCP TO BECOME LESS RELIABLE //HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS - DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, - "mserv start: resuseaddr set\n" ); - ) - - sockError = setsockopt( listenfd, - SOL_SOCKET, - SO_REUSEADDR, - ( const char * )&reuseaddr_on, - sizeof( int ) - ); + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "mserv start: resuseaddr set\n" ); + sockError = setsockopt( listenfd, SOL_SOCKET, SO_REUSEADDR, + ( const char * )&reuseaddr_on, sizeof( int )); if( sockError == UPNP_SOCKETERROR ) { shutdown( listenfd, SD_BOTH ); UpnpCloseSocket( listenfd ); @@ -652,9 +623,9 @@ get_miniserver_sockets( MiniServerSockArray * out, ); if( sockError == UPNP_SOCKETERROR ) { #ifdef WIN32 - errCode = WSAGetLastError(); + errCode = WSAGetLastError(); #else - errCode = errno; + errCode = errno; #endif if( errno == EADDRINUSE ) errCode = 1; @@ -665,18 +636,16 @@ get_miniserver_sockets( MiniServerSockArray * out, } if( sockError == UPNP_SOCKETERROR ) { - DBGONLY( perror( "mserv start: bind failed" ); - ) - shutdown( listenfd, SD_BOTH ); + perror( "mserv start: bind failed" ); + shutdown( listenfd, SD_BOTH ); UpnpCloseSocket( listenfd ); return UPNP_E_SOCKET_BIND; // bind failed } - DBGONLY( UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, - "mserv start: bind success\n" ); - ) + UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__, + "mserv start: bind success\n" ); - success = listen( listenfd, SOMAXCONN ); + success = listen( listenfd, SOMAXCONN ); if( success == UPNP_SOCKETERROR ) { shutdown( listenfd, SD_BOTH ); UpnpCloseSocket( listenfd ); @@ -694,11 +663,10 @@ get_miniserver_sockets( MiniServerSockArray * out, if( ( miniServerStopSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - MSERV, __FILE__, __LINE__, - "Error in socket operation !!!\n" ); - ) - shutdown( listenfd, SD_BOTH ); + UpnpPrintf( UPNP_CRITICAL, + MSERV, __FILE__, __LINE__, + "Error in socket operation !!!\n" ); + shutdown( listenfd, SD_BOTH ); UpnpCloseSocket( listenfd ); return UPNP_E_OUTOF_SOCKET; } @@ -711,11 +679,10 @@ get_miniserver_sockets( MiniServerSockArray * out, if( bind( miniServerStopSock, ( struct sockaddr * )&serverAddr, sizeof( serverAddr ) ) == UPNP_SOCKETERROR ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - MSERV, __FILE__, __LINE__, - "Error in binding localhost!!!\n" ); - ) - shutdown( listenfd, SD_BOTH ); + UpnpPrintf( UPNP_CRITICAL, + MSERV, __FILE__, __LINE__, + "Error in binding localhost!!!\n" ); + shutdown( listenfd, SD_BOTH ); UpnpCloseSocket( listenfd ); shutdown( miniServerStopSock, SD_BOTH ); UpnpCloseSocket( miniServerStopSock ); @@ -805,7 +772,7 @@ StartMiniServer( unsigned short listen_port ) TPJobSetFreeFunction( &job, ( free_routine ) free ); - success = ThreadPoolAddPersistent( &gRecvThreadPool, &job, NULL ); + success = ThreadPoolAddPersistent( &gMiniServerThreadPool, &job, NULL ); if( success < 0 ) { shutdown( miniSocket->miniServerSock, SD_BOTH ); @@ -877,11 +844,9 @@ StopMiniServer( void ) sock = socket( AF_INET, SOCK_DGRAM, 0 ); if( sock == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" ); - ) - return 0; + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_SERVER:StopSSDPServer: Error in socket operation !!!\n" ); + return 0; } while( gMServState != MSERV_IDLE ) { diff --git a/upnp/src/genlib/net/http/httpparser.c b/upnp/src/genlib/net/http/httpparser.c index 20253c2..0351814 100644 --- a/upnp/src/genlib/net/http/httpparser.c +++ b/upnp/src/genlib/net/http/httpparser.c @@ -101,7 +101,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = { /***********************************************************************/ -/************* scanner **************/ +/************* scanner *************/ /***********************************************************************/ @@ -109,19 +109,19 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = { #define TOKCHAR_LF 0xA /************************************************************************ -* Function : scanner_init +* Function : scanner_init * -* Parameters : -* OUT scanner_t* scanner ; Scanner Object to be initialized -* IN membuffer* bufptr ; Buffer to be copied +* Parameters : +* OUT scanner_t* scanner ; Scanner Object to be initialized +* IN membuffer* bufptr ; Buffer to be copied * -* Description : Intialize scanner +* Description : Intialize scanner * -* Return : void ; +* Return : void ; * -* Note : +* Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void scanner_init( OUT scanner_t * scanner, IN membuffer * bufptr ) { @@ -131,72 +131,72 @@ scanner_init( OUT scanner_t * scanner, } /************************************************************************ -* Function : is_separator_char +* Function : is_separator_char * -* Parameters : -* IN char c ; character to be tested against used separator values +* Parameters : +* IN char c ; character to be tested against used separator values * -* Description : Finds the separator character. +* Description : Finds the separator character. * -* Return : xboolean ; +* Return : xboolean ; * -* Note : +* Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_separator_char( IN char c ) { return strchr( " \t()<>@,;:\\\"/[]?={}", c ) != NULL; } /************************************************************************ -* Function : is_identifier_char +* Function : is_identifier_char * -* Parameters : -* IN char c ; character to be tested for separator values +* Parameters : +* IN char c ; character to be tested for separator values * -* Description : Calls the function to indentify separator character +* Description : Calls the function to indentify separator character * -* Return : xboolean ; +* Return : xboolean ; * -* Note : +* Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_identifier_char( IN char c ) { return ( c >= 32 && c <= 126 ) && !is_separator_char( c ); } /************************************************************************ -* Function : is_control_char +* Function : is_control_char * -* Parameters : -* IN char c ; character to be tested for a control character +* Parameters : +* IN char c ; character to be tested for a control character * -* Description : Determines if the passed value is a control character +* Description : Determines if the passed value is a control character * -* Return : xboolean ; +* Return : xboolean ; * -* Note : +* Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_control_char( IN char c ) { return ( ( c >= 0 && c <= 31 ) || ( c == 127 ) ); } /************************************************************************ -* Function : is_qdtext_char +* Function : is_qdtext_char * -* Parameters : -* IN char cc ; character to be tested for CR/LF +* Parameters : +* IN char cc ; character to be tested for CR/LF * -* Description : Checks to see if the passed in value is CR/LF +* Description : Checks to see if the passed in value is CR/LF * -* Return : xboolean ; +* Return : xboolean ; * -* Note : +* Note : ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_qdtext_char( IN char cc ) { unsigned char c = ( unsigned char )cc; @@ -214,22 +214,22 @@ is_qdtext_char( IN char cc ) } /************************************************************************ -* Function : scanner_get_token +* Function : scanner_get_token * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object -* OUT memptr* token ; Token -* OUT token_type_t* tok_type ; Type of token +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object +* OUT memptr* token ; Token +* OUT token_type_t* tok_type ; Type of token * -* Description : reads next token from the input stream -* note: 0 and is used as a marker, and will not be valid in a quote +* Description : reads next token from the input stream +* note: 0 and is used as a marker, and will not be valid in a quote * -* Return : parse_status_t ; -* PARSE_OK -* PARSE_INCOMPLETE -- not enuf chars to get a token -* PARSE_FAILURE -- bad msg format +* Return : parse_status_t ; +* PARSE_OK +* PARSE_INCOMPLETE -- not enuf chars to get a token +* PARSE_FAILURE -- bad msg format * -* Note : +* Note : ************************************************************************/ static parse_status_t scanner_get_token( INOUT scanner_t * scanner, @@ -364,38 +364,40 @@ scanner_get_token( INOUT scanner_t * scanner, } /************************************************************************ -* Function : scanner_get_str +* Function : scanner_get_str * -* Parameters : -* IN scanner_t* scanner ; Scanner Object +* Parameters : +* IN scanner_t* scanner ; Scanner Object * -* Description : returns ptr to next char in string +* Description : returns ptr to next char in string * -* Return : char* ; +* Return : char* ; * -* Note : +* Note : ************************************************************************/ -static XINLINE char * +static UPNP_INLINE char * scanner_get_str( IN scanner_t * scanner ) { return scanner->msg->buf + scanner->cursor; } /************************************************************************ -* Function : scanner_pushback +* Function : scanner_pushback * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object -* IN size_t pushback_bytes ; Bytes to be moved back +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object +* IN size_t pushback_bytes ; Bytes to be moved back * -* Description : Move back by a certain number of bytes. -* This is used to put back one or more tokens back into the input +* Description : Move back by a certain number of bytes. +* This is used to put back one or more tokens back into the input * -* Return : void ; +* Return : void ; * -* Note : +* Note : ************************************************************************/ -static XINLINE void +#warning The only use of the function 'scanner_pushback()' in the code is commented out. +#warning 'scanner_pushback()' is a good candidate for removal. +static UPNP_INLINE void scanner_pushback( INOUT scanner_t * scanner, IN size_t pushback_bytes ) { @@ -404,34 +406,34 @@ scanner_pushback( INOUT scanner_t * scanner, /***********************************************************************/ -/************* end of scanner **************/ +/************* end of scanner **************/ /***********************************************************************/ /***********************************************************************/ -/************* parser **************/ +/************* parser **************/ /***********************************************************************/ /***********************************************************************/ -/************* http_message_t **************/ +/************* http_message_t **************/ /***********************************************************************/ /************************************************************************ -* Function : httpmsg_compare +* Function : httpmsg_compare * -* Parameters : -* void* param1 ; -* void* param2 ; +* Parameters : +* void* param1 ; +* void* param2 ; * -* Description : Compares name id in the http headers. +* Description : Compares name id in the http headers. * -* Return : int ; +* Return : int ; * -* Note : +* Note : ************************************************************************/ static int httpmsg_compare( void *param1, @@ -445,16 +447,16 @@ httpmsg_compare( void *param1, } /************************************************************************ -* Function : httpheader_free +* Function : httpheader_free * -* Parameters : -* void *msg ; +* Parameters : +* void *msg ; * -* Description : Free memory allocated for the http header +* Description : Free memory allocated for the http header * -* Return : void ; +* Return : void ; * -* Note : +* Note : ************************************************************************/ static void httpheader_free( void *msg ) @@ -467,16 +469,16 @@ httpheader_free( void *msg ) } /************************************************************************ -* Function : httpmsg_init +* Function : httpmsg_init * -* Parameters : -* INOUT http_message_t* msg ; HTTP Message Object +* Parameters : +* INOUT http_message_t* msg ; HTTP Message Object * -* Description : Initialize and allocate memory for http message +* Description : Initialize and allocate memory for http message * -* Return : void ; +* Return : void ; * -* Note : +* Note : ************************************************************************/ void httpmsg_init( INOUT http_message_t * msg ) @@ -490,16 +492,16 @@ httpmsg_init( INOUT http_message_t * msg ) } /************************************************************************ -* Function : httpmsg_destroy +* Function : httpmsg_destroy * -* Parameters : -* INOUT http_message_t* msg ; HTTP Message Object +* Parameters : +* INOUT http_message_t* msg ; HTTP Message Object * -* Description : Free memory allocated for the http message +* Description : Free memory allocated for the http message * -* Return : void ; +* Return : void ; * -* Note : +* Note : ************************************************************************/ void httpmsg_destroy( INOUT http_message_t * msg ) @@ -516,19 +518,19 @@ httpmsg_destroy( INOUT http_message_t * msg ) } /************************************************************************ -* Function : httpmsg_find_hdr_str +* Function : httpmsg_find_hdr_str * -* Parameters : -* IN http_message_t* msg ; HTTP Message Object -* IN const char* header_name ; Header name to be compared with +* Parameters : +* IN http_message_t* msg ; HTTP Message Object +* IN const char* header_name ; Header name to be compared with * -* Description : Compares the header name with the header names stored -* in the linked list of messages +* Description : Compares the header name with the header names stored +* in the linked list of messages * -* Return : http_header_t* - Pointer to a header on success; -* NULL on failure +* Return : http_header_t* - Pointer to a header on success; +* NULL on failure * -* Note : +* Note : ************************************************************************/ http_header_t * httpmsg_find_hdr_str( IN http_message_t * msg, @@ -553,19 +555,19 @@ httpmsg_find_hdr_str( IN http_message_t * msg, } /************************************************************************ -* Function : httpmsg_find_hdr +* Function : httpmsg_find_hdr * -* Parameters : -* IN http_message_t* msg ; HTTP Message Object -* IN int header_name_id ; Header Name ID to be compared with -* OUT memptr* value ; Buffer to get the ouput to. +* Parameters : +* IN http_message_t* msg ; HTTP Message Object +* IN int header_name_id ; Header Name ID to be compared with +* OUT memptr* value ; Buffer to get the ouput to. * -* Description : Finds header from a list, with the given 'name_id'. +* Description : Finds header from a list, with the given 'name_id'. * -* Return : http_header_t* - Pointer to a header on success; * -* NULL on failure +* Return : http_header_t* - Pointer to a header on success; +* NULL on failure * -* Note : +* Note : ************************************************************************/ http_header_t * httpmsg_find_hdr( IN http_message_t * msg, @@ -598,23 +600,23 @@ httpmsg_find_hdr( IN http_message_t * msg, /***********************************************************************/ -/************* http_parser_t **************/ +/************* http_parser_t **************/ /***********************************************************************/ /************************************************************************ -* Function : skip_blank_lines +* Function : skip_blank_lines * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object * -* Description : skips blank lines at the start of a msg. +* Description : skips blank lines at the start of a msg. * -* Return : int ; +* Return : int ; * -* Note : +* Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int skip_blank_lines( INOUT scanner_t * scanner ) { memptr token; @@ -637,21 +639,21 @@ skip_blank_lines( INOUT scanner_t * scanner ) } /************************************************************************ -* Function : skip_lws +* Function : skip_lws * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object * -* Description : skip linear whitespace. +* Description : skip linear whitespace. * -* Return : int ; -* PARSE_OK: (LWS)* removed from input -* PARSE_FAILURE: bad input -* PARSE_INCOMPLETE: incomplete input +* Return : int ; +* PARSE_OK: (LWS)* removed from input +* PARSE_FAILURE: bad input +* PARSE_INCOMPLETE: incomplete input * -* Note : +* Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int skip_lws( INOUT scanner_t * scanner ) { memptr token; @@ -690,23 +692,23 @@ skip_lws( INOUT scanner_t * scanner ) } /************************************************************************ -* Function : match_non_ws_string +* Function : match_non_ws_string * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object -* OUT memptr* str ; Buffer to get the scanner buffer contents. +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object +* OUT memptr* str ; Buffer to get the scanner buffer contents. * -* Description : Match a string without whitespace or CRLF (%S) +* Description : Match a string without whitespace or CRLF (%S) * -* Return : XINLINE parse_status_t ; -* PARSE_OK -* PARSE_NO_MATCH -* PARSE_FAILURE -* PARSE_INCOMPLETE +* Return : UPNP_INLINE parse_status_t ; +* PARSE_OK +* PARSE_NO_MATCH +* PARSE_FAILURE +* PARSE_INCOMPLETE * -* Note : +* Note : ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_non_ws_string( INOUT scanner_t * scanner, OUT memptr * str ) { @@ -754,25 +756,25 @@ match_non_ws_string( INOUT scanner_t * scanner, } /************************************************************************ -* Function : match_raw_value +* Function : match_raw_value * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object -* OUT memptr* raw_value ; Buffer to get the scanner buffer -* contents +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object +* OUT memptr* raw_value ; Buffer to get the scanner buffer +* contents * -* Description : Matches a raw value in a the input; value's length -* can be 0 or more. Whitespace after value is trimmed. On success, -* scanner points the CRLF that ended the value +* Description : Matches a raw value in a the input; value's length +* can be 0 or more. Whitespace after value is trimmed. On success, +* scanner points the CRLF that ended the value * -* Return : parse_status_t ; -* PARSE_OK -* PARSE_INCOMPLETE -* PARSE_FAILURE +* Return : parse_status_t ; +* PARSE_OK +* PARSE_INCOMPLETE +* PARSE_FAILURE * -* Note : +* Note : ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_raw_value( INOUT scanner_t * scanner, OUT memptr * raw_value ) { @@ -846,24 +848,24 @@ match_raw_value( INOUT scanner_t * scanner, /************************************************************************ * Function: match_int -* -* Parameters: -* INOUT scanner_t* scanner ; Scanner Object -* IN int base : Base of number in the string; -* valid values: 10 or 16 -* OUT int* value ; Number stored here -* -* Description: Matches an unsigned integer value in the input. The -* integer is returned in 'value'. Except for PARSE_OK result, the -* scanner's cursor is moved back to its original position on error. -* -* Returns: -* PARSE_OK -* PARSE_NO_MATCH -- got different kind of token -* PARSE_FAILURE -- bad input -* PARSE_INCOMPLETE +* +* Parameters: +* INOUT scanner_t* scanner ; Scanner Object +* IN int base : Base of number in the string; +* valid values: 10 or 16 +* OUT int* value ; Number stored here +* +* Description: Matches an unsigned integer value in the input. The +* integer is returned in 'value'. Except for PARSE_OK result, the +* scanner's cursor is moved back to its original position on error. +* +* Returns: +* PARSE_OK +* PARSE_NO_MATCH -- got different kind of token +* PARSE_FAILURE -- bad input +* PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +static UPNP_INLINE int match_int( INOUT scanner_t * scanner, IN int base, OUT int *value ) @@ -907,22 +909,22 @@ match_int( INOUT scanner_t * scanner, } /************************************************************************ -* Function: read_until_crlf -* -* Parameters: -* INOUT scanner_t* scanner ; Scanner Object -* OUT memptr* str ; Buffer to copy scanner buffer contents to -* +* Function: read_until_crlf +* +* Parameters: +* INOUT scanner_t* scanner ;Scanner Object +* OUT memptr* str ; Buffer to copy scanner buffer contents to +* * Description: Reads data until end of line; the crlf at the end of * line is not consumed. On error, scanner is not restored. On * success, 'str' points to a string that runs until eol -* -* Returns: -* PARSE_OK -* PARSE_FAILURE -* PARSE_INCOMPLETE +* +* Returns: +* PARSE_OK +* PARSE_FAILURE +* PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +static UPNP_INLINE int read_until_crlf( INOUT scanner_t * scanner, OUT memptr * str ) { @@ -951,19 +953,21 @@ read_until_crlf( INOUT scanner_t * scanner, } /************************************************************************ -* Function: skip_to_end_of_header -* -* Parameters: +* Function: skip_to_end_of_header +* +* Parameters: * INOUT scanner_t* scanner ; Scanner Object -* -* Description: Skip to end of header -* -* Returns: -* PARSE_OK -* PARSE_FAILURE -* PARSE_INCOMPLETE +* +* Description: Skip to end of header +* +* Returns: +* PARSE_OK +* PARSE_FAILURE +* PARSE_INCOMPLETE ************************************************************************/ -static XINLINE int +#warning There are currently no uses of the function 'skip_to_end_of_header()' in the code. +#warning 'skip_to_end_of_header()' is a good candidate for removal. +static UPNP_INLINE int skip_to_end_of_header( INOUT scanner_t * scanner ) { memptr dummy_raw_value; @@ -977,10 +981,10 @@ skip_to_end_of_header( INOUT scanner_t * scanner ) * Function: match_char * * Parameters: -* INOUT scanner_t* scanner ; Scanner Object -* IN char c ; Character to be compared with -* IN xboolean case_sensitive; Flag indicating whether comparison should -* be case sensitive +* INOUT scanner_t* scanner ; Scanner Object +* IN char c ; Character to be compared with +* IN xboolean case_sensitive; Flag indicating whether +* comparison should be case sensitive * * Description: Compares a character to the next char in the scanner; * on error, scanner chars are not restored @@ -990,7 +994,7 @@ skip_to_end_of_header( INOUT scanner_t * scanner ) * PARSE_NO_MATCH * PARSE_INCOMPLETE ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t match_char( INOUT scanner_t * scanner, IN char c, IN xboolean case_sensitive ) @@ -1045,24 +1049,24 @@ match_char( INOUT scanner_t * scanner, // PARSE_NO_MATCH -- input does not match pattern /************************************************************************ -* Function : vfmatch +* Function : vfmatch * -* Parameters : -* INOUT scanner_t* scanner ; Scanner Object -* IN const char* fmt ; Pattern Format -* va_list argp ; List of variable arguments +* Parameters : +* INOUT scanner_t* scanner ; Scanner Object +* IN const char* fmt ; Pattern Format +* va_list argp ; List of variable arguments * -* Description : Extracts variable parameters depending on the passed -* in format parameter. Parses data also based on the passed in -* format parameter. +* Description : Extracts variable parameters depending on the passed +* in format parameter. Parses data also based on the passed in +* format parameter. * -* Return : int ; -* PARSE_OK -* PARSE_INCOMPLETE -* PARSE_FAILURE - bad input -* PARSE_NO_MATCH - input does not match pattern +* Return : int ; +* PARSE_OK +* PARSE_INCOMPLETE +* PARSE_FAILURE - bad input +* PARSE_NO_MATCH - input does not match pattern * -* Note : +* Note : ************************************************************************/ static int vfmatch( INOUT scanner_t * scanner, @@ -1242,20 +1246,20 @@ vfmatch( INOUT scanner_t * scanner, } /************************************************************************ -* Function: match -* -* Parameters: -* INOUT scanner_t* scanner ; Scanner Object -* IN const char* fmt; Pattern format -* ... -* -* Description: matches a variable parameter list and takes necessary -* actions based on the data type specified. -* -* Returns: -* PARSE_OK -* PARSE_NO_MATCH -* PARSE_INCOMPLETE +* Function: match +* +* Parameters: +* INOUT scanner_t* scanner ; Scanner Object +* IN const char* fmt; Pattern format +* ... +* +* Description: matches a variable parameter list and takes necessary +* actions based on the data type specified. +* +* Returns: +* PARSE_OK +* PARSE_NO_MATCH +* PARSE_INCOMPLETE ************************************************************************/ static int match( INOUT scanner_t * scanner, @@ -1273,21 +1277,21 @@ match( INOUT scanner_t * scanner, } /************************************************************************ -* Function: matchstr -* -* Parameters: -* IN char *str ; String to be matched -* IN size_t slen ; Length of the string -* IN const char* fmt ; Pattern format -* ... -* -* Description: Matches a variable parameter list with a string -* and takes actions based on the data type specified. -* -* Returns: -* PARSE_OK -* PARSE_NO_MATCH -- failure to match pattern 'fmt' -* PARSE_FAILURE -- 'str' is bad input +* Function: matchstr +* +* Parameters: +* IN char *str ; String to be matched +* IN size_t slen ; Length of the string +* IN const char* fmt ; Pattern format +* ... +* +* Description: Matches a variable parameter list with a string +* and takes actions based on the data type specified. +* +* Returns: +* PARSE_OK +* PARSE_NO_MATCH -- failure to match pattern 'fmt' +* PARSE_FAILURE -- 'str' is bad input ************************************************************************/ int matchstr( IN char *str, @@ -1327,17 +1331,17 @@ matchstr( IN char *str, } /************************************************************************ -* Function: parser_init -* -* Parameters: +* Function: parser_init +* +* Parameters: * OUT http_parser_t* parser ; HTTP Parser object -* -* Description: Initializes the parser object. -* -* Returns: -* void +* +* Description: Initializes the parser object. +* +* Returns: +* void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void parser_init( OUT http_parser_t * parser ) { memset( parser, 0, sizeof( http_parser_t ) ); @@ -1351,17 +1355,17 @@ parser_init( OUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_requestline -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Get HTTP Method, URL location and version information. -* -* Returns: -* PARSE_OK -* PARSE_SUCCESS -* PARSE_FAILURE +* Function: parser_parse_requestline +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Get HTTP Method, URL location and version information. +* +* Returns: +* PARSE_OK +* PARSE_SUCCESS +* PARSE_FAILURE ************************************************************************/ static parse_status_t parser_parse_requestline( INOUT http_parser_t * parser ) @@ -1467,17 +1471,17 @@ parser_parse_requestline( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_responseline -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Get HTTP Method, URL location and version information. -* -* Returns: -* PARSE_OK -* PARSE_SUCCESS -* PARSE_FAILURE +* Function: parser_parse_responseline +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Get HTTP Method, URL location and version information. +* +* Returns: +* PARSE_OK +* PARSE_SUCCESS +* PARSE_FAILURE ************************************************************************/ parse_status_t parser_parse_responseline( INOUT http_parser_t * parser ) @@ -1564,17 +1568,17 @@ parser_parse_responseline( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_headers -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Get HTTP Method, URL location and version information. -* -* Returns: -* PARSE_OK -* PARSE_SUCCESS -* PARSE_FAILURE +* Function: parser_parse_headers +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Get HTTP Method, URL location and version information. +* +* Returns: +* PARSE_OK +* PARSE_SUCCESS +* PARSE_FAILURE ************************************************************************/ parse_status_t parser_parse_headers( INOUT http_parser_t * parser ) @@ -1860,19 +1864,19 @@ parser_parse_headers_old( INOUT http_parser_t * parser ) // ****************************** /************************************************************************ -* Function: parser_parse_entity_using_clen -* -* Parameters: +* Function: parser_parse_entity_using_clen +* +* Parameters: * INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: reads entity using content-length -* -* Returns: -* PARSE_INCOMPLETE -* PARSE_FAILURE -- entity length > content-length value -* PARSE_SUCCESS +* +* Description: reads entity using content-length +* +* Returns: +* PARSE_INCOMPLETE +* PARSE_FAILURE -- entity length > content-length value +* PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_entity_using_clen( INOUT http_parser_t * parser ) { //int entity_length; @@ -1907,19 +1911,19 @@ parser_parse_entity_using_clen( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_chunky_body -* -* Parameters: +* Function: parser_parse_chunky_body +* +* Parameters: * INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Read data in the chunks -* -* Returns: -* PARSE_INCOMPLETE -* PARSE_FAILURE -- entity length > content-length value -* PARSE_SUCCESS +* +* Description: Read data in the chunks +* +* Returns: +* PARSE_INCOMPLETE +* PARSE_FAILURE -- entity length > content-length value +* PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_body( INOUT http_parser_t * parser ) { parse_status_t status; @@ -1952,19 +1956,19 @@ parser_parse_chunky_body( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_chunky_headers -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Read headers at the end of the chunked entity -* -* Returns: -* PARSE_INCOMPLETE -* PARSE_FAILURE -- entity length > content-length value -* PARSE_SUCCESS +* Function: parser_parse_chunky_headers +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Read headers at the end of the chunked entity +* +* Returns: +* PARSE_INCOMPLETE +* PARSE_FAILURE -- entity length > content-length value +* PARSE_SUCCESS ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_headers( INOUT http_parser_t * parser ) { parse_status_t status; @@ -1991,20 +1995,20 @@ parser_parse_chunky_headers( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_chunky_entity -* -* Parameters: -* INOUT http_parser_t* parser - HTTP Parser Object -* -* Description: Read headers at the end of the chunked entity -* -* Returns: -* PARSE_INCOMPLETE -* PARSE_FAILURE -- entity length > content-length value -* PARSE_SUCCESS -* PARSE_CONTINUE_1 +* Function: parser_parse_chunky_entity +* +* Parameters: +* INOUT http_parser_t* parser - HTTP Parser Object +* +* Description: Read headers at the end of the chunked entity +* +* Returns: +* PARSE_INCOMPLETE +* PARSE_FAILURE -- entity length > content-length value +* PARSE_SUCCESS +* PARSE_CONTINUE_1 ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_chunky_entity( INOUT http_parser_t * parser ) { scanner_t *scanner = &parser->scanner; @@ -2020,10 +2024,9 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser ) status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy ); if( status != PARSE_OK ) { scanner->cursor = save_pos; - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "CHUNK COULD NOT BE PARSED\n" ); ) - return status; + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "CHUNK COULD NOT BE PARSED\n" ); + return status; } // remove chunk info just matched; just retain data membuffer_delete( &parser->msg.msg, save_pos, @@ -2046,17 +2049,17 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_entity_until_close -* -* Parameters: +* Function: parser_parse_entity_until_close +* +* Parameters: * INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Read headers at the end of the chunked entity -* -* Returns: -* PARSE_INCOMPLETE_ENTITY +* +* Description: Read headers at the end of the chunked entity +* +* Returns: +* PARSE_INCOMPLETE_ENTITY ************************************************************************/ -static XINLINE parse_status_t +static UPNP_INLINE parse_status_t parser_parse_entity_until_close( INOUT http_parser_t * parser ) { size_t cursor; @@ -2079,19 +2082,19 @@ parser_parse_entity_until_close( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_get_entity_read_method -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Determines method to read entity -* -* Returns: -* PARSE_OK -* PARSE_FAILURE -* PARSE_COMPLETE -- no more reading to do +* Function: parser_get_entity_read_method +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Determines method to read entity +* +* Returns: +* PARSE_OK +* PARSE_FAILURE +* PARSE_COMPLETE -- no more reading to do ************************************************************************/ -XINLINE parse_status_t +UPNP_INLINE parse_status_t parser_get_entity_read_method( INOUT http_parser_t * parser ) { http_message_t *hmsg = &parser->msg; @@ -2149,11 +2152,10 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) if( raw_find_str( &hdr_value, "chunked" ) >= 0 ) { // read method to use chunked transfer encoding parser->ent_position = ENTREAD_USING_CHUNKED; - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "Found Chunked Encoding ....\n" ); ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "Found Chunked Encoding ....\n" ); - return PARSE_CONTINUE_1; + return PARSE_CONTINUE_1; } } // * use content length @@ -2185,19 +2187,19 @@ parser_get_entity_read_method( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_parse_entity -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: Determines method to read entity -* -* Returns: -* PARSE_OK -* PARSE_FAILURE -* PARSE_COMPLETE -- no more reading to do +* Function: parser_parse_entity +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: Determines method to read entity +* +* Returns: +* PARSE_OK +* PARSE_FAILURE +* PARSE_COMPLETE -- no more reading to do ************************************************************************/ -XINLINE parse_status_t +UPNP_INLINE parse_status_t parser_parse_entity( INOUT http_parser_t * parser ) { parse_status_t status = PARSE_OK; @@ -2240,15 +2242,15 @@ parser_parse_entity( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_request_init -* -* Parameters: -* OUT http_parser_t* parser ; HTTP Parser object -* -* Description: Initializes parser object for a request -* -* Returns: -* void +* Function: parser_request_init +* +* Parameters: +* OUT http_parser_t* parser ; HTTP Parser object +* +* Description: Initializes parser object for a request +* +* Returns: +* void ************************************************************************/ void parser_request_init( OUT http_parser_t * parser ) @@ -2259,16 +2261,16 @@ parser_request_init( OUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_response_init -* -* Parameters: -* OUT http_parser_t* parser ; HTTP Parser object -* IN http_method_t request_method ; Request method -* -* Description: Initializes parser object for a response -* -* Returns: -* void +* Function: parser_response_init +* +* Parameters: +* OUT http_parser_t* parser ; HTTP Parser object +* IN http_method_t request_method ; Request method +* +* Description: Initializes parser object for a response +* +* Returns: +* void ************************************************************************/ void parser_response_init( OUT http_parser_t * parser, @@ -2281,16 +2283,16 @@ parser_response_init( OUT http_parser_t * parser, } /************************************************************************ -* Function: parser_parse -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser object -* -* Description: The parser function. Depending on the position of the -* parser object the actual parsing function is invoked -* -* Returns: -* void +* Function: parser_parse +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser object +* +* Description: The parser function. Depending on the position of the +* parser object the actual parsing function is invoked +* +* Returns: +* void ************************************************************************/ parse_status_t parser_parse( INOUT http_parser_t * parser ) @@ -2337,19 +2339,19 @@ parser_parse( INOUT http_parser_t * parser ) } /************************************************************************ -* Function: parser_append -* -* Parameters: -* INOUT http_parser_t* parser ; HTTP Parser Object -* IN const char* buf ; buffer to be appended to the parser -* buffer -* IN size_t buf_length ; Size of the buffer -* -* Description: The parser function. Depending on the position of the -* parser object the actual parsing function is invoked -* -* Returns: -* void +* Function: parser_append +* +* Parameters: +* INOUT http_parser_t* parser ; HTTP Parser Object +* IN const char* buf ; buffer to be appended to the parser +* buffer +* IN size_t buf_length ; Size of the buffer +* +* Description: The parser function. Depending on the position of the +* parser object the actual parsing function is invoked +* +* Returns: +* void ************************************************************************/ parse_status_t parser_append( INOUT http_parser_t * parser, @@ -2373,20 +2375,20 @@ parser_append( INOUT http_parser_t * parser, } /************************************************************************ -********** end of parser *********** +********** end of parser *********** ************************************************************************/ /************************************************************************ -* Function: raw_to_int -* -* Parameters: -* IN memptr* raw_value ; Buffer to be converted -* IN int base ; Base to use for conversion -* -* Description: Converts raw character data to long-integer value -* -* Returns: -* int +* Function: raw_to_int +* +* Parameters: +* IN memptr* raw_value ; Buffer to be converted +* IN int base ; Base to use for conversion +* +* Description: Converts raw character data to long-integer value +* +* Returns: +* int ************************************************************************/ int raw_to_int( IN memptr * raw_value, @@ -2414,50 +2416,63 @@ raw_to_int( IN memptr * raw_value, } /************************************************************************ -* Function: raw_find_str -* -* Parameters: -* IN memptr* raw_value ; Buffer containg the string -* IN const char* str ; Substring to be found -* -* Description: Find a substring from raw character string buffer -* -* Returns: +* Function: raw_find_str +* +* Parameters: +* IN memptr* raw_value ; Buffer containg the string +* IN const char* str ; Substring to be found +* +* Description: Find a substring from raw character string buffer +* +* Side effects: raw_value is transformed to lowercase. +* +* Returns: * int - index at which the substring is found. ************************************************************************/ int -raw_find_str( IN memptr * raw_value, +raw_find_str( IN memptr *raw_value, IN const char *str ) { char c; char *ptr; + int i = 0; - c = raw_value->buf[raw_value->length]; // save - raw_value->buf[raw_value->length] = 0; // null-terminate + // save + c = raw_value->buf[raw_value->length]; - // Use strcasestr because the string may not always be exact case - ptr = strcasestr( raw_value->buf, str ); + // Make it lowercase + for (i = 0; raw_value->buf[i]; ++i) { + raw_value->buf[i] = tolower(raw_value->buf[i]); + } - raw_value->buf[raw_value->length] = c; // restore + // null-terminate + raw_value->buf[raw_value->length] = 0; + + // Find the substring position + ptr = strstr( raw_value->buf, str ); + + // restore the "length" byte + raw_value->buf[raw_value->length] = c; if( ptr == 0 ) { return -1; } - return ptr - raw_value->buf; // return index + // return index + return ptr - raw_value->buf; } /************************************************************************ -* Function: method_to_str -* -* Parameters: -* IN http_method_t method ; HTTP method -* -* Description: A wrapper function that maps a method id to a method -* nameConverts a http_method id stored in the HTTP Method -* -* Returns: -* const char* ptr - Ptr to the HTTP Method * +* Function: method_to_str +* +* Parameters: +* IN http_method_t method ; HTTP method +* +* Description: A wrapper function that maps a method id to a method +* nameConverts a http_method id stored in the HTTP Method +* +* Returns: +* const char* ptr - Ptr to the HTTP Method ************************************************************************/ const char * method_to_str( IN http_method_t method ) @@ -2472,50 +2487,48 @@ method_to_str( IN http_method_t method ) } /************************************************************************ -* Function: print_http_headers -* -* Parameters: -* http_message_t* hmsg ; HTTP Message object -* -* Description: -* -* Returns: -* void +* Function: print_http_headers +* +* Parameters: +* http_message_t* hmsg ; HTTP Message object +* +* Description: +* +* Returns: +* void ************************************************************************/ +#ifdef DEBUG void print_http_headers( http_message_t * hmsg ) { - ListNode *node; - - //NNS: dlist_node *node; + // NNS: dlist_node *node; http_header_t *header; // print start line if( hmsg->is_request ) { - //printf( "method = %d, version = %d.%d, url = %.*s\n", - // hmsg->method, hmsg->major_version, hmsg->minor_version, - // hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff); + printf( "method = %d, version = %d.%d, url = %.*s\n", + hmsg->method, hmsg->major_version, hmsg->minor_version, + (int)hmsg->uri.pathquery.size, hmsg->uri.pathquery.buff); } else { - // printf( "resp status = %d, version = %d.%d, status msg = %.*s\n", - // hmsg->status_code, hmsg->major_version, hmsg->minor_version, - // (int)hmsg->status_msg.length, hmsg->status_msg.buf); + printf( "resp status = %d, version = %d.%d, status msg = %.*s\n", + hmsg->status_code, hmsg->major_version, hmsg->minor_version, + (int)hmsg->status_msg.length, hmsg->status_msg.buf); } // print headers - node = ListHead( &hmsg->headers ); - //NNS: node = dlist_first_node( &hmsg->headers ); + // NNS: node = dlist_first_node( &hmsg->headers ); while( node != NULL ) { - header = ( http_header_t * ) node->item; - //NNS: header = (http_header_t *)node->data; - //printf( "hdr name: %.*s, value: %.*s\n", - // (int)header->name.length, header->name.buf, - // (int)header->value.length, header->value.buf ); + // NNS: header = (http_header_t *)node->data; + printf( "hdr name: %.*s, value: %.*s\n", + (int)header->name.length, header->name.buf, + (int)header->value.length, header->value.buf ); node = ListNext( &hmsg->headers, node ); - - //NNS: node = dlist_next( &hmsg->headers, node ); + // NNS: node = dlist_next( &hmsg->headers, node ); } } +#endif + diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 421e5f3..d144441 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -40,25 +40,25 @@ #include #include #ifndef UPNP_USE_BCBPP -#ifndef UPNP_USE_MSVCPP - #include - #include -#endif + #ifndef UPNP_USE_MSVCPP + #include + #include + #endif #endif #ifndef WIN32 - #include - #include - #include - #include - #include - #include - #include - #include - #include + #include + #include + #include + #include + #include + #include + #include + #include + #include #else - #include - #include + #include + #include #endif #include "unixutil.h" #include "upnp.h" @@ -74,17 +74,17 @@ #define DOSOCKET_WRITE 0 /************************************************************************ -* Function: http_FixUrl -* -* Parameters: -* IN uri_type* url ; URL to be validated and fixed +* Function: http_FixUrl +* +* Parameters: +* IN uri_type* url ; URL to be validated and fixed * OUT uri_type* fixed_url ; URL after being fixed. -* -* Description: Validates URL -* -* Returns: -* UPNP_E_INVALID_URL -* UPNP_E_SUCCESS +* +* Description: Validates URL +* +* Returns: +* UPNP_E_INVALID_URL +* UPNP_E_SUCCESS ************************************************************************/ int http_FixUrl( IN uri_type * url, @@ -111,18 +111,18 @@ http_FixUrl( IN uri_type * url, } /************************************************************************ -* Function: http_FixStrUrl -* -* Parameters: -* IN char* urlstr ; Character string as a URL -* IN int urlstrlen ; Length of the character string +* Function: http_FixStrUrl +* +* Parameters: +* IN char* urlstr ; Character string as a URL +* IN int urlstrlen ; Length of the character string * OUT uri_type* fixed_url ; Fixed and corrected URL -* -* Description: Parses URL and then validates URL -* -* Returns: -* UPNP_E_INVALID_URL -* UPNP_E_SUCCESS +* +* Description: Parses URL and then validates URL +* +* Returns: +* UPNP_E_INVALID_URL +* UPNP_E_SUCCESS ************************************************************************/ int http_FixStrUrl( IN char *urlstr, @@ -139,18 +139,18 @@ http_FixStrUrl( IN char *urlstr, } /************************************************************************ -* Function: http_Connect -* -* Parameters: -* IN uri_type* destination_url ; URL containing destination information -* OUT uri_type *url ; Fixed and corrected URL -* +* Function: http_Connect +* +* Parameters: +* IN uri_type* destination_url ; URL containing destination information +* OUT uri_type *url ; Fixed and corrected URL +* * Description: Gets destination address from URL and then connects to the * remote end -* -* Returns: -* socket descriptor on sucess -* UPNP_E_OUTOF_SOCKET +* +* Returns: +* socket descriptor on sucess +* UPNP_E_OUTOF_SOCKET * UPNP_E_SOCKET_CONNECT on error ************************************************************************/ int @@ -169,10 +169,8 @@ http_Connect( IN uri_type * destination_url, if( connect( connfd, ( struct sockaddr * )&url->hostport.IPv4address, sizeof( struct sockaddr_in ) ) == -1 ) { #ifdef WIN32 - DBGONLY( - UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__, - "connect error: %d\n", WSAGetLastError()); - ) + UpnpPrintf(UPNP_CRITICAL, HTTP, __FILE__, __LINE__, + "connect error: %d\n", WSAGetLastError()); #endif shutdown( connfd, SD_BOTH ); UpnpCloseSocket( connfd ); @@ -183,23 +181,23 @@ http_Connect( IN uri_type * destination_url, } /************************************************************************ -* Function: http_RecvMessage -* -* Parameters: -* IN SOCKINFO *info ; Socket information object -* OUT http_parser_t* parser, HTTP parser object -* IN http_method_t request_method ; HTTP request method -* IN OUT int* timeout_secs ; time out -* OUT int* http_error_code ; HTTP error code returned -* +* Function: http_RecvMessage +* +* Parameters: +* IN SOCKINFO *info ; Socket information object +* OUT http_parser_t* parser, HTTP parser object +* IN http_method_t request_method ; HTTP request method +* IN OUT int* timeout_secs ; time out +* OUT int* http_error_code ; HTTP error code returned +* * Description: 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 +* +* Returns: +* UPNP_E_BAD_HTTPMSG +* UPNP_E_SUCCESS ************************************************************************/ int http_RecvMessage( IN SOCKINFO * info, @@ -226,12 +224,10 @@ http_RecvMessage( IN SOCKINFO * info, status = parser_append( parser, buf, num_read ); if( status == PARSE_SUCCESS ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "<<< (RECVD) <<<\n%s\n-----------------\n", - parser->msg.msg.buf ); - //print_http_headers( &parser->msg ); - ) + 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 ) { @@ -252,12 +248,10 @@ http_RecvMessage( IN SOCKINFO * info, } } else if( num_read == 0 ) { if( ok_on_close ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "<<< (RECVD) <<<\n%s\n-----------------\n", - parser->msg.msg.buf ); - //print_http_headers( &parser->msg ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "<<< (RECVD) <<<\n%s\n-----------------\n", + parser->msg.msg.buf ); + print_http_headers( &parser->msg ); return 0; } else { @@ -273,29 +267,29 @@ http_RecvMessage( IN SOCKINFO * info, } /************************************************************************ -* Function: http_SendMessage -* -* Parameters: +* Function: http_SendMessage +* +* Parameters: * IN SOCKINFO *info ; Socket information object -* IN OUT int * TimeOut ; time out value -* IN const char* fmt, ... Pattern format to take actions upon -* -* Description: Sends a message to the destination based on the -* IN const char* fmt parameter -* fmt types: -* 'f': arg = const char * file name -* 'm': arg1 = const char * mem_buffer; arg2= size_t buf_length -* E.g.: -* char *buf = "POST /xyz.cgi http/1.1\r\n\r\n"; -* char *filename = "foo.dat"; -* int status = http_SendMessage( tcpsock, "mf", -* buf, strlen(buf), // args for memory buffer -* filename ); // arg for file -* -* Returns: -* UPNP_E_OUTOF_MEMORY -* UPNP_E_FILE_READ_ERROR -* UPNP_E_SUCCESS +* IN OUT int * TimeOut ; time out value +* IN const char* fmt, ... Pattern format to take actions upon +* +* Description: Sends a message to the destination based on the +* IN const char* fmt parameter +* fmt types: +* 'f': arg = const char * file name +* 'm': arg1 = const char * mem_buffer; arg2= size_t buf_length +* E.g.: +* char *buf = "POST /xyz.cgi http/1.1\r\n\r\n"; +* char *filename = "foo.dat"; +* int status = http_SendMessage( tcpsock, "mf", +* buf, strlen(buf), // args for memory buffer +* filename ); // arg for file +* +* Returns: +* UPNP_E_OUTOF_MEMORY +* UPNP_E_FILE_READ_ERROR +* UPNP_E_SUCCESS ************************************************************************/ int http_SendMessage( IN SOCKINFO * info, @@ -455,11 +449,9 @@ http_SendMessage( IN SOCKINFO * info, num_written = sock_write( info, file_buf, num_read, TimeOut ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - ">>> (SENT) >>>\n%.*s\n------------\n", - ( int )num_written, file_buf ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + ">>> (SENT) >>>\n%.*s\n------------\n", + ( int )num_written, file_buf ); //Send error nothing we can do if( num_written != num_read ) { @@ -485,10 +477,9 @@ http_SendMessage( IN SOCKINFO * info, num_written = sock_write( info, buf, buf_length, TimeOut ); if( ( size_t ) num_written != buf_length ) goto end; - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - ">>> (SENT) >>>\n%.*s\n------------\n", - ( int )buf_length, buf ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + ">>> (SENT) >>>\n%.*s\n------------\n", + ( int )buf_length, buf ); } } } @@ -500,24 +491,24 @@ http_SendMessage( IN SOCKINFO * info, } /************************************************************************ -* Function: http_RequestAndResponse -* -* Parameters: -* IN uri_type* destination ; Destination URI object which contains -* remote IP address among other elements -* IN const char* request ; Request to be sent -* IN size_t request_length ; Length of the request +* Function: http_RequestAndResponse +* +* Parameters: +* IN uri_type* destination ; Destination URI object which contains +* remote IP address among other elements +* IN const char* request ; Request to be sent +* IN size_t request_length ; Length of the request * IN http_method_t req_method ; HTTP Request method -* IN int timeout_secs ; time out value -* OUT http_parser_t* response ; Parser object to receive the repsonse -* -* Description: Initiates socket, connects to the destination, sends a -* request and waits for the response from the remote end -* -* Returns: -* UPNP_E_SOCKET_ERROR -* UPNP_E_SOCKET_CONNECT -* Error Codes returned by http_SendMessage +* IN int timeout_secs ; time out value +* OUT http_parser_t* response; Parser object to receive the repsonse +* +* Description: Initiates socket, connects to the destination, sends a +* request and waits for the response from the remote end +* +* Returns: +* UPNP_E_SOCKET_ERROR +* UPNP_E_SOCKET_CONNECT +* Error Codes returned by http_SendMessage * Error Codes returned by http_RecvMessage ************************************************************************/ int @@ -572,25 +563,24 @@ http_RequestAndResponse( IN uri_type * destination, } /************************************************************************ -* Function : http_Download +* Function : http_Download * -* Parameters : -* IN const char* url_str : String as a URL -* IN int timeout_secs : time out value -* OUT char** document : buffer to store the document extracted -* from the donloaded message. -* OUT int* doc_length : length of the extracted document -* OUT char* content_type : Type of content +* Parameters : +* IN const char* url_str: String as a URL +* IN int timeout_secs: time out value +* OUT char** document: buffer to store the document extracted +* from the donloaded message. +* OUT int* doc_length: length of the extracted document +* OUT char* content_type: Type of content * -* Description : Download the document message and extract the document +* Description : Download the document message and extract the document * from the message. * -* Return : int; -* UPNP_E_SUCCESS; -* UPNP_E_INVALID_URL; -* +* Return : int; +* UPNP_E_SUCCESS; +* UPNP_E_INVALID_URL; * -* Note : +* Note : ************************************************************************/ int http_Download( IN const char *url_str, @@ -601,10 +591,10 @@ http_Download( IN const char *url_str, { int ret_code; uri_type url; - char *msg_start, - *entity_start, - *hoststr, - *temp; + char *msg_start; + char *entity_start; + char *hoststr; + char *temp; http_parser_t response; size_t msg_length; size_t hostlen; @@ -614,11 +604,9 @@ http_Download( IN const char *url_str, char *urlPath = alloca( strlen( url_str ) + 1 ); //ret_code = parse_uri( (char*)url_str, strlen(url_str), &url ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n", - url_str ); - ) - ret_code = + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n", + url_str ); + ret_code = http_FixStrUrl( ( char * )url_str, strlen( url_str ), &url ); if( ret_code != UPNP_E_SUCCESS ) { return ret_code; @@ -641,32 +629,26 @@ http_Download( IN const char *url_str, *temp = '\0'; hostlen = strlen( hoststr ); *temp = '/'; - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HOSTNAME : %s Length : %zu\n", hoststr, hostlen ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen ); - ret_code = http_MakeMessage( - &request, 1, 1, - "Q" "s" "bcDCUc", - HTTPMETHOD_GET, url.pathquery.buff, url.pathquery.size, - "HOST: ", - hoststr, hostlen ); + ret_code = http_MakeMessage( + &request, 1, 1, + "Q" "s" "bcDCUc", + HTTPMETHOD_GET, url.pathquery.buff, url.pathquery.size, + "HOST: ", + hoststr, hostlen ); if( ret_code != 0 ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Makemessage failed\n" ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Makemessage failed\n" ); membuffer_destroy( &request ); return ret_code; } - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Buffer:\n %s\n----------END--------\n", request.buf ); - ) - // get doc msg - ret_code = + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Buffer:\n %s\n----------END--------\n", request.buf ); + // get doc msg + ret_code = http_RequestAndResponse( &url, request.buf, request.length, HTTPMETHOD_GET, timeout_secs, &response ); @@ -676,11 +658,8 @@ http_Download( IN const char *url_str, return ret_code; } - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, "Response\n" ); - ) - DBGONLY( print_http_headers( &response.msg ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "Response\n" ); + print_http_headers( &response.msg ); // optional content-type if( content_type ) { @@ -771,13 +750,10 @@ MakePostMessage( const char *url_str, char *hoststr, *temp; - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, "DOWNLOAD URL : %s\n", url_str ); - ) - - ret_code = + ret_code = http_FixStrUrl( ( char * )url_str, strlen( url_str ), url ); - if( ret_code != UPNP_E_SUCCESS ) { return ret_code; } @@ -799,9 +775,8 @@ MakePostMessage( const char *url_str, *temp = '\0'; hostlen = strlen( hoststr ); *temp = '/'; - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HOSTNAME : %s Length : %zd\n", hoststr, hostlen ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen ); if( contentLength >= 0 ) { ret_code = http_MakeMessage( @@ -833,19 +808,18 @@ MakePostMessage( const char *url_str, } if( ret_code != 0 ) { - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Makemessage failed\n" ); - ) - membuffer_destroy( request ); + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Makemessage failed\n" ); + membuffer_destroy( request ); + return ret_code; } - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Buffer:\n %s\n" "----------END--------\n", - request->buf ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Buffer:\n %s\n" "----------END--------\n", + request->buf ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /************************************************************************ @@ -1108,11 +1082,10 @@ MakeGetMessage( const char *url_str, char *hoststr, *temp; - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "DOWNLOAD URL : %s\n", url_str ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "DOWNLOAD URL : %s\n", url_str ); - ret_code = + ret_code = http_FixStrUrl( ( char * )url_str, strlen( url_str ), url ); if( ret_code != UPNP_E_SUCCESS ) { @@ -1136,9 +1109,8 @@ MakeGetMessage( const char *url_str, *temp = '\0'; hostlen = strlen( hoststr ); *temp = '/'; - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HOSTNAME : %s Length : %zd\n", hoststr, hostlen ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HOSTNAME : %s Length : %"PRIzu"\n", hoststr, hostlen ); if( proxy_str ) { querystr = url_str; @@ -1156,19 +1128,18 @@ MakeGetMessage( const char *url_str, hoststr, hostlen ); if( ret_code != 0 ) { - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Makemessage failed\n" ); - ) - membuffer_destroy( request ); + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Makemessage failed\n" ); + membuffer_destroy( request ); + return ret_code; } - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Buffer:\n %s\n" "----------END--------\n", - request->buf ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Buffer:\n %s\n" "----------END--------\n", + request->buf ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /************************************************************************ @@ -1297,25 +1268,25 @@ ReadResponseLineAndHeaders( IN SOCKINFO * info, } /************************************************************************ -* Function : http_ReadHttpGet +* Function : http_ReadHttpGet * -* Parameters : -* IN void *Handle : Handle to the HTTP get object -* IN OUT char *buf : Buffer to get the read and parsed data -* IN OUT unsigned int *size : Size of the buffer passed -* IN int timeout : time out value +* Parameters : +* IN void *Handle : Handle to the HTTP get object +* IN OUT char *buf : Buffer to get the read and parsed data +* IN OUT unsigned int *size : Size of the buffer passed +* IN int timeout : time out value * -* Description : Parses already existing data, then gets new data. +* Description : Parses already existing data, then gets new data. * Parses and extracts information from the new data. * -* Return : int ; -* UPNP_E_SUCCESS - On Sucess ; -* UPNP_E_INVALID_PARAM - Invalid Parameter; -* UPNP_E_BAD_RESPONSE ; -* UPNP_E_BAD_HTTPMSG ; -* UPNP_E_CANCELED ; +* Return : int ; +* UPNP_E_SUCCESS - On Sucess ; +* UPNP_E_INVALID_PARAM - Invalid Parameter; +* UPNP_E_BAD_RESPONSE ; +* UPNP_E_BAD_HTTPMSG ; +* UPNP_E_CANCELED ; * -* Note : +* Note : ************************************************************************/ int http_ReadHttpGet( IN void *Handle, @@ -1386,11 +1357,9 @@ http_ReadHttpGet( IN void *Handle, } } else if( num_read == 0 ) { if( ok_on_close ) { - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "<<< (RECVD) <<<\n%s\n-----------------\n", - handle->response.msg.msg.buf ); - //print_http_headers( &parser->msg ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "<<< (RECVD) <<<\n%s\n-----------------\n", + handle->response.msg.msg.buf ); handle->response.position = POS_COMPLETE; } else { // partial msg @@ -1850,31 +1819,26 @@ http_MakeMessage( INOUT membuffer * buf, va_start( argp, fmt ); while( ( c = *fmt++ ) != 0 ) { - - if( c == 's' ) // C string - { + if( c == 's' ) { + // C string s = ( char * )va_arg( argp, char * ); - assert( s ); - - //DBGONLY(UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a string : %s\n", s);) + UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a string : %s\n", s); if( membuffer_append( buf, s, strlen( s ) ) != 0 ) { goto error_handler; } - } else if( c == 'K' ) // Add Chunky header - { + } else if( c == 'K' ) { + // Add Chunky header if( membuffer_append ( buf, "TRANSFER-ENCODING: chunked\r\n", strlen( "Transfer-Encoding: chunked\r\n" ) ) != 0 ) { goto error_handler; } - } else if( c == 'G' ) // Add Range header - { + } else if( c == 'G' ) { + // Add Range header struct SendInstruction *RespInstr; - RespInstr = - ( struct SendInstruction * )va_arg( argp, - struct SendInstruction - * ); + RespInstr = (struct SendInstruction *) + va_arg( argp, struct SendInstruction *); assert( RespInstr ); // connection header if( membuffer_append @@ -1882,38 +1846,34 @@ http_MakeMessage( INOUT membuffer * buf, strlen( RespInstr->RangeHeader ) ) != 0 ) { goto error_handler; } - - } else if( c == 'b' ) // mem buffer - { + } else if( c == 'b' ) { + // mem buffer s = ( char * )va_arg( argp, char * ); - //DBGONLY(UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__,"Adding a char Buffer starting with: %c\n", s[0]);) + UpnpPrintf(UPNP_ALL,HTTP,__FILE__,__LINE__, + "Adding a char Buffer starting with: %c\n", s[0]); assert( s ); length = ( size_t ) va_arg( argp, size_t ); if( membuffer_append( buf, s, length ) != 0 ) { goto error_handler; } } - - else if( c == 'c' ) // crlf - { + else if( c == 'c' ) { + // crlf if( membuffer_append( buf, "\r\n", 2 ) != 0 ) { goto error_handler; } } - - else if( c == 'd' ) // integer - { + else if( c == 'd' ) { + // integer num = ( int )va_arg( argp, int ); - - sprintf( tempbuf, "%zu", num ); + sprintf( tempbuf, "%"PRIzu, num ); if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) { goto error_handler; } } - - else if( c == 'h' ) // off_t - { + else if( c == 'h' ) { + // off_t bignum = ( off_t )va_arg( argp, off_t ); sprintf( tempbuf, "%"PRId64, (int64_t)bignum ); @@ -1921,9 +1881,8 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } - - else if( c == 't' || c == 'D' ) // date - { + else if( c == 't' || c == 'D' ) { + // date if( c == 'D' ) { // header start_str = "DATE: "; @@ -1947,9 +1906,7 @@ http_MakeMessage( INOUT membuffer * buf, if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) { goto error_handler; } - } - - else if( c == 'C' ) { + } else if( c == 'C' ) { if( ( http_major_version > 1 ) || ( http_major_version == 1 && http_minor_version == 1 ) ) { @@ -1959,9 +1916,7 @@ http_MakeMessage( INOUT membuffer * buf, goto error_handler; } } - } - - else if( c == 'N' ) { + } else if( c == 'N' ) { // content-length header bignum = ( off_t )va_arg( argp, off_t ); @@ -1972,11 +1927,8 @@ http_MakeMessage( INOUT membuffer * buf, "CONTENT-LENGTH: ", bignum ) != 0 ) { goto error_handler; } - } - - else if( c == 'S' || c == 'U' ) { + } else if( c == 'S' || c == 'U' ) { // SERVER or USER-AGENT header - temp_str = ( c == 'S' ) ? "SERVER: " : "USER-AGENT: "; get_sdk_info( tempbuf ); if (http_MakeMessage( @@ -1985,34 +1937,25 @@ http_MakeMessage( INOUT membuffer * buf, temp_str, tempbuf ) != 0 ) { goto error_handler; } - } - - else if( c == 'X' ) // C string - { + } else if( c == 'X' ) { + // C string s = ( char * )va_arg( argp, char * ); - assert( s ); - if( membuffer_append_str( buf, "X-User-Agent: ") != 0 ) { goto error_handler; } if( membuffer_append( buf, s, strlen( s ) ) != 0 ) { goto error_handler; } - } - - else if( c == 'R' ) { + } else if( c == 'R' ) { // response start line // e.g.: 'HTTP/1.1 200 OK' // - // code status_code = ( int )va_arg( argp, int ); - assert( status_code > 0 ); sprintf( tempbuf, "HTTP/%d.%d %d ", http_major_version, http_minor_version, status_code ); - // str status_msg = http_get_code_text( status_code ); if (http_MakeMessage( @@ -2022,40 +1965,31 @@ http_MakeMessage( INOUT membuffer * buf, status_msg ) != 0 ) { goto error_handler; } - } - - else if( c == 'B' ) { + } else if( c == 'B' ) { // body of a simple reply // - status_code = ( int )va_arg( argp, int ); - sprintf( tempbuf, "%s%d %s%s", "

", status_code, http_get_code_text( status_code ), "

" ); bignum = strlen( tempbuf ); - if (http_MakeMessage( buf, http_major_version, http_minor_version, "NTcs", bignum, // content-length "text/html", // content-type - tempbuf ) != 0 ) // body - { + tempbuf ) != 0 // body + ) { goto error_handler; } - } - - else if( c == 'Q' ) { + } else if( c == 'Q' ) { // request start line // GET /foo/bar.html HTTP/1.1\r\n - method = ( http_method_t ) va_arg( argp, http_method_t ); method_str = method_to_str( method ); url_str = ( const char * )va_arg( argp, const char * ); num = ( size_t )va_arg( argp, size_t ); // length of url_str - if (http_MakeMessage( buf, http_major_version, http_minor_version, "ssbsdsdc", @@ -2064,20 +1998,15 @@ http_MakeMessage( INOUT membuffer * buf, " HTTP/", http_major_version, ".", http_minor_version ) != 0 ) { goto error_handler; } - } - - else if( c == 'q' ) { + } else if( c == 'q' ) { // request start line and HOST header - method = ( http_method_t ) va_arg( argp, http_method_t ); - uri_ptr = ( uri_type * ) va_arg( argp, uri_type * ); assert( uri_ptr ); if( http_FixUrl( uri_ptr, &url ) != 0 ) { error_code = UPNP_E_INVALID_URL; goto error_handler; } - if (http_MakeMessage( buf, http_major_version, http_minor_version, "Q" "sbc", @@ -2085,28 +2014,23 @@ http_MakeMessage( INOUT membuffer * buf, "HOST: ", url.hostport.text.buff, url.hostport.text.size ) != 0 ) { goto error_handler; } - } - - else if( c == 'T' ) { + } else if( c == 'T' ) { // content type header temp_str = ( const char * )va_arg( argp, const char * ); // type/subtype format - if (http_MakeMessage( buf, http_major_version, http_minor_version, "ssc", "CONTENT-TYPE: ", temp_str ) != 0 ) { goto error_handler; } - } - - else { + } else { assert( 0 ); } } return 0; - error_handler: +error_handler: va_end( argp ); membuffer_destroy( buf ); return error_code; @@ -2174,18 +2098,15 @@ MakeGetMessageEx( const char *url_str, *temp; do { - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "DOWNLOAD URL : %s\n", url_str ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "DOWNLOAD URL : %s\n", url_str ); - if( ( errCode = http_FixStrUrl( ( char * )url_str, - strlen( url_str ), - url ) ) != UPNP_E_SUCCESS ) { + if( ( errCode = http_FixStrUrl( ( char * )url_str, + strlen( url_str ), url ) ) != UPNP_E_SUCCESS ) { break; } // make msg membuffer_init( request ); - urlPath = alloca( strlen( url_str ) + 1 ); if( !urlPath ) { errCode = UPNP_E_OUTOF_MEMORY; @@ -2193,9 +2114,7 @@ MakeGetMessageEx( const char *url_str, } memset( urlPath, 0, strlen( url_str ) + 1 ); - strcpy( urlPath, url_str ); - hoststr = strstr( urlPath, "//" ); if( hoststr == NULL ) { errCode = UPNP_E_INVALID_URL; @@ -2212,13 +2131,11 @@ MakeGetMessageEx( const char *url_str, *temp = '\0'; hostlen = strlen( hoststr ); *temp = '/'; + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HOSTNAME : %s Length : %"PRIzu"\n", + hoststr, hostlen ); - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HOSTNAME : %s Length : %zd\n", - hoststr, hostlen ); - ) - - errCode = http_MakeMessage( + errCode = http_MakeMessage( request, 1, 1, "Q" "s" "bc" "GDCUc", HTTPMETHOD_GET, url->pathquery.buff, url->pathquery.size, @@ -2227,49 +2144,48 @@ MakeGetMessageEx( const char *url_str, pRangeSpecifier ); if( errCode != 0 ) { - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Makemessage failed\n" ); - ) - membuffer_destroy( request ); + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Makemessage failed\n" ); + membuffer_destroy( request ); + return errCode; } } while( 0 ); - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "HTTP Buffer:\n %s\n" "----------END--------\n", - request->buf ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "HTTP Buffer:\n %s\n" "----------END--------\n", + request->buf ); - return errCode; + return errCode; } #define SIZE_RANGE_BUFFER 50 /************************************************************************ -* Function : http_OpenHttpGetEx +* Function : http_OpenHttpGetEx * -* Parameters : -* IN const char *url_str : String as a URL -* IN OUT void **Handle : Pointer to buffer to store HTTP -* post handle -* IN OUT char **contentType : Type of content -* OUT int *contentLength : length of content -* OUT int *httpStatus : HTTP status returned on receiving a -* response message -* IN int timeout : time out value +* Parameters : +* IN const char *url_str : String as a URL +* IN OUT void **Handle : Pointer to buffer to store HTTP +* post handle +* IN OUT char **contentType : Type of content +* OUT int *contentLength : length of content +* OUT int *httpStatus : HTTP status returned on receiving a +* response message +* IN int timeout : time out value * -* Description : Makes the HTTP GET message, connects to the peer, +* Description : Makes the HTTP GET message, connects to the peer, * sends the HTTP GET request, gets the response and parses the * response. * -* Return : int; -* UPNP_E_SUCCESS - On Success ; -* UPNP_E_INVALID_PARAM - Invalid Paramters ; -* UPNP_E_OUTOF_MEMORY ; -* UPNP_E_SOCKET_ERROR ; -* UPNP_E_BAD_RESPONSE ; +* Return : int; +* UPNP_E_SUCCESS - On Success ; +* UPNP_E_INVALID_PARAM - Invalid Paramters ; +* UPNP_E_OUTOF_MEMORY ; +* UPNP_E_SOCKET_ERROR ; +* UPNP_E_BAD_RESPONSE ; * -* Note : +* Note : * ************************************************************************/ int @@ -2427,7 +2343,7 @@ http_OpenHttpGetEx( IN const char *url_str, * Description : Returns the server information for the operating * system * -* Return : XINLINE void +* Return : UPNP_INLINE void * * Note : ************************************************************************/ diff --git a/upnp/src/genlib/net/http/statcodes.c b/upnp/src/genlib/net/http/statcodes.c index 950c379..ad690e1 100644 --- a/upnp/src/genlib/net/http/statcodes.c +++ b/upnp/src/genlib/net/http/statcodes.c @@ -118,7 +118,7 @@ static xboolean gInitialized = FALSE; * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void init_table( IN const char *encoded_str, OUT const char *table[], IN int tbl_size ) @@ -144,7 +144,7 @@ init_table( IN const char *encoded_str, * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void init_tables( void ) { init_table( Http1xxStr, Http1xxCodes, NUM_1XX_CODES ); diff --git a/upnp/src/genlib/net/http/webserver.c b/upnp/src/genlib/net/http/webserver.c index b59ba03..3551ab0 100644 --- a/upnp/src/genlib/net/http/webserver.c +++ b/upnp/src/genlib/net/http/webserver.c @@ -205,7 +205,7 @@ extern str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES]; * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void media_list_init( void ) { int i; @@ -243,7 +243,7 @@ media_list_init( void ) * 0 on success; * -1 on error ************************************************************************/ -static XINLINE int +static UPNP_INLINE int search_extension( IN const char *extension, OUT const char **con_type, OUT const char **con_subtype ) @@ -290,7 +290,7 @@ search_extension( IN const char *extension, * 0 - On Sucess * UPNP_E_OUTOF_MEMORY - on memory allocation failures ************************************************************************/ -XINLINE int +UPNP_INLINE int get_content_type( IN const char *filename, OUT DOMString * content_type ) { @@ -348,7 +348,7 @@ get_content_type( IN const char *filename, * Returns: * void ************************************************************************/ -static XINLINE void +static UPNP_INLINE void glob_alias_init( void ) { struct xml_alias_t *alias = &gAliasDoc; @@ -370,7 +370,7 @@ glob_alias_init( void ) * Returns: * BOOLEAN ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean is_valid_alias( IN const struct xml_alias_t *alias ) { return alias->doc.buf != NULL; @@ -637,13 +637,13 @@ get_file_info( IN const char *filename, rc = get_content_type( filename, &info->content_type ); - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "file info: %s, length: %lld, last_mod=%s readable=%d\n", - filename, (long long)info->file_length, - asctime( gmtime( &info->last_modified ) ), - info->is_readable ); ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "file info: %s, length: %lld, last_mod=%s readable=%d\n", + filename, (long long)info->file_length, + asctime( gmtime( &info->last_modified ) ), + info->is_readable ); - return rc; + return rc; } /************************************************************************ @@ -700,7 +700,7 @@ web_server_set_root_dir( IN const char *root_dir ) * TRUE - On Success * FALSE if request is not an alias ************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean get_alias( IN const char *request_file, OUT struct xml_alias_t *alias, OUT struct File_Info *info ) @@ -1586,14 +1586,11 @@ http_RecvPostMessage( http_parser_t * parser, } } else if( num_read == 0 ) { if( ok_on_close ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, HTTP, __FILE__, __LINE__, - "<<< (RECVD) <<<\n%s\n-----------------\n", - parser->msg.msg.buf ); - //print_http_headers( &parser->msg ); - ) - - parser->position = POS_COMPLETE; + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "<<< (RECVD) <<<\n%s\n-----------------\n", + parser->msg.msg.buf ); + print_http_headers( &parser->msg ); + parser->position = POS_COMPLETE; } else { // partial msg parser->http_error_code = HTTP_BAD_REQUEST; // or response @@ -1760,10 +1757,9 @@ web_server_callback( IN http_parser_t * parser, } } - DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, - "webserver: request processed...\n" ); - ) + UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__, + "webserver: request processed...\n" ); - membuffer_destroy( &headers ); + membuffer_destroy( &headers ); membuffer_destroy( &filename ); } diff --git a/upnp/src/genlib/net/uri/uri.c b/upnp/src/genlib/net/uri/uri.c index a6a1105..ca3cdc1 100644 --- a/upnp/src/genlib/net/uri/uri.c +++ b/upnp/src/genlib/net/uri/uri.c @@ -367,16 +367,20 @@ free_URL_list( URL_list * list ) * uri_type *in ; URI object * * Description : Function useful in debugging for printing a parsed uri. -* Compiled out with DBGONLY macro. * * Return : void ; * * Note : ************************************************************************/ -DBGONLY( void print_uri( uri_type * in ) { - print_token( &in->scheme ); - print_token( &in->hostport.text ); - print_token( &in->pathquery ); print_token( &in->fragment );} ) +#ifdef DEBUG +void print_uri( uri_type *in ) +{ + print_token( &in->scheme ); + print_token( &in->hostport.text ); + print_token( &in->pathquery ); + print_token( &in->fragment ); +} +#endif /************************************************************************ * Function : print_token @@ -385,20 +389,23 @@ DBGONLY( void print_uri( uri_type * in ) { * token * in ; token * * Description : Function useful in debugging for printing a token. -* Compiled out with DBGONLY macro. * * Return : void ; * * Note : ************************************************************************/ -DBGONLY( void print_token( token * in ) { - int i = 0; - printf( "Token Size : %d\n\'", in->size ); - for( i = 0; i < in->size; i++ ) { - putchar( in->buff[i] );} - putchar( '\'' ); putchar( '\n' );} - - ) +#ifdef DEBUG +void print_token(token * in) +{ + int i = 0; + printf( "Token Size : %"PRIzu"\n\'", in->size ); + for( i = 0; i < in->size; i++ ) { + putchar( in->buff[i] ); + } + putchar( '\'' ); + putchar( '\n' ); +} +#endif /************************************************************************ * Function : token_string_casecmp @@ -417,8 +424,10 @@ DBGONLY( void print_token( token * in ) { * * Note : ************************************************************************/ - int token_string_casecmp( token * in1, - char *in2 ) { +int token_string_casecmp( + token * in1, + char *in2 ) +{ int in2_length = strlen( in2 ); if( in1->size != in2_length ) @@ -790,9 +799,8 @@ remove_dots( char *in, return UPNP_E_OUTOF_MEMORY; Segments[0] = NULL; - DBGONLY( UpnpPrintf - ( UPNP_ALL, API, __FILE__, __LINE__, - "REMOVE_DOTS: before: %s\n", in ) ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "REMOVE_DOTS: before: %s\n", in ); while( ( copyFrom < max ) && ( *copyFrom != '?' ) && ( *copyFrom != '#' ) ) { @@ -837,9 +845,8 @@ remove_dots( char *in, } ( *copyTo ) = 0; free( Segments ); - DBGONLY( UpnpPrintf - ( UPNP_ALL, API, __FILE__, __LINE__, - "REMOVE_DOTS: after: %s\n", in ) ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "REMOVE_DOTS: after: %s\n", in ); return UPNP_E_SUCCESS; } diff --git a/upnp/src/genlib/service_table/service_table.c b/upnp/src/genlib/service_table/service_table.c index 0a8520b..99115a9 100644 --- a/upnp/src/genlib/service_table/service_table.c +++ b/upnp/src/genlib/service_table/service_table.c @@ -433,7 +433,7 @@ FindServiceControlURLPath( service_table * table, * * Parameters : * service_info *service ;Service whose information is to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints information from the @@ -443,38 +443,54 @@ FindServiceControlURLPath( service_table * table, * * Note : ************************************************************************/ -DBGONLY( void printService( service_info * service, Dbg_Level level, - Dbg_Module module ) { - if( service ) { - if( service->serviceType ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "serviceType: %s\n", service->serviceType ); - if( service->serviceId ) - UpnpPrintf( level, module, __FILE__, __LINE__, "serviceId: %s\n", - service->serviceId ); if( service->SCPDURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, "SCPDURL: %s\n", - service->SCPDURL ); if( service->controlURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, "controlURL: %s\n", - service->controlURL ); if( service->eventURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, "eventURL: %s\n", - service->eventURL ); if( service->UDN ) - UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n", - service->UDN ); if( service->active ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "Service is active\n" ); - else - UpnpPrintf( level, module, __FILE__, __LINE__, - "Service is inactive\n" );} - } - - ) +#ifdef DEBUG +void printService( + service_info *service, + Upnp_LogLevel level, + Dbg_Module module ) +{ + if( service ) { + if( service->serviceType ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "serviceType: %s\n", service->serviceType ); + } + if( service->serviceId ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "serviceId: %s\n", service->serviceId ); + } + if( service->SCPDURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "SCPDURL: %s\n", service->SCPDURL ); + } + if( service->controlURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "controlURL: %s\n", service->controlURL ); + } + if( service->eventURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "eventURL: %s\n", service->eventURL ); + } + if( service->UDN ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "UDN: %s\n\n", service->UDN ); + } + if( service->active ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "Service is active\n" ); + } else { + UpnpPrintf( level, module, __FILE__, __LINE__, + "Service is inactive\n" ); + } + } +} +#endif /************************************************************************ * Function : printServiceList * * Parameters : * service_info *service ; Service whose information is to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints information of each @@ -484,43 +500,55 @@ DBGONLY( void printService( service_info * service, Dbg_Level level, * * Note : ************************************************************************/ - DBGONLY( void printServiceList( service_info * service, - Dbg_Level level, - Dbg_Module module ) { - while( service ) { - if( service->serviceType ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "serviceType: %s\n", service->serviceType ); - if( service->serviceId ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "serviceId: %s\n", service->serviceId ); - if( service->SCPDURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "SCPDURL: %s\n", service->SCPDURL ); - if( service->controlURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "controlURL: %s\n", service->controlURL ); - if( service->eventURL ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "eventURL: %s\n", service->eventURL ); - if( service->UDN ) - UpnpPrintf( level, module, __FILE__, __LINE__, "UDN: %s\n\n", - service->UDN ); if( service->active ) - UpnpPrintf( level, module, __FILE__, __LINE__, - "Service is active\n" ); - else - UpnpPrintf( level, module, __FILE__, __LINE__, - "Service is inactive\n" ); - service = service->next;} - } - ) +#ifdef DEBUG +void printServiceList( + service_info * service, + Upnp_LogLevel level, + Dbg_Module module ) +{ + while( service ) { + if( service->serviceType ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "serviceType: %s\n", service->serviceType ); + } + if( service->serviceId ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "serviceId: %s\n", service->serviceId ); + } + if( service->SCPDURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "SCPDURL: %s\n", service->SCPDURL ); + } + if( service->controlURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "controlURL: %s\n", service->controlURL ); + } + if( service->eventURL ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "eventURL: %s\n", service->eventURL ); + } + if( service->UDN ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "UDN: %s\n\n", service->UDN ); + } + if( service->active ) { + UpnpPrintf( level, module, __FILE__, __LINE__, + "Service is active\n" ); + } else { + UpnpPrintf( level, module, __FILE__, __LINE__, + "Service is inactive\n" ); + } + service = service->next; + } +} +#endif /************************************************************************ * Function : printServiceTable * * Parameters : * service_table * table ; Service table to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints the URL base of the table @@ -531,15 +559,18 @@ DBGONLY( void printService( service_info * service, Dbg_Level level, * * Note : ************************************************************************/ - DBGONLY( void printServiceTable( service_table * table, - Dbg_Level level, - Dbg_Module module ) { - UpnpPrintf( level, module, __FILE__, __LINE__, - "URL_BASE: %s\n", table->URLBase ); - UpnpPrintf( level, module, __FILE__, __LINE__, - "Services: \n" ); - printServiceList( table->serviceList, level, module );} - ) +#ifdef DEBUG +void printServiceTable( + service_table * table, + Upnp_LogLevel level, + Dbg_Module module ) +{ + UpnpPrintf( level, module, __FILE__, __LINE__, + "URL_BASE: %s\n", table->URLBase ); + UpnpPrintf( level, module, __FILE__, __LINE__, + "Services: \n" ); + printServiceList( table->serviceList, level, module );} +#endif /************************************************************************ * Function : freeService @@ -554,7 +585,7 @@ DBGONLY( void printService( service_info * service, Dbg_Level level, * * Note : ************************************************************************/ - void freeService( service_info * in ) +void freeService( service_info * in ) { if( in ) { if( in->serviceType ) @@ -849,12 +880,10 @@ getServiceList( IXML_Node * node, ( ! ( current->controlURL = resolve_rel_url( URLBase, tempDOMString ) ) ) ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, GENA, __FILE__, __LINE__, - "BAD OR MISSING CONTROL URL" ) ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, GENA, __FILE__, __LINE__, - "CONTROL URL SET TO NULL IN SERVICE INFO" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "BAD OR MISSING CONTROL URL" ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "CONTROL URL SET TO NULL IN SERVICE INFO" ); current->controlURL = NULL; fail = 0; } @@ -870,12 +899,10 @@ getServiceList( IXML_Node * node, ( ! ( current->eventURL = resolve_rel_url( URLBase, tempDOMString ) ) ) ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, GENA, __FILE__, __LINE__, - "BAD OR MISSING EVENT URL" ) ); - DBGONLY( UpnpPrintf - ( UPNP_INFO, GENA, __FILE__, __LINE__, - "EVENT URL SET TO NULL IN SERVICE INFO" ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "BAD OR MISSING EVENT URL" ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "EVENT URL SET TO NULL IN SERVICE INFO" ); current->eventURL = NULL; fail = 0; } @@ -908,20 +935,20 @@ getServiceList( IXML_Node * node, } /************************************************************************ -* Function : getAllServiceList +* Function : getAllServiceList * -* Parameters : -* IXML_Node *node ; XML node information -* char * URLBase ; provides Base URL to resolve relative URL -* service_info **out_end ; service added is returned to the output -* parameter +* Parameters : +* IXML_Node *node ; XML node information +* char * URLBase ; provides Base URL to resolve relative URL +* service_info **out_end ; service added is returned to the output +* parameter * -* Description : Returns pointer to service info after getting the +* Description : Returns pointer to service info after getting the * sub-elements of the service info. * -* Return : service_info * ; +* Return : service_info * ; * -* Note : +* Note : ************************************************************************/ service_info * getAllServiceList( IXML_Node * node, @@ -1092,20 +1119,20 @@ addServiceTable( IXML_Node * node, } /************************************************************************ -* Function : getServiceTable -* -* Parameters : -* IXML_Node *node ; XML node information -* service_table *out ; output parameter which will contain the -* service list and URL -* const char *DefaultURLBase ; Default base URL on which the URL -* will be returned. -* -* Description : Retrieve service from the table -* -* Return : int ; -* -* Note : + * Function : getServiceTable + * + * Parameters : + * IXML_Node *node ; XML node information + * service_table *out ; output parameter which will contain the + * service list and URL + * const char *DefaultURLBase ; Default base URL on which the URL + * will be returned. + * + * Description : Retrieve service from the table + * + * Return : int ; + * + * Note : ************************************************************************/ int getServiceTable( IXML_Node * node, @@ -1126,9 +1153,8 @@ getServiceTable( IXML_Node * node, } } - if( ( out->serviceList = getAllServiceList( root, out->URLBase, - &out-> - endServiceList ) ) ) { + if( ( out->serviceList = getAllServiceList( + root, out->URLBase, &out->endServiceList ) ) ) { return 1; } diff --git a/upnp/src/genlib/util/membuffer.c b/upnp/src/genlib/util/membuffer.c index 2299c3e..bed1a61 100644 --- a/upnp/src/genlib/util/membuffer.c +++ b/upnp/src/genlib/util/membuffer.c @@ -171,7 +171,7 @@ memptr_cmp_nocase( IN memptr * m, * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void membuffer_initialize( INOUT membuffer * m ) { m->buf = NULL; diff --git a/upnp/src/inc/config.h b/upnp/src/inc/config.h index 279d2d3..aaa6ee6 100644 --- a/upnp/src/inc/config.h +++ b/upnp/src/inc/config.h @@ -304,27 +304,6 @@ -/** @name DBGONLY - The {\bf DBGONLY} macro allows code to be marked so that it - is only included in the DEBUG build and not the release. To - use this macro, put the code inside of the parentheses: - - {\tt DBGONLY(int i;)} - - This will cause a declaration of the integer {\tt i} only - in the debug build. - */ - -//@{ -#ifdef DEBUG -# define DBGONLY(x) x -#else -# define DBGONLY(x) -#endif -//@} - - - #undef EXCLUDE_WEB_SERVER #undef EXCLUDE_MINISERVER #ifdef INTERNAL_WEB_SERVER @@ -359,13 +338,6 @@ # define CLIENTONLY(x) #endif -#ifdef INCLUDE_DEVICE_APIS -# define DEVICEONLY(x) x -#else -# define DEVICEONLY(x) -#endif - //@} #endif - diff --git a/upnp/src/inc/gena.h b/upnp/src/inc/gena.h index d41cd87..cf5720e 100644 --- a/upnp/src/inc/gena.h +++ b/upnp/src/inc/gena.h @@ -89,25 +89,26 @@ #define DEFAULT_TIMEOUT 1801 - extern ithread_mutex_t GlobalClientSubscribeMutex; -//Lock the subscription +// Lock the subscription #define SubscribeLock() \ - DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \ - "Trying Subscribe Lock")); \ + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ + "Trying Subscribe Lock"); \ ithread_mutex_lock(&GlobalClientSubscribeMutex); \ - DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe Lock");) + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ + "Subscribe Lock"); -//Unlock the subscription +// Unlock the subscription #define SubscribeUnlock() \ - DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__, \ - "Trying Subscribe UnLock")); \ + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ + "Trying Subscribe UnLock"); \ ithread_mutex_unlock(&GlobalClientSubscribeMutex); \ - DBGONLY(UpnpPrintf(UPNP_INFO,GENA,__FILE__,__LINE__,"Subscribe UnLock");) + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ + "Subscribe UnLock"); -//Structure to send NOTIFY message to all subscribed control points +// Structure to send NOTIFY message to all subscribed control points typedef struct NOTIFY_THREAD_STRUCT { char * headers; DOMString propertySet; @@ -161,11 +162,13 @@ EXTERN_C void genaCallback (IN http_parser_t *parser, * return UPNP_E_SUCCESS if service response is OK else * returns appropriate error ***************************************************************************/ -CLIENTONLY( - EXTERN_C int genaSubscribe(UpnpClient_Handle client_handle, - char * PublisherURL, - int * TimeOut, - Upnp_SID out_sid );) +#ifdef INCLUDE_CLIENT_APIS +EXTERN_C int genaSubscribe( + UpnpClient_Handle client_handle, + char * PublisherURL, + int * TimeOut, + Upnp_SID out_sid ); +#endif /************************************************************************ @@ -184,8 +187,11 @@ CLIENTONLY( * return UPNP_E_SUCCESS if service response is OK else * returns appropriate error ***************************************************************************/ -CLIENTONLY(EXTERN_C int genaUnSubscribe(UpnpClient_Handle client_handle, - const Upnp_SID in_sid);) +#ifdef INCLUDE_CLIENT_APIS +EXTERN_C int genaUnSubscribe( + UpnpClient_Handle client_handle, + const Upnp_SID in_sid); +#endif /************************************************************************ * Function : genaUnregisterClient @@ -202,8 +208,9 @@ CLIENTONLY(EXTERN_C int genaUnSubscribe(UpnpClient_Handle client_handle, * Returns: int * return UPNP_E_SUCCESS if successful else returns appropriate error ***************************************************************************/ -CLIENTONLY(EXTERN_C int genaUnregisterClient( - UpnpClient_Handle client_handle);) +#ifdef INCLUDE_CLIENT_APIS +EXTERN_C int genaUnregisterClient(UpnpClient_Handle client_handle); +#endif //server /************************************************************************ @@ -218,8 +225,9 @@ CLIENTONLY(EXTERN_C int genaUnregisterClient( * Returns: int * returns UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE ****************************************************************************/ -DEVICEONLY(EXTERN_C int genaUnregisterDevice( - UpnpDevice_Handle device_handle);) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaUnregisterDevice(UpnpDevice_Handle device_handle); +#endif /************************************************************************ @@ -242,10 +250,12 @@ DEVICEONLY(EXTERN_C int genaUnregisterDevice( * return UPNP_E_SUCCESS if service response is OK else * returns appropriate error ***************************************************************************/ -CLIENTONLY(EXTERN_C int genaRenewSubscription( - IN UpnpClient_Handle client_handle, - IN const Upnp_SID in_sid, - OUT int * TimeOut);) +#ifdef INCLUDE_CLIENT_APIS +EXTERN_C int genaRenewSubscription( + IN UpnpClient_Handle client_handle, + IN const Upnp_SID in_sid, + OUT int * TimeOut); +#endif /**************************************************************************** * Function : genaNotifyAll * @@ -265,33 +275,40 @@ CLIENTONLY(EXTERN_C int genaRenewSubscription( * Note : This function is similar to the genaNotifyAllExt. The only difference * is it takes event variable array instead of xml document. ****************************************************************************/ -DEVICEONLY(EXTERN_C int genaNotifyAll(UpnpDevice_Handle device_handle, - char *UDN, - char *servId, - char **VarNames, - char **VarValues, - int var_count - );) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaNotifyAll( + UpnpDevice_Handle device_handle, + char *UDN, + char *servId, + char **VarNames, + char **VarValues, + int var_count); +#endif /**************************************************************************** -* Function : genaNotifyAllExt +* Function : genaNotifyAllExt * -* Parameters : -* IN UpnpDevice_Handle device_handle : Device handle -* IN char *UDN : Device udn -* IN char *servId : Service ID -* IN IXML_Document *PropSet : XML document Event varible property set +* Parameters : +* IN UpnpDevice_Handle device_handle : Device handle +* IN char *UDN : Device udn +* IN char *servId : Service ID +* IN IXML_Document *PropSet : XML document Event varible property set * -* Description : This function sends a notification to all the subscribed +* Description : This function sends a notification to all the subscribed * control points * -* Return : int +* Return : int * -* Note : This function is similar to the genaNotifyAll. the only difference -* is it takes the document instead of event variable array +* Note : This function is similar to the genaNotifyAll. the only difference +* is it takes the document instead of event variable array ****************************************************************************/ -DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle, - char *UDN, char *servId,IN IXML_Document *PropSet);) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaNotifyAllExt( + UpnpDevice_Handle device_handle, + char *UDN, + char *servId, + IN IXML_Document *PropSet); +#endif /**************************************************************************** * Function : genaInitNotify @@ -314,13 +331,15 @@ DEVICEONLY(EXTERN_C int genaNotifyAllExt(UpnpDevice_Handle device_handle, * Note : No other event will be sent to this control point before the * intial state table dump. ****************************************************************************/ -DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle, - IN char *UDN, - IN char *servId, - IN char **VarNames, - IN char **VarValues, - IN int var_count, - IN Upnp_SID sid);) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle, + IN char *UDN, + IN char *servId, + IN char **VarNames, + IN char **VarValues, + IN int var_count, + IN Upnp_SID sid); +#endif /**************************************************************************** * Function : genaInitNotifyExt @@ -342,12 +361,14 @@ DEVICEONLY(EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle, * Note : No other event will be sent to this control point before the * intial state table dump. ****************************************************************************/ -DEVICEONLY(EXTERN_C int genaInitNotifyExt( - IN UpnpDevice_Handle device_handle, - IN char *UDN, - IN char *servId, - IN IXML_Document *PropSet, - IN Upnp_SID sid);) +#ifdef INCLUDE_DEVICE_APIS +EXTERN_C int genaInitNotifyExt( + IN UpnpDevice_Handle device_handle, + IN char *UDN, + IN char *servId, + IN IXML_Document *PropSet, + IN Upnp_SID sid); +#endif /************************************************************************ diff --git a/upnp/src/inc/http_client.h b/upnp/src/inc/http_client.h index 16eb4aa..1f45073 100644 --- a/upnp/src/inc/http_client.h +++ b/upnp/src/inc/http_client.h @@ -214,37 +214,101 @@ EXTERN_C ssize_t readLine(int fd, char *out, int max, int *timeout); EXTERN_C int remove_dots(char * in, int size); -DBGONLY(EXTERN_C void print_http_request(http_message - *message,Dbg_Level DLevel, - Dbg_Module Module,char *DbgFileName, - int DbgLineNo);); +#ifdef DEBUG +EXTERN_C void print_http_request( + http_message *message, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_http_request( + http_message *message, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif -DBGONLY(EXTERN_C void print_http_response(http_message *message, - Dbg_Level DLevel, - Dbg_Module Module,char *DbgFileName, - int DbgLineNo);); +#ifdef DEBUG +EXTERN_C void print_http_response( + http_message *message, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_http_response( + http_message *message, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif -DBGONLY(EXTERN_C void print_token( token * in, - Dbg_Level DLevel, - Dbg_Module Module, - char *DbgFileName, - int DbgLineNo);); +#ifdef DEBUG +EXTERN_C void print_token( + token *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_token( + token *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif -DBGONLY(EXTERN_C void print_status_line(http_status *in, - Dbg_Level DLevel, - Dbg_Module Module, - char *DbgFileName, - int DbgLineNo);); +#ifdef DEBUG +EXTERN_C void print_status_line( + http_status *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_status_line( + http_status *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif -DBGONLY(EXTERN_C void print_request_line(http_request *in, - Dbg_Level DLevel, - Dbg_Module Module, - char *DbgFileName,int DbgLineNo)); +#ifdef DEBUG +EXTERN_C void print_request_line( + http_request *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_request_line( + http_request *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif -DBGONLY(EXTERN_C void print_uri( uri_type *in, - Dbg_Level DLevel, - Dbg_Module Module, - char *DbgFileName, - int DbgLineNo);); +#ifdef DEBUG +EXTERN_C void print_uri( + uri_type *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo); +#else +static inline void print_uri( + uri_type *in, + Upnp_LogLevel DLevel, + Dbg_Module Module, + char *DbgFileName, + int DbgLineNo) {} +#endif #endif + diff --git a/upnp/src/inc/httpparser.h b/upnp/src/inc/httpparser.h index 5052aa3..821862b 100644 --- a/upnp/src/inc/httpparser.h +++ b/upnp/src/inc/httpparser.h @@ -448,15 +448,17 @@ int matchstr( IN char *str, IN size_t slen, IN const char* fmt, ... ); int raw_to_int( IN memptr* raw_value, int base ); /************************************************************************ -* Function: raw_find_str -* -* Parameters: -* IN memptr* raw_value ; Buffer containg the string -* IN const char* str ; Substring to be found -* -* Description: Find a substring from raw character string buffer -* -* Returns: +* Function: raw_find_str +* +* Parameters: +* IN memptr* raw_value ; Buffer containg the string +* IN const char* str ; Substring to be found +* +* Description: Find a substring from raw character string buffer +* +* Side effects: raw_value is transformed to lowercase. +* +* Returns: * int - index at which the substring is found. ************************************************************************/ int raw_find_str( IN memptr* raw_value, IN const char* str ); @@ -476,17 +478,21 @@ int raw_find_str( IN memptr* raw_value, IN const char* str ); const char* method_to_str( IN http_method_t method ); /************************************************************************ -* Function: print_http_headers -* -* Parameters: -* http_message_t* hmsg ; HTTP Message object -* -* Description: -* -* Returns: -* void +* Function: print_http_headers +* +* Parameters: +* http_message_t* hmsg ; HTTP Message object +* +* Description: +* +* Returns: +* void ************************************************************************/ -void print_http_headers( IN http_message_t* hmsg ); +#ifdef DEBUG +void print_http_headers( IN http_message_t *hmsg ); +#else +static UPNP_INLINE void print_http_headers( IN http_message_t *hmsg ) {} +#endif #ifdef __cplusplus } // extern "C" @@ -494,3 +500,4 @@ void print_http_headers( IN http_message_t* hmsg ); #endif // GENLIB_NET_HTTP_HTTPPARSER_H + diff --git a/upnp/src/inc/miniserver.h b/upnp/src/inc/miniserver.h index e546da8..fbe9faf 100644 --- a/upnp/src/inc/miniserver.h +++ b/upnp/src/inc/miniserver.h @@ -88,7 +88,11 @@ void SetHTTPGetCallback( MiniServerCallback callback ); * * Note : ************************************************************************/ +#ifdef INCLUDE_DEVICE_APIS void SetSoapCallback( MiniServerCallback callback ); +#else +static inline void SetSoapCallback( MiniServerCallback callback ) {} +#endif /************************************************************************ * Function : SetGenaCallback diff --git a/upnp/src/inc/service_table.h b/upnp/src/inc/service_table.h index 2b857ce..9118456 100644 --- a/upnp/src/inc/service_table.h +++ b/upnp/src/inc/service_table.h @@ -47,7 +47,7 @@ extern "C" { #define SID_SIZE 41 -DEVICEONLY( +#ifdef INCLUDE_DEVICE_APIS typedef struct SUBSCRIPTION { Upnp_SID sid; @@ -61,18 +61,19 @@ typedef struct SUBSCRIPTION { typedef struct SERVICE_INFO { - DOMString serviceType; - DOMString serviceId; + DOMString serviceType; + DOMString serviceId; char *SCPDURL ; char *controlURL; char *eventURL; - DOMString UDN; + DOMString UDN; int active; int TotalSubscriptions; - subscription *subscriptionList; + subscription *subscriptionList; struct SERVICE_INFO *next; } service_info; + typedef struct SERVICE_TABLE { DOMString URLBase; service_info *serviceList; @@ -80,7 +81,7 @@ typedef struct SERVICE_TABLE { } service_table; -/* Functions for Subscriptions */ +/* Functions for Subscriptions */ /************************************************************************ * Function : copy_subscription @@ -253,7 +254,7 @@ service_info * FindServiceControlURLPath( service_table *table, * * Parameters : * service_info *service ;Service whose information is to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints information from the @@ -263,16 +264,24 @@ service_info * FindServiceControlURLPath( service_table *table, * * Note : ************************************************************************/ -DBGONLY(void printService(service_info *service,Dbg_Level - level, - Dbg_Module module)); +#ifdef DEBUG +void printService( + service_info *service, + Upnp_LogLevel level, + Dbg_Module module); +#else +static UPNP_INLINE void printService( + service_info *service, + Upnp_LogLevel level, + Dbg_Module module) {} +#endif /************************************************************************ * Function : printServiceList * * Parameters : * service_info *service ; Service whose information is to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints information of each @@ -282,15 +291,24 @@ DBGONLY(void printService(service_info *service,Dbg_Level * * Note : ************************************************************************/ -DBGONLY(void printServiceList(service_info *service, - Dbg_Level level, Dbg_Module module)); +#ifdef DEBUG +void printServiceList( + service_info *service, + Upnp_LogLevel level, + Dbg_Module module); +#else +static UPNP_INLINE void printServiceList( + service_info *service, + Upnp_LogLevel level, + Dbg_Module module) {} +#endif /************************************************************************ * Function : printServiceTable * * Parameters : * service_table * table ; Service table to be printed -* Dbg_Level level ; Debug level specified to the print function +* Upnp_LogLevel level ; Debug level specified to the print function * Dbg_Module module ; Debug module specified to the print function * * Description : For debugging purposes prints the URL base of the table @@ -301,9 +319,17 @@ DBGONLY(void printServiceList(service_info *service, * * Note : ************************************************************************/ -DBGONLY(void printServiceTable(service_table * - table,Dbg_Level - level,Dbg_Module module)); +#ifdef DEBUG +void printServiceTable( + service_table *table, + Upnp_LogLevel level, + Dbg_Module module); +#else +static UPNP_INLINE void printServiceTable( + service_table *table, + Upnp_LogLevel level, + Dbg_Module module) {} +#endif /************************************************************************ * Function : freeService @@ -451,10 +477,11 @@ int getSubElement(const char *element_name, IXML_Node *node, IXML_Node **out); -) /* DEVICEONLY */ +#endif /* INCLUDE_DEVICE_APIS */ #ifdef __cplusplus } #endif #endif /* _SERVICE_TABLE */ + diff --git a/upnp/src/inc/soaplib.h b/upnp/src/inc/soaplib.h index 71fc7cb..2231192 100644 --- a/upnp/src/inc/soaplib.h +++ b/upnp/src/inc/soaplib.h @@ -33,28 +33,28 @@ #define SOAPLIB_H -//SOAP module API to be called in Upnp-Dk API +// SOAP module API to be called in Upnp-Dk API /**************************************************************************** -* Function : soap_device_callback +* Function : soap_device_callback * -* Parameters : -* IN http_parser_t *parser : Parsed request received by the device -* IN http_message_t* request : HTTP request -* INOUT SOCKINFO *info : socket info +* Parameters : +* IN http_parser_t *parser : Parsed request received by the device +* IN http_message_t* request : HTTP request +* INOUT SOCKINFO *info : socket info * -* Description : This is a callback called by minisever after receiving -* the request from the control point. This function will start -* processing the request. It calls handle_invoke_action to handle the -* SOAP action +* Description : This is a callback called by minisever after receiving +* the request from the control point. This function will start +* processing the request. It calls handle_invoke_action to handle the +* SOAP action * -* Return : void +* Return : void * -* Note : +* Note : ****************************************************************************/ -void soap_device_callback( - IN http_parser_t *parser, - IN http_message_t* request, - INOUT SOCKINFO *info ); +void soap_device_callback( + IN http_parser_t *parser, + IN http_message_t* request, + INOUT SOCKINFO *info ); /**************************************************************************** diff --git a/upnp/src/inc/ssdplib.h b/upnp/src/inc/ssdplib.h index 7fa8e48..f8c7271 100644 --- a/upnp/src/inc/ssdplib.h +++ b/upnp/src/inc/ssdplib.h @@ -184,12 +184,12 @@ typedef int (*ParserFun)(char *, Event *); //int AnalyzeCommand(char * szCommand, Event * Evt); /************************************************************************ -* Function : Make_Socket_NoBlocking -* -* Parameters: -* IN int sock: socket +* Function : Make_Socket_NoBlocking * -* Description: +* Parameters: +* IN int sock: socket +* +* Description: * This function to make ssdp socket non-blocking. * * Returns: int @@ -198,12 +198,12 @@ typedef int (*ParserFun)(char *, Event *); int Make_Socket_NoBlocking (int sock); /************************************************************************ -* Function : ssdp_handle_device_request -* -* Parameters: +* Function : ssdp_handle_device_request +* +* Parameters: * IN void *data: * -* Description: +* Description: * This function handles the search request. It do the sanity checks of * the request and then schedules a thread to send a random time reply ( * random within maximum time given by the control point to reply). @@ -211,22 +211,29 @@ int Make_Socket_NoBlocking (int sock); * Returns: void * * 1 if successful else appropriate error ***************************************************************************/ -void ssdp_handle_device_request( IN http_message_t* hmsg, - IN struct sockaddr_in* dest_addr ); +#ifdef INCLUDE_DEVICE_APIS +void ssdp_handle_device_request( + IN http_message_t* hmsg, + IN struct sockaddr_in* dest_addr ); +#else +static inline void ssdp_handle_device_request( + IN http_message_t* hmsg, + IN struct sockaddr_in* dest_addr ) {} +#endif /************************************************************************ -* Function : ssdp_handle_ctrlpt_msg -* -* Parameters: +* Function : ssdp_handle_ctrlpt_msg +* +* Parameters: * IN http_message_t* hmsg: SSDP message from the device * IN struct sockaddr_in* dest_addr: Address of the device * IN xboolean timeout: timeout kept by the control point while sending -* search message +* search message * IN void* cookie: Cookie stored by the control point application. -* This cookie will be returned to the control point -* in the callback -* -* Description: +* This cookie will be returned to the control point +* in the callback +* +* Description: * This function handles the ssdp messages from the devices. These * messages includes the search replies, advertisement of device coming * alive and bye byes. @@ -234,20 +241,21 @@ void ssdp_handle_device_request( IN http_message_t* hmsg, * Returns: void * ***************************************************************************/ -void ssdp_handle_ctrlpt_msg( IN http_message_t* hmsg, - IN struct sockaddr_in* dest_addr, - IN xboolean timeout, - IN void* cookie ); +void ssdp_handle_ctrlpt_msg( + IN http_message_t* hmsg, + IN struct sockaddr_in* dest_addr, + IN xboolean timeout, + IN void* cookie ); /************************************************************************ -* Function : unique_service_name -* -* Parameters: -* IN char *cmd: Service Name string -* OUT SsdpEvent *Evt: The SSDP event structure partially filled -* by all the function. +* Function : unique_service_name * -* Description: +* Parameters: +* IN char *cmd: Service Name string +* OUT SsdpEvent *Evt: The SSDP event structure partially filled +* by all the function. +* +* Description: * This function fills the fields of the event structure like DeviceType, * Device UDN and Service Type * @@ -258,12 +266,12 @@ int unique_service_name(char * cmd, SsdpEvent * Evt); /************************************************************************ -* Function : get_ssdp_sockets -* -* Parameters: +* Function : get_ssdp_sockets +* +* Parameters: * OUT MiniServerSockArray *out: Arrays of SSDP sockets * -* Description: +* Description: * This function creates the ssdp sockets. It set their option to listen * for multicast traffic. * @@ -274,12 +282,12 @@ int get_ssdp_sockets(MiniServerSockArray *out); /************************************************************************ -* Function : readFromSSDPSocket -* -* Parameters: +* Function : readFromSSDPSocket +* +* Parameters: * IN SOCKET socket: SSDP socket * -* Description: +* Description: * This function reads the data from the ssdp socket. * * Returns: void @@ -289,13 +297,13 @@ void readFromSSDPSocket(SOCKET socket); /************************************************************************ -* Function : ssdp_request_type1 -* -* Parameters: +* Function : ssdp_request_type1 +* +* Parameters: * IN char *cmd: command came in the ssdp request * -* Description: -* This function figures out the type of the SSDP search in the +* Description: +* This function figures out the type of the SSDP search in the * in the request. * * Returns: enum SsdpSearchType @@ -305,14 +313,14 @@ enum SsdpSearchType ssdp_request_type1(IN char *cmd); /************************************************************************ -* Function : ssdp_request_type -* -* Parameters: +* Function : ssdp_request_type +* +* Parameters: * IN char *cmd: command came in the ssdp request * OUT SsdpEvent *Evt: The event structure partially filled by * this function. * -* Description: +* Description: * This function starts filling the SSDP event structure based upon the * request received. * @@ -323,17 +331,15 @@ int ssdp_request_type(IN char * cmd, OUT SsdpEvent * Evt); /************************************************************************ -* Function : SearchByTarget -* -* Parameters: -* IN int Mx:Number of seconds to wait, to collect all the -* responses. -* char *St: Search target. -* void *Cookie: cookie provided by control point application. This -* cokie will be returned to application in the -* callback. +* Function : SearchByTarget * -* Description: +* Parameters: +* IN int Mx:Number of seconds to wait, to collect all the responses. +* char *St: Search target. +* void *Cookie: cookie provided by control point application. This +* cokie will be returned to application in the callback. +* +* Description: * This function creates and send the search request for a specific URL. * * Returns: int @@ -342,214 +348,224 @@ int ssdp_request_type(IN char * cmd, OUT SsdpEvent * Evt); int SearchByTarget(IN int Mx, IN char *St, IN void *Cookie); /************************************************************************ -* Function : DeviceAdvertisement -* -* Parameters: -* IN char * DevType : type of the device -* IN int RootDev: flag to indicate if the device is root device -* IN char * nt : value of NT -* IN char * usn : -* IN char * location :Location URL. -* IN int duration :Service duration in sec. +* Function : DeviceAdvertisement * -* Description: -* This function creates the device advertisement request based on +* Parameters: +* IN char *DevType : type of the device +* IN int RootDev : flag to indicate if the device is root device +* IN char *Udn : +* IN char *Location: Location URL. +* IN int Duration : Service duration in sec. +* +* Description: +* This function creates the device advertisement request based on * the input parameter, and send it to the multicast channel. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceAdvertisement(IN char * DevType, int RootDev,char * Udn, - IN char * Location, IN int Duration); +int DeviceAdvertisement( + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : DeviceShutdown -* +* Function : DeviceShutdown +* * Parameters: * IN char *DevType: Device Type. * IN int RootDev:1 means root device. -* IN char * Udn: Device UDN +* IN char *Udn: Device UDN * IN char *_Server: -* IN char * Location: Location URL -* IN int Duration :Device duration in sec. +* IN char *Location: Location URL +* IN int Duration :Device duration in sec. * -* Description: +* Description: * This function creates a HTTP device shutdown request packet * and sent it to the multicast channel through RequestHandler. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceShutdown( IN char * DevType, - IN int RootDev, - IN char * Udn, - IN char * _Server, - IN char * Location, - IN int Duration ); +int DeviceShutdown( + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *_Server, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : DeviceReply -* +* Function : DeviceReply +* * Parameters: * IN struct sockaddr_in * DestAddr:destination IP address. * IN char *DevType: Device type * IN int RootDev: 1 means root device 0 means embedded device. -* IN char * Udn: Device UDN -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN char *Udn: Device UDN +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. +* +* Description: * This function creates the reply packet based on the input parameter, * and send it to the client address given in its input parameter DestAddr. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int DeviceReply(IN struct sockaddr_in * DestAddr, - IN char *DevType, - IN int RootDev, - IN char * Udn, - IN char * Location, IN int Duration); +int DeviceReply( + IN struct sockaddr_in * DestAddr, + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, IN int Duration); /************************************************************************ -* Function : SendReply -* +* Function : SendReply +* * Parameters: * IN struct sockaddr_in * DestAddr:destination IP address. * IN char *DevType: Device type * IN int RootDev: 1 means root device 0 means embedded device. * IN char * Udn: Device UDN * IN char *_Server: -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. * IN int ByType: * -* Description: +* Description: * This function creates the reply packet based on the input parameter, * and send it to the client addesss given in its input parameter DestAddr. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int SendReply(IN struct sockaddr_in * DestAddr, - IN char *DevType, - IN int RootDev, - IN char * Udn, - IN char * Location, - IN int Duration, - IN int ByType ); +int SendReply( + IN struct sockaddr_in * DestAddr, + IN char *DevType, + IN int RootDev, + IN char *Udn, + IN char *Location, + IN int Duration, + IN int ByType ); /************************************************************************ -* Function : ServiceAdvertisement -* +* Function : ServiceAdvertisement +* * Parameters: * IN char * Udn: Device UDN * IN char *ServType: Service Type. * IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN int Duration :Life time of this device. +* +* Description: * This function creates the advertisement packet based * on the input parameter, and send it to the multicast channel. - * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceAdvertisement( IN char * Udn, - IN char * ServType, - IN char * Location, - IN int Duration); +int ServiceAdvertisement( + IN char *Udn, + IN char *ServType, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : ServiceReply -* +* Function : ServiceReply +* * Parameters: * IN struct sockaddr_in *DestAddr: -* IN char * Udn: Device UDN +* IN char *Udn: Device UDN * IN char *ServType: Service Type. * IN char *Server: Not used -* IN char * Location: Location of Device description document. -* IN int Duration :Life time of this device. - -* Description: +* IN char *Location: Location of Device description document. +* IN int Duration :Life time of this device. +* +* Description: * This function creates the advertisement packet based * on the input parameter, and send it to the multicast channel. - * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceReply(IN struct sockaddr_in *DestAddr, - IN char * ServType, - IN char * Udn, - IN char * Location, - IN int Duration); +int ServiceReply( + IN struct sockaddr_in *DestAddr, + IN char *ServType, + IN char *Udn, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : ServiceShutdown -* -* Parameters: -* IN char * Udn: Device UDN +* Function : ServiceShutdown +* +* Parameters: +* IN char *Udn: Device UDN * IN char *ServType: Service Type. -* IN char * Location: Location of Device description document. -* IN int Duration :Service duration in sec. - -* Description: +* IN char *Location: Location of Device description document. +* IN int Duration :Service duration in sec. +* +* Description: * This function creates a HTTP service shutdown request packet * and sent it to the multicast channel through RequestHandler. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int ServiceShutdown( IN char * Udn, IN char * ServType, - IN char * Location, - IN int Duration); +int ServiceShutdown( + IN char *Udn, + IN char *ServType, + IN char *Location, + IN int Duration); /************************************************************************ -* Function : advertiseAndReplyThread -* -* Parameters: -* IN void *data: Structure containing the search request +* Function : advertiseAndReplyThread * -* Description: +* Parameters: +* IN void *data: Structure containing the search request +* +* Description: * This function is a wrapper function to reply the search request * coming from the control point. * * Returns: void * * always return NULL ***************************************************************************/ -void * advertiseAndReplyThread(IN void * data); +void *advertiseAndReplyThread(IN void * data); /************************************************************************ -* Function : AdvertiseAndReply -* -* Parameters: -* IN int AdFlag: -1 = Send shutdown, 0 = send reply, -* 1 = Send Advertisement +* Function : AdvertiseAndReply +* +* Parameters: +* IN int AdFlag: -1 = Send shutdown, +* 0 = send reply, +* 1 = Send Advertisement * IN UpnpDevice_Handle Hnd: Device handle * IN enum SsdpSearchType SearchType:Search type for sending replies * IN struct sockaddr_in *DestAddr:Destination address -* IN char *DeviceType:Device type +* IN char *DeviceType:Device type * IN char *DeviceUDN:Device UDN -* IN char *ServiceType:Service type +* IN char *ServiceType:Service type * IN int Exp:Advertisement age * -* Description: +* Description: * This function to send SSDP advertisements, replies and shutdown messages. * * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ -int AdvertiseAndReply(IN int AdFlag, - IN UpnpDevice_Handle Hnd, - IN enum SsdpSearchType SearchType, - IN struct sockaddr_in *DestAddr, - IN char *DeviceType, - IN char *DeviceUDN, - IN char *ServiceType, int Exp); +int AdvertiseAndReply( + IN int AdFlag, + IN UpnpDevice_Handle Hnd, + IN enum SsdpSearchType SearchType, + IN struct sockaddr_in *DestAddr, + IN char *DeviceType, + IN char *DeviceUDN, + IN char *ServiceType, int Exp); #endif diff --git a/upnp/src/inc/unixutil.h b/upnp/src/inc/unixutil.h index 0f9624f..6b2566c 100644 --- a/upnp/src/inc/unixutil.h +++ b/upnp/src/inc/unixutil.h @@ -36,12 +36,11 @@ #include #ifndef WIN32 - #include + #include #else - #define XINLINE - - typedef int socklen_t; - #define EAFNOSUPPORT 97 + typedef int socklen_t; + #define EAFNOSUPPORT 97 #endif #endif // GENLIB_NET_UNIXUTIL_H + diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h index a1ef4e6..c32a39f 100644 --- a/upnp/src/inc/upnpapi.h +++ b/upnp/src/inc/upnpapi.h @@ -71,33 +71,46 @@ struct Handle_Info Upnp_FunPtr Callback; // Callback function pointer. char * Cookie; - DEVICEONLY(char DescURL[LINE_SIZE];) // URL for the use of SSDP - DEVICEONLY(char DescXML[LINE_SIZE];) // XML file path for device - //description + // Device Only +#ifdef INCLUDE_DEVICE_APIS + char DescURL[LINE_SIZE]; // URL for the use of SSDP + char DescXML[LINE_SIZE]; // XML file path for device + //description - DEVICEONLY(int MaxAge;) // Advertisement timeout - DEVICEONLY(IXML_Document *DescDocument;) // Description parsed in - //terms of DOM document - DEVICEONLY(IXML_NodeList *DeviceList;) // List of devices in the - //description document - DEVICEONLY(IXML_NodeList *ServiceList;) // List of services in the - // description document - DEVICEONLY(service_table ServiceTable;) //table holding subscriptions and + int MaxAge; // Advertisement timeout + IXML_Document *DescDocument;// Description parsed in + //terms of DOM document + IXML_NodeList *DeviceList; // List of devices in the + //description document + IXML_NodeList *ServiceList; // List of services in the + // description document + service_table ServiceTable; //table holding subscriptions and //URL information - DEVICEONLY(int MaxSubscriptions;) - DEVICEONLY(int MaxSubscriptionTimeOut;) + int MaxSubscriptions; + int MaxSubscriptionTimeOut; +#endif - //Client only - CLIENTONLY(client_subscription * ClientSubList;) //client subscription list - CLIENTONLY(LinkedList SsdpSearchList;) // active ssdp searches + // Client only +#ifdef INCLUDE_CLIENT_APIS + client_subscription *ClientSubList; //client subscription list + LinkedList SsdpSearchList; // active ssdp searches +#endif int aliasInstalled; // 0 = not installed; otherwise installed -} ; +}; extern ithread_mutex_t GlobalHndMutex; Upnp_Handle_Type GetHandleInfo(int Hnd, struct Handle_Info **HndInfo); -#define HandleLock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Lock")); ithread_mutex_lock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"LOCK")); -#define HandleUnlock() DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Trying Unlock")); ithread_mutex_unlock(&GlobalHndMutex); DBGONLY(UpnpPrintf(UPNP_INFO,API,__FILE__,__LINE__,"Unlock")); +#define HandleLock() \ + UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Trying Lock"); \ + ithread_mutex_lock(&GlobalHndMutex); \ + UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "LOCK"); + +#define HandleUnlock() \ + UpnpPrintf(UPNP_INFO, API,__FILE__, __LINE__, "Trying Unlock"); \ + ithread_mutex_unlock(&GlobalHndMutex); \ + UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Unlock"); + Upnp_Handle_Type GetClientHandleInfo(int *client_handle_out, struct Handle_Info **HndInfo); Upnp_Handle_Type GetDeviceHandleInfo(int *device_handle_out, @@ -111,7 +124,7 @@ extern unsigned short LOCAL_PORT; extern TimerThread gTimerThread; extern ThreadPool gRecvThreadPool; extern ThreadPool gSendThreadPool; - +extern ThreadPool gMiniServerThreadPool; typedef enum { SUBSCRIBE, diff --git a/upnp/src/inc/uri.h b/upnp/src/inc/uri.h index 229d653..1c3847c 100644 --- a/upnp/src/inc/uri.h +++ b/upnp/src/inc/uri.h @@ -182,13 +182,16 @@ void free_URL_list(URL_list * list); * uri_type *in ; URI object * * Description : Function useful in debugging for printing a parsed uri. -* Compiled out with DBGONLY macro. * * Return : void ; * * Note : ************************************************************************/ -DBGONLY(void print_uri( uri_type *in);) +#ifdef DEBUG +void print_uri(uri_type *in); +#else +static UPNP_INLINE void print_uri(uri_type *in) {} +#endif /************************************************************************ * Function : print_token @@ -197,13 +200,16 @@ DBGONLY(void print_uri( uri_type *in);) * token * in ; * * Description : Function useful in debugging for printing a token. -* Compiled out with DBGONLY macro. * * Return : void ; * * Note : ************************************************************************/ -void print_token( token * in); +#ifdef DEBUG +void print_token(token *in); +#else +static UPNP_INLINE void print_token(token * in) {} +#endif /************************************************************************ * Function : token_string_casecmp diff --git a/upnp/src/inc/util.h b/upnp/src/inc/util.h index 74a2229..3982d5d 100644 --- a/upnp/src/inc/util.h +++ b/upnp/src/inc/util.h @@ -47,12 +47,6 @@ #endif -#ifdef NO_DEBUG -#define DBG(x) -#else -#define DBG(x) x -#endif - #define GEMD_OUT_OF_MEMORY -1 #define EVENT_TIMEDOUT -2 #define EVENT_TERMINATE -3 @@ -142,31 +136,28 @@ void linecopylen( OUT char dest[LINE_SIZE], IN const char* src, IN size_t srclen #endif ////////////////////////////////// - // C specific #ifndef __cplusplus -#ifndef WIN32 - #define XINLINE inline -#else +#ifdef WIN32 + #ifndef S_ISREG + #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + #endif - #ifndef S_ISREG - #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) - #endif - - #ifndef S_ISDIR - #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) - #endif + #ifndef S_ISDIR + #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) + #endif - #define EADDRINUSE WSAEADDRINUSE + #define EADDRINUSE WSAEADDRINUSE - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define strcasecmp stricmp + #define strncasecmp strnicmp - #define sleep(a) Sleep((a)*1000) - #define usleep(a) Sleep((a)/1000) + #define sleep(a) Sleep((a)*1000) + #define usleep(a) Sleep((a)/1000) #endif #endif // __cplusplus #endif /* GENLIB_UTIL_UTIL_H */ + diff --git a/upnp/src/soap/soap_ctrlpt.c b/upnp/src/soap/soap_ctrlpt.c index 73ed788..43970be 100644 --- a/upnp/src/soap/soap_ctrlpt.c +++ b/upnp/src/soap/soap_ctrlpt.c @@ -244,7 +244,7 @@ get_node_value( IN IXML_Node * node ) * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_host_and_path( IN char *ctrl_url, OUT const memptr *host, OUT const memptr *path, @@ -277,7 +277,7 @@ get_host_and_path( IN char *ctrl_url, * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_action_name( IN char *action, OUT memptr * name ) { @@ -303,7 +303,7 @@ get_action_name( IN char *action, * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int add_man_header( INOUT membuffer * headers ) { char *soap_action_hdr; @@ -619,11 +619,10 @@ SoapSendAction( IN char *action_url, err_code = UPNP_E_OUTOF_MEMORY; // default error - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Inside SoapSendAction():" ); - ) - // init - membuffer_init( &request ); + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Inside SoapSendAction():" ); + // init + membuffer_init( &request ); membuffer_init( &responsename ); // print action @@ -642,11 +641,12 @@ SoapSendAction( IN char *action_url, goto error_handler; } - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "path=%.*s, hostport=%.*s\n", - url.pathquery.size, url.pathquery.buff, - url.hostport.text.size, - url.hostport.text.buff ); ) + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "path=%.*s, hostport=%.*s\n", + (int)url.pathquery.size, + url.pathquery.buff, + (int)url.hostport.text.size, + url.hostport.text.buff ); xml_start_len = strlen( xml_start ); xml_end_len = strlen( xml_end ); @@ -770,11 +770,10 @@ SoapSendActionEx( IN char *action_url, err_code = UPNP_E_OUTOF_MEMORY; // default error - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Inside SoapSendActionEx():" ); - ) - // init - membuffer_init( &request ); + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Inside SoapSendActionEx():" ); + // init + membuffer_init( &request ); membuffer_init( &responsename ); // header string @@ -798,11 +797,12 @@ SoapSendActionEx( IN char *action_url, goto error_handler; } - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "path=%.*s, hostport=%.*s\n", - url.pathquery.size, url.pathquery.buff, - url.hostport.text.size, - url.hostport.text.buff ); ) + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "path=%.*s, hostport=%.*s\n", + (int)url.pathquery.size, + url.pathquery.buff, + (int)url.hostport.text.size, + url.hostport.text.buff ); xml_start_len = strlen( xml_start ); xml_body_start_len = strlen( xml_body_start ); diff --git a/upnp/src/soap/soap_device.c b/upnp/src/soap/soap_device.c index f8b6350..98a02f7 100644 --- a/upnp/src/soap/soap_device.c +++ b/upnp/src/soap/soap_device.c @@ -85,7 +85,7 @@ const char *ContentTypeHeader = * 0 if successful else returns appropriate error. * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_request_type( IN http_message_t * request, OUT memptr * action_name ) { @@ -262,7 +262,7 @@ send_error_response( IN SOCKINFO * info, * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void send_var_query_response( IN SOCKINFO * info, IN const char *var_value, IN http_message_t * hmsg ) @@ -326,12 +326,12 @@ send_var_query_response( IN SOCKINFO * info, * Description : This function separates the action node from * the root DOM node. * -* Return : static XINLINE int +* Return : static UPNP_INLINE int * 0 if successful, or -1 if fails. * * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_action_node( IN IXML_Document * TempDoc, IN char *NodeName, OUT IXML_Document ** RespNode ) @@ -344,11 +344,10 @@ get_action_node( IN IXML_Document * TempDoc, int ret_code = -1; // error, by default IXML_NodeList *nl = NULL; - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "get_action_node(): node name =%s\n ", NodeName ); - ) + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "get_action_node(): node name =%s\n ", NodeName ); - * RespNode = NULL; + *RespNode = NULL; // Got the Envelope node here EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc ); @@ -682,7 +681,7 @@ get_device_info( IN http_message_t * request, * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void send_action_response( IN SOCKINFO * info, IN IXML_Document * action_resp, IN http_message_t * request ) @@ -738,15 +737,15 @@ send_action_response( IN SOCKINFO * info, xml_response, strlen( xml_response ), end_body, strlen( end_body ) ); - DBGONLY( if( ret_code != 0 ) { - UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Failed to send response: err code = %d\n", - ret_code );} - ) + if( ret_code != 0 ) { + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Failed to send response: err code = %d\n", + ret_code ); + } - err_code = 0; + err_code = 0; - error_handler: +error_handler: ixmlFreeDOMString( xml_response ); membuffer_destroy( &headers ); if( err_code != 0 ) { @@ -770,7 +769,7 @@ send_action_response( IN SOCKINFO * info, * returns 0 if successful else returns -1. * Note : ****************************************************************************/ -static XINLINE int +static UPNP_INLINE int get_var_name( IN IXML_Document * TempDoc, OUT char *VarName ) { @@ -814,14 +813,13 @@ get_var_name( IN IXML_Document * TempDoc, Temp = ixmlNode_getNodeValue( VarNode ); linecopy( VarName, Temp ); - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Received query for variable name %s\n", - VarName ); - ) + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Received query for variable name %s\n", + VarName ); - ret_val = 0; // success + ret_val = 0; // success - error_handler: +error_handler: return ret_val; } @@ -842,7 +840,7 @@ get_var_name( IN IXML_Document * TempDoc, * * Note : ****************************************************************************/ -static XINLINE void +static UPNP_INLINE void handle_query_variable( IN SOCKINFO * info, IN http_message_t * request, IN IXML_Document * xml_doc ) @@ -878,8 +876,8 @@ handle_query_variable( IN SOCKINFO * info, // send event soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie ); - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Return from callback for var request\n" ) ); + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Return from callback for var request\n" ); // validate, and handle result if( variable.CurrentVal == NULL ) { @@ -968,8 +966,8 @@ handle_invoke_action( IN SOCKINFO * info, action.ErrCode = UPNP_E_SUCCESS; action.CtrlPtIPAddr = info->foreign_ip_addr; - DBGONLY( UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, - "Calling Callback\n" ) ); + UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, + "Calling Callback\n" ); soap_event_callback( UPNP_CONTROL_ACTION_REQUEST, &action, cookie ); diff --git a/upnp/src/ssdp/ssdp_ctrlpt.c b/upnp/src/ssdp/ssdp_ctrlpt.c index bd1fc9b..fbeebd0 100644 --- a/upnp/src/ssdp/ssdp_ctrlpt.c +++ b/upnp/src/ssdp/ssdp_ctrlpt.c @@ -55,12 +55,12 @@ /************************************************************************ -* Function : send_search_result -* -* Parameters: +* Function : send_search_result +* +* Parameters: * IN void *data: Search reply from the device -* -* Description: +* +* Description: * This function sends a callback to the control point application with * a SEARCH result * @@ -125,16 +125,16 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, // we are assuming that there can be only one client supported at a time - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return; } // copy ctrlpt_callback = ctrlpt_info->Callback; ctrlpt_cookie = ctrlpt_info->Cookie; - HandleUnlock( ); + HandleUnlock(); // search timeout if( timeout ) { @@ -268,9 +268,9 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, return; // bad reply } //check each current search - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); return; } node = ListHead( &ctrlpt_info->SsdpSearchList ); @@ -344,28 +344,30 @@ ssdp_handle_ctrlpt_msg( IN http_message_t * hmsg, node = ListNext( &ctrlpt_info->SsdpSearchList, node ); } - HandleUnlock( ); + HandleUnlock(); //ctrlpt_callback( UPNP_DISCOVERY_SEARCH_RESULT, ¶m, cookie ); } } /************************************************************************ -* Function : process_reply -* -* Parameters: -* IN char* request_buf: the response came from the device -* IN int buf_len: The length of the response buffer -* IN struct sockaddr_in* dest_addr: The address of the device -* IN void *cookie : cookie passed by the control point application -* at the time of sending search message +* Function : process_reply * -* Description: +* Parameters: +* IN char* request_buf: the response came from the device +* IN int buf_len: The length of the response buffer +* IN struct sockaddr_in* dest_addr: The address of the device +* IN void *cookie : cookie passed by the control point application +* at the time of sending search message +* +* Description: * This function processes reply recevied from a search * * Returns: void * ***************************************************************************/ -static XINLINE void +#warning There are currently no uses of the function 'process_reply()' in the code. +#warning 'process_reply()' is a good candidate for removal. +static UPNP_INLINE void process_reply( IN char *request_buf, IN int buf_len, IN struct sockaddr_in *dest_addr, @@ -388,17 +390,17 @@ process_reply( IN char *request_buf, } /************************************************************************ -* Function : CreateClientRequestPacket -* -* Parameters: -* IN char * RqstBuf:Output string in HTTP format. -* IN char *SearchTarget:Search Target -* IN int Mx dest_addr: Number of seconds to wait to -* collect all the responses +* Function : CreateClientRequestPacket * -* Description: +* Parameters: +* IN char * RqstBuf:Output string in HTTP format. +* IN char *SearchTarget:Search Target +* IN int Mx dest_addr: Number of seconds to wait to +* collect all the responses +* +* Description: * This function creates a HTTP search request packet -* depending on the input parameter. +* depending on the input parameter. * * Returns: void * @@ -430,12 +432,12 @@ CreateClientRequestPacket( IN char *RqstBuf, } /************************************************************************ -* Function : searchExpired -* -* Parameters: +* Function : searchExpired +* +* Parameters: * IN void * arg: * -* Description: +* Description: * This function * * Returns: void @@ -456,13 +458,13 @@ searchExpired( void *arg ) void *cookie = NULL; int found = 0; - HandleLock( ); + HandleLock(); //remove search target from search list if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { free( id ); - HandleUnlock( ); + HandleUnlock(); return; } @@ -483,7 +485,7 @@ searchExpired( void *arg ) } node = ListNext( &ctrlpt_info->SsdpSearchList, node ); } - HandleUnlock( ); + HandleUnlock(); if( found ) { ctrlpt_callback( UPNP_DISCOVERY_SEARCH_TIMEOUT, NULL, cookie ); @@ -536,11 +538,10 @@ SearchByTarget( IN int Mx, if( ReqBuf == NULL ) return UPNP_E_OUTOF_MEMORY; - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - ">>> SSDP SEND >>>\n%s\n", ReqBuf ); - ) + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + ">>> SSDP SEND >>>\n%s\n", ReqBuf ); - timeTillRead = Mx; + timeTillRead = Mx; if( timeTillRead < MIN_SEARCH_TIME ) { timeTillRead = MIN_SEARCH_TIME; @@ -559,9 +560,9 @@ SearchByTarget( IN int Mx, FD_SET( gSsdpReqSocket, &wrSet ); //add search criteria to list - HandleLock( ); + HandleLock(); if( GetClientHandleInfo( &handle, &ctrlpt_info ) != HND_CLIENT ) { - HandleUnlock( ); + HandleUnlock(); free( ReqBuf ); return UPNP_E_INTERNAL_ERROR; } @@ -582,33 +583,30 @@ SearchByTarget( IN int Mx, newArg->timeoutEventId = ( *id ); ListAddTail( &ctrlpt_info->SsdpSearchList, newArg ); - HandleUnlock( ); + HandleUnlock(); setsockopt( gSsdpReqSocket, IPPROTO_IP, IP_MULTICAST_IF, ( char * )&addr, sizeof( addr ) ); if( select( gSsdpReqSocket + 1, NULL, &wrSet, NULL, NULL ) == UPNP_SOCKETERROR ) { - DBGONLY( if( errno == EBADF ) { - UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_LIB :RequestHandler:An invalid file descriptor" - " was givenin one of the sets. \n" );} - else - if( errno == EINTR ) { - UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_LIB :RequestHandler: A non blocked " - "signal was caught. \n" );} - else - if( errno == EINVAL ) { - UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_LIB :RequestHandler: n is negative. \n" );} - else - if( errno == ENOMEM ) { - UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_LIB : RequestHandler:select was unable to " - "allocate memory for internal tables.\n" );} - ) -shutdown( gSsdpReqSocket, SD_BOTH ); + if( errno == EBADF ) { + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_LIB :RequestHandler:An invalid file descriptor" + " was givenin one of the sets. \n" ); + } else if( errno == EINTR ) { + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_LIB :RequestHandler: A non blocked " + "signal was caught. \n" ); + } else if( errno == EINVAL ) { + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_LIB :RequestHandler: n is negative. \n" ); + } else if( errno == ENOMEM ) { + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_LIB : RequestHandler:select was unable to " + "allocate memory for internal tables.\n" ); + } + shutdown( gSsdpReqSocket, SD_BOTH ); UpnpCloseSocket( gSsdpReqSocket ); free( ReqBuf ); return UPNP_E_INTERNAL_ERROR; diff --git a/upnp/src/ssdp/ssdp_device.c b/upnp/src/ssdp/ssdp_device.c index 967a7d1..18d30b0 100644 --- a/upnp/src/ssdp/ssdp_device.c +++ b/upnp/src/ssdp/ssdp_device.c @@ -43,22 +43,22 @@ #include "unixutil.h" #ifdef WIN32 - #include - #include + #include + #include #endif -#define MSGTYPE_SHUTDOWN 0 +#define MSGTYPE_SHUTDOWN 0 #define MSGTYPE_ADVERTISEMENT 1 -#define MSGTYPE_REPLY 2 +#define MSGTYPE_REPLY 2 /************************************************************************ -* Function : advertiseAndReplyThread -* -* Parameters: -* IN void *data: Structure containing the search request +* Function : advertiseAndReplyThread * -* Description: -* This function is a wrapper function to reply the search request +* Parameters: +* IN void *data: Structure containing the search request +* +* Description: +* This function is a wrapper function to reply the search request * coming from the control point. * * Returns: void * @@ -81,11 +81,11 @@ advertiseAndReplyThread( IN void *data ) } /************************************************************************ -* Function : ssdp_handle_device_request -* +* Function : ssdp_handle_device_request +* * Parameters: -* IN http_message_t* hmsg: SSDP search request from the control point -* IN struct sockaddr_in* dest_addr: The address info of control point +* IN http_message_t* hmsg: SSDP search request from the control point +* IN struct sockaddr_in* dest_addr: The address info of control point * * Description: * This function handles the search request. It do the sanity checks of @@ -95,6 +95,7 @@ advertiseAndReplyThread( IN void *data ) * Returns: void * * 1 if successful else appropriate error ***************************************************************************/ +#ifdef INCLUDE_DEVICE_APIS void ssdp_handle_device_request( IN http_message_t * hmsg, IN struct sockaddr_in *dest_addr ) @@ -135,30 +136,30 @@ ssdp_handle_device_request( IN http_message_t * hmsg, return; // bad ST header } - HandleLock( ); + HandleLock(); // device info if( GetDeviceHandleInfo( &handle, &dev_info ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return; // no info found } maxAge = dev_info->MaxAge; - HandleUnlock( ); + HandleUnlock(); - DBGONLY( UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "ssdp_handle_device_request with Cmd %d SEARCH\n", - event.Cmd ); - UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "MAX-AGE = %d\n", maxAge ); - UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "MX = %d\n", event.Mx ); - UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "DeviceType = %s\n", event.DeviceType ); - UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "DeviceUuid = %s\n", event.UDN ); - UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, - "ServiceType = %s\n", event.ServiceType ); ) + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "ssdp_handle_device_request with Cmd %d SEARCH\n", + event.Cmd ); + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "MAX-AGE = %d\n", maxAge ); + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "MX = %d\n", event.Mx ); + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "DeviceType = %s\n", event.DeviceType ); + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "DeviceUuid = %s\n", event.UDN ); + UpnpPrintf( UPNP_PACKET, API, __FILE__, __LINE__, + "ServiceType = %s\n", event.ServiceType ); - threadArg = + threadArg = ( SsdpSearchReply * ) malloc( sizeof( SsdpSearchReply ) ); if( threadArg == NULL ) { @@ -185,11 +186,12 @@ ssdp_handle_device_request( IN http_message_t * hmsg, mx = 1; } - replyTime = rand( ) % mx; + replyTime = rand() % mx; TimerThreadSchedule( &gTimerThread, replyTime, REL_SEC, &job, SHORT_TERM, NULL ); } +#endif /************************************************************************ * Function : NewRequestHandler @@ -220,9 +222,9 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr, ReplySock = socket( AF_INET, SOCK_DGRAM, 0 ); if( ReplySock == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP_LIB: New Request Handler:" - "Error in socket operation !!!\n" ) ); + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP_LIB: New Request Handler:" + "Error in socket operation !!!\n" ); return UPNP_E_OUTOF_SOCKET; } @@ -247,13 +249,12 @@ NewRequestHandler( IN struct sockaddr_in *DestAddr, // So, NUM_COPY has been changed from 2 to 1. NumCopy = 0; while( NumCopy < NUM_COPY ) { - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - ">>> SSDP SEND >>>\n%s\n", - *( RqPacket + Index ) ); - ) - rc = sendto( ReplySock, *( RqPacket + Index ), - strlen( *( RqPacket + Index ) ), - 0, ( struct sockaddr * )DestAddr, socklen ); + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + ">>> SSDP SEND >>>\n%s\n", + *( RqPacket + Index ) ); + rc = sendto( ReplySock, *( RqPacket + Index ), + strlen( *( RqPacket + Index ) ), + 0, ( struct sockaddr * )DestAddr, socklen ); imillisleep( SSDP_PAUSE ); ++NumCopy; } @@ -388,11 +389,10 @@ DeviceAdvertisement( IN char *DevType, char *msgs[3]; int ret_code; - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "In function SendDeviceAdvertisemenrt\n" ); - ) + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "In function SendDeviceAdvertisemenrt\n" ); - DestAddr.sin_family = AF_INET; + DestAddr.sin_family = AF_INET; DestAddr.sin_addr.s_addr = inet_addr( SSDP_IP ); DestAddr.sin_port = htons( SSDP_PORT ); @@ -783,11 +783,11 @@ DeviceShutdown( IN char *DevType, Mil_Usn, Location, Duration, &msgs[0] ); } - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "In function DeviceShutdown\n" ); ) - // both root and sub-devices need to send these two messages - CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn, - Location, Duration, &msgs[1] ); + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "In function DeviceShutdown\n" ); + // both root and sub-devices need to send these two messages + CreateServicePacket( MSGTYPE_SHUTDOWN, Udn, Udn, + Location, Duration, &msgs[1] ); sprintf( Mil_Usn, "%s::%s", Udn, DevType ); CreateServicePacket( MSGTYPE_SHUTDOWN, DevType, Mil_Usn, diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c index fd3ee8a..aaf07d7 100644 --- a/upnp/src/ssdp/ssdp_server.c +++ b/upnp/src/ssdp/ssdp_server.c @@ -91,14 +91,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; * Returns: int * UPNP_E_SUCCESS if successful else appropriate error ***************************************************************************/ - int AdvertiseAndReply( IN int AdFlag, - IN UpnpDevice_Handle Hnd, - IN enum SsdpSearchType SearchType, - IN struct sockaddr_in *DestAddr, - IN char *DeviceType, - IN char *DeviceUDN, - IN char *ServiceType, - int Exp ) +int AdvertiseAndReply( IN int AdFlag, + IN UpnpDevice_Handle Hnd, + IN enum SsdpSearchType SearchType, + IN struct sockaddr_in *DestAddr, + IN char *DeviceType, + IN char *DeviceUDN, + IN char *ServiceType, + int Exp ) { int i, j; @@ -115,14 +115,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; const DOMString tmpStr; char SERVER[200]; - DBGONLY( const DOMString dbgStr; - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside AdvertiseAndReply with AdFlag = %d\n", - AdFlag ); ) + const DOMString dbgStr; + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Inside AdvertiseAndReply with AdFlag = %d\n", + AdFlag ); - HandleLock( ); + HandleLock(); if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock( ); + HandleUnlock(); return UPNP_E_INVALID_HANDLE; } defaultExp = SInfo->MaxAge; @@ -139,24 +139,20 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; // parse the device list and send advertisements/replies for( i = 0;; i++ ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Entering new device list with i = %d\n\n", - i ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Entering new device list with i = %d\n\n", i ); - tmpNode = ixmlNodeList_item( SInfo->DeviceList, i ); + tmpNode = ixmlNodeList_item( SInfo->DeviceList, i ); if( tmpNode == NULL ) { - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting new device list with i = %d\n\n", - i ); - ) - break; + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting new device list with i = %d\n\n", i ); + break; } - DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode ); + dbgStr = ixmlNode_getNodeName( tmpNode ); UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Extracting device type once for %s\n", - dbgStr ); ) + "Extracting device type once for %s\n", + dbgStr ); // extract device type ixmlNodeList_free( nodeList ); nodeList = NULL; @@ -167,15 +163,14 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; continue; } - DBGONLY( dbgStr = ixmlNode_getNodeName( tmpNode ); - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Extracting UDN for %s\n", dbgStr ); ) + dbgStr = ixmlNode_getNodeName( tmpNode ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Extracting UDN for %s\n", dbgStr ); - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Extracting device type\n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Extracting device type\n" ); - tmpNode2 = ixmlNodeList_item( nodeList, 0 ); + tmpNode2 = ixmlNodeList_item( nodeList, 0 ); if( tmpNode2 == NULL ) { continue; } @@ -184,11 +179,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; continue; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Extracting device type \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Extracting device type \n" ); - tmpStr = ixmlNode_getNodeValue( textNode ); + tmpStr = ixmlNode_getNodeValue( textNode ); if( tmpStr == NULL ) { continue; } @@ -198,47 +192,41 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; continue; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Extracting device type = %s\n", devType ); - if( tmpNode == NULL ) { - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "TempNode is NULL\n" );} - dbgStr = ixmlNode_getNodeName( tmpNode ); - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Extracting UDN for %s\n", dbgStr ); ) - // extract UDN - ixmlNodeList_free( nodeList ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Extracting device type = %s\n", devType ); + if( tmpNode == NULL ) { + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "TempNode is NULL\n" ); + } + dbgStr = ixmlNode_getNodeName( tmpNode ); + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Extracting UDN for %s\n", dbgStr ); + // extract UDN + ixmlNodeList_free( nodeList ); nodeList = NULL; nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * ) tmpNode, "UDN" ); if( nodeList == NULL ) { - - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, - __LINE__, "UDN not found!!!\n" ); - ) + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, + __LINE__, "UDN not found!!!\n" ); continue; } tmpNode2 = ixmlNodeList_item( nodeList, 0 ); if( tmpNode2 == NULL ) { - - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, - __LINE__, "UDN not found!!!\n" ); - ) - continue; + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, + __LINE__, "UDN not found!!!\n" ); + continue; } textNode = ixmlNode_getFirstChild( tmpNode2 ); if( textNode == NULL ) { - - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, - __LINE__, "UDN not found!!!\n" ); - ) - continue; + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, + __LINE__, "UDN not found!!!\n" ); + continue; } tmpStr = ixmlNode_getNodeValue( textNode ); if( tmpStr == NULL ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, - "UDN not found!!!!\n" ); - ) + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "UDN not found!!!!\n" ); continue; } strcpy( UDNstr, tmpStr ); @@ -246,9 +234,8 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; continue; } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Sending UDNStr = %s \n", UDNstr ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Sending UDNStr = %s \n", UDNstr ); if( AdFlag ) { // send the device advertisement if( AdFlag == 1 ) { @@ -278,22 +265,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; { if( DeviceUDN != NULL && strlen( DeviceUDN ) != 0 ) { if( strcasecmp( DeviceUDN, UDNstr ) ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, API, __FILE__, - __LINE__, - "DeviceUDN=%s and search " - "UDN=%s did not match\n", - UDNstr, DeviceUDN ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "DeviceUDN=%s and search " + "UDN=%s did not match\n", + UDNstr, DeviceUDN ); break; } else { - DBGONLY( UpnpPrintf - ( UPNP_INFO, API, __FILE__, - __LINE__, - "DeviceUDN=%s and search " - "UDN=%s MATCH\n", UDNstr, - DeviceUDN ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "DeviceUDN=%s and search " + "UDN=%s MATCH\n", UDNstr, + DeviceUDN ); SendReply( DestAddr, devType, 0, UDNstr, SInfo->DescURL, defaultExp, 0 ); @@ -306,25 +287,18 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; if( !strncasecmp ( DeviceType, devType, strlen( DeviceType ) ) ) { - DBGONLY( UpnpPrintf - ( UPNP_INFO, API, __FILE__, __LINE__, - "DeviceType=%s and search devType=%s MATCH\n", - devType, DeviceType ); - ) - SendReply( DestAddr, devType, 0, UDNstr, - SInfo->DescURL, defaultExp, 1 ); - } - - DBGONLY( - else - UpnpPrintf( UPNP_INFO, API, __FILE__, - __LINE__, - "DeviceType=%s and search devType=%s" - " DID NOT MATCH\n", - devType, DeviceType ); - ) - - break; + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "DeviceType=%s and search devType=%s MATCH\n", + devType, DeviceType ); + SendReply( DestAddr, devType, 0, UDNstr, + SInfo->DescURL, defaultExp, 1 ); + } else { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "DeviceType=%s and search devType=%s" + " DID NOT MATCH\n", + devType, DeviceType ); + } + break; } default: break; @@ -332,11 +306,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; } // send service advertisements for services corresponding // to the same device - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Sending service Advertisement\n" ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Sending service Advertisement\n" ); - tmpNode = ixmlNodeList_item( SInfo->ServiceList, i ); + tmpNode = ixmlNodeList_item( SInfo->ServiceList, i ); if( tmpNode == NULL ) { continue; } @@ -345,10 +318,9 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; nodeList = ixmlElement_getElementsByTagName( ( IXML_Element * ) tmpNode, "service" ); if( nodeList == NULL ) { - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "Service not found 3\n" ); - ) - continue; + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "Service not found 3\n" ); + continue; } for( j = 0;; j++ ) { tmpNode = ixmlNodeList_item( nodeList, j ); @@ -357,15 +329,11 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; ixmlNodeList_free( tmpNodeList ); tmpNodeList = NULL; - tmpNodeList = ixmlElement_getElementsByTagName( ( IXML_Element - * ) tmpNode, - "serviceType" ); - + tmpNodeList = ixmlElement_getElementsByTagName( + ( IXML_Element *)tmpNode, "serviceType" ); if( tmpNodeList == NULL ) { - DBGONLY( UpnpPrintf - ( UPNP_CRITICAL, API, __FILE__, __LINE__, - "ServiceType not found \n" ); - ) + UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__, + "ServiceType not found \n" ); continue; } tmpNode2 = ixmlNodeList_item( tmpNodeList, 0 ); @@ -386,19 +354,16 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; continue; } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "ServiceType = %s\n", servType ); - ) - if( AdFlag ) { + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "ServiceType = %s\n", servType ); + if( AdFlag ) { if( AdFlag == 1 ) { ServiceAdvertisement( UDNstr, servType, SInfo->DescURL, Exp ); - } else // AdFlag == -1 - { + } else { // AdFlag == -1 ServiceShutdown( UDNstr, servType, SInfo->DescURL, Exp ); } - } else { switch ( SearchType ) { case SSDP_ALL: @@ -433,11 +398,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0; ixmlNodeList_free( nodeList ); nodeList = NULL; } - DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting AdvertiseAndReply : \n" ); - ) + UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, + "Exiting AdvertiseAndReply : \n" ); - HandleUnlock( ); + HandleUnlock( ); return UPNP_E_SUCCESS; @@ -677,7 +641,7 @@ free_ssdp_event_handler_data( void *the_data ) * Returns: xboolean * returns TRUE if msg is valid else FALSE ***************************************************************************/ -static XINLINE xboolean +static UPNP_INLINE xboolean valid_ssdp_msg( IN http_message_t * hmsg ) { memptr hdr_value; @@ -719,7 +683,7 @@ valid_ssdp_msg( IN http_message_t * hmsg ) * Returns: int * 0 if successful -1 if error ***************************************************************************/ -static XINLINE int +static UPNP_INLINE int start_event_handler( void *Data ) { @@ -733,20 +697,18 @@ start_event_handler( void *Data ) if( status == PARSE_FAILURE ) { if( parser->msg.method != HTTPMETHOD_NOTIFY || !parser->valid_ssdp_notify_hack ) { - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP recvd bad msg code = %d\n", - status ); - ) - // ignore bad msg, or not enuf mem - goto error_handler; + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP recvd bad msg code = %d\n", + status ); + // ignore bad msg, or not enuf mem + goto error_handler; } // valid notify msg } else if( status != PARSE_SUCCESS ) { - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "SSDP recvd bad msg code = %d\n", status ); - ) + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "SSDP recvd bad msg code = %d\n", status ); - goto error_handler; + goto error_handler; } // check msg if( !valid_ssdp_msg( &parser->msg ) ) { @@ -784,14 +746,10 @@ ssdp_event_handler_thread( void *the_data ) // send msg to device or ctrlpt if( ( hmsg->method == HTTPMETHOD_NOTIFY ) || ( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) { - CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr, - FALSE, NULL ); - ); + FALSE, NULL );); } else { - - DEVICEONLY( ssdp_handle_device_request( hmsg, &data->dest_addr ); - ); + ssdp_handle_device_request( hmsg, &data->dest_addr ); } // free data @@ -863,21 +821,18 @@ readFromSSDPSocket( SOCKET socket ) if( byteReceived > 0 ) { requestBuf[byteReceived] = '\0'; - DBGONLY( UpnpPrintf( UPNP_INFO, SSDP, + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, "Received response !!! " "%s From host %s \n", requestBuf, inet_ntoa( clientAddr.sin_addr ) ); - ) - DBGONLY( UpnpPrintf( UPNP_PACKET, SSDP, - __FILE__, __LINE__, - "Received multicast packet:" - "\n %s\n", requestBuf ); - ) - //add thread pool job to handle request - if( data != NULL ) { + UpnpPrintf( UPNP_PACKET, SSDP, __FILE__, __LINE__, + "Received multicast packet:" + "\n %s\n", requestBuf ); + //add thread pool job to handle request + if( data != NULL ) { data->parser.msg.msg.length += byteReceived; // null-terminate data->parser.msg.msg.buf[byteReceived] = 0; @@ -891,7 +846,6 @@ readFromSSDPSocket( SOCKET socket ) free_ssdp_event_handler_data( data ); } } - } else { free_ssdp_event_handler_data( data ); } @@ -926,9 +880,9 @@ get_ssdp_sockets( MiniServerSockArray * out ) CLIENTONLY( if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - SSDP, __FILE__, __LINE__, - "Error in socket operation !!!\n" ); ) + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in socket operation !!!\n" ); return UPNP_E_OUTOF_SOCKET;} setsockopt( ssdpReqSock, IPPROTO_IP, @@ -938,11 +892,10 @@ get_ssdp_sockets( MiniServerSockArray * out ) if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - SSDP, __FILE__, __LINE__, - "Error in socket operation !!!\n" ); - ) - CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in socket operation !!!\n" ); + CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); return UPNP_E_OUTOF_SOCKET; } @@ -951,11 +904,10 @@ get_ssdp_sockets( MiniServerSockArray * out ) if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR, ( char * )&onOff, sizeof( onOff ) ) != 0 ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - SSDP, __FILE__, __LINE__, - "Error in set reuse addr !!!\n" ); - ) - CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in set reuse addr !!!\n" ); + CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); shutdown( ssdpSock, SD_BOTH ); UpnpCloseSocket( ssdpSock ); @@ -966,11 +918,10 @@ get_ssdp_sockets( MiniServerSockArray * out ) if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT, ( char * )&onOff, sizeof( onOff ) ) != 0 ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - SSDP, __FILE__, __LINE__, - "Error in set reuse port !!!\n" ); - ) - CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in set reuse port !!!\n" ); + CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); shutdown( ssdpSock, SD_BOTH ); UpnpCloseSocket( ssdpSock ); @@ -986,10 +937,9 @@ get_ssdp_sockets( MiniServerSockArray * out ) if( bind ( ssdpSock, ( struct sockaddr * )&ssdpAddr, sizeof( ssdpAddr ) ) != 0 ) { - DBGONLY( UpnpPrintf - ( UPNP_CRITICAL, SSDP, __FILE__, __LINE__, - "Error in binding !!!\n" ); - ) + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in binding !!!\n" ); shutdown( ssdpSock, SD_BOTH ); UpnpCloseSocket( ssdpSock ); CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); @@ -1003,11 +953,10 @@ get_ssdp_sockets( MiniServerSockArray * out ) if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP, ( char * )&ssdpMcastAddr, sizeof( struct ip_mreq ) ) != 0 ) { - DBGONLY( UpnpPrintf - ( UPNP_CRITICAL, SSDP, __FILE__, __LINE__, - "Error in joining" " multicast group !!!\n" ); - ) - shutdown( ssdpSock, SD_BOTH ); + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in joining" " multicast group !!!\n" ); + shutdown( ssdpSock, SD_BOTH ); CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); UpnpCloseSocket( ssdpSock ); CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); @@ -1019,8 +968,8 @@ get_ssdp_sockets( MiniServerSockArray * out ) addr.s_addr = inet_addr(LOCAL_HOST); if (setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF, (char *)&addr, sizeof addr) != 0) { - DBGONLY(UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, - "Couldn't set multicast interface.\n" )); + UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, + "Couldn't set multicast interface.\n" ); /* This is probably not a critical error, so let's continue. */ } @@ -1029,11 +978,10 @@ get_ssdp_sockets( MiniServerSockArray * out ) IP_MULTICAST_TTL, &ttl, sizeof( ttl ) ); if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST, ( char * )&option, sizeof( option ) ) != 0 ) { - DBGONLY( UpnpPrintf( UPNP_CRITICAL, - SSDP, __FILE__, __LINE__, - "Error in setting broadcast !!!\n" ); - ) - shutdown( ssdpSock, SD_BOTH ); + UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in setting broadcast !!!\n" ); + shutdown( ssdpSock, SD_BOTH ); CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); UpnpCloseSocket( ssdpSock ); CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); diff --git a/upnp/src/urlconfig/urlconfig.c b/upnp/src/urlconfig/urlconfig.c index 621e23f..7da2fa3 100644 --- a/upnp/src/urlconfig/urlconfig.c +++ b/upnp/src/urlconfig/urlconfig.c @@ -62,7 +62,7 @@ * * Note : ************************************************************************/ -static XINLINE void +static UPNP_INLINE void addrToString( IN const struct sockaddr_in *addr, OUT char ipaddr_port[] ) { @@ -87,7 +87,7 @@ addrToString( IN const struct sockaddr_in *addr, * * Note : 'newAlias' should be freed using free() ************************************************************************/ -static XINLINE int +static UPNP_INLINE int calc_alias( IN const char *alias, IN const char *rootPath, OUT char **newAlias ) @@ -148,7 +148,7 @@ calc_alias( IN const char *alias, * * Note : ************************************************************************/ -static XINLINE int +static UPNP_INLINE int calc_descURL( IN const char *ipPortStr, IN const char *alias, OUT char descURL[LINE_SIZE] ) @@ -168,11 +168,10 @@ calc_descURL( IN const char *ipPortStr, strcat( descURL, ipPortStr ); strcat( descURL, alias ); - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "desc url: %s\n", descURL ); - ) + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "desc url: %s\n", descURL ); - return UPNP_E_SUCCESS; + return UPNP_E_SUCCESS; } /************************************************************************ @@ -408,18 +407,16 @@ configure_urlbase( INOUT IXML_Document * doc, goto error_handler; } - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "desc url: %s\n", docURL ); - ) - DBGONLY( UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, - "doc = %s\n", xml_str ); - ) - // store in web server - err_code = + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "desc url: %s\n", docURL ); + UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__, + "doc = %s\n", xml_str ); + // store in web server + err_code = web_server_set_alias( new_alias, xml_str, strlen( xml_str ), last_modified ); - error_handler: +error_handler: free( root_path ); free( new_alias );