libUPnP 1.14.19
Functions
Optional Tool API

Additional, optional utility API that can be helpful in writing applications. More...

Functions

UPNP_EXPORT_SPEC const char * UpnpGetErrorMessage (int errorcode)
 Converts an SDK error code into a string error message suitable for display. The memory returned from this function should NOT be freed.
 
UPNP_EXPORT_SPEC int UpnpResolveURL (const char *BaseURL, const char *RelURL, char *AbsURL)
 Combines a base URL and a relative URL into a single absolute URL.
 
UPNP_EXPORT_SPEC int UpnpResolveURL2 (const char *BaseURL, const char *RelURL, char **AbsURL)
 Combines a base URL and a relative URL into a single absolute URL.
 
UPNP_EXPORT_SPEC IXML_DocumentUpnpMakeAction (const char *ActionName, const char *ServType, int NumArg, const char *Arg,...)
 Creates an action request packet based on its input parameters (status variable name and value pair).
 
UPNP_EXPORT_SPEC IXML_DocumentUpnpMakeActionResponse (const char *ActionName, const char *ServType, int NumArg, const char *Arg,...)
 Ceates an action response packet based on its output parameters (status variable name and value pair).
 
UPNP_EXPORT_SPEC int UpnpAddToAction (IXML_Document **ActionDoc, const char *ActionName, const char *ServType, const char *ArgName, const char *ArgVal)
 Adds the argument in the action request.
 
UPNP_EXPORT_SPEC int UpnpAddToActionResponse (IXML_Document **ActionResponse, const char *ActionName, const char *ServType, const char *ArgName, const char *ArgVal)
 Creates an action response packet based on its output parameters (status variable name and value pair).
 
UPNP_EXPORT_SPEC IXML_DocumentUpnpCreatePropertySet (int NumArg, const char *Arg,...)
 Creates a property set message packet.
 
UPNP_EXPORT_SPEC int UpnpAddToPropertySet (IXML_Document **PropSet, const char *ArgName, const char *ArgVal)
 Can be used when an application needs to transfer the status of many variables at once.
 

Detailed Description

Additional, optional utility API that can be helpful in writing applications.

This additional API can be compiled out in order to save code size in the library. Refer to the file README for details.

Function Documentation

◆ UpnpAddToAction()

UPNP_EXPORT_SPEC int UpnpAddToAction ( IXML_Document **  ActionDoc,
const char *  ActionName,
const char *  ServType,
const char *  ArgName,
const char *  ArgVal 
)

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 Upnp_Document variable initialized with NULL should be passed as a parameter.

It is a wrapper function that calls addToAction() function to add the argument in the action request.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: One or more of the parameters are invalid.
  • UPNP_E_OUTOF_MEMORY: Insufficient resources exist to complete this operation.
Parameters
[in,out]ActionDocA pointer to store the action document node.
[in]ActionNameThe action name.
[in]ServTypeThe service type.
[in]ArgNameThe status variable name.
[in]ArgValThe status variable value.

References addToAction().

◆ UpnpAddToActionResponse()

UPNP_EXPORT_SPEC int UpnpAddToActionResponse ( IXML_Document **  ActionResponse,
const char *  ActionName,
const char *  ServType,
const char *  ArgName,
const char *  ArgVal 
)

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 Upnp_Document variable initialized with NULL should be passed as a parameter.

It is a wrapper function that calls addToAction() function to add the argument in the action request.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: One or more of the parameters are invalid.
  • UPNP_E_OUTOF_MEMORY: Insufficient resources exist to complete this operation.
Parameters
[in,out]ActionResponsePointer to a document to store the action document node.
[in]ActionNameThe action name.
[in]ServTypeThe service type.
[in]ArgNameThe status variable name.
[in]ArgValThe status variable value.

References addToAction().

Referenced by IncrementBrightness(), IncrementColor(), IncrementContrast(), IncrementVolume(), TvDevicePowerOff(), TvDevicePowerOn(), TvDeviceSetBrightness(), TvDeviceSetChannel(), TvDeviceSetColor(), TvDeviceSetContrast(), TvDeviceSetTint(), and TvDeviceSetVolume().

◆ UpnpAddToPropertySet()

UPNP_EXPORT_SPEC int UpnpAddToPropertySet ( IXML_Document **  PropSet,
const char *  ArgName,
const char *  ArgVal 
)

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 NULL and pass that as the first parameter.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: One or more of the parameters are invalid.
  • UPNP_E_OUTOF_MEMORY: Insufficient resources exist to complete this operation.
Parameters
[in,out]PropSetA pointer to the document containing the property set document node.
[in]ArgNameThe status variable name.
[in]ArgValThe status variable value.

References ixmlDocument_createElement(), ixmlDocument_createTextNode(), ixmlNode_appendChild(), ixmlNode_getFirstChild(), ixmlParseBufferEx(), ErrorString::rc, UPNP_E_INVALID_PARAM, UPNP_E_OUTOF_MEMORY, and UPNP_E_SUCCESS.

Referenced by TvDeviceHandleSubscriptionRequest().

◆ UpnpCreatePropertySet()

UPNP_EXPORT_SPEC IXML_Document * UpnpCreatePropertySet ( int  NumArg,
const char *  Arg,
  ... 
)

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.

Returns
NULL on failure, or the property-set document node.
Parameters
[in]NumArgThe number of argument pairs passed.
[in]ArgThe status variable name and value pair.
[in]...Variable sized list with the rest of the parameters.

References ixmlDocument_createElement(), ixmlDocument_createTextNode(), ixmlNode_appendChild(), ixmlNode_getFirstChild(), and ixmlParseBufferEx().

Referenced by TvDeviceSetServiceTableVar().

◆ UpnpGetErrorMessage()

UPNP_EXPORT_SPEC const char * UpnpGetErrorMessage ( int  errorcode)

Converts an SDK error code into a string error message suitable for display. The memory returned from this function should NOT be freed.

Returns
An ASCII text string representation of the error message associated with the error code or the string "Unknown error code"
Parameters
[in]errorcodeThe SDK error code to convert.

References ErrorMessages, ErrorString::rc, and ErrorString::rcError.

◆ UpnpMakeAction()

UPNP_EXPORT_SPEC IXML_Document * UpnpMakeAction ( const char *  ActionName,
const char *  ServType,
int  NumArg,
const char *  Arg,
  ... 
)

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.

It is a wrapper function that calls makeAction() function to create the action request.

Returns
The action node of Upnp_Document type or NULL if the operation failed.
Parameters
[in]ActionNameName of the action request or response.
[in]ServTypeThe service type.
[in]NumArgNumber of argument pairs to be passed.
[in]Argpointer to the first argument.
[in]...Argument list.

References makeAction().

◆ UpnpMakeActionResponse()

UPNP_EXPORT_SPEC IXML_Document * UpnpMakeActionResponse ( const char *  ActionName,
const char *  ServType,
int  NumArg,
const char *  Arg,
  ... 
)

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.

Returns
The action node of Upnp_Document type or NULL if the operation failed.
Parameters
[in]ActionNameThe action name.
[in]ServTypeThe service type..
[in]NumArgThe number of argument pairs passed.
[in]ArgThe status variable name and value pair.
[in]...Other status variable name and value pairs.

References makeAction().

◆ UpnpResolveURL()

UPNP_EXPORT_SPEC int UpnpResolveURL ( const char *  BaseURL,
const char *  RelURL,
char *  AbsURL 
)

Combines a base URL and a relative URL into a single absolute URL.

The memory for AbsURL needs to be allocated by the caller and must be large enough to hold the BaseURL and RelURL combined.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: RelURL is NULL.
  • UPNP_E_INVALID_URL: The BaseURL / RelURL combination does not form a valid URL.
  • UPNP_E_OUTOF_MEMORY: Insufficient resources exist to complete this operation.
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.
Parameters
[in]BaseURLThe base URL to combine.
[in]RelURLThe relative URL to BaseURL.
[out]AbsURLA pointer to a buffer to store the absolute URL.

References resolve_rel_url(), UPNP_E_INVALID_PARAM, UPNP_E_INVALID_URL, and UPNP_E_SUCCESS.

◆ UpnpResolveURL2()

UPNP_EXPORT_SPEC int UpnpResolveURL2 ( const char *  BaseURL,
const char *  RelURL,
char **  AbsURL 
)

Combines a base URL and a relative URL into a single absolute URL.

The memory for AbsURL becomes owned by the caller and should be freed later.

Returns
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_INVALID_PARAM: RelURL is NULL.
  • UPNP_E_INVALID_URL: The BaseURL / RelURL combination does not form a valid URL.
  • UPNP_E_OUTOF_MEMORY: Insufficient resources exist to complete this operation.
Parameters
[in]BaseURLThe base URL to combine.
[in]RelURLThe relative URL to BaseURL.
[out]AbsURLA pointer to a pointer to a buffer to store the absolute URL. Must be freed later by the caller.

References resolve_rel_url(), UPNP_E_INVALID_PARAM, UPNP_E_INVALID_URL, and UPNP_E_SUCCESS.

Referenced by SampleUtil_FindAndParseService().