Linux邮件系统服务器Word下载.docx
- 文档编号:19325292
- 上传时间:2023-01-05
- 格式:DOCX
- 页数:13
- 大小:16.83KB
Linux邮件系统服务器Word下载.docx
《Linux邮件系统服务器Word下载.docx》由会员分享,可在线阅读,更多相关《Linux邮件系统服务器Word下载.docx(13页珍藏版)》请在冰豆网上搜索。
#defineMAX_SIZE20
#defineSUCCESS1
#defineFAIL0
定义结构体
structuser_info//userregisterinformation
{
charaddress[20];
//emailaddress
charpasswd[20];
//emailpasswd
charconfirm_passwd[20];
//confirmemailpasswd
chartelephone[15];
//telephonenumber
};
structemail_info{
charemail_info_id[6];
charsend_address[20];
//senduseraddress
charreceive_address[20];
//receiveuseraddress
charemail_content[MAX_SIZE_CONTENT];
//emailcontent
charsend_datetime[40];
//sendemailtime
charflag[2];
//markthisemailhadsended
structuser_infouserinfo[MAX_SIZE];
structclient{
intclient_sockfd;
intflag;
charusername[20];
structuser_login{
charusername[17];
charuserpasswd[17];
函数声明
void*thread_total(void*arg);
void*thread_r(void*arg);
void*thread_w(void*arg);
intpackage_open(char*ch,structclient*arg);
intpackage_close(char*ch,structemail_info*arg);
intwrite_login_ok(intclient_socket);
intwrite_login_error(intclient_socket);
intwrite_register_ok(intclient_socket);
intwrite_register_error(intclient_socket);
intcheck_user_passwd(char*address,char*passwd);
intstory_user_info(structuser_infouserinfo);
intset_user_online(char*address,char*flag);
intselect_online_user_address(char*address);
intstory_email_info(structemail_infoemailinfo);
intset_email_flag(char*address,char*email_info_id);
structemail_infoselect_email_info(char*address,int*flag);
intdelete_email_info();
、
#include"
server.h"
intcheck_user_passwd(char*address,char*passwd){
MYSQL*connect_user_info;
MYSQL_RES*res=NULL;
MYSQL_ROW*row;
intre;
//markuserornot
charsql[200];
memset(sql,0x00,sizeof(sql));
sprintf(sql,"
select*fromuser_infowhereaddress='
%s'
andpasswd='
"
address,passwd);
connect_user_info=mysql_init(NULL);
if(connect_user_info==NULL){
perror("
init:
);
exit
(1);
}
connect_user_info=mysql_real_connect(connect_user_info,"
localhost"
"
root"
"
NeuMail"
0,NULL,0);
if(connect_user_info){
printf("
connectmysqlsuccess\n"
}else{
connectmysqlfail\n"
re=mysql_query(connect_user_info,sql);
printf("
re=%d\n"
re);
if(re)
queryfail%s\n"
mysql_error(connect_user_info));
else{
res=mysql_store_result(connect_user_info);
if(mysql_fetch_row(res)!
=NULL){
flag=SUCCESS;
}else
flag=FAIL;
mysql_free_result(res);
flag=%d\n"
flag);
mysql_close(connect_user_info);
mysql_library_end();
returnflag;
}
intstory_user_info(structuser_infouserinfo){
intre,re1;
inti;
charsql1[200];
memset(sql1,0x00,sizeof(sql1));
sprintf(
sql,
insertintouser_info(address,passwd,confirm_passwd,telephone)values('
'
)"
userinfo.address,userinfo.passwd,userinfo.confirm_passwd,
userinfo.telephone);
sprintf(sql1,"
insertintouser_online(address,online)values('
n'
userinfo.address);
connectsuccess1\n"
connectfail\n"
if(re){
insertfail\n"
i=FAIL;
i=SUCCESS;
re1=mysql_query(connect_user_info,sql1);
returni;
intset_user_online(char*address,char*flag){
MYSQL*set_user_online;
updateuser_onlinesetonline='
whereaddress='
flag,
address);
sql=%s\n"
sql);
set_user_online=mysql_init(NULL);
if(set_user_online==NULL){
set_user_online=mysql_real_connect(set_user_online,"
if(set_user_online){
connectsuccess2\n"
re=mysql_query(set_user_online,sql);
mysql_close(set_user_online);
intselect_online_user_address(char*address){
MYSQL*connect_user_online;
MYSQL_RES*res_ptr;
MYSQL_ROWsqlrow;
inti,j,k,online;
selectonlinefromuser_onlinewhereaddress='
address);
connect_user_online=mysql_init(NULL);
if(connect_user_online==NULL){
connect_user_online=mysql_real_connect(connect_user_online,"
if(connect_user_online){
connectsuccess3\n"
re=mysql_query(connect_user_online,sql);
selectfail\n"
mysql_error(connect_user_online));
res_ptr=mysql_use_result(connect_user_online);
if(res_ptr){
while((sqlrow=mysql_fetch_row(res_ptr))){
i=0;
while(i<
mysql_field_count(connect_user_online)){
strcpy(flag,sqlrow[i]);
i++;
}
}
}else{
printf("
getvaluesfail\n"
}
mysql_close(connect_user_online);
if(0==strcmp(flag,"
y"
)){
online=1;
online=0;
returnonline;
intstory_email_info(structemail_infoemailinfo){
MYSQL*connect_email_info;
charsql[MAXSIZE];
insertintoemail_info(send_address,receive_address,email_content,send_datetime,flag)values('
emailinfo.send_address,emailinfo.receive_address,
emailinfo.email_content,emailinfo.send_datetime,emailinfo.flag);
connect_email_info=mysql_init(NULL);
if(connect_email_info==NULL){
connect_email_info=mysql_real_connect(connect_email_info,"
if(connect_email_info){
connectsuccess4\n"
re=mysql_query(connect_email_info,sql);
mysql_close(connect_email_info);
connect_email_info=NULL;
structemail_infoselect_email_info(char*address,int*flag){
inti,j,k;
structemail_infoemailinfo;
j=0;
*flag=0;
select*fromemail_infowhereflag='
andreceive_address='
connectsuccess5\n"
mysql_error(connect_email_info));
res_ptr=mysql_use_result(connect_email_info);
j=0;
mysql_field_count(connect_email_info)){
strcpy(emailinfo.email_info_id,sqlrow[i++]);
strcpy(emailinfo.send_address,sqlrow[i++]);
strcpy(emailinfo.receive_address,sqlrow[i++]);
strcpy(emailinfo.email_content,sqlrow[i++]);
strcpy(emailinfo.send_datetime,sqlrow[i++]);
strcpy(emailinfo.flag,sqlrow[i++]);
*flag=1;
break;
/*NOP*/
returnemailinfo;
intset_email_flag(char*address,char*email_info_id){
MYSQL*set_email_flag;
updateemail_infosetflag='
y'
wherereceive_address='
andemail_info_id='
address,email_info_id);
set_email_flag=mysql_init(NULL);
if(set_email_flag==NULL){
set_email_flag=mysql_real_connect(set_email_flag,"
if(set_email_flag){
connectsuccess6\n"
re=mysql_query(set_email_flag,sql);
mysql_close(set_email_flag);
intdelete_email_info(){
MYSQL*connect_
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Linux 邮件系统 服务器
![提示](https://static.bdocx.com/images/bang_tan.gif)