⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pop3__client_8c-source.html

📁 Freescale mcu OpenTCP-1.0.4.doc.html.zip 文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
00173         pop3_client.<a class="code" href="structpop3c__struct.html#m6">msgtotal</a> = 0;00174         pop3_client.<a class="code" href="structpop3c__struct.html#m7">curmsgindex</a> = 0;00175         pop3_client.<a class="code" href="structpop3c__struct.html#m8">curmsgtotlen</a> = 0;00176         pop3_client.<a class="code" href="structpop3c__struct.html#m9">curmsghlen</a> = 0;00177         pop3_client.<a class="code" href="structpop3c__struct.html#m10">headerbuf</a>[0] = <span class="charliteral">'\0'</span>;00178         pop3_client.<a class="code" href="structpop3c__struct.html#m11">charsinheaderbuf</a> = 0;00179         pop3_client.<a class="code" href="structpop3c__struct.html#m12">from</a>[0] = <span class="charliteral">'\0'</span>;00180         pop3_client.<a class="code" href="structpop3c__struct.html#m13">subject</a>[0] = <span class="charliteral">'\0'</span>;00181         00182         <a class="code" href="pop3__client_8c.html#a0">pop3c_init_done</a> = 0x01;                         <span class="comment">/* We are initialized now       */</span>00183 00184 }<a name="l00194"></a><a class="code" href="pop3__client_8c.html#a4">00194</a> UINT8 <a class="code" href="pop3__client_8c.html#a33">pop3c_getstate</a> (<span class="keywordtype">void</span>){00195         <span class="keywordflow">return</span>(pop3_client.<a class="code" href="structpop3c__struct.html#m0">state</a>);00196         00197 }00198 00199 <span class="comment">/********************************************************************************</span>00200 <span class="comment">Function:               pop3c_eventlistener</span>00201 <span class="comment"></span>00202 <span class="comment">Parameters:             INT8 cbhandle - handle to TCP socket where event is coming from </span>00203 <span class="comment">                                UINT8 event - type of event</span>00204 <span class="comment">                                UINT32 par1 - parameter the meaning of depends on event</span>00205 <span class="comment">                                UINT32 par2 - parameter the meaning of depends on event</span>00206 <span class="comment">                                </span>00207 <span class="comment">Return val:             INT32 - depends on event but usually (-1) is error of some</span>00208 <span class="comment">                                                kind and positive reply means OK</span>00209 <span class="comment">                                </span>00210 <span class="comment">Date:                   21.8.2002</span>00211 <span class="comment"></span>00212 <span class="comment">Desc:                   This function is given to TCP socket as function pointer to be</span>00213 <span class="comment">                                used by TCP engine to make callbacks to inform about events</span>00214 <span class="comment">                                on TCP e.g. arriving data. Main functionality of this function </span>00215 <span class="comment">                                is to parse data from TCP to detect POP3 server reply commands,</span>00216 <span class="comment">                                handling out retransmissions and making state changes</span>00217 <span class="comment">*********************************************************************************/</span>00218 00219 00220 INT32 pop3c_eventlistener (INT8 cbhandle, UINT8 event, UINT32 par1, UINT32 par2)00221 {00222         <span class="comment">/* This function is called by TCP stack to inform about events  */</span>00223         00224         UINT8 cmd;00225         UINT16 i;00226         <span class="keyword">static</span> UINT16 len;00227         <span class="keyword">static</span> UINT16 match;00228         <span class="keyword">static</span> UINT8  end_detect;00229         UINT8 ch;00230         UINT8 j;00231         UINT8 endbuf[4];00232                 00233         00234         <span class="keywordflow">if</span>( cbhandle != pop3_client.<a class="code" href="structpop3c__struct.html#m3">sochandle</a>)          <span class="comment">/* Not our handle       */</span>00235                 <span class="keywordflow">return</span>(-1);00236         00237         <span class="keywordflow">switch</span>( event ) {00238         00239                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a54">TCP_EVENT_CONREQ</a>:00240                 00241                         <span class="comment">/* We don't allow incoming connections  */</span>00242                         00243                         <span class="keywordflow">return</span>(-1);00244         00245                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a57">TCP_EVENT_ABORT</a>:00246                 00247                         <span class="keywordflow">if</span>(pop3_client.<a class="code" href="structpop3c__struct.html#m0">state</a> &gt; <a class="code" href="pop3__client_8h.html#a4">POP3C_CLOSED</a>) {00248                                 <span class="comment">/* Inform application   */</span>      00249                                 <a class="code" href="pop3c__callbacks_8c.html#a47">pop3c_error</a>();  00250                         }00251                 00252                         pop3c_changestate(<a class="code" href="pop3__client_8h.html#a4">POP3C_CLOSED</a>);00253                         pop3_client.<a class="code" href="structpop3c__struct.html#m5">unacked</a> = 0;00254                         00255                         <span class="keywordflow">return</span>(1);00256                 00257                         <span class="keywordflow">break</span>;00258                 00259                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a55">TCP_EVENT_CONNECTED</a>:00260                 00261                         <span class="keywordflow">if</span>(pop3_client.<a class="code" href="structpop3c__struct.html#m0">state</a> == <a class="code" href="pop3__client_8h.html#a6">POP3C_CONNECTIONOPEN_SENT</a>) {00262                                 DEBUGOUT(<span class="stringliteral">"POP3 TCP connection opened\r\n"</span>);00263                                 pop3c_changestate(<a class="code" href="pop3__client_8h.html#a7">POP3C_CONNECTION_OPENED</a>);00264                                 pop3_client.<a class="code" href="structpop3c__struct.html#m5">unacked</a> = 0;00265                                 <span class="keywordflow">return</span>(-1);00266                         }00267                                 00268                         <span class="keywordflow">break</span>;00269                         00270                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a56">TCP_EVENT_CLOSE</a>:00271                 00272                         pop3c_changestate(<a class="code" href="pop3__client_8h.html#a4">POP3C_CLOSED</a>);00273                         pop3_client.<a class="code" href="structpop3c__struct.html#m5">unacked</a> = 0;00274                         <span class="keywordflow">return</span>(1);00275                 00276                         <span class="keywordflow">break</span>;00277                         00278                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a58">TCP_EVENT_ACK</a>:00279                 00280                         <span class="comment">/* Our message is acked */</span>00281                         00282                         pop3_client.<a class="code" href="structpop3c__struct.html#m5">unacked</a> = 0;00283                         00284                         <span class="keywordflow">break</span>;00285                         00286                 <span class="keywordflow">case</span> <a class="code" href="tcp__ip_8h.html#a60">TCP_EVENT_DATA</a>:00287                 00288                         <span class="comment">/* Do we have unacked data?     */</span>00289                         00290                         <span class="keywordflow">if</span>(pop3_client.<a class="code" href="structpop3c__struct.html#m5">unacked</a>)00291                                 <span class="keywordflow">return</span>(-1);00292                 00293                         <span class="comment">/* Get reply from server        */</span>00294                         00295                         <span class="keywordflow">if</span>(par1 &lt; 3)                                    <span class="comment">/* Long enough? */</span>00296                                 <span class="keywordflow">return</span>(-1);00297                 00298                         <span class="comment">/* Get command                          */</span>00299                         00300                         <a class="code" href="system_8h.html#a14">NETWORK_RECEIVE_INITIALIZE</a>(received_tcp_packet.buf_index);00301                         cmd = <a class="code" href="system_8h.html#a9">RECEIVE_NETWORK_B</a>();00302                         <a class="code" href="system_8h.html#a14">NETWORK_RECEIVE_INITIALIZE</a>(received_tcp_packet.buf_index);00303 00304                         <span class="keywordflow">switch</span>(pop3_client.<a class="code" href="structpop3c__struct.html#m0">state</a>) {00305                                 00306                                 <span class="keywordflow">case</span> <a class="code" href="pop3__client_8h.html#a7">POP3C_CONNECTION_OPENED</a>:00307                                 00308                                         <span class="keywordflow">if</span>(cmd == POP3C_OK)     {00309                                                 DEBUGOUT(<span class="stringliteral">"POP3 Server is ready\r\n"</span>);00310                                                 pop3c_changestate(<a class="code" href="pop3__client_8h.html#a8">POP3C_SERVER_READY</a>);00311                                                 <span class="keywordflow">return</span>(1);00312                                         }00313                                         00314                                         <span class="keywordflow">break</span>;00315                                 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -