git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@399 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2008-06-02 03:43:25 +00:00
parent 1401fce206
commit 1175a0cadb
6 changed files with 841 additions and 1113 deletions

View File

@ -1029,7 +1029,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED = DEBUG INCLUDE_DEVICE_APIS INCLUDE_CLIENT_APIS EXCLUDE_GENA=0
PREDEFINED = DEBUG INCLUDE_DEVICE_APIS INCLUDE_CLIENT_APIS EXCLUDE_GENA=0 EXCLUDE_DOM=0
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.

View File

@ -784,10 +784,10 @@ extern "C" {
EXPORT_SPEC int UpnpInit(
/*! The host local IP address to use, in string format, for example
* "192.168.0.1", or \c NULL to use the first adapter's IP address. */
IN const char *HostIP,
const char *HostIP,
/*! Local Port to listen for incoming connections
* \c NULL will pick an arbitrary free port. */
IN unsigned short DestPort);
unsigned short DestPort);
/*!
@ -826,10 +826,10 @@ EXPORT_SPEC int UpnpInit2(
/*! The interface name to use by the UPnP SDK operations.
* Examples: "eth0", "xl0", "Local Area Connection", \c NULL to
* use the first suitable interface. */
IN const char *IfName,
const char *IfName,
/*! Local Port to listen for incoming connections.
* \c NULL will pick an arbitrary free port. */
IN unsigned short DestPort);
unsigned short DestPort);
/*!
@ -946,15 +946,15 @@ EXPORT_SPEC char *UpnpGetServerIp6Address();
* register this root device.
*/
EXPORT_SPEC int UpnpRegisterRootDevice(
/*! Pointer to a string containing the description URL for this root device
/*! [in] Pointer to a string containing the description URL for this root device
* instance. */
IN const char *DescUrl,
/*! Pointer to the callback function for receiving asynchronous events. */
IN Upnp_FunPtr Callback,
/*! Pointer to user data returned with the callback function when invoked. */
IN const void *Cookie,
/*! Pointer to a variable to store the new device handle. */
OUT UpnpDevice_Handle *Hnd);
const char *DescUrl,
/*! [in] Pointer to the callback function for receiving asynchronous events. */
Upnp_FunPtr Callback,
/*! [in] Pointer to user data returned with the callback function when invoked. */
const void *Cookie,
/*! [out] Pointer to a variable to store the new device handle. */
UpnpDevice_Handle *Hnd);
/*!
* \brief Registers a device application with the UPnP Library. Similar to
@ -1025,24 +1025,24 @@ EXPORT_SPEC int UpnpRegisterRootDevice(
* description document.
*/
EXPORT_SPEC int UpnpRegisterRootDevice2(
/*! The type of the description document. */
IN Upnp_DescType descriptionType,
/*! Treated as a URL, file name or memory buffer depending on
/*! [in] The type of the description document. */
Upnp_DescType descriptionType,
/*! [in] Treated as a URL, file name or memory buffer depending on
* description type. */
IN const char* description,
/*! The length of memory buffer if passing a description in a buffer,
const char* description,
/*! [in] The length of memory buffer if passing a description in a buffer,
* otherwise it is ignored. */
IN size_t bufferLen,
/*! If nonzero, \c URLBase of description document is configured and
size_t bufferLen,
/*! [in] If nonzero, \c URLBase of description document is configured and
* the description is served using the internal web server. */
IN int config_baseURL,
/*! Pointer to the callback function for receiving asynchronous events. */
int config_baseURL,
/*! [in] Pointer to the callback function for receiving asynchronous events. */
IN Upnp_FunPtr Fun,
/*! Pointer to user data returned with the callback function when
/*! [in] Pointer to user data returned with the callback function when
* invoked. */
IN const void* Cookie,
/*! Pointer to a variable to store the new device handle. */
OUT UpnpDevice_Handle* Hnd);
const void* Cookie,
/*! [out] Pointer to a variable to store the new device handle. */
UpnpDevice_Handle* Hnd);
/*!
@ -1081,19 +1081,18 @@ EXPORT_SPEC int UpnpRegisterRootDevice2(
* register this root device.
*/
EXPORT_SPEC int UpnpRegisterRootDevice3(
/*! Pointer to a string containing the description URL for this root
/*! [in] Pointer to a string containing the description URL for this root
* device instance. */
IN const char *DescUrl,
/*! Pointer to the callback function for receiving asynchronous events. */
IN Upnp_FunPtr Callback,
/*! Pointer to user data returned with the callback function when
* invoked. */
IN const void *Cookie,
/*! Pointer to a variable to store the new device handle. */
OUT UpnpDevice_Handle *Hnd,
/*! Address family of this device. Can be AF_INET for an IPv4 device, or
const char *DescUrl,
/*! [in] Pointer to the callback function for receiving asynchronous events. */
Upnp_FunPtr Callback,
/*! [in] Pointer to user data returned with the callback function when invoked. */
const void *Cookie,
/*! [out] Pointer to a variable to store the new device handle. */
UpnpDevice_Handle *Hnd,
/*! [in] Address family of this device. Can be AF_INET for an IPv4 device, or
* AF_INET6 for an IPv6 device. Defaults to AF_INET. */
IN const int AddressFamily);
const int AddressFamily);
/*!
@ -1112,8 +1111,8 @@ EXPORT_SPEC int UpnpRegisterRootDevice3(
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
*/
EXPORT_SPEC int UpnpUnRegisterRootDevice(
/*! The handle of the root device instance to unregister. */
IN UpnpDevice_Handle);
/*! [in] The handle of the root device instance to unregister. */
UpnpDevice_Handle);
/*!
@ -1135,12 +1134,12 @@ EXPORT_SPEC int UpnpUnRegisterRootDevice(
* register this control point.
*/
EXPORT_SPEC int UpnpRegisterClient(
/*! Pointer to a function for receiving asynchronous events. */
IN Upnp_FunPtr Callback,
/*! Pointer to user data returned with the callback function when invoked. */
IN const void *Cookie,
/*! Pointer to a variable to store the new control point handle. */
OUT UpnpClient_Handle *Hnd);
/*! [in] Pointer to a function for receiving asynchronous events. */
Upnp_FunPtr Callback,
/*! [in] Pointer to user data returned with the callback function when invoked. */
const void *Cookie,
/*! [out] Pointer to a variable to store the new control point handle. */
UpnpClient_Handle *Hnd);
/*!
@ -1160,8 +1159,8 @@ EXPORT_SPEC int UpnpRegisterClient(
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid control point handle.
*/
EXPORT_SPEC int UpnpUnRegisterClient(
/*! The handle of the control point instance to unregister. */
IN UpnpClient_Handle Hnd);
/*! [in] The handle of the control point instance to unregister. */
UpnpClient_Handle Hnd);
/*!
@ -1171,11 +1170,11 @@ EXPORT_SPEC int UpnpUnRegisterClient(
* of this function is global to the SDK (= same as \b UpnpSetMaxContentLength).
*/
EXPORT_SPEC int UpnpSetContentLength(
/*! The handle of the device instance for which the coincoming content
/*! [in] The handle of the device instance for which the coincoming content
* length needs to be set. */
IN UpnpClient_Handle Hnd,
/*! Permissible content length */
IN int contentLength);
UpnpClient_Handle Hnd,
/*! [in] Permissible content length */
int contentLength);
/*!
@ -1193,9 +1192,9 @@ EXPORT_SPEC int UpnpSetContentLength(
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
*/
EXPORT_SPEC int UpnpSetMaxContentLength(
/*! The maximum permissible content length for incoming SOAP actions,
* in bytes. */
IN size_t contentLength);
/*! [in] The maximum permissible content length for incoming SOAP actions,
* in bytes. */
size_t contentLength);
/* @} Initialization and Registration */
@ -2075,13 +2074,13 @@ EXPORT_SPEC int UpnpUnSubscribeAsync(
* allocated.
*/
EXPORT_SPEC int UpnpDownloadUrlItem(
/*! URL of an item to download. */
IN const char *url,
/*! Buffer to store the downloaded item. */
OUT char **outBuf,
/*! HTTP header value content type if present. It should be at least
/*! [in] URL of an item to download. */
const char *url,
/*! [out] Buffer to store the downloaded item. */
char **outBuf,
/*! [out] HTTP header value content type if present. It should be at least
* \c LINE_SIZE bytes in size. */
OUT char *contentType);
char *contentType);
/*!
@ -2113,20 +2112,20 @@ EXPORT_SPEC int UpnpDownloadUrlItem(
* remote server.
*/
EXPORT_SPEC int UpnpOpenHttpGet(
/*! The URL of an item to get. */
IN const char *url,
/*! A pointer to store the handle for this connection. */
IN OUT void **handle,
/*! A buffer to store the media type of the item. */
IN OUT char **contentType,
/*! A pointer to store the length of the item. */
IN OUT int *contentLength,
/*! The status returned on receiving a response message. */
IN OUT int *httpStatus,
/*! The time out value sent with the request during which a response
/*! [in] The URL of an item to get. */
const char *url,
/*! [in,out] A pointer to store the handle for this connection. */
void **handle,
/*! [in,out] A buffer to store the media type of the item. */
char **contentType,
/*! [in,out] A pointer to store the length of the item. */
int *contentLength,
/*! [in,out] The status returned on receiving a response message. */
int *httpStatus,
/*! [in] The time out value sent with the request during which a response
* is expected from the server, failing which, an error is reported
* back to the user. */
IN int timeout);
int timeout);
/*!
@ -2158,22 +2157,22 @@ EXPORT_SPEC int UpnpOpenHttpGet(
* remote server.
*/
EXPORT_SPEC int UpnpOpenHttpGetProxy(
/*! The URL of an item to get. */
IN const char *url,
/*! The URL of the proxy. */
IN const char *proxy_str,
/*! A pointer to store the handle for this connection. */
IN OUT void **handle,
/*! A buffer to store the media type of the item. */
IN OUT char **contentType,
/*! A pointer to store the length of the item. */
IN OUT int *contentLength,
/*! The status returned on receiving a response message. */
IN OUT int *httpStatus,
/*! The time out value sent with the request during which a response
/*! [in] The URL of an item to get. */
const char *url,
/*! [in] The URL of the proxy. */
const char *proxy_str,
/*! [in,out] A pointer to store the handle for this connection. */
void **handle,
/*! [in,out] A buffer to store the media type of the item. */
char **contentType,
/*! [in,out] A pointer to store the length of the item. */
int *contentLength,
/*! [in,out] The status returned on receiving a response message. */
int *httpStatus,
/*! [in] The time out value sent with the request during which a response
* is expected from the server, failing which, an error is reported
* back to the user. */
IN int timeout);
int timeout);
/*!
@ -2207,24 +2206,24 @@ EXPORT_SPEC int UpnpOpenHttpGetProxy(
* remote server.
*/
EXPORT_SPEC int UpnpOpenHttpGetEx(
/*! The URL of the item to get. */
IN const char *url,
/*! A pointer to store the handle for this connection. */
IN OUT void **handle,
/*! A buffer to store the media type of the item. */
IN OUT char **contentType,
/*! A buffer to store the length of the item. */
IN OUT int *contentLength,
/*! The status returned on receiving a response message from the remote server. */
IN OUT int *httpStatus,
/*! An integer value representing the low end of a range to retrieve. */
IN int lowRange,
/*! An integer value representing the high end of a range to retrieve. */
IN int highRange,
/*! A time out value sent with the request during which a response is
/*! [in] The URL of the item to get. */
const char *url,
/*! [in,out] A pointer to store the handle for this connection. */
void **handle,
/*! [in,out] A buffer to store the media type of the item. */
char **contentType,
/*! [in,out] A buffer to store the length of the item. */
int *contentLength,
/*! [in,out] The status returned on receiving a response message from the remote server. */
int *httpStatus,
/*! [in] An integer value representing the low end of a range to retrieve. */
int lowRange,
/*! [in] An integer value representing the high end of a range to retrieve. */
int highRange,
/*! [in] A time out value sent with the request during which a response is
* expected from the server, failing which, an error is reported back
* to the user. */
IN int timeout);
int timeout);
/*!
@ -2245,16 +2244,16 @@ EXPORT_SPEC int UpnpOpenHttpGetEx(
* value.
*/
EXPORT_SPEC int UpnpReadHttpGet(
/*! The token created by the call to \b UpnpOpenHttpGet. */
IN void *handle,
/*! The buffer to store the read item. */
IN OUT char *buf,
/*! The size of the buffer to be read. */
IN OUT unsigned int *size,
/*! The time out value sent with the request during which a response is
/*! [in] The token created by the call to \b UpnpOpenHttpGet. */
void *handle,
/*! [in,out] The buffer to store the read item. */
char *buf,
/*! [in,out] The size of the buffer to be read. */
unsigned int *size,
/*! [in] The time out value sent with the request during which a response is
* expected from the server, failing which, an error is reported back to
* the user. */
IN int timeout);
int timeout);
/*!
@ -2266,12 +2265,12 @@ EXPORT_SPEC int UpnpReadHttpGet(
* or \b total is not a valid pointer.
*/
EXPORT_SPEC int UpnpHttpGetProgress(
/*! The token created by the call to \b UpnpOpenHttpGet. */
IN void *handle,
/*! The number of bytes received. */
OUT unsigned int *length,
/*! The content length. */
OUT unsigned int *total);
/*! [in] The token created by the call to \b UpnpOpenHttpGet. */
void *handle,
/*! [out] The number of bytes received. */
unsigned int *length,
/*! [out] The content length. */
unsigned int *total);
/*!
@ -2281,7 +2280,10 @@ EXPORT_SPEC int UpnpHttpGetProgress(
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_PARAM: \b handle is not a valid pointer.
*/
EXPORT_SPEC int UpnpCancelHttpGet(IN void *handle);
EXPORT_SPEC int UpnpCancelHttpGet(
/*! [in] The handle of the connection created by the call to
* \b UpnpOpenHttpPost. */
void *handle);
/*!
* \brief Closes the connection and frees memory that was allocated for the
@ -2291,7 +2293,10 @@ EXPORT_SPEC int UpnpCancelHttpGet(IN void *handle);
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_PARAM: \b handle is not a valid pointer.
*/
EXPORT_SPEC int UpnpCloseHttpGet(IN void *handle);
EXPORT_SPEC int UpnpCloseHttpGet(
/*! [in] The handle of the connection created by the call to
* \b UpnpOpenHttpPost. */
void *handle);
/*!
@ -2320,18 +2325,18 @@ EXPORT_SPEC int UpnpCloseHttpGet(IN void *handle);
* allocated.
*/
EXPORT_SPEC int UpnpOpenHttpPost(
/*! The URL in which to send the POST request. */
IN const char *url,
/*! A pointer in which to store the handle for this connection. This
/*! [in] The URL in which to send the POST request. */
const char *url,
/*! [in,out] A pointer in which to store the handle for this connection. This
* handle is required for futher operations over this connection. */
IN OUT void **handle,
/*! A buffer to store the media type of content being sent. */
IN const char *contentType,
/*! The length of the content, in bytes, being posted. */
IN int contentLength,
/*! The time out value sent with the request during which a response
* is expected from the receiver, failing which, an error is reported. */
IN int timeout);
void **handle,
/*! [in] A buffer to store the media type of content being sent. */
const char *contentType,
/*! [in] The length of the content, in bytes, being posted. */
int contentLength,
/*! [in] The time out value sent with the request during which a response
* is expected from the receiver, failing which, an error is reported. */
int timeout);
/*!
@ -2348,16 +2353,16 @@ EXPORT_SPEC int UpnpOpenHttpPost(
* allocated.
*/
EXPORT_SPEC int UpnpWriteHttpPost(
/*! The handle of the connection created by the call to
/*! [in] The handle of the connection created by the call to
* \b UpnpOpenHttpPost. */
IN void *handle,
/*! The buffer to be posted. */
IN char *buf,
/*! The size, in bytes of \b buf. */
IN unsigned int *size,
/*! A timeout value sent with the request during which a response is
void *handle,
/*! [in] The buffer to be posted. */
char *buf,
/*! [in] The size, in bytes of \b buf. */
unsigned int *size,
/*! [in] A timeout value sent with the request during which a response is
* expected from the server, failing which, an error is reported. */
IN int timeout);
int timeout);
/*!
@ -2374,14 +2379,14 @@ EXPORT_SPEC int UpnpWriteHttpPost(
* allocated.
*/
EXPORT_SPEC int UpnpCloseHttpPost(
/*! The handle of the connection to close, created by the call to
/*! [in] The handle of the connection to close, created by the call to
* \b UpnpOpenHttpPost. */
IN void *handle,
/*! A pointer to a buffer to store the final status of the connection. */
IN OUT int *httpStatus,
/*! A time out value sent with the request during which a response is
void *handle,
/*! [in,out] A pointer to a buffer to store the final status of the connection. */
int *httpStatus,
/*! [in] A time out value sent with the request during which a response is
* expected from the server, failing which, an error is reported. */
IN int timeout);
int timeout);
/*!
@ -2412,10 +2417,10 @@ EXPORT_SPEC int UpnpCloseHttpPost(
* allocated.
*/
EXPORT_SPEC int UpnpDownloadXmlDoc(
/*! URL of the XML document. */
IN const char *url,
/*! A pointer in which to store the XML document. */
OUT IXML_Document **xmlDoc);
/*! [in] URL of the XML document. */
const char *url,
/*! [out] A pointer in which to store the XML document. */
IXML_Document **xmlDoc);
/*! @} Control Point HTTP API */
@ -2443,16 +2448,16 @@ EXPORT_SPEC int UpnpDownloadXmlDoc(
* web server, pass \c NULL for \b rootDir; to activate, pass a valid directory
* string.
*
* Note that this function is not available when the web server is not compiled
* into the SDK.
* \note This function is not available when the web server is not compiled
* into the UPnP Library.
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_ARGUMENT: \b rootDir is an invalid directory.
*/
EXPORT_SPEC int UpnpSetWebServerRootDir(
/*! Path of the root directory of the web server. */
IN const char *rootDir);
/*! [in] Path of the root directory of the web server. */
const char *rootDir);
/*!
@ -2604,8 +2609,8 @@ EXPORT_SPEC int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback);
* \li \c UPNP_E_INVALID_ARGUMENT: \b enable is not valid.
*/
EXPORT_SPEC int UpnpEnableWebserver(
/*! \c TRUE to enable, \c FALSE to disable. */
IN int enable);
/*! [in] \c TRUE to enable, \c FALSE to disable. */
int enable);
/*!
@ -2625,13 +2630,16 @@ EXPORT_SPEC int UpnpIsWebserverEnabled();
* functions contained in a \b VirtualDirCallbacks structure registered
* via \b UpnpSetVirtualDirCallbacks.
*
* \note This function is not available when the web server is not
* compiled into the UPnP Library.
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_ARGUMENT: \b dirName is not valid.
*/
EXPORT_SPEC int UpnpAddVirtualDir(
/*! The name of the new directory mapping to add. */
IN const char *dirName);
/*! [in] The name of the new directory mapping to add. */
const char *dirName);
/*!
@ -2642,8 +2650,8 @@ EXPORT_SPEC int UpnpAddVirtualDir(
* \li \c UPNP_E_INVALID_ARGUMENT: \b dirName is not valid.
*/
EXPORT_SPEC int UpnpRemoveVirtualDir(
/*! The name of the virtual directory mapping to remove. */
IN const char *dirName);
/*! [in] The name of the virtual directory mapping to remove. */
const char *dirName);
/*!

View File

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

View File

@ -33,6 +33,11 @@
#include "config.h"
/*!
* \file
*/
#include <sys/stat.h>
@ -168,17 +173,17 @@ Upnp_SID gUpnpSdkNLSuuid;
// FIXME Put this declaration in the proper header file
static int
GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
IN char *description,
IN unsigned int bufferLen,
IN int config_baseURL,
IN int AddressFamily,
OUT IXML_Document ** xmlDoc,
OUT char descURL[LINE_SIZE] );
static int GetDescDocumentAndURL(
IN Upnp_DescType descriptionType,
IN char *description,
IN unsigned int bufferLen,
IN int config_baseURL,
IN int AddressFamily,
OUT IXML_Document ** xmlDoc,
OUT char descURL[LINE_SIZE] );
int UpnpInit(IN const char *HostIP, IN unsigned short DestPort)
int UpnpInit(const char *HostIP, unsigned short DestPort)
{
int retVal;
@ -231,7 +236,7 @@ int UpnpInit(IN const char *HostIP, IN unsigned short DestPort)
}
int UpnpInit2(IN const char *IfName, IN unsigned short DestPort)
int UpnpInit2(const char *IfName, unsigned short DestPort)
{
int retVal;
@ -406,10 +411,10 @@ char *UpnpGetServerIp6Address()
#ifdef INCLUDE_DEVICE_APIS
int UpnpRegisterRootDevice(
IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle *Hnd)
const char *DescUrl,
Upnp_FunPtr Fun,
const void *Cookie,
UpnpDevice_Handle *Hnd)
{
struct Handle_Info *HInfo = NULL;
int retVal = 0;
@ -537,13 +542,13 @@ exit_function:
#ifdef INCLUDE_DEVICE_APIS
int UpnpRegisterRootDevice2(
IN Upnp_DescType descriptionType,
IN const char *description_const,
IN size_t bufferLen, // ignored unless descType == UPNPREG_BUF_DESC
IN int config_baseURL,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle *Hnd)
Upnp_DescType descriptionType,
const char *description_const,
size_t bufferLen, // ignored unless descType == UPNPREG_BUF_DESC
int config_baseURL,
Upnp_FunPtr Fun,
const void *Cookie,
UpnpDevice_Handle *Hnd)
{
struct Handle_Info *HInfo = NULL;
int retVal = 0;
@ -667,11 +672,11 @@ exit_function:
#ifdef INCLUDE_DEVICE_APIS
int UpnpRegisterRootDevice3(
IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd,
IN const int AddressFamily )
const char *DescUrl,
Upnp_FunPtr Fun,
const void *Cookie,
UpnpDevice_Handle *Hnd,
const int AddressFamily)
{
struct Handle_Info *HInfo;
int retVal = 0;
@ -800,7 +805,7 @@ exit_function:
#ifdef INCLUDE_DEVICE_APIS
int UpnpUnRegisterRootDevice(IN UpnpDevice_Handle Hnd)
int UpnpUnRegisterRootDevice(UpnpDevice_Handle Hnd)
{
int retVal = 0;
struct Handle_Info *HInfo = NULL;
@ -826,9 +831,9 @@ int UpnpUnRegisterRootDevice(IN UpnpDevice_Handle Hnd)
HandleUnlock();
#if EXCLUDE_SSDP == 0
retVal = AdvertiseAndReply( -1, Hnd, 0, ( struct sockaddr * )NULL,
( char * )NULL, ( char * )NULL,
( char * )NULL, HInfo->MaxAge );
retVal = AdvertiseAndReply(-1, Hnd, 0, (struct sockaddr *)NULL,
(char *)NULL, (char *)NULL,
(char *)NULL, HInfo->MaxAge);
#endif
HandleLock();
@ -867,12 +872,11 @@ int UpnpUnRegisterRootDevice(IN UpnpDevice_Handle Hnd)
#endif // INCLUDE_DEVICE_APIS
/*****************************************************************************/
#ifdef INCLUDE_CLIENT_APIS
int UpnpRegisterClient(
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpClient_Handle *Hnd)
Upnp_FunPtr Fun,
const void *Cookie,
UpnpClient_Handle *Hnd)
{
struct Handle_Info *HInfo;
@ -925,9 +929,8 @@ int UpnpRegisterClient(
#endif // INCLUDE_CLIENT_APIS
/*****************************************************************************/
#ifdef INCLUDE_CLIENT_APIS
int UpnpUnRegisterClient(IN UpnpClient_Handle Hnd)
int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
{
struct Handle_Info *HInfo;
ListNode *node = NULL;
@ -979,10 +982,8 @@ int UpnpUnRegisterClient(IN UpnpClient_Handle Hnd)
#endif // INCLUDE_CLIENT_APIS
// *************************************************************
#ifdef INCLUDE_DEVICE_APIS
#ifdef INTERNAL_WEB_SERVER
/**************************************************************************
* Function: GetNameForAlias
*
@ -2932,141 +2933,85 @@ UpnpGetServiceVarStatus( IN UpnpClient_Handle Hnd,
return retVal;
} /****************** End of UpnpGetServiceVarStatus *********************/
}
#endif // INCLUDE_CLIENT_APIS
#endif // EXCLUDE_SOAP
//---------------------------------------------------------------------------
//
// Client API's
//
//---------------------------------------------------------------------------
/**************************************************************************
* Function: UpnpOpenHttpPost
/******************************************************************************
*
* Parameters:
*
* Description:
* Client API's
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
*****************************************************************************/
int
UpnpOpenHttpPost( IN const char *url,
IN OUT void **handle,
IN const char *contentType,
IN int contentLength,
IN int timeout )
int UpnpOpenHttpPost(
const char *url,
void **handle,
const char *contentType,
int contentLength,
int timeout)
{
return http_OpenHttpPost( url, handle, contentType, contentLength,
timeout );
}
/**************************************************************************
* Function: UpnpWriteHttpPost
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpWriteHttpPost( IN void *handle,
IN char *buf,
IN unsigned int *size,
IN int timeout )
int UpnpWriteHttpPost(
void *handle,
char *buf,
unsigned int *size,
int timeout)
{
return http_WriteHttpPost( handle, buf, size, timeout );
}
/**************************************************************************
* Function: UpnpCloseHttpPost
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpCloseHttpPost( IN void *handle,
IN OUT int *httpStatus,
int timeout )
int UpnpCloseHttpPost(
void *handle,
int *httpStatus,
int timeout)
{
return http_CloseHttpPost( handle, httpStatus, timeout );
}
/**************************************************************************
* Function: UpnpOpenHttpGet
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpOpenHttpGet( IN const char *url_str,
IN OUT void **Handle,
IN OUT char **contentType,
OUT int *contentLength,
OUT int *httpStatus,
IN int timeout )
int UpnpOpenHttpGet(
const char *url_str,
void **Handle,
char **contentType,
int *contentLength,
int *httpStatus,
int timeout)
{
return http_OpenHttpGet( url_str, Handle, contentType, contentLength,
httpStatus, timeout );
}
/**************************************************************************
* Function: UpnpOpenHttpGetProxy
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpOpenHttpGetProxy( IN const char *url_str,
IN const char *proxy_str,
IN OUT void **Handle,
IN OUT char **contentType,
OUT int *contentLength,
OUT int *httpStatus,
IN int timeout )
int UpnpOpenHttpGetProxy(
const char *url_str,
const char *proxy_str,
void **Handle,
char **contentType,
int *contentLength,
int *httpStatus,
int timeout)
{
return http_OpenHttpGetProxy( url_str, proxy_str, Handle, contentType, contentLength,
httpStatus, timeout );
}
/**************************************************************************
* Function: UpnpOpenHttpGetEx
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpOpenHttpGetEx( IN const char *url_str,
IN OUT void **Handle,
IN OUT char **contentType,
OUT int *contentLength,
OUT int *httpStatus,
IN int lowRange,
IN int highRange,
IN int timeout )
int UpnpOpenHttpGetEx(
const char *url_str,
void **Handle,
char **contentType,
int *contentLength,
int *httpStatus,
int lowRange,
int highRange,
int timeout)
{
return http_OpenHttpGetEx( url_str,
Handle,
@ -3076,93 +3021,31 @@ UpnpOpenHttpGetEx( IN const char *url_str,
}
/**************************************************************************
* Function: UpnpCancelHttpGet
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpCancelHttpGet( IN void *Handle )
int UpnpCancelHttpGet(void *Handle)
{
return http_CancelHttpGet( Handle );
}
/**************************************************************************
* Function: UpnpCloseHttpGet
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpCloseHttpGet( IN void *Handle )
{
return http_CloseHttpGet( Handle );
}
/**************************************************************************
* Function: UpnpReadHttpGet
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpReadHttpGet( IN void *Handle,
IN OUT char *buf,
IN OUT unsigned int *size,
IN int timeout )
{
return http_ReadHttpGet( Handle, buf, size, timeout );
return http_CancelHttpGet(Handle);
}
/**************************************************************************
* Function: UpnpHttpGetProgress
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful.
* UPNP_E_INVALID_PARAM if the provided pointers were invalid.
***************************************************************************/
int
UpnpHttpGetProgress( IN void *Handle,
OUT unsigned int *length,
OUT unsigned int *total )
int UpnpCloseHttpGet(void *Handle)
{
return http_HttpGetProgress(Handle, length, total);
return http_CloseHttpGet(Handle);
}
/**************************************************************************
* Function: UpnpDownloadUrlItem
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
int
UpnpDownloadUrlItem( const char *url,
char **outBuf,
char *contentType )
int UpnpReadHttpGet(void *Handle, char *buf, unsigned int *size, int timeout)
{
return http_ReadHttpGet(Handle, buf, size, timeout);
}
int UpnpHttpGetProgress(void *Handle, unsigned int *length, unsigned int *total)
{
return http_HttpGetProgress(Handle, length, total);
}
int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
{
int ret_code;
int dummy;
@ -3181,16 +3064,12 @@ UpnpDownloadUrlItem( const char *url,
return ret_code;
}
/**************************************************************************
* Function: UpnpDownloadXmlDoc
/*!
* \brief UpnpDownloadXmlDoc
*
* Parameters:
*
* Description:
*
* Return Values: int
* UPNP_E_SUCCESS if successful else sends appropriate error.
***************************************************************************/
* \return UPNP_E_SUCCESS if successful otherwise the appropriate error code.
*/
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
{
int ret_code;
@ -3418,7 +3297,7 @@ ExitFunction:
}
int UpnpInitStartServers(IN unsigned short DestPort)
int UpnpInitStartServers(unsigned short DestPort)
{
int retVal = 0;
@ -3921,8 +3800,8 @@ int GetFreeHandle()
/* Assumes at most one client */
Upnp_Handle_Type GetClientHandleInfo(
IN UpnpClient_Handle *client_handle_out,
OUT struct Handle_Info **HndInfo)
UpnpClient_Handle *client_handle_out,
struct Handle_Info **HndInfo)
{
Upnp_Handle_Type ret = HND_CLIENT;
UpnpClient_Handle client;
@ -4022,14 +3901,7 @@ int FreeHandle(int Upnp_Handle)
}
/*!
* \brief Print handle info.
*
* \return UPNP_E_SUCCESS if successful, otherwise returns appropriate error.
*/
int PrintHandleInfo(
/*! [in] Handle index. */
IN UpnpClient_Handle Hnd)
int PrintHandleInfo(UpnpClient_Handle Hnd)
{
struct Handle_Info * HndInfo;
if (HandleTable[Hnd] != NULL) {
@ -4051,7 +3923,7 @@ int PrintHandleInfo(
}
void printNodes( IXML_Node * tmpRoot, int depth )
void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
@ -4078,7 +3950,7 @@ void printNodes( IXML_Node * tmpRoot, int depth )
}
int getlocalhostname(OUT char *out, IN const int out_len)
int getlocalhostname(char *out, const int out_len)
{
#ifdef WIN32
struct hostent *h=NULL;
@ -4218,24 +4090,7 @@ void AutoAdvertise(void *input)
#ifdef INTERNAL_WEB_SERVER
/*!
* \brief Sets the document root directory for the internal web server.
*
* This directory is considered the root directory (i.e. "/") of the web server.
* This function also activates or deactivates the web server.
*
* To disable the web server, pass NULL for rootDir, to activate pass a valid
* directory string.
*
* \note This function is not available when the web server is not compiled
* into the UPnP Library.
*
* \return UPNP_E_SUCCESS if successful else returns appropriate error.
*/
int UpnpSetWebServerRootDir(
/* [in] Path of the root directory of the web server. */
IN const char *rootDir)
int UpnpSetWebServerRootDir(const char *rootDir)
{
if( UpnpSdkInit == 0 )
return UPNP_E_FINISH;
@ -4245,26 +4100,12 @@ int UpnpSetWebServerRootDir(
membuffer_destroy( &gDocumentRootDir );
return ( web_server_set_root_dir( rootDir ) );
return web_server_set_root_dir(rootDir);
}
#endif // INTERNAL_WEB_SERVER
/*!
* \brief Adds a virtual directory mapping.
*
* All webserver requests containing the given directory are read using
* functions contained in a VirtualDirCallbacks structure registered
* via UpnpSetVirtualDirCallbacks.
*
* \note This function is not available when the web server is not
* compiled into the UPnP Library.
*
* \return UPNP_E_SUCCESS if successful else returns appropriate error.
*/
int UpnpAddVirtualDir(
/* [in] The name of the new directory mapping to add. */
IN const char *newDirName)
int UpnpAddVirtualDir(const char *newDirName)
{
virtualDirList *pNewVirtualDir;
virtualDirList *pLast;
@ -4320,14 +4161,7 @@ int UpnpAddVirtualDir(
}
/*!
* \brief Removes a virtual directory mapping.
*
* \return UPNP_E_SUCCESS if successful else returns appropriate error.
*/
int UpnpRemoveVirtualDir(
/* [in] The name of the directory mapping to remove. */
IN const char *dirName)
int UpnpRemoveVirtualDir(const char *dirName)
{
virtualDirList *pPrev;
@ -4380,9 +4214,6 @@ int UpnpRemoveVirtualDir(
}
/*!
* \brief Removes all the virtual directory mappings.
*/
void UpnpRemoveAllVirtualDirs()
{
virtualDirList *pCur;
@ -4406,15 +4237,7 @@ void UpnpRemoveAllVirtualDirs()
}
/*!
* \brief Enables or disables the webserver. A value of TRUE enables the
* webserver, FALSE disables it.
*
* \return UPNP_E_SUCCESS if successful else returns appropriate error.
*/
int UpnpEnableWebserver(
/* [in] TRUE to enable, FALSE to disable. */
IN int enable)
int UpnpEnableWebserver(int enable)
{
int retVal;
@ -4539,16 +4362,9 @@ int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback)
}
/*!
* \brief
*
* \deprecated Use UpnpSetMaxContentLength() instead.
*/
int UpnpSetContentLength(
/* [in] . */
IN UpnpClient_Handle Hnd,
/* [in] . */
IN int contentLength)
UpnpClient_Handle Hnd,
int contentLength)
{
int errCode = UPNP_E_SUCCESS;
struct Handle_Info *HInfo = NULL;
@ -4581,23 +4397,7 @@ int UpnpSetContentLength(
}
/*!
* \brief Sets the maximum content-length that the SDK will process on an
* incoming SOAP requests or responses.
*
* This API allows devices that have memory constraints to exhibit consistent
* behaviour if the size of the incoming SOAP message exceeds the memory that
* device can allocate.
*
* The default maximum content-length is {\tt DEFAULT_SOAP_CONTENT_LENGTH}
* == 16K bytes.
*
* \return UPNP_E_SUCCESS if the operation completed successfully.
*/
int UpnpSetMaxContentLength(
/*! Permissible content length, in bytes. The maximum size to be set. */
IN size_t contentLength
)
int UpnpSetMaxContentLength(size_t contentLength)
{
int errCode = UPNP_E_SUCCESS;

View File

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

View File

@ -34,6 +34,11 @@
#define UPNPAPI_H
/*!
* \file
*/
#include "client_table.h"
#include "upnp.h"
#include "VirtualDir.h" /* for struct VirtualDirCallbacks */
@ -369,6 +374,16 @@ int getlocalhostname(
const int out_len);
/*!
* \brief Print handle info.
*
* \return UPNP_E_SUCCESS if successful, otherwise returns appropriate error.
*/
int PrintHandleInfo(
/*! [in] Handle index. */
UpnpClient_Handle Hnd);
extern WebServerState bWebServerState;