rtt-f030/components/net/uip/doc/html/a00180.html

465 lines
47 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: apps/webclient/webclient.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul></div>
<h1>apps/webclient/webclient.c</h1><a href="a00110.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup apps</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \defgroup webclient Web client</span>
<a name="l00008"></a>00008 <span class="comment"> * @{</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * This example shows a HTTP client that is able to download web pages</span>
<a name="l00011"></a>00011 <span class="comment"> * and files from web servers. It requires a number of callback</span>
<a name="l00012"></a>00012 <span class="comment"> * functions to be implemented by the module that utilizes the code:</span>
<a name="l00013"></a>00013 <span class="comment"> * webclient_datahandler(), webclient_connected(),</span>
<a name="l00014"></a>00014 <span class="comment"> * webclient_timedout(), webclient_aborted(), webclient_closed().</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 <span class="comment"></span>
<a name="l00017"></a>00017 <span class="comment">/**</span>
<a name="l00018"></a>00018 <span class="comment"> * \file</span>
<a name="l00019"></a>00019 <span class="comment"> * Implementation of the HTTP client.</span>
<a name="l00020"></a>00020 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="comment">/*</span>
<a name="l00024"></a>00024 <span class="comment"> * Copyright (c) 2002, Adam Dunkels.</span>
<a name="l00025"></a>00025 <span class="comment"> * All rights reserved.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00028"></a>00028 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00029"></a>00029 <span class="comment"> * are met:</span>
<a name="l00030"></a>00030 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00031"></a>00031 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00032"></a>00032 <span class="comment"> * 2. Redistributions in binary form must reproduce the above</span>
<a name="l00033"></a>00033 <span class="comment"> * copyright notice, this list of conditions and the following</span>
<a name="l00034"></a>00034 <span class="comment"> * disclaimer in the documentation and/or other materials provided</span>
<a name="l00035"></a>00035 <span class="comment"> * with the distribution.</span>
<a name="l00036"></a>00036 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00037"></a>00037 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00038"></a>00038 <span class="comment"> * written permission.</span>
<a name="l00039"></a>00039 <span class="comment"> *</span>
<a name="l00040"></a>00040 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00041"></a>00041 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00042"></a>00042 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00043"></a>00043 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00044"></a>00044 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00045"></a>00045 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00046"></a>00046 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00047"></a>00047 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00048"></a>00048 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00049"></a>00049 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00050"></a>00050 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00051"></a>00051 <span class="comment"> *</span>
<a name="l00052"></a>00052 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00053"></a>00053 <span class="comment"> *</span>
<a name="l00054"></a>00054 <span class="comment"> * $Id: webclient.c,v 1.2 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00055"></a>00055 <span class="comment"> *</span>
<a name="l00056"></a>00056 <span class="comment"> */</span>
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include "uiplib.h"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="a00111.html">webclient.h</a>"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "<a class="code" href="a00103.html">resolv.h</a>"</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00064"></a>00064
<a name="l00065"></a><a class="code" href="a00163.html#g31be289fd8ec3fe09b0088165d13976d">00065</a> <span class="preprocessor">#define WEBCLIENT_TIMEOUT 100</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>
<a name="l00067"></a><a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">00067</a> <span class="preprocessor">#define WEBCLIENT_STATE_STATUSLINE 0</span>
<a name="l00068"></a><a class="code" href="a00163.html#gc4357cec23abca29d2bb885803625a6a">00068</a> <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_HEADERS 1</span>
<a name="l00069"></a><a class="code" href="a00163.html#g4d457c50e6f2cef57167c3804ce8bf7c">00069</a> <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_DATA 2</span>
<a name="l00070"></a><a class="code" href="a00163.html#g863c94b0ed4a76997e53a3ccd5d0b6c3">00070</a> <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_CLOSE 3</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span>
<a name="l00072"></a><a class="code" href="a00163.html#g40fb1fb2d990ce04ae9bbee275627c03">00072</a> <span class="preprocessor">#define HTTPFLAG_NONE 0</span>
<a name="l00073"></a><a class="code" href="a00163.html#gda99954e0f6905091885934e86c278cc">00073</a> <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_OK 1</span>
<a name="l00074"></a><a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">00074</a> <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_MOVED 2</span>
<a name="l00075"></a><a class="code" href="a00163.html#g38af81a4c9884ce89803fc3e52383112">00075</a> <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_ERROR 3</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>
<a name="l00077"></a>00077
<a name="l00078"></a><a class="code" href="a00163.html#g3212e70c55244608ac16316888c354f0">00078</a> <span class="preprocessor">#define ISO_nl 0x0a</span>
<a name="l00079"></a><a class="code" href="a00163.html#g6cda47c85ce1b58b501b44ac9cccc50e">00079</a> <span class="preprocessor"></span><span class="preprocessor">#define ISO_cr 0x0d</span>
<a name="l00080"></a><a class="code" href="a00163.html#g71e1b022f7b7fa3a154f19372b239935">00080</a> <span class="preprocessor"></span><span class="preprocessor">#define ISO_space 0x20</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00097.html">webclient_state</a> s;
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00086"></a>00086 <span class="keywordtype">char</span> *
<a name="l00087"></a><a class="code" href="a00163.html#g4433d3af16ea083a81576d0f18ba57c9">00087</a> <a class="code" href="a00163.html#g4433d3af16ea083a81576d0f18ba57c9">webclient_mimetype</a>(<span class="keywordtype">void</span>)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089 <span class="keywordflow">return</span> s.<a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>;
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00092"></a>00092 <span class="keywordtype">char</span> *
<a name="l00093"></a><a class="code" href="a00163.html#g41e616d3fcc17e0aabfe8ab45ef0d30f">00093</a> <a class="code" href="a00163.html#g41e616d3fcc17e0aabfe8ab45ef0d30f">webclient_filename</a>(<span class="keywordtype">void</span>)
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 <span class="keywordflow">return</span> s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>;
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00098"></a>00098 <span class="keywordtype">char</span> *
<a name="l00099"></a><a class="code" href="a00163.html#g0e0ea5f24b77f124ba33bcbc7ede5bfb">00099</a> <a class="code" href="a00163.html#g0e0ea5f24b77f124ba33bcbc7ede5bfb">webclient_hostname</a>(<span class="keywordtype">void</span>)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <span class="keywordflow">return</span> s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>;
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00104"></a>00104 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>
<a name="l00105"></a><a class="code" href="a00163.html#g2a939aa4fcffabbce1dc1f784a7e0ad3">00105</a> <a class="code" href="a00163.html#g2a939aa4fcffabbce1dc1f784a7e0ad3">webclient_port</a>(<span class="keywordtype">void</span>)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 <span class="keywordflow">return</span> s.<a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>;
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00110"></a>00110 <span class="keywordtype">void</span>
<a name="l00111"></a><a class="code" href="a00163.html#g3caacabb2fe1c71921e1a471719ccbd2">00111</a> <a class="code" href="a00163.html#g3caacabb2fe1c71921e1a471719ccbd2">webclient_init</a>(<span class="keywordtype">void</span>)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00116"></a>00116 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00117"></a>00117 init_connection(<span class="keywordtype">void</span>)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> = <span class="keyword">sizeof</span>(http_get) - 1 + 1 +
<a name="l00122"></a>00122 <span class="keyword">sizeof</span>(http_10) - 1 +
<a name="l00123"></a>00123 <span class="keyword">sizeof</span>(http_crnl) - 1 +
<a name="l00124"></a>00124 <span class="keyword">sizeof</span>(http_host) - 1 +
<a name="l00125"></a>00125 <span class="keyword">sizeof</span>(http_crnl) - 1 +
<a name="l00126"></a>00126 strlen(http_user_agent_fields) +
<a name="l00127"></a>00127 strlen(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>) + strlen(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>);
<a name="l00128"></a>00128 s.<a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a> = 0;
<a name="l00129"></a>00129
<a name="l00130"></a>00130 s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00133"></a>00133 <span class="keywordtype">void</span>
<a name="l00134"></a><a class="code" href="a00163.html#g1d34be506a61db90dd7829117efdf8cf">00134</a> <a class="code" href="a00163.html#g1d34be506a61db90dd7829117efdf8cf">webclient_close</a>(<span class="keywordtype">void</span>)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#g863c94b0ed4a76997e53a3ccd5d0b6c3">WEBCLIENT_STATE_CLOSE</a>;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00139"></a>00139 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
<a name="l00140"></a><a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">00140</a> <a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">webclient_get</a>(<span class="keywordtype">char</span> *<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>, <span class="keywordtype">char</span> *<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>)
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142 <span class="keyword">struct </span><a class="code" href="a00088.html">uip_conn</a> *conn;
<a name="l00143"></a>00143 <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> *ipaddr;
<a name="l00144"></a>00144 <span class="keyword">static</span> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> addr;
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="comment">/* First check if the host is an IP address. */</span>
<a name="l00147"></a>00147 ipaddr = &amp;addr;
<a name="l00148"></a>00148 <span class="keywordflow">if</span>(uiplib_ipaddrconv(host, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)addr) == 0) {
<a name="l00149"></a>00149 ipaddr = (<a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> *)<a class="code" href="a00160.html#g66d19181ad5fe8b8f7c84d1f1d46a2ec">resolv_lookup</a>(host);
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="keywordflow">if</span>(ipaddr == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00152"></a>00152 <span class="keywordflow">return</span> 0;
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155
<a name="l00156"></a>00156 conn = <a class="code" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect</a>(ipaddr, <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(port));
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <span class="keywordflow">if</span>(conn == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00159"></a>00159 <span class="keywordflow">return</span> 0;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a>00162 s.<a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a> = port;
<a name="l00163"></a>00163 strncpy(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, file, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00164"></a>00164 strncpy(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, host, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>));
<a name="l00165"></a>00165
<a name="l00166"></a>00166 init_connection();
<a name="l00167"></a>00167 <span class="keywordflow">return</span> 1;
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00170"></a>00170 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *
<a name="l00171"></a>00171 copy_string(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *dest,
<a name="l00172"></a>00172 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *src, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="a00088.html#0ef3ae2764714bf90620075c374c262e">len</a>)
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174 strncpy(dest, src, len);
<a name="l00175"></a>00175 <span class="keywordflow">return</span> dest + len;
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00178"></a>00178 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00179"></a>00179 senddata(<span class="keywordtype">void</span>)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <a class="code" href="a00088.html#0ef3ae2764714bf90620075c374c262e">len</a>;
<a name="l00182"></a>00182 <span class="keywordtype">char</span> *getrequest;
<a name="l00183"></a>00183 <span class="keywordtype">char</span> *cptr;
<a name="l00184"></a>00184
<a name="l00185"></a>00185 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; 0) {
<a name="l00186"></a>00186 cptr = getrequest = (<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00187"></a>00187
<a name="l00188"></a>00188 cptr = copy_string(cptr, http_get, <span class="keyword">sizeof</span>(http_get) - 1);
<a name="l00189"></a>00189 cptr = copy_string(cptr, s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, strlen(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00190"></a>00190 *cptr++ = <a class="code" href="a00163.html#g71e1b022f7b7fa3a154f19372b239935">ISO_space</a>;
<a name="l00191"></a>00191 cptr = copy_string(cptr, http_10, <span class="keyword">sizeof</span>(http_10) - 1);
<a name="l00192"></a>00192
<a name="l00193"></a>00193 cptr = copy_string(cptr, http_crnl, <span class="keyword">sizeof</span>(http_crnl) - 1);
<a name="l00194"></a>00194
<a name="l00195"></a>00195 cptr = copy_string(cptr, http_host, <span class="keyword">sizeof</span>(http_host) - 1);
<a name="l00196"></a>00196 cptr = copy_string(cptr, s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, strlen(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>));
<a name="l00197"></a>00197 cptr = copy_string(cptr, http_crnl, <span class="keyword">sizeof</span>(http_crnl) - 1);
<a name="l00198"></a>00198
<a name="l00199"></a>00199 cptr = copy_string(cptr, http_user_agent_fields,
<a name="l00200"></a>00200 strlen(http_user_agent_fields));
<a name="l00201"></a>00201
<a name="l00202"></a>00202 len = s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>()?
<a name="l00203"></a>00203 <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>():
<a name="l00204"></a>00204 s.getrequestleft;
<a name="l00205"></a>00205 <a class="code" href="a00147.html#g04b053a623aac7cd4195157d470661b3">uip_send</a>(&amp;(getrequest[s.<a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a>]), len);
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 }
<a name="l00208"></a>00208 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00209"></a>00209 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00210"></a>00210 acked(<span class="keywordtype">void</span>)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len;
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; 0) {
<a name="l00215"></a>00215 len = s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>()?
<a name="l00216"></a>00216 <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>():
<a name="l00217"></a>00217 s.getrequestleft;
<a name="l00218"></a>00218 s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> -= len;
<a name="l00219"></a>00219 s.<a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a> += len;
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00223"></a>00223 <span class="keyword">static</span> <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>
<a name="l00224"></a>00224 parse_statusline(<a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 <span class="keywordtype">char</span> *cptr;
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="keywordflow">while</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> &lt; <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>)) {
<a name="l00229"></a>00229 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] = *(<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00230"></a>00230 ++((<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>);
<a name="l00231"></a>00231 --len;
<a name="l00232"></a>00232 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] == <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>) {
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <span class="keywordflow">if</span>((strncmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_10,
<a name="l00235"></a>00235 <span class="keyword">sizeof</span>(http_10) - 1) == 0) ||
<a name="l00236"></a>00236 (strncmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_11,
<a name="l00237"></a>00237 <span class="keyword">sizeof</span>(http_11) - 1) == 0)) {
<a name="l00238"></a>00238 cptr = &amp;(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[9]);
<a name="l00239"></a>00239 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a class="code" href="a00163.html#g40fb1fb2d990ce04ae9bbee275627c03">HTTPFLAG_NONE</a>;
<a name="l00240"></a>00240 <span class="keywordflow">if</span>(strncmp(cptr, http_200, <span class="keyword">sizeof</span>(http_200) - 1) == 0) {
<a name="l00241"></a>00241 <span class="comment">/* 200 OK */</span>
<a name="l00242"></a>00242 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a class="code" href="a00163.html#gda99954e0f6905091885934e86c278cc">HTTPFLAG_OK</a>;
<a name="l00243"></a>00243 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(strncmp(cptr, http_301, <span class="keyword">sizeof</span>(http_301) - 1) == 0 ||
<a name="l00244"></a>00244 strncmp(cptr, http_302, <span class="keyword">sizeof</span>(http_302) - 1) == 0) {
<a name="l00245"></a>00245 <span class="comment">/* 301 Moved permanently or 302 Found. Location: header line</span>
<a name="l00246"></a>00246 <span class="comment"> will contain thw new location. */</span>
<a name="l00247"></a>00247 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>;
<a name="l00248"></a>00248 } <span class="keywordflow">else</span> {
<a name="l00249"></a>00249 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 1] = 0;
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 } <span class="keywordflow">else</span> {
<a name="l00252"></a>00252 <a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00253"></a>00253 <a class="code" href="a00163.html#gf11d9915ec12a8cdd9fdcbb5e8fcd5c7">webclient_aborted</a>();
<a name="l00254"></a>00254 <span class="keywordflow">return</span> 0;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="comment">/* We're done parsing the status line, so we reset the pointer</span>
<a name="l00258"></a>00258 <span class="comment"> and start parsing the HTTP headers.*/</span>
<a name="l00259"></a>00259 s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00260"></a>00260 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#gc4357cec23abca29d2bb885803625a6a">WEBCLIENT_STATE_HEADERS</a>;
<a name="l00261"></a>00261 <span class="keywordflow">break</span>;
<a name="l00262"></a>00262 } <span class="keywordflow">else</span> {
<a name="l00263"></a>00263 ++s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>;
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 <span class="keywordflow">return</span> len;
<a name="l00267"></a>00267 }
<a name="l00268"></a>00268 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00269"></a>00269 <span class="keyword">static</span> <span class="keywordtype">char</span>
<a name="l00270"></a>00270 casecmp(<span class="keywordtype">char</span> *str1, <span class="keyword">const</span> <span class="keywordtype">char</span> *str2, <span class="keywordtype">char</span> len)
<a name="l00271"></a>00271 {
<a name="l00272"></a>00272 <span class="keyword">static</span> <span class="keywordtype">char</span> c;
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keywordflow">while</span>(len &gt; 0) {
<a name="l00275"></a>00275 c = *str1;
<a name="l00276"></a>00276 <span class="comment">/* Force lower-case characters. */</span>
<a name="l00277"></a>00277 <span class="keywordflow">if</span>(c &amp; 0x40) {
<a name="l00278"></a>00278 c |= 0x20;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 <span class="keywordflow">if</span>(*str2 != c) {
<a name="l00281"></a>00281 <span class="keywordflow">return</span> 1;
<a name="l00282"></a>00282 }
<a name="l00283"></a>00283 ++str1;
<a name="l00284"></a>00284 ++str2;
<a name="l00285"></a>00285 --len;
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287 <span class="keywordflow">return</span> 0;
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00290"></a>00290 <span class="keyword">static</span> <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>
<a name="l00291"></a>00291 parse_headers(<a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len)
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293 <span class="keywordtype">char</span> *cptr;
<a name="l00294"></a>00294 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> i;
<a name="l00295"></a>00295
<a name="l00296"></a>00296 <span class="keywordflow">while</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> &lt; <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>)) {
<a name="l00297"></a>00297 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] = *(<span class="keywordtype">char</span> *)uip_appdata;
<a name="l00298"></a>00298 ++((<span class="keywordtype">char</span> *)uip_appdata);
<a name="l00299"></a>00299 --len;
<a name="l00300"></a>00300 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] == <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>) {
<a name="l00301"></a>00301 <span class="comment">/* We have an entire HTTP header line in s.httpheaderline, so</span>
<a name="l00302"></a>00302 <span class="comment"> we parse it. */</span>
<a name="l00303"></a>00303 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[0] == <a class="code" href="a00161.html#g6cda47c85ce1b58b501b44ac9cccc50e">ISO_cr</a>) {
<a name="l00304"></a>00304 <span class="comment">/* This was the last header line (i.e., and empty "\r\n"), so</span>
<a name="l00305"></a>00305 <span class="comment"> we are done with the headers and proceed with the actual</span>
<a name="l00306"></a>00306 <span class="comment"> data. */</span>
<a name="l00307"></a>00307 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#g4d457c50e6f2cef57167c3804ce8bf7c">WEBCLIENT_STATE_DATA</a>;
<a name="l00308"></a>00308 <span class="keywordflow">return</span> len;
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310
<a name="l00311"></a>00311 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 1] = 0;
<a name="l00312"></a>00312 <span class="comment">/* Check for specific HTTP header fields. */</span>
<a name="l00313"></a>00313 <span class="keywordflow">if</span>(casecmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_content_type,
<a name="l00314"></a>00314 <span class="keyword">sizeof</span>(http_content_type) - 1) == 0) {
<a name="l00315"></a>00315 <span class="comment">/* Found Content-type field. */</span>
<a name="l00316"></a>00316 cptr = strchr(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, <span class="charliteral">';'</span>);
<a name="l00317"></a>00317 <span class="keywordflow">if</span>(cptr != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00318"></a>00318 *cptr = 0;
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 strncpy(s.<a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>, s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a> +
<a name="l00321"></a>00321 <span class="keyword">sizeof</span>(http_content_type) - 1, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>));
<a name="l00322"></a>00322 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(casecmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_location,
<a name="l00323"></a>00323 <span class="keyword">sizeof</span>(http_location) - 1) == 0) {
<a name="l00324"></a>00324 cptr = s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a> +
<a name="l00325"></a>00325 <span class="keyword">sizeof</span>(http_location) - 1;
<a name="l00326"></a>00326
<a name="l00327"></a>00327 <span class="keywordflow">if</span>(strncmp(cptr, http_http, 7) == 0) {
<a name="l00328"></a>00328 cptr += 7;
<a name="l00329"></a>00329 <span class="keywordflow">for</span>(i = 0; i &lt; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 7; ++i) {
<a name="l00330"></a>00330 <span class="keywordflow">if</span>(*cptr == 0 ||
<a name="l00331"></a>00331 *cptr == <span class="charliteral">'/'</span> ||
<a name="l00332"></a>00332 *cptr == <span class="charliteral">' '</span> ||
<a name="l00333"></a>00333 *cptr == <span class="charliteral">':'</span>) {
<a name="l00334"></a>00334 s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>[i] = 0;
<a name="l00335"></a>00335 <span class="keywordflow">break</span>;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>[i] = *cptr;
<a name="l00338"></a>00338 ++cptr;
<a name="l00339"></a>00339 }
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341 strncpy(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, cptr, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00342"></a>00342 <span class="comment">/* s.file[s.httpheaderlineptr - i] = 0;*/</span>
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344
<a name="l00345"></a>00345
<a name="l00346"></a>00346 <span class="comment">/* We're done parsing, so we reset the pointer and start the</span>
<a name="l00347"></a>00347 <span class="comment"> next line. */</span>
<a name="l00348"></a>00348 s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00349"></a>00349 } <span class="keywordflow">else</span> {
<a name="l00350"></a>00350 ++s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 <span class="keywordflow">return</span> len;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00356"></a>00356 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00357"></a>00357 newdata(<span class="keywordtype">void</span>)
<a name="l00358"></a>00358 {
<a name="l00359"></a>00359 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len;
<a name="l00360"></a>00360
<a name="l00361"></a>00361 len = <a class="code" href="a00147.html#g1a1bc437c09ddef238abab41d77c3177">uip_datalen</a>();
<a name="l00362"></a>00362
<a name="l00363"></a>00363 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>) {
<a name="l00364"></a>00364 len = parse_statusline(len);
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#gc4357cec23abca29d2bb885803625a6a">WEBCLIENT_STATE_HEADERS</a> &amp;&amp; len &gt; 0) {
<a name="l00368"></a>00368 len = parse_headers(len);
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370
<a name="l00371"></a>00371 <span class="keywordflow">if</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g4d457c50e6f2cef57167c3804ce8bf7c">WEBCLIENT_STATE_DATA</a> &amp;&amp;
<a name="l00372"></a>00372 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> != <a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>) {
<a name="l00373"></a>00373 <a class="code" href="a00163.html#gc4b119801e50cc1824498a1cdf9adc37">webclient_datahandler</a>((<span class="keywordtype">char</span> *)uip_appdata, len);
<a name="l00374"></a>00374 }
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00377"></a>00377 <span class="keywordtype">void</span>
<a name="l00378"></a><a class="code" href="a00163.html#g9e6d2864f390a4ba1ac60dc65e2b9815">00378</a> <a class="code" href="a00163.html#g9e6d2864f390a4ba1ac60dc65e2b9815">webclient_appcall</a>(<span class="keywordtype">void</span>)
<a name="l00379"></a>00379 {
<a name="l00380"></a>00380 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#gdb971fb1525d0c5002f52125b05f3218">uip_connected</a>()) {
<a name="l00381"></a>00381 s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00382"></a>00382 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>;
<a name="l00383"></a>00383 senddata();
<a name="l00384"></a>00384 <a class="code" href="a00163.html#g6b942c1ef22f8cd1a726ef3364c9fbea">webclient_connected</a>();
<a name="l00385"></a>00385 <span class="keywordflow">return</span>;
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g863c94b0ed4a76997e53a3ccd5d0b6c3">WEBCLIENT_STATE_CLOSE</a>) {
<a name="l00389"></a>00389 <a class="code" href="a00163.html#gf8f12c820cc08da32aa62898bfc02db3">webclient_closed</a>();
<a name="l00390"></a>00390 <a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00391"></a>00391 <span class="keywordflow">return</span>;
<a name="l00392"></a>00392 }
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#gfbd5fc486dfdf6bf6fc9db52b1f418c4">uip_aborted</a>()) {
<a name="l00395"></a>00395 <a class="code" href="a00163.html#gf11d9915ec12a8cdd9fdcbb5e8fcd5c7">webclient_aborted</a>();
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#g7b2ac4b18bd2ac3912fe67b3b17158c3">uip_timedout</a>()) {
<a name="l00398"></a>00398 <a class="code" href="a00163.html#g23705efb9077187881f094fc9be13bde">webclient_timedout</a>();
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400
<a name="l00401"></a>00401
<a name="l00402"></a>00402 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>()) {
<a name="l00403"></a>00403 s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00404"></a>00404 acked();
<a name="l00405"></a>00405 }
<a name="l00406"></a>00406 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>()) {
<a name="l00407"></a>00407 s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00408"></a>00408 newdata();
<a name="l00409"></a>00409 }
<a name="l00410"></a>00410 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#ga8933ad15a2e2947dae4a5cff50e6007">uip_rexmit</a>() ||
<a name="l00411"></a>00411 <a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>() ||
<a name="l00412"></a>00412 <a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>()) {
<a name="l00413"></a>00413 senddata();
<a name="l00414"></a>00414 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="a00147.html#g58bb90796c1cdad3aac2ecf44d87b20e">uip_poll</a>()) {
<a name="l00415"></a>00415 ++s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a>;
<a name="l00416"></a>00416 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> == <a class="code" href="a00163.html#g31be289fd8ec3fe09b0088165d13976d">WEBCLIENT_TIMEOUT</a>) {
<a name="l00417"></a>00417 <a class="code" href="a00163.html#g23705efb9077187881f094fc9be13bde">webclient_timedout</a>();
<a name="l00418"></a>00418 <a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00419"></a>00419 <span class="keywordflow">return</span>;
<a name="l00420"></a>00420 }
<a name="l00421"></a>00421 <span class="comment">/* senddata();*/</span>
<a name="l00422"></a>00422 }
<a name="l00423"></a>00423
<a name="l00424"></a>00424 <span class="keywordflow">if</span>(<a class="code" href="a00147.html#gef6c4140c632b6a406779342cf3b6eb6">uip_closed</a>()) {
<a name="l00425"></a>00425 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> != <a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>) {
<a name="l00426"></a>00426 <span class="comment">/* Send NULL data to signal EOF. */</span>
<a name="l00427"></a>00427 <a class="code" href="a00163.html#gc4b119801e50cc1824498a1cdf9adc37">webclient_datahandler</a>(<a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, 0);
<a name="l00428"></a>00428 } <span class="keywordflow">else</span> {
<a name="l00429"></a>00429 <span class="keywordflow">if</span>(<a class="code" href="a00160.html#g66d19181ad5fe8b8f7c84d1f1d46a2ec">resolv_lookup</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>) == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00430"></a>00430 <a class="code" href="a00160.html#ge4dcbbe6c641d2e3b8537b479df5fc99">resolv_query</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>);
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 <a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">webclient_get</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, s.<a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>, s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>);
<a name="l00433"></a>00433 }
<a name="l00434"></a>00434 }
<a name="l00435"></a>00435 }
<a name="l00436"></a>00436 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00437"></a>00437 <span class="comment"></span>
<a name="l00438"></a>00438 <span class="comment">/** @} */</span><span class="comment"></span>
<a name="l00439"></a>00439 <span class="comment">/** @} */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>