亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pop3_client.c

?? 在freescale 的ne64上開發的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 *Copyright (c) 2000-2002 Viola Systems Ltd.
 *All rights reserved.
 *
 *Redistribution and use in source and binary forms, with or without
 *modification, are permitted provided that the following conditions
 *are met:
 *
 *1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 *
 *2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 *3. The end-user documentation included with the redistribution, if
 *any, must include the following acknowledgment:
 *	"This product includes software developed by Viola
 *	Systems (http://www.violasystems.com/)."
 *
 *Alternately, this acknowledgment may appear in the software itself,
 *if and wherever such third-party acknowledgments normally appear.
 *
 *4. The names "OpenTCP" and "Viola Systems" must not be used to
 *endorse or promote products derived from this software without prior
 *written permission. For written permission, please contact
 *opentcp@opentcp.org.
 *
 *5. Products derived from this software may not be called "OpenTCP",
 *nor may "OpenTCP" appear in their name, without prior written
 *permission of the Viola Systems Ltd.
 *
 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE
 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *====================================================================
 *
 *OpenTCP is the unified open source TCP/IP stack available on a series
 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
 *
 *For more information on how to network-enable your devices, or how to
 *obtain commercial technical support for OpenTCP, please see
 *<http://www.violasystems.com/>.
 */

/** \file pop3_client.c
 *	\brief OpenTCP POP3 client implementation
 *	\author
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\version 1.0
 *	\date 20.08.2002
 *	\bug
 *	\warning
 *	\todo
 *
 *	OpenTCP implementation of POP3 client that uses TCP api. For interface
 *	functions declarations see /pop3/pop3_client.h.
 */

#include "debug.h"
#include "datatypes.h"
#include "globalvariables.h"
#include "system.h"
#include "timers.h"
#include "tcp_ip.h"
#ifdef POP3_WANTED
#include "pop3_client.h"


UINT8 pop3c_init_done = 0; /**< Defines whether pop3c_init has already been invoked or not */

/**	\brief	Holds information needed by the POP3 client for successful operation.
 *
 *	All of the information that the POP3 client is using for operation
 *	are stored here. See pop3c_struct definition for more
 *	information about the structure fields.
 */
struct pop3c_struct pop3_client;


/* The applications that use TCP must implement following function stubs			*/
/* void application_name_init (void) - call once when processor starts				*/
/* void application_name_run (void) - call periodically on main loop				*/
/* INT32 application_name_eventlistener (INT8, UINT8, UINT32, UINT32)				*/
/* - called by TCP input process to inform arriving data, errors etc				*/


/* POP3 Client application		*/


/** \brief Start E-mail reading procedure
 * 	\author
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 11.09.2002
 *	\param ip IP address of POP3 server from which to read the e-mails
 *	\param port Port on the server
 *	\return
 *		\li -1 - Error
 *		\li >0 - Connection procedure started (OK)
 *
 *	This function is called by user when she wants to start E-mail
 *	reading procedure. The function is responsible of establishing
 *	connection to POP3 server. After connection is established the
 *	POP3 client engine starts to make callbacks to user functions
 *	in order to get username information, data etc.
 */
INT8 pop3c_connect (UINT32 ip, UINT16 port){
	/* Do we have socket	*/

	if( pop3_client.sochandle < 0 ) {
		DEBUGOUT("pop3c_connect() called but no socket\r\n");
		return(-1);
	}

	if( pop3_client.state < POP3C_CLOSED ) {
		DEBUGOUT("pop3c_connect() called but uninitialized\r\n");
		return(-1);
	}

	if( pop3_client.state == POP3C_CLOSED )	{
		DEBUGOUT("POP3 Connection request going to be processed\r\n");
		pop3_client.remip = ip;
		pop3_client.remport = port;
		pop3c_changestate(POP3C_OPEN_REQUESTED);
		return(1);
	}

	return(-1);

}

/** \brief Initialize POP3 client
 * 	\author
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 12.08.2002
 *
 *	This function should be called once when system starts.
 *	Make sure that system services e.g. timers, TCP are initialized
 *	before initializing applications!
 */
void pop3c_init (void){

	if(pop3c_init_done) {
		DEBUGOUT("POP3 client already initialized\r\n");
		return;
	}


	/* Get timer handle	*/

	pop3_client.tmrhandle = get_timer();

	/* Get TCP Socket	*/

	pop3_client.sochandle = tcp_getsocket(TCP_TYPE_CLIENT, TCP_TOS_NORMAL, TCP_DEF_TOUT, pop3c_eventlistener);

	if( pop3_client.sochandle < 0 )	{
		DEBUGOUT("pop3c_init() uncapable of getting socket\r\n");
		RESET_SYSTEM();
	}

	pop3c_changestate(POP3C_CLOSED);
	pop3_client.remip = 0;
	pop3_client.remport = 0;
	pop3_client.unacked = 0;
	pop3_client.msgtotal = 0;
	pop3_client.curmsgindex = 0;
	pop3_client.curmsgtotlen = 0;
	pop3_client.curmsghlen = 0;
	pop3_client.headerbuf[0] = '\0';
	pop3_client.charsinheaderbuf = 0;
	pop3_client.from[0] = '\0';
	pop3_client.subject[0] = '\0';

	pop3c_init_done = 0x01;				/* We are initialized now	*/

}
/** \brief Get current POP3 client state
 * 	\author
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 10.10.2002
 *	\return Current POP3 client state
 *
 *	Invoke this function to get current state of the POP3 client
 *
 */
UINT8 pop3c_getstate (void){
	return(pop3_client.state);

}

/********************************************************************************
Function:		pop3c_eventlistener

Parameters:		INT8 cbhandle - handle to TCP socket where event is coming from
				UINT8 event - type of event
				UINT32 par1 - parameter the meaning of depends on event
				UINT32 par2 - parameter the meaning of depends on event

Return val:		INT32 - depends on event but usually (-1) is error of some
						kind and positive reply means OK

Date:			21.8.2002

Desc:			This function is given to TCP socket as function pointer to be
				used by TCP engine to make callbacks to inform about events
				on TCP e.g. arriving data. Main functionality of this function
				is to parse data from TCP to detect POP3 server reply commands,
				handling out retransmissions and making state changes
*********************************************************************************/


INT32 pop3c_eventlistener (INT8 cbhandle, UINT8 event, UINT32 par1, UINT32 par2)
{
	/* This function is called by TCP stack to inform about events	*/

	UINT8 cmd;
	UINT16 i;
	static UINT16 len;
	static UINT16 match;
	static UINT8  end_detect;
	UINT8 ch;
	UINT8 j;
	UINT8 endbuf[4];

	par2 = 0;
	j = 0;
	len = 0;
	endbuf[0] = 0;

	if( cbhandle != pop3_client.sochandle)		/* Not our handle	*/
		return(-1);

	switch( event ) {

		case TCP_EVENT_CONREQ:

			/* We don't allow incoming connections	*/

			return(-1);

		case TCP_EVENT_ABORT:

			if(pop3_client.state > POP3C_CLOSED) {
				/* Inform application	*/
				pop3c_error();
			}

			pop3c_changestate(POP3C_CLOSED);
			pop3_client.unacked = 0;

			return(1);

			break;

		case TCP_EVENT_CONNECTED:

			if(pop3_client.state == POP3C_CONNECTIONOPEN_SENT) {
				DEBUGOUT("POP3 TCP connection opened\r\n");
				pop3c_changestate(POP3C_CONNECTION_OPENED);
				pop3_client.unacked = 0;
				return(-1);
			}

			break;

		case TCP_EVENT_CLOSE:

			pop3c_changestate(POP3C_CLOSED);
			pop3_client.unacked = 0;
			return(1);

			break;

		case TCP_EVENT_ACK:

			/* Our message is acked	*/

			pop3_client.unacked = 0;

			break;

		case TCP_EVENT_DATA:

			/* Do we have unacked data?	*/

			if(pop3_client.unacked)
				return(-1);

			/* Get reply from server	*/

			if(par1 < 3)					/* Long enough?	*/
				return(-1);

			/* Get command				*/

			NETWORK_RECEIVE_INITIALIZE(received_tcp_packet.buf_index);
			cmd = RECEIVE_NETWORK_B();
			NETWORK_RECEIVE_INITIALIZE(received_tcp_packet.buf_index);

			switch(pop3_client.state) {

				case POP3C_CONNECTION_OPENED:

					if(cmd == POP3C_OK)	{
						DEBUGOUT("POP3 Server is ready\r\n");
						pop3c_changestate(POP3C_SERVER_READY);
						return(1);
					}

					break;

				case POP3C_USERNAME_SENT:

					if(cmd == POP3C_OK)	{
						DEBUGOUT("USER +OK by POP3 server\r\n");
						pop3c_changestate(POP3C_USERNAME_ACKED);
						return(1);
					}

					break;

				case POP3C_PASSWORD_SENT:

					if(cmd == POP3C_OK) {
						DEBUGOUT("PASS +OK by POP3 server\r\n");
						pop3c_changestate(POP3C_PASSWORD_ACKED);
						return(1);
					}

					break;

				case POP3C_STAT_SENT:

					if(cmd == POP3C_OK)	{
						DEBUGOUT("STAT get from POP3 server\r\n");

						/* Parse number of messages	*/

						NETWORK_RECEIVE_INITIALIZE(received_tcp_packet.buf_index);

						pop3_client.msgtotal = 0;
						pop3_client.curmsgindex = 0;
						pop3_client.curmsgtotlen = 0;
						pop3_client.curmsghlen = 0;
						if( pop3c_parsestat() < 0 )	{
							/* Error parsing STAT reply	*/
							/* Inform application		*/
							pop3c_error();
							(void)tcp_abort(pop3_client.sochandle);
							pop3c_changestate(POP3C_CLOSED);
							pop3_client.unacked = 0;
							return(1);
						}

						/* Inform application about the nmbr of messages	*/
						pop3c_messages(pop3_client.msgtotal);

						pop3c_changestate(POP3C_STAT_GET);
						return(1);
					}

					break;

				case POP3C_LIST_SENT:

					if(cmd == POP3C_OK)	{
						DEBUGOUT("LIST get from POP3 server\r\n");

						/* Parse message total len	*/

						NETWORK_RECEIVE_INITIALIZE(received_tcp_packet.buf_index);

						pop3_client.curmsgtotlen = 0;

						if(pop3c_parselist() < 0) {
							/* Error parsing LIST reply	*/
							/* Inform application		*/
							(void)pop3c_error();
							(void)tcp_abort(pop3_client.sochandle);
							pop3c_changestate(POP3C_CLOSED);
							pop3_client.unacked = 0;
							return(1);

						}


						pop3c_changestate(POP3C_LIST_GET);
						return(1);
					}

					break;

				case POP3C_TOP0_SENT:

					if(cmd == POP3C_OK) {
						DEBUGOUT("TOP x 0 get from POP3 server\r\n");

						/* Continue imediately to receive header	*/
						pop3_client.curmsghlen = 0;
						pop3_client.from[0] = '\0';
						pop3_client.subject[0] = '\0';
						match = 0;

						/* Receive untill LF found	*/

						for(i=0; i<(UINT16)par1; i++)
						{
							ch = RECEIVE_NETWORK_B();

							if(ch == '\n')
							{	i++;
								break;
							}
						}

						par1 = i;


						pop3c_changestate(POP3C_RECEIVING_HEADER);
					}else
						break;

				case POP3C_RECEIVING_HEADER:
				case POP3C_RECEIVING_HDR_FROM:
				case POP3C_RECEIVING_HDR_SUBJ:

					pop3_client.curmsghlen += (UINT16)par1;

					if( pop3_client.curmsghlen > (pop3_client.curmsgtotlen + 100) )	{
						/* Somebody tries to fool us	*/
						/* Move to next msg				*/

						pop3c_changestate(POP3C_MESSAGE_RECEIVED);
						break;

					}

					/* We try to find 'from:', or 'subject:'	*/

					NETWORK_RECEIVE_INITIALIZE(received_tcp_packet.buf_index);

					for( i=0; i<(UINT16)par1; i++) {

						ch = RECEIVE_NETWORK_B();

						if( pop3_client.state == POP3C_RECEIVING_HEADER) {

							if( ch == '\r')	{
								pop3_client.charsinheaderbuf = 0;
								continue;
							}

							if( ch == '\n')	{
								pop3_client.charsinheaderbuf = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产成人91porn| 日韩avvvv在线播放| 捆绑调教美女网站视频一区| 成人av在线播放网站| 91麻豆精品国产91久久久资源速度| 日韩精品一区二| 亚洲国产va精品久久久不卡综合| 国产91色综合久久免费分享| 久久丁香综合五月国产三级网站| 99久久综合精品| 国产夜色精品一区二区av| 自拍偷拍欧美精品| 青娱乐精品视频在线| 91精品国产一区二区三区蜜臀| 国产精品国产自产拍高清av王其| 欧美a级一区二区| 777久久久精品| 日韩精品电影在线观看| 欧美日韩在线播放一区| 亚洲一二三四在线| 99国产一区二区三精品乱码| 国产精品动漫网站| 国产一区二区精品在线观看| 欧美精品一区在线观看| 精品无码三级在线观看视频| 日韩欧美一级片| 蜜臀av性久久久久av蜜臀妖精| 欧美一区三区四区| 久久精品国产99久久6| 国产三级欧美三级日产三级99| 国产永久精品大片wwwapp| 久久久精品中文字幕麻豆发布| 高清不卡在线观看av| 欧美国产精品专区| 蜜臀av国产精品久久久久| 久久影音资源网| 91啦中文在线观看| 日本伊人色综合网| 国产精品国产精品国产专区不蜜| 欧美在线视频不卡| 激情综合色综合久久| 欧美经典三级视频一区二区三区| 欧美性生活一区| 激情综合色播五月| 亚洲综合男人的天堂| 国产蜜臀av在线一区二区三区| 91欧美一区二区| 麻豆成人av在线| 日本不卡一区二区三区高清视频| 日本不卡在线视频| 欧美国产视频在线| 91精品免费在线观看| 成人理论电影网| 国产乱子伦视频一区二区三区 | 亚洲精品免费在线观看| 精品剧情在线观看| 欧美日韩亚洲另类| 欧美一级免费观看| 日韩亚洲欧美成人一区| 欧美一区午夜视频在线观看| 精品国内二区三区| 精品第一国产综合精品aⅴ| 日韩一级大片在线观看| 久久精品无码一区二区三区| 精品国产乱码久久久久久蜜臀 | 麻豆传媒一区二区三区| 国产精品视频看| 欧美刺激午夜性久久久久久久| 99久久99精品久久久久久| 日韩精品久久理论片| 五月婷婷色综合| 樱花草国产18久久久久| 中文字幕色av一区二区三区| 久久亚洲综合色一区二区三区| 欧美在线不卡一区| 91麻豆高清视频| 欧美人伦禁忌dvd放荡欲情| 欧美在线啊v一区| 欧美精品在线观看播放| 色综合久久天天| 欧美日韩一区在线| 精品国产伦一区二区三区观看体验| 91美女在线看| 99久久久国产精品免费蜜臀| 不卡一区二区中文字幕| av电影一区二区| 91亚洲国产成人精品一区二区三 | 国产另类ts人妖一区二区| 亚洲成人免费观看| 国产乱码精品一区二区三区av| 国产老肥熟一区二区三区| 一本一道综合狠狠老| 精品国内片67194| 久久久精品免费观看| 成人免费在线视频| 亚洲一区在线观看免费| 国产一区二区视频在线| 国产精品一级在线| 不卡高清视频专区| 不卡的av网站| 欧美日韩亚洲国产综合| 欧美肥胖老妇做爰| 麻豆免费看一区二区三区| 国产精品少妇自拍| 高清不卡一区二区在线| 色综合婷婷久久| 久久影院视频免费| 日日摸夜夜添夜夜添国产精品| 国产网站一区二区| 亚洲在线成人精品| 国产精品亚洲一区二区三区妖精| 91久久一区二区| 成人网在线免费视频| 欧美日免费三级在线| 中文字幕第一区综合| 久久99精品视频| 91超碰这里只有精品国产| 亚洲日本成人在线观看| 国产裸体歌舞团一区二区| 国产欧美va欧美不卡在线| 三级精品在线观看| 欧美日韩一区在线观看| 伊人性伊人情综合网| 欧美激情一区不卡| 国产精品福利一区二区三区| 欧美性受xxxx黑人xyx| 国产午夜久久久久| 秋霞电影网一区二区| 91在线观看下载| 国产精品不卡视频| 国产成人高清视频| 久久精品免费在线观看| 亚洲欧美日韩国产综合| 成人性生交大片免费| 国产欧美视频一区二区三区| 麻豆精品一区二区综合av| 日韩午夜激情免费电影| 五月婷婷欧美视频| 欧美日韩一卡二卡| 亚洲另类中文字| 在线观看国产日韩| 亚洲欧美日韩一区二区| 色菇凉天天综合网| 亚洲丝袜另类动漫二区| 色婷婷久久久综合中文字幕| 亚洲欧洲性图库| 在线观看精品一区| 国产精品视频看| 91视频国产观看| 亚洲一二三四区| 欧美视频在线一区| 奇米影视一区二区三区| 在线综合视频播放| 久久成人18免费观看| 亚洲精品一线二线三线| 成人综合婷婷国产精品久久| 国产婷婷色一区二区三区四区| 成人av影视在线观看| 欧美日韩国产一级二级| 亚洲综合免费观看高清完整版在线| 粉嫩高潮美女一区二区三区| 中文字幕一区二区三区在线观看| 成人网页在线观看| 亚洲欧美日韩精品久久久久| 欧美在线综合视频| 久久成人免费网站| 国产视频一区在线观看| 91麻豆国产香蕉久久精品| 日精品一区二区| 成人免费毛片片v| 高清国产午夜精品久久久久久| 亚洲图片欧美色图| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 久久不见久久见免费视频7| 日韩欧美的一区二区| 在线观看国产精品网站| 麻豆成人91精品二区三区| 日韩在线一二三区| 国产二区国产一区在线观看| 日韩欧美电影在线| 国产在线精品一区二区夜色 | 日韩精品色哟哟| 精品国产一区二区精华| 国产精品18久久久| 日韩精彩视频在线观看| 精品国产亚洲一区二区三区在线观看| 风间由美一区二区三区在线观看| 91高清在线观看| 中文字幕在线一区免费| 91美女视频网站| 国产综合久久久久影院| 日本不卡在线视频| 石原莉奈一区二区三区在线观看| 在线国产亚洲欧美| 国产传媒欧美日韩成人| 91影院在线观看| 国产日产欧美一区二区三区| 中文字幕巨乱亚洲| 91精品国产综合久久香蕉麻豆| 免费在线视频一区|