⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seventcontent.c

📁 brew开发的日历程序 完全模仿mediaplayer的结构设计 值得初学者学习
💻 C
字号:
/**
 * File Name    : SeventContent.c                                                                 
 * Created      : 07/04/19                                                                        
 * Author       : ZhongNingLin@neusoft.com                                                                    
 * Model        : 05YOP                                                                           
 * Description  : [[CN]] 此文件的职责是: [[CN]]                           
**/
#include "SeventContent.h"
#include "schedule.h"

/**************************************************************************
*	Function Name	 :	SEventContent_InitNodeHead                                            
*	Description		 :	表头分配空间
*	Input Parameters :	NodeHead**					
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void SEventContent_InitNodeHead(NodeHead **nodeHead)
{
	NodeHead *nHead = NULL;
	/*表头分配空间*/
	nHead = (NodeHead*)MALLOC(sizeof(NodeHead));
    nHead->next = NULL;
	*nodeHead = nHead;
}

/**************************************************************************
*	Function Name	 :	SEventContent_Insert                                            
*	Description		 :	插入数据到链表
*	Input Parameters :	EventData 				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_IsEmpty(NodeHead *head)
{	
	EventData *node;
	
	node = head->next;
	
	while(node != NULL)
	{		
		return FALSE;
	}
	
	return TRUE;
}

/**************************************************************************
*	Function Name	 :	SEventContent_Insert                                            
*	Description		 :	插入数据到链表
*	Input Parameters :	EventData 				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_Insert(EventData *data, Schedule* pme)
{
	EventData *previous  = NULL;
	EventData *node      = NULL;
	uint8     eventCount = 0;

	if( pme->head == NULL || data == NULL )
		return FALSE;

	node = (EventData*)MALLOC(sizeof(EventData));

	if( node == NULL )
		return FALSE;

	node->eAlarm = data->eAlarm;
	node->eType  = data->eType;
	node->next   = NULL;
	WSTRCPY( node->eContent, data->eContent );
	WSTRCPY( node->eDate, data->eDate );
	WSTRCPY( node->eName, data->eName );
	WSTRCPY( node->eTelNo, data->eTelNo );
	WSTRCPY( node->eTime, data->eTime );
    /*释放内存*/
	FREE(data);	

	if( SEventContent_IsEmpty(pme->head) )
	{
		node->index = 1;
		pme->head->next = node;
		return TRUE;
	}
	
	data = pme->head->next;	
	
	while(data != NULL)
	{		
		eventCount++;
		previous = data;
		data = data->next;
	}

	node->index = eventCount + 1;
	previous->next = node;

	data = NULL;
	previous = NULL;

	return TRUE;	
}

/**************************************************************************
*	Function Name	 :	SEventContent_FreeList                                           
*	Description		 :	释放链表
*	Input Parameters :	Schedule* 				
*	Output Parameters:	None												
*	Return Value	 :	None			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
void SEventContent_FreeList(Schedule* pme)
{
	EventData *curr_node = NULL;
    EventData *previous  = NULL;

	curr_node = pme->head->next;
	
	while(curr_node != NULL )
	{
		previous = curr_node;		
		curr_node = curr_node->next;

		FREE( previous );
		previous = NULL;
	}

	FREEIF( curr_node );
	FREEIF( pme->head );
}

/**************************************************************************
*	Function Name	 :	SEventContent_DeletData                                           
*	Description		 :	删除事件
*	Input Parameters :	Schedule* ,uint8 				
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_DeletEvt(Schedule* pme ,uint8 index)
{
	EventData *curr_node = NULL;
    EventData *previous  = NULL;	

	curr_node = pme->head->next;

	while(curr_node != NULL && curr_node->index != index )
	{
		previous = curr_node;		
		curr_node = curr_node->next;
	}

	if(previous == NULL && curr_node != NULL)//要删除的是第一个
	{
		pme->head->next = curr_node->next;
		curr_node->next = NULL;

		FREEIF(curr_node);

		curr_node = NULL;	
	}
	else
	{
		previous->next = curr_node->next;
		curr_node->next = NULL;

		FREEIF(curr_node);

		curr_node = NULL;
	}

	return FALSE;
}

/**************************************************************************
*	Function Name	 :	SEventContent_GetEvtByDate                                           
*	Description		 :	根据日期获得事件信息
*	Input Parameters :	Schedule* ,EventData* 				
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_GetEvtByDate(Schedule* pme ,EventData *data)
{
	EventData *curr_node = NULL;
    EventData *previous  = NULL;
	EventData *m_pTemp = data;
	/*是否有事件*/
	boolean   hasEvts    = FALSE;

	if( data == NULL)
		return FALSE;

	curr_node = pme->head->next;

	while(curr_node != NULL )
	{
		previous = curr_node;
		curr_node = curr_node->next;
		
		if( WSTRCMP(previous->eDate,data->eDate) == 0 )
		{
		
			m_pTemp->eAlarm = previous->eAlarm;
			m_pTemp->eType  = previous->eType;		
			m_pTemp->index  = previous->index;
			WSTRCPY( m_pTemp->eContent, previous->eContent );
			WSTRCPY( m_pTemp->eDate, previous->eDate );
			WSTRCPY( m_pTemp->eName, previous->eName );
			WSTRCPY( m_pTemp->eTelNo, previous->eTelNo );
			WSTRCPY( m_pTemp->eTime, previous->eTime );			
			m_pTemp->next = (EventData*)MALLOC(sizeof(EventData));

			m_pTemp = m_pTemp->next;
			m_pTemp->next   = NULL;
			hasEvts = TRUE;
		}
	}

	if( !hasEvts )
	{/*当前日期下没有事件*/
	    /*释放空间*/
		FREEIF(data);
		
		return FALSE;
	}

	m_pTemp = data;
	while(m_pTemp != NULL)
	{
		previous = m_pTemp;
		m_pTemp = m_pTemp->next;
		if( m_pTemp->index == 0)
		{
			previous->next = NULL;
			FREEIF(m_pTemp);
		}
	}



	return TRUE;
}

/**************************************************************************
*	Function Name	 :	SEventContent_FreeEvent                                           
*	Description		 :	根据日期获得事件信息
*	Input Parameters :	EventData* 				
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_FreeEvent(EventData *data)
{
	//EventData *curr_node = NULL;
    EventData *previous  = NULL;

	if(data == NULL)
		return FALSE;
	
	previous = data;	

	while(previous != NULL )
	{
		previous = data;
		data = data->next;		
		FREEIF( previous );		 		
	}
	FREEIF( data );
/*
	curr_node = data;	

	while(curr_node != NULL )
	{
		previous = curr_node;
		curr_node = curr_node->next;		
		FREEIF( previous );		 		
	}
	FREEIF( curr_node );
*/
	return TRUE;
}

/**************************************************************************
*	Function Name	 :	SEventContent_GetEvtByID                                           
*	Description		 :	根据索引获得事件信息
*	Input Parameters :	Schedule* ,EventData* 				
*	Output Parameters:	None												
*	Return Value	 :	boolean			
*	Date			 :	2007/04/19											
*	Author			 :	ZhongNingLin@neusoft.com              								
***************************************************************************/
boolean SEventContent_GetEvtByID(Schedule* pme ,EventData *data)
{
	EventData *curr_node = NULL;
    EventData *previous  = NULL;

	if( data == NULL)
		return FALSE;

	curr_node = pme->head->next;

	while(curr_node != NULL )
	{
		previous = curr_node;
		curr_node = curr_node->next;
		
		if( previous->index == data->index )
		{
			data->eAlarm = previous->eAlarm;
			data->eType  = previous->eType;			
			WSTRCPY( data->eContent, previous->eContent );
			WSTRCPY( data->eDate, previous->eDate );
			WSTRCPY( data->eName, previous->eName );
			WSTRCPY( data->eTelNo, previous->eTelNo );
			WSTRCPY( data->eTime, previous->eTime );			
		
			return TRUE;
		}
	}

	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -