<!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/webserver/httpd-cgi.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/webserver/httpd-cgi.c</h1><a href="a00112.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 httpd</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"> * \file</span>
<a name="l00008"></a>00008 <span class="comment"> *         Web server script interface</span>
<a name="l00009"></a>00009 <span class="comment"> * \author</span>
<a name="l00010"></a>00010 <span class="comment"> *         Adam Dunkels &lt;adam@sics.se&gt;</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="comment">/*</span>
<a name="l00015"></a>00015 <span class="comment"> * Copyright (c) 2001-2006, Adam Dunkels.</span>
<a name="l00016"></a>00016 <span class="comment"> * All rights reserved.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00019"></a>00019 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00020"></a>00020 <span class="comment"> * are met:</span>
<a name="l00021"></a>00021 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00022"></a>00022 <span class="comment"> *    notice, this list of conditions and the following disclaimer.</span>
<a name="l00023"></a>00023 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00024"></a>00024 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the</span>
<a name="l00025"></a>00025 <span class="comment"> *    documentation and/or other materials provided with the distribution.</span>
<a name="l00026"></a>00026 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00027"></a>00027 <span class="comment"> *    products derived from this software without specific prior</span>
<a name="l00028"></a>00028 <span class="comment"> *    written permission.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00031"></a>00031 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00032"></a>00032 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00033"></a>00033 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00034"></a>00034 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00035"></a>00035 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00036"></a>00036 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00037"></a>00037 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00038"></a>00038 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00039"></a>00039 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00040"></a>00040 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00041"></a>00041 <span class="comment"> *</span>
<a name="l00042"></a>00042 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00043"></a>00043 <span class="comment"> *</span>
<a name="l00044"></a>00044 <span class="comment"> * $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00045"></a>00045 <span class="comment"> *</span>
<a name="l00046"></a>00046 <span class="comment"> */</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "<a class="code" href="a00127.html">psock.h</a>"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "httpd.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "<a class="code" href="a00113.html">httpd-cgi.h</a>"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "httpd-fs.h"</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <a class="code" href="a00164.html#g1dbc635a2924806f42d7e3273a6a69b5">HTTPD_CGI_CALL</a>(<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, <span class="stringliteral">"file-stats"</span>, file_stats);
<a name="l00058"></a>00058 <a class="code" href="a00164.html#g1dbc635a2924806f42d7e3273a6a69b5">HTTPD_CGI_CALL</a>(tcp, <span class="stringliteral">"tcp-connections"</span>, tcp_stats);
<a name="l00059"></a>00059 <a class="code" href="a00164.html#g1dbc635a2924806f42d7e3273a6a69b5">HTTPD_CGI_CALL</a>(net, <span class="stringliteral">"net-stats"</span>, net_stats);
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code" href="a00079.html">httpd_cgi_call</a> *calls[] = { &amp;file, &amp;tcp, &amp;net, <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> };
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00064"></a>00064 <span class="keyword">static</span>
<a name="l00065"></a>00065 <a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(nullfunction(<span class="keyword">struct</span> <a class="code" href="a00080.html">httpd_state</a> *s, <span class="keywordtype">char</span> *ptr))
<a name="l00066"></a>00066 {
<a name="l00067"></a>00067   <a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00068"></a>00068   <a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00071"></a>00071 httpd_cgifunction
<a name="l00072"></a><a class="code" href="a00164.html#ge6f849e94cf6e214be8ffa9a548ecfcd">00072</a> <a class="code" href="a00164.html#ge6f849e94cf6e214be8ffa9a548ecfcd">httpd_cgi</a>(<span class="keywordtype">char</span> *<a class="code" href="a00079.html#9a84c69ec5a4705ccb1ca99fcd120add">name</a>)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074   <span class="keyword">const</span> <span class="keyword">struct </span><a class="code" href="a00079.html">httpd_cgi_call</a> **f;
<a name="l00075"></a>00075 
<a name="l00076"></a>00076   <span class="comment">/* Find the matching name in the table, return the function. */</span>
<a name="l00077"></a>00077   <span class="keywordflow">for</span>(f = calls; *f != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>; ++f) {
<a name="l00078"></a>00078     <span class="keywordflow">if</span>(strncmp((*f)-&gt;name, name, strlen((*f)-&gt;name)) == 0) {
<a name="l00079"></a>00079       return (*f)-&gt;function;
<a name="l00080"></a>00080     }
<a name="l00081"></a>00081   }
<a name="l00082"></a>00082   <span class="keywordflow">return</span> nullfunction;
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00085"></a>00085 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>
<a name="l00086"></a>00086 generate_file_stats(<span class="keywordtype">void</span> *arg)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088   <span class="keywordtype">char</span> *f = (<span class="keywordtype">char</span> *)arg;
<a name="l00089"></a>00089   <span class="keywordflow">return</span> snprintf((<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>, <a class="code" href="a00150.html#ge0825474feee11b4e038bfe71757875f">UIP_APPDATA_SIZE</a>, <span class="stringliteral">"%5u"</span>, httpd_fs_count(f));
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00092"></a>00092 <span class="keyword">static</span>
<a name="l00093"></a>00093 <a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(file_stats(<span class="keyword">struct</span> <a class="code" href="a00080.html">httpd_state</a> *s, <span class="keywordtype">char</span> *ptr))
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095   <a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00096"></a>00096 
<a name="l00097"></a>00097   <a class="code" href="a00158.html#g10d9a9201cba1a6db623284c475c6cea">PSOCK_GENERATOR_SEND</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>, generate_file_stats, strchr(ptr, <span class="charliteral">' '</span>) + 1);
<a name="l00098"></a>00098   
<a name="l00099"></a>00099   <a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00102"></a>00102 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> closed[] =   <span class="comment">/*  "CLOSED",*/</span>
<a name="l00103"></a>00103 {0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
<a name="l00104"></a>00104 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> syn_rcvd[] = <span class="comment">/*  "SYN-RCVD",*/</span>
<a name="l00105"></a>00105 {0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
<a name="l00106"></a>00106  0x44,  0};
<a name="l00107"></a>00107 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> syn_sent[] = <span class="comment">/*  "SYN-SENT",*/</span>
<a name="l00108"></a>00108 {0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
<a name="l00109"></a>00109  0x54,  0};
<a name="l00110"></a>00110 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> established[] = <span class="comment">/*  "ESTABLISHED",*/</span>
<a name="l00111"></a>00111 {0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
<a name="l00112"></a>00112  0x45, 0x44, 0};
<a name="l00113"></a>00113 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> fin_wait_1[] = <span class="comment">/*  "FIN-WAIT-1",*/</span>
<a name="l00114"></a>00114 {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
<a name="l00115"></a>00115  0x54, 0x2d, 0x31, 0};
<a name="l00116"></a>00116 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> fin_wait_2[] = <span class="comment">/*  "FIN-WAIT-2",*/</span>
<a name="l00117"></a>00117 {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
<a name="l00118"></a>00118  0x54, 0x2d, 0x32, 0};
<a name="l00119"></a>00119 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> closing[] = <span class="comment">/*  "CLOSING",*/</span>
<a name="l00120"></a>00120 {0x43, 0x4c, 0x4f, 0x53, 0x49,
<a name="l00121"></a>00121  0x4e, 0x47, 0};
<a name="l00122"></a>00122 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> time_wait[] = <span class="comment">/*  "TIME-WAIT,"*/</span>
<a name="l00123"></a>00123 {0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
<a name="l00124"></a>00124  0x49, 0x54, 0};
<a name="l00125"></a>00125 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> last_ack[] = <span class="comment">/*  "LAST-ACK"*/</span>
<a name="l00126"></a>00126 {0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
<a name="l00127"></a>00127  0x4b, 0};
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *states[] = {
<a name="l00130"></a>00130   closed,
<a name="l00131"></a>00131   syn_rcvd,
<a name="l00132"></a>00132   syn_sent,
<a name="l00133"></a>00133   established,
<a name="l00134"></a>00134   fin_wait_1,
<a name="l00135"></a>00135   fin_wait_2,
<a name="l00136"></a>00136   closing,
<a name="l00137"></a>00137   time_wait,
<a name="l00138"></a>00138   last_ack};
<a name="l00139"></a>00139   
<a name="l00140"></a>00140 
<a name="l00141"></a>00141 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>
<a name="l00142"></a>00142 generate_tcp_stats(<span class="keywordtype">void</span> *arg)
<a name="l00143"></a>00143 {
<a name="l00144"></a>00144   <span class="keyword">struct </span><a class="code" href="a00088.html">uip_conn</a> *conn;
<a name="l00145"></a>00145   <span class="keyword">struct </span><a class="code" href="a00080.html">httpd_state</a> *s = (<span class="keyword">struct </span><a class="code" href="a00080.html">httpd_state</a> *)arg;
<a name="l00146"></a>00146     
<a name="l00147"></a>00147   conn = &amp;<a class="code" href="a00150.html#gf703683056d2bfa5c81fa157dcb20fe2">uip_conns</a>[s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a>];
<a name="l00148"></a>00148   <span class="keywordflow">return</span> snprintf((<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>, <a class="code" href="a00150.html#ge0825474feee11b4e038bfe71757875f">UIP_APPDATA_SIZE</a>,
<a name="l00149"></a>00149                  <span class="stringliteral">"&lt;tr&gt;&lt;td&gt;%d&lt;/td&gt;&lt;td&gt;%u.%u.%u.%u:%u&lt;/td&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;%u&lt;/td&gt;&lt;td&gt;%u&lt;/td&gt;&lt;td&gt;%c %c&lt;/td&gt;&lt;/tr&gt;\r\n"</span>,
<a name="l00150"></a>00150                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#0cd09beee671e7e9efb0b4aced10249e">lport</a>),
<a name="l00151"></a>00151                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#79510aa86d3fa0a0fc6cfc49b1da7279">ripaddr</a>[0]) &gt;&gt; 8,
<a name="l00152"></a>00152                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#79510aa86d3fa0a0fc6cfc49b1da7279">ripaddr</a>[0]) &amp; 0xff,
<a name="l00153"></a>00153                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#79510aa86d3fa0a0fc6cfc49b1da7279">ripaddr</a>[1]) &gt;&gt; 8,
<a name="l00154"></a>00154                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#79510aa86d3fa0a0fc6cfc49b1da7279">ripaddr</a>[1]) &amp; 0xff,
<a name="l00155"></a>00155                  <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(conn-&gt;<a class="code" href="a00088.html#1df6aa054ef2fa634ac4c6f418228285">rport</a>),
<a name="l00156"></a>00156                  states[conn-&gt;<a class="code" href="a00088.html#a5f58074435cdc180f17de69651beebd">tcpstateflags</a> &amp; <a class="code" href="a00150.html#g13dfcb4a5f920e108253ade527a66cc2">UIP_TS_MASK</a>],
<a name="l00157"></a>00157                  conn-&gt;<a class="code" href="a00088.html#4289c59840b128f2f6526e9da2711d47">nrtx</a>,
<a name="l00158"></a>00158                  conn-&gt;<a class="code" href="a00088.html#2d9732cf5752d30bd11cb25dc7d0c8d3">timer</a>,
<a name="l00159"></a>00159                  (<a class="code" href="a00147.html#gef14e83c046e19ab9fe9d1bbcca276c2">uip_outstanding</a>(conn))? <span class="charliteral">'*'</span>:<span class="charliteral">' '</span>,
<a name="l00160"></a>00160                  (<a class="code" href="a00147.html#g64a238a5c02640a7a4aef004163aeb47">uip_stopped</a>(conn))? <span class="charliteral">'!'</span>:<span class="charliteral">' '</span>);
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00163"></a>00163 <span class="keyword">static</span>
<a name="l00164"></a>00164 <a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(tcp_stats(<span class="keyword">struct</span> <a class="code" href="a00080.html">httpd_state</a> *s, <span class="keywordtype">char</span> *ptr))
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166   
<a name="l00167"></a>00167   <a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00168"></a>00168 
<a name="l00169"></a>00169   <span class="keywordflow">for</span>(s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a> = 0; s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a> &lt; <a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; ++s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a>) {
<a name="l00170"></a>00170     <span class="keywordflow">if</span>((<a class="code" href="a00150.html#gf703683056d2bfa5c81fa157dcb20fe2">uip_conns</a>[s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a>].tcpstateflags &amp; UIP_TS_MASK) != <a class="code" href="a00150.html#g28eda870cff3d8e3cf2949e6f57a502b">UIP_CLOSED</a>) {
<a name="l00171"></a>00171       <a class="code" href="a00158.html#g10d9a9201cba1a6db623284c475c6cea">PSOCK_GENERATOR_SEND</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>, generate_tcp_stats, s);
<a name="l00172"></a>00172     }
<a name="l00173"></a>00173   }
<a name="l00174"></a>00174 
<a name="l00175"></a>00175   <a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<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">unsigned</span> <span class="keywordtype">short</span>
<a name="l00179"></a>00179 generate_net_stats(<span class="keywordtype">void</span> *arg)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181   <span class="keyword">struct </span><a class="code" href="a00080.html">httpd_state</a> *s = (<span class="keyword">struct </span><a class="code" href="a00080.html">httpd_state</a> *)arg;
<a name="l00182"></a>00182   <span class="keywordflow">return</span> snprintf((<span class="keywordtype">char</span> *)uip_appdata, <a class="code" href="a00150.html#ge0825474feee11b4e038bfe71757875f">UIP_APPDATA_SIZE</a>,
<a name="l00183"></a>00183                   <span class="stringliteral">"%5u\n"</span>, ((<a class="code" href="a00153.html#g727459e5c4f777543c81ffffa3df3f0c">uip_stats_t</a> *)&amp;<a class="code" href="a00150.html#g9ee50a40597e67fce96541ab56c3b712">uip_stat</a>)[s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a>]);
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186 <span class="keyword">static</span>
<a name="l00187"></a>00187 <a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(net_stats(<span class="keyword">struct</span> <a class="code" href="a00080.html">httpd_state</a> *s, <span class="keywordtype">char</span> *ptr))
<a name="l00188"></a>00188 {
<a name="l00189"></a>00189   <a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00190"></a>00190 
<a name="l00191"></a>00191 <span class="preprocessor">#if UIP_STATISTICS</span>
<a name="l00192"></a>00192 <span class="preprocessor"></span>
<a name="l00193"></a>00193   <span class="keywordflow">for</span>(s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a> = 0; s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a> &lt; <span class="keyword">sizeof</span>(<a class="code" href="a00150.html#g9ee50a40597e67fce96541ab56c3b712">uip_stat</a>) / <span class="keyword">sizeof</span>(<a class="code" href="a00153.html#g727459e5c4f777543c81ffffa3df3f0c">uip_stats_t</a>);
<a name="l00194"></a>00194       ++s-&gt;<a class="code" href="a00080.html#6df929b448ea98bc44d41f5e96237bda">count</a>) {
<a name="l00195"></a>00195     <a class="code" href="a00158.html#g10d9a9201cba1a6db623284c475c6cea">PSOCK_GENERATOR_SEND</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>, generate_net_stats, s);
<a name="l00196"></a>00196   }
<a name="l00197"></a>00197   
<a name="l00198"></a>00198 <span class="preprocessor">#endif </span><span class="comment">/* UIP_STATISTICS */</span>
<a name="l00199"></a>00199   
<a name="l00200"></a>00200   <a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s-&gt;<a class="code" href="a00080.html#9dd8edeece221c853a4c4516bf1b01c2">sout</a>);
<a name="l00201"></a>00201 }
<a name="l00202"></a>00202 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00203"></a>00203 <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>