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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? pop3_client.c

?? opentcp_mcf5282原代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/***************************************************************************************
File:			pop3_client.c

Date:			20.8.2002

Version:		0.1

Author:			Jari Lahti (jari@violasystems.com)

Description:	This file contains POP3 E-mail client implementation that uses Viola
				TCP API.

Version Info:	20.8.2002 - First version (JaL)
***************************************************************************************/

#include "opentcp.h"


UINT8 pop3c_init_done = 0;
struct POP3CStruct POP3Client;


/* 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		*/


/********************************************************************************
Function:		pop3c_connect

Parameters:		UINT32 ip - ip address of POP3 server
				UINT16 port - port on server (remote port)

Return val:		INT8 - (-1) = Error
					 -  >0 = Connection procedure started (OK)

Date:			11.9.2002

Desc:			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( POP3Client.sochandle < 0 )
	{
		DEBUGOUT("pop3c_connect() called but no socket\r\n");
		return(-1);
	}

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

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

	return(-1);

}


/********************************************************************************
Function:		pop3c_init

Parameters:		void

Return val:		void

Date:			12.8.2002

Desc:			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	*/

	POP3Client.tmrhandle = get_timer();

	/* Get TCP Socket	*/

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

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

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

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

}

/********************************************************************************
Function:		pop3c_getstate

Parameters:		void

Return val:		UINT8 state

Date:			10.10.2002

Desc:			Returns the state of POP3 client
*********************************************************************************/

UINT8 pop3c_getstate (void)
{
	return(POP3Client.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 match;
	static UINT8  end_detect;
	UINT8 ch;

	if( cbhandle != POP3Client.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(POP3Client.state > POP3C_CLOSED)
			{
				/* Inform application	*/
				pop3c_error();
			}

			pop3c_changestate(POP3C_CLOSED);
			POP3Client.unacked = 0;

			return(1);

			break;

		case TCP_EVENT_CONNECTED:

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

			break;

		case TCP_EVENT_CLOSE:

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

			break;

		case TCP_EVENT_ACK:

			/* Our message is acked	*/

			POP3Client.unacked = 0;

			break;

		case TCP_EVENT_DATA:

			/* Do we have unacked data?	*/

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

			/* Get reply from server	*/

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

			/* Get command				*/

			NETWORK_RECEIVE_INITIALIZE(ReceivedTCPPacket.BufIndex);
			cmd = RECEIVE_NETWORK_B();
			NETWORK_RECEIVE_INITIALIZE(ReceivedTCPPacket.BufIndex);

			switch(POP3Client.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(ReceivedTCPPacket.BufIndex);

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

						/* Inform application about the nmbr of messages	*/
						pop3c_messages(POP3Client.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(ReceivedTCPPacket.BufIndex);

						POP3Client.curmsgtotlen = 0;

						if(pop3c_parselist() < 0)
						{
							/* Error parsing LIST reply	*/
							/* Inform application		*/
							pop3c_error();
							tcp_abort(POP3Client.sochandle);
							pop3c_changestate(POP3C_CLOSED);
							POP3Client.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	*/
						POP3Client.curmsghlen = 0;
						POP3Client.from[0] = '\0';
						POP3Client.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:


					POP3Client.curmsghlen += (UINT16)par1;

					if( POP3Client.curmsghlen > (POP3Client.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(ReceivedTCPPacket.BufIndex);

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

						ch = RECEIVE_NETWORK_B();

						if( POP3Client.state == POP3C_RECEIVING_HEADER)
						{

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

							if( ch == '\n')
							{
								POP3Client.charsinheaderbuf = 0;
								continue;
							}

							if( ch == ' ')		/* Remove spaces	*/
								continue;

							/* Buffer already full for this line?	*/

							if(POP3Client.charsinheaderbuf > 8)
								continue;

							/* End of header? (parsing of that is not absolutely correct)	*/
							/* We detect it from CRLF. or LFCR. or CR. or LF.				*/
							/* the correct indication being CRLF.CRLF						*/

							if( (ch == '.') && (POP3Client.charsinheaderbuf == 0) )
							{
								/* Remove CRLF.CRLF from header length	*/

								if( POP3Client.curmsghlen >= 5 )
									POP3Client.curmsghlen -= 5;

								pop3c_changestate(POP3C_TOP0_GET);
								break;
							}


							ch = otcp_tolower(ch);

							POP3Client.headerbuf[POP3Client.charsinheaderbuf] = ch;
							POP3Client.charsinheaderbuf++;
							POP3Client.headerbuf[POP3Client.charsinheaderbuf] = '\0';

							/* Is it 'from:' ?	*/

							if(otcp_bufsearch(&POP3Client.headerbuf[0],POP3Client.charsinheaderbuf,(UINT8*)"from:",1) == 0)
							{
								/* Continue imidiately to read sender	*/

								POP3Client.from[0] = '\0';
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HDR_FROM);
								continue;
							}

							/* Is it 'subject:' ?	*/

							if(otcp_bufsearch(&POP3Client.headerbuf[0],POP3Client.charsinheaderbuf,(UINT8*)"subject:",1) == 0)
							{
								/* Continue imidiately to read subject	*/

								POP3Client.subject[0] = '\0';
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HDR_SUBJ);
								continue;
							}

						}	/* of RECEIVING_HEADER	*/


						if( POP3Client.state == POP3C_RECEIVING_HDR_FROM)
						{
							if( ch == ' ')		/* Remove spaces	*/
							{
								if(POP3Client.charsinheaderbuf == 0)
									continue;
							}

							if( ch == '\r')
							{
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

							if( ch == '\n')
							{
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

							/* Store it	*/

							POP3Client.from[POP3Client.charsinheaderbuf] = ch;
							POP3Client.charsinheaderbuf++;
							POP3Client.from[POP3Client.charsinheaderbuf] = '\0';

							if(POP3Client.charsinheaderbuf >= POP3C_SENDERMAXLEN)
							{
								/* The buffer is exceeded	*/
								/* Mark it corrupted		*/

								POP3Client.from[0] = '\0';
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

						} 	/* of RECEIVING_HDR_FROM	*/


						if( POP3Client.state == POP3C_RECEIVING_HDR_SUBJ)
						{
							if( ch == ' ')		/* Remove spaces	*/
							{
								if(POP3Client.charsinheaderbuf == 0)
									continue;
							}

							if( ch == '\r')
							{
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

							if( ch == '\n')
							{
								POP3Client.charsinheaderbuf = 0;
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

							/* Store it	*/

							POP3Client.subject[POP3Client.charsinheaderbuf] = ch;
							POP3Client.charsinheaderbuf++;
							POP3Client.subject[POP3Client.charsinheaderbuf] = '\0';

							if(POP3Client.charsinheaderbuf >= POP3C_SUBJECTMAXLEN)
							{
								/* The buffer is exeeded	*/
								/* Mark it corrupted		*/

								POP3Client.subject[0] = '\0';
								pop3c_changestate(POP3C_RECEIVING_HEADER);
								continue;
							}

						} 	/* of RECEIVING_HDR_SUBJ	*/


					}


					break;


				case POP3C_RETR_SENT:

					if(cmd == POP3C_OK)
					{
						DEBUGOUT("RETR +OK by POP3 server\r\n");

						/* Continue imidiately to receive message	*/

						pop3c_changestate(POP3C_RECEIVING_MSG_HEADER);

					}
					else
						break;

				case POP3C_RECEIVING_MSG_HEADER:

					/* Try to find empty row to detect the start of actual message	*/

					match = 0;
					NETWORK_RECEIVE_INITIALIZE(ReceivedTCPPacket.BufIndex);

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

						if(match == 0)
						{
							if( (ch == '\r') || (ch == '\n') )
								match++;
							else
								match = 0;
							continue;
						}

						if(match == 1)
						{
							if( (ch == '\r') || (ch == '\n'))
								match++;
							else
								match = 0;
							continue;
						}

						if(match == 2)
						{
							if( (ch == '\r') || (ch == '\n'))
								match++;
							else
								match = 0;
							continue;
						}

						if(match == 3)
						{
							if( (ch == '\r') || (ch == '\n'))
							{
								match++;

								/* Continue to read the actual msg	*/
								par1 -= (i + 1);
								pop3c_changestate(POP3C_RECEIVING_MSG);
								break;
							}
							else
								match = 0;
							continue;
						}

					}

					/* If we don't find the end of header we will timeout	*/
					/* on pop3c_run so no error handling here				*/

					if( POP3Client.state !=	POP3C_RECEIVING_MSG)
						break;

					end_detect = 0;

					case POP3C_RECEIVING_MSG:

						/* Search is this packet end of msg and do not give	*/
						/* CRLF.CRLF to application							*/


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

							pop3c_data(ch);

							if( (ch == '\r') && (end_detect != 3))
								end_detect = 0;


							if( end_detect == 0 )
							{
								if(ch == '\r')
									end_detect++;
								else
									end_detect = 0;

								continue;
							}

							if( end_detect == 1 )
							{
								if(ch == '\n')
									end_detect++;
								else
									end_detect = 0;

								continue;
							}

							if( end_detect == 2 )
							{
								if(ch == '.')
									end_detect++;
								else
									end_detect = 0;

								continue;
							}

							if( end_detect == 3 )
							{
								if(ch == '\r')
									end_detect++;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
yourporn久久国产精品| 久草精品在线观看| 激情综合网激情| 91丨porny丨在线| 日韩精品中文字幕一区二区三区 | 国产成人av影院| 欧美日韩在线综合| 国产精品网站在线播放| 精一区二区三区| 一本大道久久a久久精二百| 久久伊人中文字幕| 午夜电影网一区| 91亚洲精品久久久蜜桃| 国产三级欧美三级日产三级99| 日韩精品免费视频人成| 一区二区免费在线播放| 成人亚洲一区二区一| 精品少妇一区二区三区在线播放| 曰韩精品一区二区| 成人污污视频在线观看| 2020国产精品自拍| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美视频一区二区三区四区| 中文字幕亚洲精品在线观看 | 日本午夜精品视频在线观看| 欧美在线视频你懂得| 亚洲人成人一区二区在线观看| 国产成人精品影院| 国产日韩欧美精品综合| 国产高清无密码一区二区三区| 欧美不卡一区二区| 黑人巨大精品欧美黑白配亚洲| 欧美一级一区二区| 日韩经典中文字幕一区| 欧美少妇一区二区| 午夜视频一区二区| 欧美午夜精品免费| 国产亚洲欧洲一区高清在线观看| 天天av天天翘天天综合网色鬼国产| 在线欧美小视频| 成人免费一区二区三区在线观看 | 国产日本一区二区| 久久疯狂做爰流白浆xx| 欧美疯狂做受xxxx富婆| 夜夜亚洲天天久久| 99视频有精品| 国产精品欧美极品| 国产露脸91国语对白| 欧美一区二区日韩一区二区| 亚洲国产日韩av| 色综合久久中文综合久久97| 亚洲视频你懂的| aaa国产一区| 国产精品美女久久久久久2018| 人人狠狠综合久久亚洲| 欧美性感一区二区三区| 亚洲日本电影在线| 大桥未久av一区二区三区中文| 国产午夜精品理论片a级大结局| 极品少妇xxxx精品少妇偷拍| 日韩免费高清电影| 免费欧美高清视频| 日韩三区在线观看| 久久国产尿小便嘘嘘| 日韩欧美三级在线| 国内精品久久久久影院色| 日韩精品中文字幕在线一区| 久久99精品国产.久久久久久| 日韩免费电影网站| 激情综合五月天| 久久亚洲精华国产精华液 | 中文字幕免费不卡在线| 国产激情视频一区二区三区欧美| 中文字幕中文字幕中文字幕亚洲无线| 成人av在线资源网| 国产亚洲va综合人人澡精品| 亚洲免费大片在线观看| 日本高清视频一区二区| 亚洲成a人在线观看| 91超碰这里只有精品国产| 国产中文字幕一区| 欧美精彩视频一区二区三区| 在线区一区二视频| 免费在线欧美视频| 国产精品久久久久久一区二区三区 | 久久久99久久精品欧美| 99国产精品国产精品久久| 一区二区三区中文字幕精品精品| 欧美性受极品xxxx喷水| 日韩一区精品视频| 精品国产精品网麻豆系列| 国产精华液一区二区三区| 亚洲婷婷综合色高清在线| 欧美视频一区二| 精品亚洲aⅴ乱码一区二区三区| 亚洲国产精品精华液2区45| 97精品国产露脸对白| 午夜亚洲福利老司机| 欧美刺激午夜性久久久久久久| 国产精品1区2区3区在线观看| 亚洲同性同志一二三专区| 在线观看91av| 国产乱淫av一区二区三区| 综合欧美一区二区三区| www.日韩av| 美女在线视频一区| 中文字幕成人网| 欧美丝袜丝交足nylons图片| 久久精品国产免费看久久精品| 国产日韩欧美电影| 欧美日韩在线播放三区四区| 六月丁香婷婷久久| 国产精品高清亚洲| 91麻豆精品国产91久久久| 国产福利视频一区二区三区| 国产精品久久三| 欧美一区二区在线观看| av成人动漫在线观看| 午夜电影网一区| 国产精品日日摸夜夜摸av| 欧美视频一区在线| 成人小视频在线| 性久久久久久久久| 国产精品午夜电影| 欧美一区二区精品| 97精品国产97久久久久久久久久久久| 亚洲一区二区三区激情| www国产亚洲精品久久麻豆| 色欲综合视频天天天| 国内精品伊人久久久久av影院| 一区二区不卡在线播放 | 日日夜夜免费精品视频| 久久综合中文字幕| 欧美精选午夜久久久乱码6080| 国产成人av影院| 欧美96一区二区免费视频| 亚洲免费av高清| 久久久不卡网国产精品二区 | 国产精品资源在线看| 麻豆国产一区二区| 亚洲在线视频免费观看| 亚洲欧美在线观看| 国产精品2024| 久久99国内精品| 午夜精品一区二区三区三上悠亚 | 欧美日韩aaa| 国产成人免费av在线| 毛片一区二区三区| 亚洲美女偷拍久久| 国产精品美女久久久久久久久| 久久人人爽爽爽人久久久| 91精品国产丝袜白色高跟鞋| 成人久久久精品乱码一区二区三区| 国产一区二区在线观看视频| 一区二区三区在线视频免费观看| 亚洲欧美日韩一区| 国产欧美日韩精品一区| 国产精品色眯眯| 国产香蕉久久精品综合网| 日韩无一区二区| 在线不卡免费av| aaa欧美色吧激情视频| av在线这里只有精品| 国产91丝袜在线播放0| 国产在线国偷精品免费看| 美国一区二区三区在线播放| 奇米在线7777在线精品| 肉丝袜脚交视频一区二区| 亚洲国产精品欧美一二99| 亚洲精品日日夜夜| 亚洲欧美乱综合| 中文字幕在线一区| 亚洲三级在线观看| 亚洲嫩草精品久久| 亚洲丝袜美腿综合| 亚洲欧洲制服丝袜| 亚洲精品国久久99热| 亚洲同性同志一二三专区| 久久人人97超碰com| 国产精品卡一卡二卡三| 国产精品国产自产拍在线| 中文子幕无线码一区tr| 欧美国产国产综合| 中文字幕第一区第二区| 国产精品久久久爽爽爽麻豆色哟哟 | 免费成人在线视频观看| 青青草国产成人99久久| 久久成人羞羞网站| 国产美女主播视频一区| 激情文学综合插| 蜜桃传媒麻豆第一区在线观看| 免费精品视频在线| 黄色日韩网站视频| 国产一区不卡精品| 国产成人av一区二区| 国产精品系列在线播放| 91浏览器在线视频| 欧美系列亚洲系列| 欧美一区二区女人| 精品国产sm最大网站免费看|