http_lib.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <HTML>
  2. <HEAD>
  3. <TITLE>http_lib(3) manual page</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <A HREF="#toc">Table of Contents</A><P>
  7. <H2><A NAME="sect1" HREF="#toc1">NAME</A></H2>
  8. http_server, http_port, http_put, http_get, http_head, http_delete,
  9. http_parse_url - Http data exchanges mini library.
  10. <P>
  11. <H2><A NAME="sect2" HREF="#toc2"><B>SYNOPSIS</B></A></H2>
  12. <B>#include</B> <B>&quot;http_lib.h"</B>
  13. <P>
  14. <B>extern</B> <B>char</B> <B>*http_server;</B>
  15. <P>
  16. <B>extern</B> <B>int</B> <B>http_port;</B>
  17. <P>
  18. <B>extern</B> <B>char</B> <B>*http_proxy_server;</B>
  19. <P>
  20. <B>extern</B> <B>int</B> <B>http_proxy_port;</B>
  21. <P>
  22. <B>http_retcode</B> <B>http_put</B><BR>
  23. <B>(</B><BR>
  24. <B>char</B> <B>*filename,</B><BR>
  25. <B>char</B> <B>*data,</B><BR>
  26. <B>int</B> <B>length,</B><BR>
  27. <B>int</B> <B>overwrite,</B><BR>
  28. <B>char</B> <B>*type</B><BR>
  29. <B>);</B>
  30. <P>
  31. <B>http_retcode</B> <B>http_get</B><BR>
  32. <B>(</B><BR>
  33. <B>char</B> <B>*filename,</B><BR>
  34. <B>char</B> <B>**pdata,</B><BR>
  35. <B>int</B> <B>*plength,</B><BR>
  36. <B>char</B> <B>*typebuf</B><BR>
  37. <B>);</B>
  38. <P>
  39. <B>http_retcode</B> <B>http_head</B><BR>
  40. <B>(</B><BR>
  41. <B>char</B> <B>*filename,</B><BR>
  42. <B>int</B> <B>*plength,</B><BR>
  43. <B>char</B> <B>*typebuf</B><BR>
  44. <B>);</B>
  45. <P>
  46. <B>http_retcode</B> <B>http_delete(char</B> <B>*filename);</B>
  47. <P>
  48. <B>http_retcode</B> <B>http_parse_url</B><BR>
  49. <B>(</B><BR>
  50. <B>char</B> <B>*url,</B><BR>
  51. <B>char</B> <B>**pfilename</B><BR>
  52. <B>);</B>
  53. <P>
  54. <H2><A NAME="sect3" HREF="#toc3"><B>PARAMETERS</B></A></H2>
  55. <B>char</B> <B>*filename</B> (http_put)<BR>
  56. Name of the ressource to create.
  57. <P>
  58. <B>char</B> <B>*data</B><BR>
  59. Pointer to the data to send.
  60. <P>
  61. <B>int</B> <B>length</B><BR>
  62. Length of the data to send.
  63. <P>
  64. <B>int</B> <B>overwrite</B><BR>
  65. Flag to request to overwrite the ressource if it was already
  66. existing.
  67. <P>
  68. <B>char</B> <B>*type</B><BR>
  69. Type of the data, if NULL default type is used.
  70. <P>
  71. <B>char</B> <B>*filename</B> (http_get)<BR>
  72. Name of the ressource to read.
  73. <P>
  74. <B>char</B> <B>**pdata</B><BR>
  75. Address of a pointer variable which will be set to point toward
  76. allocated memory containing read data.
  77. <P>
  78. <DL>
  79. <DT><B>int</B> <B>*plength</B> <DD>(http_get)
  80. Address of integer variable which will be set to length of the
  81. read data.
  82. <P>
  83. </DD>
  84. </DL>
  85. <B>char</B> <B>*typebuf</B> (http_get)<BR>
  86. Allocated buffer where the read data type is returned. If NULL,
  87. the type is not returned.
  88. <P>
  89. <DL>
  90. <DT><B>int</B> <B>*plength</B> <DD>(http_head)
  91. Address of integer variable which will be set to length of the
  92. data.
  93. <P>
  94. </DD>
  95. </DL>
  96. <B>char</B> <B>*typebuf</B> (http_head)<BR>
  97. Allocated buffer where the data type is returned. If NULL, the
  98. type is not returned.
  99. <P>
  100. <B>char</B> <B>*url</B><BR>
  101. Writeable copy of an url.
  102. <P>
  103. <B>char</B> <B>**pfilename</B><BR>
  104. Address of a pointer that will be filled with allocated filename
  105. the pointer must be equal to NULL before calling or it will be
  106. automatically freed (<i>free(3)</i>).
  107. <P>
  108. <H2><A NAME="sect4" HREF="#toc4"><B>DESCRIPTION</B></A></H2>
  109. <B>http_server</B><BR>
  110. Pointer to a mallocated string containing server name or NULL.
  111. <P>
  112. <B>http_port</B><BR>
  113. Server port number.
  114. <P>
  115. <B>http_proxy_server</B><BR>
  116. Pointer a string containing proxy server name to use or NULL for noproxy.
  117. <P>
  118. <B>http_port</B><BR>
  119. Proxy server port number (or 0).
  120. <P>
  121. <B>http_put</B><BR>
  122. Put data on the server<BR>
  123. <P>
  124. This function sends data to the http data server. The data will be
  125. stored under the ressource name filename.
  126. <P>
  127. <B>http_get</B><BR>
  128. Get data from the server
  129. <P>
  130. This function gets data from the http data server. The data is read
  131. from the ressource named filename. Address of new new allocated
  132. memory block is filled in pdata whose length is returned via plength.
  133. <P>
  134. <B>http_head</B><BR>
  135. Request the header
  136. <P>
  137. This function outputs the header of thehttp data server. The header
  138. is from the ressource named filename. The length and type of data is
  139. eventually returned (like for http_get(3)).
  140. <P>
  141. <B>http_delete</B><BR>
  142. Delete data on the server
  143. <P>
  144. This function request a DELETE on the http data server.
  145. <P>
  146. <B>http_parse_url</B><BR>
  147. Parses an url : setting the http_server and http_port global variables
  148. and returning the filename to pass to http_get/put/...
  149. <P>
  150. <H2><A NAME="sect5" HREF="#toc5"><B>RETURNS</B></A></H2>
  151. <B>http_put</B><BR>
  152. A negative error code or a positive code from the server.
  153. <p>
  154. <B>http_get</B><BR>
  155. A negative error code or a positive code from the server.
  156. <P>
  157. <B>http_head</B><BR>
  158. A negative error code or a positive code from the server.
  159. <P>
  160. <B>http_delete</B><BR>
  161. A negative error code or a positive code from the server.
  162. <P>
  163. <B>http_parse_url</B><BR>
  164. A negative error code or 0 if sucessfully parsed.
  165. <P>
  166. Possible values for a <B>http_retcode</B> are as follows:
  167. <P>
  168. Client side errors.<BR>
  169. <B>ERRHOST</B> No such host.<BR>
  170. <B>ERRSOCK</B> Can't create socket.<BR>
  171. <B>ERRCONN</B> Can't connect to host.<BR>
  172. <B>ERRWRHD</B> Write error on socket while writing header.
  173. <B>ERRWRDT</B> Write error on socket while writing data.
  174. <B>ERRRDHD</B> Read error on socket while reading result.
  175. <B>ERRPAHD</B> Invalid answer from data server.
  176. <B>ERRNULL</B> Null data pointer.<BR>
  177. <B>ERRNOLG</B> No/Bad length in header.<BR>
  178. <DL>
  179. <DT><B>ERRMEM</B> <DD>Can't allocate memory.
  180. <B>ERRRDDT</B> Read error while reading data.
  181. <B>ERRURLH</B> Invalid url - must start with `http://'.
  182. <B>ERRURLP</B> Invalid port in url.
  183. <P>
  184. </DD>
  185. </DL>
  186. Return code by the server.<BR>
  187. <DL>
  188. <DT><B>ERR400</B> <DD>Invalid query.
  189. <B>ERR403</B> Forbidden.
  190. </DD>
  191. </DL>
  192. <DL>
  193. <DT><B>ERR408</B> <DD>Request timeout.
  194. </DD>
  195. </DL>
  196. <DL>
  197. <DT><B>ERR500</B> <DD>Server error.
  198. </DD>
  199. </DL>
  200. <DL>
  201. <DT><B>ERR501</B> <DD>Not implemented.
  202. </DD>
  203. </DL>
  204. <DL>
  205. <DT><B>ERR503</B> <DD>Service overloaded.
  206. <P>
  207. </DD>
  208. </DL>
  209. Succesful results.<BR>
  210. <DL>
  211. <DT><B>OK0</B> <DD> Successfull parse.
  212. </DD>
  213. </DL>
  214. <DL>
  215. <DT><B>OK201</B> <DD> Ressource succesfully created.
  216. </DD>
  217. </DL>
  218. <DL>
  219. <DT><B>OK200</B> <DD> Ressource succesfully read.
  220. <P>
  221. </DD>
  222. </DL>
  223. <H2><A NAME="sect6" HREF="#toc6"><B>LIMITATIONS</B></A></H2>
  224. <B>http_put</B><BR>
  225. Filename is truncated to first 256 characters and type to 64.
  226. <P>
  227. <B>http_get</B><BR>
  228. Filename is truncated to first 256 characters.
  229. <P>
  230. <B>http_head</B><BR>
  231. Filename is truncated to first 256 characters.
  232. <P>
  233. <B>http_delete</B><BR>
  234. Filename is truncated to first 256 characters.
  235. <P>
  236. <HR><P>
  237. <A NAME="toc"><B>Table of Contents</B></A><P>
  238. <UL>
  239. <LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
  240. <LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
  241. <LI><A NAME="toc2" HREF="#sect2">PARAMETERS</A></LI>
  242. <LI><A NAME="toc3" HREF="#sect3">DESCRIPTION</A></LI>
  243. <LI><A NAME="toc4" HREF="#sect4">RETURNS</A></LI>
  244. <LI><A NAME="toc5" HREF="#sect5">LIMITATIONS</A></LI>
  245. </UL>
  246. </BODY></HTML>