📄 pop3if.c1
字号:
#include "hpserver.h"
#include "netutil.h"
#include "pop3.h"
#include "net.h"
#include "ether.h"
#include "ip.h"
#include "tcp.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int total_messages=0;
/******************************************************************/
/* Callback function for POP3 Login */
/* st_pop3 *pop3:point to pop3 structure */
/* */
/* Note:You may change it for APOP */
/* */
/******************************************************************/
void pop3_on_login(st_pop3 *pop3)
{
TSOCK *socket;
socket=pop3->socket;
switch (pop3->status){
case POP3_LOGIN:
buff_instr(&socket->txb,"USER ");
buff_instr(&socket->txb,pop3->user_name);
buff_instr(&socket->txb,"\xd\xa");
pop3->status=POP3_LOGIN_USER;
break;
case POP3_LOGIN_USER:
buff_instr(&socket->txb,"PASS ");
buff_instr(&socket->txb,pop3->password);
buff_instr(&socket->txb,"\xd\xa");
pop3->status=POP3_LOGIN_PASS;
break;
}
}
/******************************************************************/
/* Callback function for POP3 LIST Command */
/* st_pop3 *pop3:point to pop3 structure */
/* */
/* Description:After we send LIST command to POP3 Server, */
/* the server return list data and call
/* pop3->getting_mail_info function.This is a */
/* sample code for pop3->getting_mail_info
/* function. */
/* */
/******************************************************************/
void pop3_on_getting_mail_info(st_pop3 *pop3,char start_of_message_flag,char end_of_message_flag)
{
char buf[256];
int i;
char ret_val;
static unsigned char line_count;
extern char buff_out_one_line(TSOCK *socket,char *line_buff,int buf_size);
TSOCK *ts;
ts=pop3->socket;
if (start_of_message_flag)
line_count=0;
while ((ret_val=buff_out_one_line(ts,buf,256))>0)
line_count++;
if (end_of_message_flag)
{
for (i=1;i<line_count-1;i++)
en_queue_get_mail(pop3,i);
en_queue_quit_mail(pop3);
total_messages=line_count-2;
if (total_messages)
P1=0x0;
else
P1=0xff;
}
}
/******************************************************************/
/* Callback function for POP3 UIDL Command */
/* st_pop3 *pop3:point to pop3 structure */
/* */
/* Description:After we send UIDL command to POP3 Server, */
/* the server return uid data and call
/* pop3->getting_mail_uid function.This is a */
/* sample code for pop3->getting_mail_uid
/* function. */
/* */
/******************************************************************/
void pop3_on_getting_mail_uid(st_pop3 *pop3,char start_of_message_flag,char end_of_message_flag)
{
}
/******************************************************************/
/* Callback function for POP3 RETR and TOP Command */
/* st_pop3 *pop3:point to pop3 structure */
/* */
/* Description:After we send RETR or TOP command to POP3 Server*/
/* ,the server return mail data and call
/* pop3->getting_mail function.This is a */
/* sample code for pop3->getting_mail
/* function. */
/* */
/******************************************************************/
void pop3_on_getting_mail(st_pop3 *pop3,char start_of_message_flag,char end_of_message_flag)
{
}
/******************************************************************/
/* Callback function for POP3 Error */
/* st_pop3 *pop3:point to pop3 structure */
/* */
/* Description:After an error,the server call
/* pop3->error function.This is a */
/* sample code for pop3->error
/* function. */
/* */
/* Note:The Error is store in pop3->last_error which is define
/* in pop3.h
/******************************************************************/
void pop3_on_error(st_pop3 *pop3)
{
char ret_val;
TSOCK *socket;
socket=pop3->socket;
printf("\nPOP3 Error Message is\n");
while (buff_out(&socket->rxb,&ret_val,1))
printf("%c",ret_val);
if ((pop3->status==POP3_LOGIN_USER)
||(pop3->status==POP3_LOGIN_PASS))
{
printf("\nPASS word ERROR");
buff_instr(&socket->txb,"quit\xD\xA");
pop3->status=POP3_CLOSE;
return ;
}
pop3->status=POP3_IDLE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -