Optional Tool API

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

## Functions

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. More...
int | UpnpResolveURL (const char *BaseURL, const char *RelURL, char *AbsURL)
| Combines a base URL and a relative URL into a single absolute URL. More...
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). More...
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). More...
int | UpnpAddToAction (IXML_Document **ActionDoc, const char *ActionName, const char *ServType, const char *ArgName, const char *ArgVal)
| Adds the argument in the action request. More...
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). More...
IXML_Document * | UpnpCreatePropertySet (int NumArg, const char *Arg,...)
| Creates a property set message packet. More...
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. More...

## 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

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] | ActionDoc | A pointer to store the action document node.
  [in] | ActionName | The action name.
  [in] | ServType | The service type.
  [in] | ArgName | The status variable name.
  [in] | ArgVal | The status variable value.

References addToAction().

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] | ActionResponse | Pointer to a document to store the action document node.
  [in] | ActionName | The action name.
  [in] | ServType | The service type.
  [in] | ArgName | The status variable name.
  [in] | ArgVal | The status variable value.

References addToAction().

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] | PropSet | A pointer to the document containing the property set document node.
  [in] | ArgName | The status variable name.
  [in] | ArgVal | The 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.

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] | NumArg | The number of argument pairs passed.
  [in] | Arg | The status variable name and value pair.

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

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] | errorcode | The SDK error code to convert.

References ErrorMessages, and ErrorString::rcError.

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] | ActionName | Name of the action request or response.
  [in] | ServType | The service type.
  [in] | NumArg | Number of argument pairs to be passed.
  [in] | Arg | pointer to the first argument.

References makeAction().

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] | ActionName | The action name.
  [in] | ServType | The service type..
  [in] | NumArg | The number of argument pairs passed.
  [in] | Arg | The status variable name and value pair.

References makeAction().

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] | BaseURL | The base URL to combine.
  [in] | RelURL | The relative URL to BaseURL.
  [out] | AbsURL | A 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.