upnptools.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*******************************************************************************
  2. *
  3. * Copyright (c) 2000-2003 Intel Corporation
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. * * Neither name of Intel Corporation nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
  22. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. ******************************************************************************/
  31. #ifndef UPNP_TOOLS_H
  32. #define UPNP_TOOLS_H
  33. /*!
  34. * \file
  35. *
  36. * \defgroup UPnPTools Optional Tool API
  37. *
  38. * \brief Additional, optional utility API that can be helpful in writing
  39. * applications.
  40. *
  41. * This additional API can be compiled out in order to save code size in the
  42. * library. Refer to the file README for details.
  43. *
  44. * @{
  45. */
  46. #include "ixml.h" /* for IXML_Document */
  47. #include "upnpconfig.h" /* for UPNP_HAVE_TOOLS */
  48. /* Function declarations only if tools compiled into the library */
  49. #if UPNP_HAVE_TOOLS
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. /*!
  54. * \brief Converts an SDK error code into a string error message suitable for
  55. * display. The memory returned from this function should NOT be freed.
  56. *
  57. * \return An ASCII text string representation of the error message associated
  58. * with the error code or the string "Unknown error code"
  59. */
  60. EXPORT_SPEC const char *UpnpGetErrorMessage(
  61. /*! [in] The SDK error code to convert. */
  62. int errorcode);
  63. /*!
  64. * \brief Combines a base URL and a relative URL into a single absolute URL.
  65. *
  66. * The memory for \b AbsURL needs to be allocated by the caller and must
  67. * be large enough to hold the \b BaseURL and \b RelURL combined.
  68. *
  69. * \return An integer representing one of the following:
  70. * \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
  71. * \li <tt>UPNP_E_INVALID_PARAM</tt>: \b RelURL is <tt>NULL</tt>.
  72. * \li <tt>UPNP_E_INVALID_URL</tt>: The \b BaseURL / \b RelURL
  73. * combination does not form a valid URL.
  74. * \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
  75. * complete this operation.
  76. */
  77. EXPORT_SPEC int UpnpResolveURL(
  78. /*! [in] The base URL to combine. */
  79. const char *BaseURL,
  80. /*! [in] The relative URL to \b BaseURL. */
  81. const char *RelURL,
  82. /*! [out] A pointer to a buffer to store the absolute URL. */
  83. char *AbsURL);
  84. /*!
  85. * \brief Combines a base URL and a relative URL into a single absolute URL.
  86. *
  87. * The memory for \b AbsURL becomes owned by the caller and should be freed
  88. * later.
  89. *
  90. * \return An integer representing one of the following:
  91. * \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
  92. * \li <tt>UPNP_E_INVALID_PARAM</tt>: \b RelURL is <tt>NULL</tt>.
  93. * \li <tt>UPNP_E_INVALID_URL</tt>: The \b BaseURL / \b RelURL
  94. * combination does not form a valid URL.
  95. * \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
  96. * complete this operation.
  97. */
  98. EXPORT_SPEC int UpnpResolveURL2(
  99. /*! [in] The base URL to combine. */
  100. const char *BaseURL,
  101. /*! [in] The relative URL to \b BaseURL. */
  102. const char *RelURL,
  103. /*! [out] A pointer to a pointer to a buffer to store the
  104. * absolute URL. Must be freed later by the caller. */
  105. char **AbsURL);
  106. /*!
  107. * \brief Creates an action request packet based on its input parameters
  108. * (status variable name and value pair).
  109. *
  110. * Any number of input parameters can be passed to this function but every
  111. * input variable name should have a matching value argument.
  112. *
  113. * It is a wrapper function that calls makeAction() function to create the
  114. * action request.
  115. *
  116. * \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
  117. * operation failed.
  118. */
  119. EXPORT_SPEC IXML_Document *UpnpMakeAction(
  120. /*! [in] Name of the action request or response. */
  121. const char *ActionName,
  122. /*! [in] The service type. */
  123. const char *ServType,
  124. /*! [in] Number of argument pairs to be passed. */
  125. int NumArg,
  126. /*! [in] pointer to the first argument. */
  127. const char *Arg,
  128. /*! [in] Argument list. */
  129. ...);
  130. /*!
  131. * \brief Ceates an action response packet based on its output parameters
  132. * (status variable name and value pair).
  133. *
  134. * Any number of input parameters can be passed to this function but every
  135. * output variable name should have a matching value argument.
  136. *
  137. * It is a wrapper function that calls makeAction() function to create the
  138. * action request.
  139. *
  140. * \return The action node of \b Upnp_Document type or <tt>NULL</tt> if the
  141. * operation failed.
  142. */
  143. EXPORT_SPEC IXML_Document *UpnpMakeActionResponse(
  144. /*! [in] The action name. */
  145. const char *ActionName,
  146. /*! [in] The service type.. */
  147. const char *ServType,
  148. /*! [in] The number of argument pairs passed. */
  149. int NumArg,
  150. /*! [in] The status variable name and value pair. */
  151. const char *Arg,
  152. /*! [in] Other status variable name and value pairs. */
  153. ...);
  154. /*!
  155. * \brief Adds the argument in the action request.
  156. *
  157. * This API is specially suitable inside a loop to add any number input
  158. * parameters into an existing action. If no action document exists in the
  159. * beginning then a <b>Upnp_Document variable initialized with <tt>NULL</tt></b>
  160. * should be passed as a parameter.
  161. *
  162. * It is a wrapper function that calls addToAction() function to add the
  163. * argument in the action request.
  164. *
  165. * \return An integer representing one of the following:
  166. * \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
  167. * \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
  168. * \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
  169. * complete this operation.
  170. */
  171. EXPORT_SPEC int UpnpAddToAction(
  172. /*! [in,out] A pointer to store the action document node. */
  173. IXML_Document **ActionDoc,
  174. /*! [in] The action name. */
  175. const char *ActionName,
  176. /*! [in] The service type. */
  177. const char *ServType,
  178. /*! [in] The status variable name. */
  179. const char *ArgName,
  180. /*! [in] The status variable value. */
  181. const char *ArgVal);
  182. /*!
  183. * \brief Creates an action response packet based on its output parameters
  184. * (status variable name and value pair).
  185. *
  186. * This API is especially suitable inside a loop to add any number of input
  187. * parameters into an existing action response. If no action document exists
  188. * in the beginning, a \b Upnp_Document variable initialized with <tt>NULL</tt>
  189. * should be passed as a parameter.
  190. *
  191. * It is a wrapper function that calls addToAction() function to add the
  192. * argument in the action request.
  193. *
  194. * \return An integer representing one of the following:
  195. * \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
  196. * \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
  197. * \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
  198. * complete this operation.
  199. */
  200. EXPORT_SPEC int UpnpAddToActionResponse(
  201. /*! [in,out] Pointer to a document to store the action document node. */
  202. IXML_Document **ActionResponse,
  203. /*! [in] The action name. */
  204. const char *ActionName,
  205. /*! [in] The service type. */
  206. const char *ServType,
  207. /*! [in] The status variable name. */
  208. const char *ArgName,
  209. /*! [in] The status variable value. */
  210. const char *ArgVal);
  211. /*!
  212. * \brief Creates a property set message packet.
  213. *
  214. * Any number of input parameters can be passed to this function but every
  215. * input variable name should have a matching value input argument.
  216. *
  217. * \return <tt>NULL</tt> on failure, or the property-set document node.
  218. */
  219. EXPORT_SPEC IXML_Document *UpnpCreatePropertySet(
  220. /*! [in] The number of argument pairs passed. */
  221. int NumArg,
  222. /*! [in] The status variable name and value pair. */
  223. const char *Arg,
  224. /*! [in] Variable sized list with the rest of the parameters. */
  225. ...);
  226. /*!
  227. * \brief Can be used when an application needs to transfer the status of many
  228. * variables at once.
  229. *
  230. * It can be used (inside a loop) to add some extra status variables into an
  231. * existing property set. If the application does not already have a property
  232. * set document, the application should create a variable initialized with
  233. * <tt>NULL</tt> and pass that as the first parameter.
  234. *
  235. * \return An integer representing one of the following:
  236. * \li <tt>UPNP_E_SUCCESS</tt>: The operation completed successfully.
  237. * \li <tt>UPNP_E_INVALID_PARAM</tt>: One or more of the parameters are invalid.
  238. * \li <tt>UPNP_E_OUTOF_MEMORY</tt>: Insufficient resources exist to
  239. * complete this operation.
  240. */
  241. EXPORT_SPEC int UpnpAddToPropertySet(
  242. /*! [in,out] A pointer to the document containing the property set document node. */
  243. IXML_Document **PropSet,
  244. /*! [in] The status variable name. */
  245. const char *ArgName,
  246. /*! [in] The status variable value. */
  247. const char *ArgVal);
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. /*! @} */
  252. #endif /* UPNP_HAVE_TOOLS */
  253. #endif /* UPNP_TOOLS_H */