📄 phonedata.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* asix window 头文件*/
#include "asixwin.h"
#include "asix_lb.h"
#include "asixapp.h"
//#include "asixwin\asix_mn.h"
//#include "asixwin\select.h"
//#include "asixwin\asix_sb.h"
#include "disp.h"
#include "phone.h"
extern PHONE_RAM_FLASH phone;
extern U8 list_to_display[MAX_LIST_NUM];
PHONE_NUM_STRU *unanswer_phone_record=NULL;
PHONE_NEWS_STRU *unread_news_record=NULL;
STATUS DataInitialPhone(void)
{
U8 i;
memset((P_VOID)phone.last_dial_phone[0].phone_num,0x0,MAX_PHONE_NUM_LEN+1);
phone.last_dial_phone[0].next=EOD;
for(i=1;i<MAX_DIAL_PHONE_NUM;i++)
{
memset((P_VOID)phone.last_dial_phone[i].phone_num,0x0,MAX_PHONE_NUM_LEN+1);
phone.last_dial_phone[i].next=i+1;
}
phone.last_dial_phone[MAX_DIAL_PHONE_NUM-1].next=EOD;
phone.empty_dial_phone=1;
memset((P_VOID)phone.last_received_phone[0].phone_num,0x0,MAX_PHONE_NUM_LEN+1);
phone.last_received_phone[0].next=EOD;
for(i=1;i<MAX_RECEIVED_PHONE_NUM;i++)
{
memset((P_VOID)phone.last_received_phone[i].phone_num,0x0,MAX_PHONE_NUM_LEN+1);
phone.last_received_phone[i].next=i+1;
}
phone.last_received_phone[MAX_RECEIVED_PHONE_NUM-1].next=EOD;
phone.empty_received_phone=1;
memset((P_VOID)phone.last_send_news[0].news_content,0x0,MAX_NEWS_LEN+1);
phone.last_send_news[0].next=EOD;
for(i=1;i<MAX_SEND_NEWS_NUM;i++)
{
memset((P_VOID)phone.last_send_news[i].news_content,0x0,MAX_NEWS_LEN+1);
phone.last_send_news[i].next=i+1;// longn_qi 2001/12/26 revied
}
phone.last_send_news[MAX_SEND_NEWS_NUM-1].next=EOD;
phone.empty_send_news=1;
memset((P_VOID)phone.last_received_news[0].news_content,0x0,MAX_NEWS_LEN+1);
phone.last_received_news[0].next=EOD;
for(i=1;i<MAX_RECEIVED_PHONE_NUM;i++)
{
memset((P_VOID)phone.last_received_news[i].news_content,0x0,MAX_NEWS_LEN+1);
phone.last_received_news[i].next=i+1;// longn_qi 2001/12/26 revied
}
phone.last_received_news[MAX_RECEIVED_PHONE_NUM-1].next=EOD;
phone.empty_received_news=1;
return ASIX_OK;
}
STATUS SaveNewDialPhone(char *new_dial_phone,U8 reserved)
{
U8 new_phone,pre_phone;
if(phone.empty_dial_phone!=EOD)
{
new_phone=phone.empty_dial_phone;
phone.empty_dial_phone=phone.last_dial_phone[new_phone].next;
memcpy(phone.last_dial_phone[new_phone].phone_num,new_dial_phone,MAX_PHONE_NUM_LEN);
phone.last_dial_phone[new_phone].next=phone.last_dial_phone[0].next;
phone.last_dial_phone[0].next=new_phone;
}else{
pre_phone=0;
new_phone=phone.last_dial_phone[0].next;
while(phone.last_dial_phone[new_phone].next!=EOD)
{
pre_phone=new_phone;
new_phone=phone.last_dial_phone[new_phone].next;
}
phone.last_dial_phone[pre_phone].next=EOD;
memcpy(phone.last_dial_phone[new_phone].phone_num,new_dial_phone,MAX_PHONE_NUM_LEN);
phone.last_dial_phone[new_phone].next=phone.last_dial_phone[0].next;
phone.last_dial_phone[0].next=new_phone;
}
return ASIX_OK;
}
STATUS SaveNewReceivedPhone(char *new_received_phone,U8 reserved)
{
U8 new_phone,pre_phone;
if(phone.empty_received_phone!=EOD)
{
new_phone=phone.empty_received_phone;
phone.empty_received_phone=phone.last_received_phone[new_phone].next;
memcpy(phone.last_received_phone[new_phone].phone_num,new_received_phone,MAX_PHONE_NUM_LEN);
phone.last_received_phone[new_phone].next=phone.last_received_phone[0].next;
phone.last_received_phone[0].next=new_phone;
}else{
pre_phone=0;
new_phone=phone.last_received_phone[0].next;
while(phone.last_received_phone[new_phone].next!=EOD)
{
pre_phone=new_phone;
new_phone=phone.last_received_phone[new_phone].next;
}
phone.last_received_phone[pre_phone].next=EOD;
memcpy(phone.last_received_phone[new_phone].phone_num,new_received_phone,MAX_PHONE_NUM_LEN);
phone.last_received_phone[new_phone].next=phone.last_received_phone[0].next;
phone.last_received_phone[0].next=new_phone;
}
return ASIX_OK;
}
STATUS SaveNewSendNews(char *new_send_news,U8 reserved)
{
U8 new_news,pre_news;
if(phone.empty_send_news!=EOD)
{
new_news=phone.empty_send_news;
phone.empty_send_news=phone.last_send_news[new_news].next;
memcpy(phone.last_send_news[new_news].news_content,new_send_news,MAX_NEWS_LEN);
phone.last_send_news[new_news].next=phone.last_send_news[0].next;
phone.last_send_news[0].next=new_news;
}else{
pre_news=0;
new_news=phone.last_send_news[0].next;
while(phone.last_send_news[new_news].next!=EOD)
{
pre_news=new_news;
new_news=phone.last_send_news[new_news].next;
}
phone.last_send_news[pre_news].next=EOD;
memcpy(phone.last_send_news[new_news].news_content,new_send_news,MAX_NEWS_LEN);
phone.last_send_news[new_news].next=phone.last_send_news[0].next;
phone.last_send_news[0].next=new_news;
}
return ASIX_OK;
}
STATUS SaveNewReceivedNews(char *new_received_news,U8 reserved)
{
U8 new_news,pre_news;
if(phone.empty_received_news!=EOD)
{
new_news=phone.empty_received_news;
phone.empty_received_news=phone.last_received_news[new_news].next;
memcpy(phone.last_received_news[new_news].news_content,new_received_news,MAX_NEWS_LEN);
phone.last_received_news[new_news].next=phone.last_received_news[0].next;
phone.last_received_news[0].next=new_news;
}else{
pre_news=0;
new_news=phone.last_received_news[0].next;
while(phone.last_received_news[new_news].next!=EOD)
{
pre_news=new_news;
new_news=phone.last_received_news[new_news].next;
}
phone.last_received_news[pre_news].next=EOD;
memcpy(phone.last_received_news[new_news].news_content,new_received_news,MAX_NEWS_LEN);
phone.last_received_news[new_news].next=phone.last_received_news[0].next;
phone.last_received_news[0].next=new_news;
}
return ASIX_OK;
}
STATUS ReadLastDialPhone(void)
{
U8 i;
U8 this_phone;
this_phone=0;
memset(list_to_display,0x0,MAX_LIST_NUM);
i=0;
while(phone.last_dial_phone[this_phone].next!=EOD)
{
list_to_display[i]=phone.last_dial_phone[this_phone].next;
this_phone=phone.last_dial_phone[this_phone].next;
i++;
}
return ASIX_OK;
}
STATUS ReadLastReceivedPhone(void)
{
U8 i;
U8 this_phone;
memset(list_to_display,0x0,MAX_LIST_NUM);
this_phone=0;
i=0;
while(phone.last_received_phone[this_phone].next!=EOD)
{
list_to_display[i]=phone.last_received_phone[this_phone].next;
this_phone=phone.last_received_phone[this_phone].next;
i++;
}
return ASIX_OK;
}
STATUS ReadLastSendNews(void)
{
U8 i;
U8 this_news;
memset(list_to_display,0x0,MAX_LIST_NUM);
this_news=0;
i=0;
while(phone.last_send_news[this_news].next!=EOD)
{
list_to_display[i]=phone.last_send_news[this_news].next;
this_news=phone.last_send_news[this_news].next;
i++;
}
return ASIX_OK;
}
STATUS ReadLastReceivedNews(void)
{
U8 i;
U8 this_news;
memset(list_to_display,0x0,MAX_LIST_NUM);
this_news=0;
i=0;
while(phone.last_received_news[this_news].next!=EOD)
{
list_to_display[i]=phone.last_received_news[this_news].next;
this_news=phone.last_received_news[this_news].next;
i++;
}
return ASIX_OK;
}
STATUS GetDialPhoneNum(U8 phone_no,char *phone_num)
{
if(phone_no<MAX_DIAL_PHONE_NUM)
{
strcpy(phone_num,phone.last_dial_phone[phone_no].phone_num);
}else
return ASIX_ERROR;
return ASIX_OK;
}
STATUS GetReceivedPhoneNum(U8 phone_no,char *phone_num)
{
if(phone_no<MAX_RECEIVED_PHONE_NUM)
{
strcpy(phone_num,phone.last_received_phone[phone_no].phone_num);
}else
return ASIX_ERROR;
return ASIX_OK;
}
STATUS GetSendNewsContent(U8 news_no,char *news_content)
{
if(news_no<MAX_SEND_NEWS_NUM)
{
strcpy(news_content,phone.last_send_news[news_no].news_content);
}else
return ASIX_ERROR;
return ASIX_OK;
}
STATUS GetReceivedNewsContent(U8 news_no,char *news_content)
{
if(news_no<MAX_RECEIVED_NEWS_NUM)
{
strcpy(news_content,phone.last_received_news[news_no].news_content);
}else
return ASIX_ERROR;
return ASIX_OK;
}
STATUS DelDialPhone(U8 phone_no)
{
U8 this_phone;
if(phone_no>=MAX_DIAL_PHONE_NUM)
return ASIX_ERROR;
if((this_phone=(U8)phone.last_dial_phone[0].next)==phone_no)
phone.last_dial_phone[0].next=phone.last_dial_phone[phone_no].next;
else{
while(phone.last_dial_phone[this_phone].next!=phone_no)
{
this_phone=phone.last_dial_phone[this_phone].next;
if(this_phone==EOD)
return ASIX_ERROR;
}
phone.last_dial_phone[this_phone].next=phone.last_dial_phone[phone_no].next;
}
memset((P_VOID)phone.last_dial_phone[phone_no].phone_num,0x0,MAX_PHONE_NUM_LEN);
phone.last_dial_phone[phone_no].next=phone.empty_dial_phone;
phone.empty_dial_phone=phone_no;
return ASIX_OK;
}
STATUS DelReceivedPhone(U8 phone_no)
{
U8 this_phone;
if(phone_no>=MAX_RECEIVED_PHONE_NUM)
return ASIX_ERROR;
if((this_phone=(U8)phone.last_received_phone[0].next)==phone_no)
phone.last_received_phone[0].next=phone.last_received_phone[phone_no].next;
else{
while(phone.last_received_phone[this_phone].next!=phone_no)
{
this_phone=phone.last_received_phone[this_phone].next;
if(this_phone==EOD)
return ASIX_ERROR;
}
phone.last_received_phone[this_phone].next=phone.last_received_phone[phone_no].next;
}
memset((P_VOID)phone.last_received_phone[phone_no].phone_num,0x0,MAX_PHONE_NUM_LEN);
phone.last_received_phone[phone_no].next=phone.empty_received_phone;
phone.empty_received_phone=phone_no;
return ASIX_OK;
}
STATUS DelSendNews(U8 news_no)
{
U8 this_news;
if(news_no>=MAX_SEND_NEWS_NUM)
return ASIX_ERROR;
if((this_news=(U8)phone.last_send_news[0].next)==news_no)
phone.last_send_news[0].next=phone.last_send_news[news_no].next;
else{
while(phone.last_send_news[this_news].next!=news_no)
{
this_news=phone.last_send_news[this_news].next;
if(this_news==EOD)
return ASIX_ERROR;
}
phone.last_send_news[this_news].next=phone.last_send_news[news_no].next;
}
memset((P_VOID)phone.last_send_news[news_no].news_content,0x0,MAX_NEWS_LEN);
phone.last_send_news[news_no].next=phone.empty_send_news;
phone.empty_send_news=news_no;
return ASIX_OK;
}
STATUS DelReceivedNews(U8 news_no)
{
U8 this_news;
if(news_no>=MAX_RECEIVED_NEWS_NUM)
return ASIX_ERROR;
if((this_news=(U8)phone.last_received_news[0].next)==news_no)
phone.last_received_news[0].next=phone.last_received_news[news_no].next;
else{
while(phone.last_received_news[this_news].next!=news_no)
{
this_news=phone.last_received_news[this_news].next;
if(this_news==EOD)
return ASIX_ERROR;
}
phone.last_received_news[this_news].next=phone.last_received_news[news_no].next;
}
memset((P_VOID)phone.last_received_news[news_no].news_content,0x0,MAX_NEWS_LEN);
phone.last_received_news[news_no].next=phone.empty_received_news;
phone.empty_received_news=news_no;
return ASIX_OK;
}
STATUS SaveUnanswerPhone(char *unanswer_phone,U8 reserved)
{
return ASIX_OK;
}
STATUS SaveUnreadNews(char *unread_news,U8 reserved)
{
return ASIX_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -