- #include "kb_dc_pub.h"
- static KB_DC_ServCfg_Map_Array *gServCfgMap=NULL;
- /*
- * 返回gServCfgMap头地址
- */
- KB_DC_ServCfg_Map_Array *KB_GetXmlServCfgMapHead(void)
- {
- return gServCfgMap;
- }
- /*
- * 返回gServCfgMap头地址
- */
- void KB_SetXmlServCfgMapHead(KB_DC_ServCfg_Map_Array *pHead)
- {
- gServCfgMap = pHead;
- }
- /*
- * 将解析的XML业务配置信息装载到DC数据结构里
- */
- void KB_DC_ReloadXmlServCfgMap(void)
- {
- kb_xml_serviceInfoNode_t *xml_serviceInfo=NULL;
- KB_DC_ServCfg_Map_Array *servCfgMap=NULL;
- int i=0;
- DCDebug3("n ----------KB_DC_ReloadXmlServCfgMap--------------------");
- xml_serviceInfo = KB_Xml_GetServiceInfoHead();
- servCfgMap = KB_GetXmlServCfgMapHead();
- if(servCfgMap==NULL)
- {
- DCDebug3("n to malloc servCfgMap!");
- servCfgMap = (KB_DC_ServCfg_Map_Array*)KBDcMalloc(sizeof(KB_DC_ServCfg_Map_Array));
- if(servCfgMap==NULL)
- {
- DCDebug1("n servCfgMap malloc error!");
- return;
- }
- KB_SetXmlServCfgMapHead(servCfgMap);
- }
- KBDcMemset(servCfgMap, 0, sizeof(KB_DC_ServCfg_Map_Array));
- while(xml_serviceInfo!=NULL)
- {
- DCDebug3("n reload!----");
- i = servCfgMap->count;
- servCfgMap->ServCfg[i].m_freq = xml_serviceInfo->st_ServiceInfo.m_freq;
- servCfgMap->ServCfg[i].m_nPid = xml_serviceInfo->st_ServiceInfo.m_nPid;
- servCfgMap->ServCfg[i].m_transactionsId = xml_serviceInfo->st_ServiceInfo.m_transactionsId;
- servCfgMap->ServCfg[i].m_type = xml_serviceInfo->st_ServiceInfo.m_type;
- strcpy((char*)servCfgMap->ServCfg[i].m_string, (const char*)xml_serviceInfo->st_ServiceInfo.m_string);
- servCfgMap->count++;
- xml_serviceInfo=xml_serviceInfo->m_pNext;
- }
- //not useful , release it
- ReleaseXmlServiceInfo();
- return;
- }
- /**
- * KB_GetServMapByPara
- * get main frequency cfg node by parameter
- *
- *
- * @return.
- */
- KB_DC_ServCfg_Map *KB_GetServMapByPara(unsigned long fre, unsigned char type)
- {
- KB_DC_ServCfg_Map_Array *ServMapArry=NULL;
- int i=0;
- ServMapArry = KB_GetXmlServCfgMapHead();
- if(ServMapArry==NULL)
- {
- DCDebug1("n [KB_GetServMapByPara]: -ServMapArry is null");
- return NULL;
- }
- for(i=0; i<ServMapArry->count; i++)
- {
- if((fre==ServMapArry->ServCfg[i].m_freq)&&(type==ServMapArry->ServCfg[i].m_type))
- {
- DCDebug3("n --find one--");
- return &ServMapArry->ServCfg[i];
- }
- }
- return NULL;
- }
- /**
- * KB_GetServCfgByPara
- * get main frequency cfg node by parameter
- *
- *
- * @return.
- */
- KB_DC_ServCfg_Map *KB_GetCurServMapItem(unsigned char type)
- {
- KBTunerPara tspara;
- kb_DC_GetCurTsInfo(&tspara);
- DCDebug3("n KB_GetCurServMapItem: tspara.frequency=%ld",tspara.frequency);
- return( KB_GetServMapByPara(tspara.frequency, type));
- }