XmlStbInfo.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:28k
源码类别:

DVD

开发平台:

C/C++

  1. #include "XmlStbInfo.h" 
  2. //#define NULL 0   
  3. static KB_MovieInfoNode          *gXmlMovieInfo     = NULL;
  4. static KB_WeatherInfoNode        *gXmlWeatherInfo   = NULL;
  5. static KB_BulletinInfoNode       *gXmlBulletinInfo  = NULL;
  6. static kb_xml_serviceInfoNode_t     *s_kb_xml_ServiceInfo   = NULL;
  7. static void AddMovieNodeValue(char *item, char *value, KB_MovieInfoNode *pXmlNodeInfo);
  8. static void AddWeatherNodeValue(char *item, char *value, KB_WeatherInfoNode *pXmlNodeInfo);
  9. static void AddBulletinNodeValue(char *item, char *value, KB_BulletinInfoNode *pXmlNodeInfo);
  10. static void AddVoteNodeValue(char *item, char *value, kb_vote_node_t*pVoteNodeInfo);
  11. void ReleaseXmlServiceInfo(void)
  12. {
  13. kb_xml_serviceInfoNode_t    *pHead_Service = NULL;
  14. kb_xml_serviceInfoNode_t    *pTail_Service = NULL;
  15. kb_xml_serviceInfoNode_t    *p_Service      = NULL;
  16. p_Service = s_kb_xml_ServiceInfo;
  17. if (NULL != p_Service)
  18. {
  19.     pHead_Service = p_Service;
  20.     pTail_Service = p_Service;
  21.     while (pTail_Service != NULL)
  22.     {
  23.      pTail_Service = pHead_Service->m_pNext;
  24.      mb_free(pHead_Service);
  25.      pHead_Service = pTail_Service;
  26.     }
  27.     s_kb_xml_ServiceInfo = NULL;
  28. }
  29. return;
  30. }
  31. void ResetXmlStbInfo(void)
  32. {    
  33.      KB_MovieInfoNode    *pHead_Movie = NULL;
  34.      KB_MovieInfoNode    *pTail_Movie = NULL;
  35.      KB_MovieInfoNode    *p_Movie      = NULL;
  36.      KB_WeatherInfoNode    *pHead_Weather = NULL;
  37.      KB_WeatherInfoNode    *pTail_Weather = NULL;
  38.      KB_WeatherInfoNode    *p_Weather      = NULL;
  39.      KB_BulletinInfoNode    *pHead_Bulletin = NULL;
  40.      KB_BulletinInfoNode    *pTail_Bulletin = NULL;
  41.      KB_BulletinInfoNode    *p_Bulletin      = NULL;
  42.    kb_vote_node_t    *pHead_Vote = NULL;
  43.      kb_vote_node_t    *pTail_Vote = NULL;
  44.      kb_vote_node_t    *p_Vote      = NULL;
  45. unsigned char index=0;
  46. //test by steven
  47. #if 1
  48. gXmlMovieInfo = NULL;
  49. #else
  50.      //清空影片信息
  51.      p_Movie = gXmlMovieInfo;
  52.      if (NULL != p_Movie)
  53.      {
  54.         pHead_Movie = p_Movie;
  55.          pTail_Movie = p_Movie;
  56.          while (pTail_Movie != NULL)
  57.          {
  58.          pTail_Movie = pHead_Movie->m_pNext;
  59. if(pHead_Movie->st_MovieInfo.m_pData!=NULL)
  60. {
  61. KB_OSPFree(pHead_Movie->st_MovieInfo.m_pData);
  62. pHead_Movie->st_MovieInfo.m_pData=NULL;
  63.          }
  64.          KB_OSPFree(pHead_Movie);
  65.          pHead_Movie = pTail_Movie;
  66.          }
  67.          gXmlMovieInfo = NULL;
  68.      }
  69. #endif
  70.      //清空天气信息
  71.      p_Weather = gXmlWeatherInfo;
  72.      if (NULL != p_Weather)
  73.      {
  74.          pHead_Weather = p_Weather;
  75.          pTail_Weather = p_Weather;
  76.          while (pTail_Weather != NULL)
  77.          {
  78.          pTail_Weather = pHead_Weather->m_pNext;
  79.          KB_OSPFree(pHead_Weather);
  80.          pHead_Weather = pTail_Weather;
  81.          }
  82.          gXmlWeatherInfo = NULL;
  83.      }
  84.      //清空政府公告信息
  85.      p_Bulletin = gXmlBulletinInfo;
  86.      if (NULL != p_Bulletin)
  87.      {
  88.          pHead_Bulletin = p_Bulletin;
  89.          pTail_Bulletin = p_Bulletin;
  90.          while (pTail_Bulletin != NULL)
  91.          {
  92.          pHead_Bulletin->st_BulletinInfo.titleLen = 0;
  93.              pHead_Bulletin->st_BulletinInfo.contentLen = 0;
  94.              if (pHead_Bulletin->st_BulletinInfo.title != NULL)
  95.              {
  96.                  KB_OSPFree(pHead_Bulletin->st_BulletinInfo.title);
  97.                  pHead_Bulletin->st_BulletinInfo.title = NULL;
  98.              }
  99.              if (pHead_Bulletin->st_BulletinInfo.content != NULL)
  100.              {
  101.                  KB_OSPFree(pHead_Bulletin->st_BulletinInfo.content);
  102.                  pHead_Bulletin->st_BulletinInfo.content = NULL;
  103.              }
  104.             
  105.              pTail_Bulletin = pHead_Bulletin->m_pNext;
  106.          KB_OSPFree(pHead_Bulletin);
  107.          pHead_Bulletin = pTail_Bulletin;
  108.          }
  109.          gXmlBulletinInfo = NULL;
  110.      }
  111. for(index=0;index<kb_vote_service_last;index++)
  112. {
  113. p_Vote = g_kb_vote_service[index];
  114.      if (NULL != p_Vote)
  115.      {
  116.          pHead_Vote = p_Vote;
  117.          pTail_Vote = p_Vote;
  118.          while (pTail_Vote != NULL)
  119.          {
  120.          if (pHead_Vote->voteService.name!= NULL)
  121.              {
  122.                  KB_OSPFree(pHead_Vote->voteService.name);
  123.                  pHead_Vote->voteService.name = NULL;
  124.              }
  125.              if (pHead_Vote->voteService.item!= NULL)
  126.              {
  127.                  KB_OSPFree(pHead_Vote->voteService.item);
  128.                  pHead_Vote->voteService.item = NULL;
  129.              }
  130.             
  131.              pTail_Vote = pHead_Vote->pNext;
  132.          KB_OSPFree(pHead_Vote );
  133.          pHead_Vote = pTail_Vote;
  134.          }
  135.          g_kb_vote_service[index] = NULL;
  136.      }
  137. }
  138.      return;
  139. }
  140. KB_MovieInfoNode *KB_GetXmlMovieInfoHead(void)
  141. {
  142.     return gXmlMovieInfo;
  143. }
  144. KB_WeatherInfoNode *KB_GetXmlWeatherInfoHead(void)
  145. {
  146.     return gXmlWeatherInfo;
  147. }
  148. KB_BulletinInfoNode *KB_GetXmlBulletinInfoHead(void)
  149. {
  150.     return gXmlBulletinInfo;
  151. }
  152. kb_xml_serviceInfoNode_t *KB_Xml_GetServiceInfoHead(void)
  153. {
  154.     return s_kb_xml_ServiceInfo;
  155. }
  156. void *LinkNewXmlInfoNode(char *pNode, KB_DC_TYPE *pDcType)
  157. {
  158. KB_MovieInfoNode    *pMovieInfo = NULL;
  159. KB_MovieInfoNode    *pTmp_Movie = NULL;
  160.     KB_WeatherInfoNode  *pWeatherInfo = NULL;
  161. KB_WeatherInfoNode  *pTmp_Weather = NULL;
  162.     KB_BulletinInfoNode *pBulletinInfo = NULL;
  163. KB_BulletinInfoNode *pTmp_Bulletin = NULL;
  164. kb_vote_node_t *pVoteInfo=NULL;
  165. kb_xml_serviceInfoNode_t  *pServiceInfo = NULL;
  166. kb_xml_serviceInfoNode_t  *pTmp_Service = NULL;
  167.     if (NULL == pNode || NULL == pDcType)
  168.     {
  169.         printf("nLinkNewXmlInfoNode::input pointer pNode(0x%x) or pDcType(0x%x) NULL",
  170.                 pNode, pDcType);
  171.         *pDcType = DC_TYPE_MAX;
  172.         return NULL;
  173.     }
  174.     //先置为无效值
  175.     *pDcType = DC_TYPE_MAX;
  176.     
  177. if (!strcmp(pNode, "nodeMInfo"))
  178. {
  179.     *pDcType = MOVIE_INFO;
  180. pMovieInfo = (KB_MovieInfoNode *)KB_OSPMalloc(sizeof(KB_MovieInfoNode));
  181.         if (NULL == pMovieInfo)
  182.         {
  183.             printf("nGetXmlStbInfoNode::KB_OSPMalloc KB_MovieInfoNode fail");
  184.             return NULL;
  185.         }
  186.         pMovieInfo->st_MovieInfo.m_pData = NULL;
  187. pMovieInfo->m_pNext = NULL;  
  188.    
  189. pTmp_Movie = gXmlMovieInfo;
  190. if (NULL == pTmp_Movie)
  191. {
  192. gXmlMovieInfo = pMovieInfo;
  193. gXmlMovieInfo->m_pNext = NULL;
  194. }
  195. else
  196. {
  197. while (pTmp_Movie->m_pNext != NULL)
  198. {
  199. pTmp_Movie = pTmp_Movie->m_pNext;
  200. }
  201. pTmp_Movie->m_pNext = pMovieInfo;
  202. pMovieInfo->m_pNext = NULL;
  203. }  
  204. //printf("nGetXmlStbInfoNode:: nodeMInfo");
  205.         return (void*)pMovieInfo;
  206. }
  207.     else if (!strcmp(pNode, "nodeWeather"))
  208.     {
  209.         *pDcType = WEATHER_INFO;
  210.         pWeatherInfo = (KB_WeatherInfoNode *)KB_OSPMalloc(sizeof(KB_WeatherInfoNode));
  211.         if (NULL == pWeatherInfo)
  212.         {
  213.             printf("nGetXmlStbInfoNode::KB_OSPMalloc KB_WeatherInfoNode fail");
  214.             return NULL;
  215.         }
  216. pWeatherInfo->m_pNext = NULL;  
  217.    
  218. pTmp_Weather = gXmlWeatherInfo;
  219. if (NULL == pTmp_Weather)
  220. {
  221. gXmlWeatherInfo = pWeatherInfo;
  222. gXmlWeatherInfo->m_pNext = NULL;
  223. }
  224. else
  225. {
  226. while (pTmp_Weather->m_pNext != NULL)
  227. {
  228. pTmp_Weather = pTmp_Weather->m_pNext;
  229. }
  230. pTmp_Weather->m_pNext = pWeatherInfo;
  231. pWeatherInfo->m_pNext = NULL;
  232. }  
  233. //printf("nGetXmlStbInfoNode:: nodeWeather");
  234.         return (void*)pWeatherInfo;
  235.     }
  236.     else if (!strcmp(pNode, "nodeBulletin"))
  237.     {
  238.         *pDcType = BULLETIN_INFO;
  239.         pBulletinInfo = (KB_BulletinInfoNode *)KB_OSPMalloc(sizeof(KB_BulletinInfoNode));
  240.         if (NULL == pBulletinInfo)
  241.         {
  242.             printf("nGetXmlStbInfoNode::KB_OSPMalloc KB_BulletinInfoNode fail");
  243.             return NULL;
  244.         }
  245.         pBulletinInfo->st_BulletinInfo.titleLen = 0;
  246.         pBulletinInfo->st_BulletinInfo.title   = NULL;
  247.         pBulletinInfo->st_BulletinInfo.contentLen = 0;
  248.         pBulletinInfo->st_BulletinInfo.content = NULL;
  249. pBulletinInfo->m_pNext = NULL;  
  250.    
  251. pTmp_Bulletin = gXmlBulletinInfo;
  252. if (NULL == pTmp_Bulletin)
  253. {
  254. gXmlBulletinInfo = pBulletinInfo;
  255. gXmlBulletinInfo->m_pNext = NULL;
  256. }
  257. else
  258. {
  259. while (pTmp_Bulletin->m_pNext != NULL)
  260. {
  261. pTmp_Bulletin = pTmp_Bulletin->m_pNext;
  262. }
  263. pTmp_Bulletin->m_pNext = pBulletinInfo;
  264. pBulletinInfo->m_pNext = NULL;
  265. }  
  266. //printf("nGetXmlStbInfoNode:: nodeBulletin");
  267.         return (void*)pBulletinInfo;
  268.     }
  269.      else if (!strcmp(pNode, "nodeVote"))
  270.     {
  271.         *pDcType = VOTE_INFO;
  272.         pVoteInfo = (kb_vote_node_t*)KB_OSPMalloc(sizeof(kb_vote_node_t));
  273.         if (NULL == pVoteInfo)
  274.         {
  275.             printf("nGetXmlStbInfoNode::KB_OSPMalloc pVoteInfo fail");
  276.             return NULL;
  277.         }
  278. pVoteInfo->voteService.nameLen=0;
  279. pVoteInfo->voteService.name=NULL;
  280. pVoteInfo->voteService.itemLen=0;
  281. pVoteInfo->voteService.item=NULL;
  282. pVoteInfo->voteService.itemIndex=0;
  283. pVoteInfo->voteService.itemCount=0;
  284. pVoteInfo->pNext=NULL;
  285. return (void*)pVoteInfo;
  286.     }
  287.     else if (!strcmp(pNode, "service"))
  288.     {
  289.         *pDcType = SERVICE_INFO;
  290.         pServiceInfo = (kb_xml_serviceInfoNode_t *)KB_OSPMalloc(sizeof(kb_xml_serviceInfoNode_t));
  291.         if (NULL == pServiceInfo)
  292.         {
  293.             printf("nGetXmlStbInfoNode::mb_malloc kb_xml_serviceInfoNode_t fail");
  294.             return NULL;
  295.         }
  296. pServiceInfo->m_pNext = NULL;  
  297.    
  298. pTmp_Service = s_kb_xml_ServiceInfo;
  299. if (NULL == pTmp_Service)
  300. {
  301. s_kb_xml_ServiceInfo = pServiceInfo;
  302. s_kb_xml_ServiceInfo->m_pNext = NULL;
  303. }
  304. else
  305. {
  306. while (pTmp_Service->m_pNext != NULL)
  307. {
  308. pTmp_Service = pTmp_Service->m_pNext;
  309. }
  310. pTmp_Service->m_pNext = pServiceInfo;
  311. pServiceInfo->m_pNext = NULL;
  312. }  
  313. //printf("nGetXmlStbInfoNode:: nodeWeather");
  314.         return (void*)pServiceInfo;
  315.     }
  316.     printf("nLinkNewXmlInfoNode::Node_Head_identifier(%s) error", pNode);
  317.         
  318. return NULL;
  319. }
  320. static void kb_xml_addServiceNodeValue(char *item, char *value, kb_xml_serviceInfoNode_t *pXmlNodeInfo)
  321. {
  322.     if (NULL == item || NULL == pXmlNodeInfo)
  323.     {
  324.         printf("nAddWeatherNodeValue::input para item(0x%x), pXmlNodeInfo(0x%x)",
  325.                 item, pXmlNodeInfo);
  326.      return;
  327.     }
  328.     if (!strcmp(item, "fre"))
  329.     {
  330. pXmlNodeInfo->st_ServiceInfo.m_freq = atoi(value);
  331.     }
  332.     else if (!strcmp(item, "pid"))
  333.     {
  334.      pXmlNodeInfo->st_ServiceInfo.m_nPid = atoi(value);
  335.     }
  336.     else if (!strcmp(item, "transactionsId"))
  337.     {
  338.      pXmlNodeInfo->st_ServiceInfo.m_transactionsId = atoi(value);
  339.     }
  340.     else if (!strcmp(item, "string"))
  341.     {
  342.      strcpy(pXmlNodeInfo->st_ServiceInfo.m_string, value);
  343.     }
  344.     else if (!strcmp(item, "type"))
  345.     {
  346.         pXmlNodeInfo->st_ServiceInfo.m_type = atoi(value);
  347.     }
  348.     return;
  349. }
  350. void AddXmlNodeValue(char *item, 
  351.                       char *value, 
  352.                       void *pXmlNodeInfo, 
  353.                       KB_DC_TYPE  DcType)
  354. {
  355.     if (NULL == item || NULL == pXmlNodeInfo)
  356.     {
  357.         printf("nAddXmlNodeValue::input para item(0x%x), pXmlNodeInfo(0x%x)",
  358.                 item, pXmlNodeInfo);
  359.      return;
  360.     }
  361.     switch (DcType)
  362.     {
  363.         case MOVIE_INFO:
  364.             AddMovieNodeValue(item, value, (KB_MovieInfoNode*)pXmlNodeInfo);
  365.             break;
  366.         case WEATHER_INFO:
  367.             AddWeatherNodeValue(item, value, (KB_WeatherInfoNode*)pXmlNodeInfo);
  368.             break;
  369.         case BULLETIN_INFO:
  370.             AddBulletinNodeValue(item, value, (KB_BulletinInfoNode*)pXmlNodeInfo);
  371.             break;
  372. case VOTE_INFO:
  373. AddVoteNodeValue(item, value, (kb_vote_node_t*)pXmlNodeInfo);
  374. break;
  375. case SERVICE_INFO:
  376.             kb_xml_addServiceNodeValue(item, value, (kb_xml_serviceInfoNode_t*)pXmlNodeInfo);
  377.             break;
  378.         default:
  379.      mb_free((void*)pXmlNodeInfo);
  380.             printf("nAddXmlNodeValue::DcType(%d) error", DcType);
  381.             break;
  382.     }
  383.     return;
  384. }
  385. static void AddMovieNodeValue(char *item, char *value, KB_MovieInfoNode *pXmlNodeInfo)
  386. {
  387.      if (NULL == item || NULL == pXmlNodeInfo)
  388.      {
  389.          printf("nAddMovieNodeValue::input para item(0x%x), pXmlNodeInfo(0x%x)",
  390.                 item, pXmlNodeInfo);
  391.      return;
  392.      }
  393.      //使用strcpy始终不是安全的做法...
  394.      if(!strcmp(item, "FType"))
  395.      {
  396.      pXmlNodeInfo->st_MovieInfo.m_cfgType=atoi(value);
  397.      }
  398.      else if (!strcmp(item, "MType"))
  399.      {
  400.      pXmlNodeInfo->st_MovieInfo.m_type = atoi(value);
  401.      }
  402.      else if (!strcmp(item, "MName"))
  403.      {
  404.      strcpy(pXmlNodeInfo->st_MovieInfo.m_strName, value);
  405.      }
  406.      else if (!strcmp(item, "MSize"))
  407.      {
  408.      pXmlNodeInfo->st_MovieInfo.m_nSize = atoi(value);
  409.      }
  410.      else if (!strcmp(item, "MTSID"))
  411.      {
  412.      pXmlNodeInfo->st_MovieInfo.m_tsID = atoi(value);
  413.      }
  414.      else if (!strcmp(item, "MServiceID"))
  415.      {
  416.      pXmlNodeInfo->st_MovieInfo.m_serviceID = atoi(value);
  417.      }
  418.      else if (!strcmp(item, "MStartTime"))
  419.      {
  420.         /*if(pXmlNodeInfo->st_MovieInfo.m_type==2)
  421.           pXmlNodeInfo->st_MovieInfo.m_nStartTime=0;
  422. else*/
  423.         pXmlNodeInfo->st_MovieInfo.m_nStartTime = atoi(value);
  424.      }
  425.      else if (!strcmp(item, "MDuration"))
  426.      {
  427.      pXmlNodeInfo->st_MovieInfo.m_nDuration = atoi(value);
  428.      }
  429.      else if (!strcmp(item, "MDCPID"))
  430.      {
  431.      pXmlNodeInfo->st_MovieInfo.m_nPid = atoi(value);
  432.      }
  433.      else if (!strcmp(item, "MDCModuleID"))
  434.      {
  435.      pXmlNodeInfo->st_MovieInfo.m_nFirstModuleId = atoi(value);
  436.      }
  437.      else if (!strcmp(item, "MDCTimesPlayed"))
  438.      {
  439.      pXmlNodeInfo->st_MovieInfo.m_nTimesPlayed = atoi(value);
  440.      }
  441.      else if (!strcmp(item, "MDCTimeStep"))
  442.      {
  443.      pXmlNodeInfo->st_MovieInfo.m_nTimeStep = atoi(value);
  444.      }
  445.      else if (!strcmp(item, "MSerial"))
  446.      {
  447.      strcpy(pXmlNodeInfo->st_MovieInfo.m_serial, value);
  448.      }
  449.      else if (!strcmp(item, "MReserve1"))
  450.      {
  451.      pXmlNodeInfo->st_MovieInfo.m_reserve1=atoi(value);
  452.      }
  453. else if (!strcmp(item, "MReserve2"))
  454.      {
  455.      pXmlNodeInfo->st_MovieInfo.m_reserve2=atoi(value);
  456.      }
  457. else if (!strcmp(item, "MReserve3"))
  458.      {
  459.      pXmlNodeInfo->st_MovieInfo.m_reserve3=atoi(value);
  460.      }
  461. else if (!strcmp(item, "MReserve4"))
  462.      {
  463.      pXmlNodeInfo->st_MovieInfo.m_reserve4=atoi(value);
  464.      }
  465. pXmlNodeInfo->st_MovieInfo.m_dataGet=kb_dc_data_no;
  466. pXmlNodeInfo->st_MovieInfo.m_pData=NULL;
  467.      return;
  468. }
  469. static void AddWeatherNodeValue(char *item, char *value, KB_WeatherInfoNode *pXmlNodeInfo)
  470. {
  471.     if (NULL == item || NULL == pXmlNodeInfo)
  472.     {
  473.         printf("nAddWeatherNodeValue::input para item(0x%x), pXmlNodeInfo(0x%x)",
  474.                 item, pXmlNodeInfo);
  475.      return;
  476.     }
  477.     if (!strcmp(item, "WCity"))
  478.     {
  479.      strcpy(pXmlNodeInfo->st_WeatherInfo.city, value);
  480.     }
  481.     else if (!strcmp(item, "WTodayDate"))
  482.     {
  483.      strcpy(pXmlNodeInfo->st_WeatherInfo.today.date, value);
  484.     }
  485.     else if (!strcmp(item, "WTodayWeather"))
  486.     {
  487.      pXmlNodeInfo->st_WeatherInfo.today.weather = atoi(value);
  488.     }
  489.     else if (!strcmp(item, "WTodayTemperature"))
  490.     {
  491.      strcpy(pXmlNodeInfo->st_WeatherInfo.today.temperature , value);
  492.     }
  493.     else if (!strcmp(item, "WTodayWeatherDes"))
  494.     {
  495.         strcpy(pXmlNodeInfo->st_WeatherInfo.today.weatherDes, value);
  496.     }
  497.     else if (!strcmp(item, "WTomorrowDate"))
  498.     {
  499.      strcpy(pXmlNodeInfo->st_WeatherInfo.tomorrow.date, value);
  500.     }
  501.     else if (!strcmp(item, "WTomorrowWeather"))
  502.     {
  503.      pXmlNodeInfo->st_WeatherInfo.tomorrow.weather = atoi(value);
  504.     }
  505.     else if (!strcmp(item, "WTomorrowTemperature"))
  506.     {
  507.      strcpy(pXmlNodeInfo->st_WeatherInfo.tomorrow.temperature, value);
  508.     }
  509.     else if (!strcmp(item, "WTomorrowWeatherDes"))
  510.     {
  511.         strcpy(pXmlNodeInfo->st_WeatherInfo.tomorrow.weatherDes, value);
  512.     }
  513.     else if (!strcmp(item, "WAfterTomorrowDate"))
  514.     {
  515.      strcpy(pXmlNodeInfo->st_WeatherInfo.afTomorrow.date, value);
  516.     }
  517.     else if (!strcmp(item, "WAfterTomorrowWeather"))
  518.     {
  519.      pXmlNodeInfo->st_WeatherInfo.afTomorrow.weather = atoi(value);
  520.     }
  521.     else if (!strcmp(item, "WAfterTomorrowTemperature"))
  522.     {
  523.      strcpy(pXmlNodeInfo->st_WeatherInfo.afTomorrow.temperature, value);
  524.     }
  525.     else if (!strcmp(item, "WAfterTomorrowWeatherDes"))
  526.     {
  527.         strcpy(pXmlNodeInfo->st_WeatherInfo.afTomorrow.weatherDes, value);
  528.     }
  529.     return;
  530. }
  531. static void AddBulletinNodeValue(char *item, char *value, KB_BulletinInfoNode *pXmlNodeInfo)
  532. {
  533.     if (NULL == item || NULL == pXmlNodeInfo)
  534.     {
  535.         printf("nAddWeatherNodeValue::input para item(0x%x), pXmlNodeInfo(0x%x)",
  536.                 item, pXmlNodeInfo);
  537.      return;
  538.     }
  539.     if (!strcmp(item, "BTitleLen"))
  540.     {
  541.      pXmlNodeInfo->st_BulletinInfo.titleLen = atoi(value);
  542.     }
  543.     else if (!strcmp(item, "BTitle"))
  544.     {
  545.         if (pXmlNodeInfo->st_BulletinInfo.title != NULL)
  546.         {
  547.          KB_OSPFree(pXmlNodeInfo->st_BulletinInfo.title);
  548.             pXmlNodeInfo->st_BulletinInfo.title = NULL;
  549.         }
  550.         if (0 == pXmlNodeInfo->st_BulletinInfo.titleLen)
  551.         {
  552.             printf("nAddBulletinNodeValue::st_BulletinInfo.titleLen is 0!");
  553.             return;
  554.         }
  555.         // +1 for ''
  556.         pXmlNodeInfo->st_BulletinInfo.title = (unsigned char *)KB_OSPMalloc(pXmlNodeInfo->st_BulletinInfo.titleLen + 1);
  557.         if (NULL == pXmlNodeInfo->st_BulletinInfo.title)
  558.         {
  559.             printf("nAddBulletinNodeValue::malloc st_BulletinInfo.title fail!");
  560.         }
  561.         else
  562.         {
  563.             strcpy(pXmlNodeInfo->st_BulletinInfo.title, value);
  564.         }
  565.     }
  566.     else if (!strcmp(item, "BContentLen"))
  567.     {
  568.      pXmlNodeInfo->st_BulletinInfo.contentLen = atoi(value);
  569.     }
  570.     else if (!strcmp(item, "BContent"))
  571.     {
  572.         if (pXmlNodeInfo->st_BulletinInfo.content != NULL)
  573.         {
  574.          KB_OSPFree(pXmlNodeInfo->st_BulletinInfo.content);
  575.             pXmlNodeInfo->st_BulletinInfo.content = NULL;
  576.         }
  577.         if (0 == pXmlNodeInfo->st_BulletinInfo.contentLen)
  578.         {
  579.             printf("nAddBulletinNodeValue::st_BulletinInfo.contentLen is 0!");
  580.             return;
  581.         }
  582.         // +1 for ''
  583.         pXmlNodeInfo->st_BulletinInfo.content = (unsigned char *)KB_OSPMalloc(pXmlNodeInfo->st_BulletinInfo.contentLen + 1);
  584.         if (NULL == pXmlNodeInfo->st_BulletinInfo.content)
  585.         {
  586.             printf("nAddBulletinNodeValue::malloc st_BulletinInfo.content fail!");
  587.         }
  588.         else
  589.         {
  590.             strcpy(pXmlNodeInfo->st_BulletinInfo.content, value);
  591.         }
  592.     }
  593.     return;
  594. }
  595. static void AddVoteNodeValue(char *item, char *value, kb_vote_node_t*pVoteNodeInfo)
  596. {
  597. kb_vote_node_t *pTemp=NULL;
  598.      if(NULL==item||NULL==pVoteNodeInfo)
  599.      {
  600.          printf("nAddVoteNodeValue::input para item(0x%x), pVoteNodeInfo(0x%x)",
  601.                      item, pVoteNodeInfo);
  602.      return;
  603.      }
  604.      if(!strcmp(item,"VService"))
  605.      {
  606.      pVoteNodeInfo->voteService.type=atoi(value);
  607.      }
  608.      else if(!strcmp(item,"VNameLen"))
  609.      {
  610.      pVoteNodeInfo->voteService.nameLen=atoi(value);
  611.      }
  612. else if(!strcmp(item,"VName"))
  613.      {
  614.      if(pVoteNodeInfo->voteService.name!=NULL)
  615. mb_free(pVoteNodeInfo->voteService.name);
  616. pVoteNodeInfo->voteService.name=(unsigned char*)mb_malloc(pVoteNodeInfo->voteService.nameLen);
  617.      if(pVoteNodeInfo->voteService.name!=NULL)
  618. strcpy(pVoteNodeInfo->voteService.name,value);
  619.      }
  620.      else if(!strcmp(item,"VItemLen"))
  621.      {
  622.      pVoteNodeInfo->voteService.itemLen=atoi(value);
  623.      }
  624. else if(!strcmp(item,"VItem"))
  625.      {
  626.      if(pVoteNodeInfo->voteService.item!=NULL)
  627. mb_free(pVoteNodeInfo->voteService.item);
  628. pVoteNodeInfo->voteService.item=(unsigned char*)mb_malloc(pVoteNodeInfo->voteService.itemLen);
  629.      if(pVoteNodeInfo->voteService.item!=NULL)
  630. strcpy(pVoteNodeInfo->voteService.item,value);
  631.      }
  632.      else if(!strcmp(item,"VItemIndex"))
  633.       {
  634.      pVoteNodeInfo->voteService.itemIndex=atoi(value);
  635.      }
  636. else if(!strcmp(item,"VItemCount"))
  637.       {
  638.      pVoteNodeInfo->voteService.itemCount=atoi(value);
  639.      }
  640. //确保只在解析第一个节点时插入链表
  641. if(!strcmp(item,"VService"))
  642. {
  643. pTemp=g_kb_vote_service[pVoteNodeInfo->voteService.type];
  644. if(pTemp==NULL)
  645. {
  646. g_kb_vote_service[pVoteNodeInfo->voteService.type]=pVoteNodeInfo;
  647. g_kb_vote_service[pVoteNodeInfo->voteService.type]->pNext=NULL;
  648. }
  649. else
  650. {
  651. while(pTemp->pNext!=NULL)
  652. {
  653. pTemp=pTemp->pNext;
  654. }
  655. pTemp->pNext=pVoteNodeInfo;
  656. pVoteNodeInfo->pNext=NULL;
  657. }  
  658. }
  659.      return;
  660. }
  661. void PrintXMLMovieInfo(void)
  662. {
  663.     KB_MovieInfoNode *pMovieInfo = NULL;                        
  664.     int            cnt = 0;
  665.     
  666.     pMovieInfo = gXmlMovieInfo;         
  667.     if (NULL == pMovieInfo) 
  668.     {
  669.         printf("nPrintXMLMovieInfo::gXmlMovieInfo is NULL");
  670.         return;
  671.     }
  672. //FType="" MType="" MName="" MSize="" MTSID="" MServiceID="" MStartTime="" 
  673. //MDuration="" MDCPID="" MDCModuleID="" MDCTimesPlayed="" MDCTimeStep="" 
  674. //MSerial="" MReserve1="" MReserve2="" MReserve3="" MReserve4=""
  675.     printf("n*********---MovieInfo---Begin---***********");
  676.     while (pMovieInfo != NULL)
  677.     {        
  678.       printf("nn----------%d-----------", cnt);
  679.       printf("nFType          :        %d", pMovieInfo->st_MovieInfo.m_cfgType);
  680.         printf("nMType          :        %d", pMovieInfo->st_MovieInfo.m_type);
  681.         printf("nMName          :        %s", pMovieInfo->st_MovieInfo.m_strName);
  682.         printf("nMTSID     :        %d", pMovieInfo->st_MovieInfo.m_tsID);
  683.         printf("nMServiceID      :        %d", pMovieInfo->st_MovieInfo.m_serviceID);
  684.         printf("nMStartTime          :        %d", pMovieInfo->st_MovieInfo.m_nStartTime);
  685.         printf("nMDuration     :        %d", pMovieInfo->st_MovieInfo.m_nDuration);
  686.  printf("nMDCTimeStep   :        %d", pMovieInfo->st_MovieInfo.m_nTimeStep);
  687.  printf("nm_nTimesPlayed   :        %d", pMovieInfo->st_MovieInfo.m_nTimesPlayed);
  688.         printf("nMDCPID           :        %d", pMovieInfo->st_MovieInfo.m_nPid);
  689.         printf("nMDCModuleID :        %d", pMovieInfo->st_MovieInfo.m_nFirstModuleId);
  690.  //printf("nMSerial    :        %s", pMovieInfo->st_MovieInfo.m_serial);
  691.         //printf("nMReserve1           :        %d", pMovieInfo->st_MovieInfo.m_reserve1);
  692.         //printf("nMReserve2 :        %d", pMovieInfo->st_MovieInfo.m_reserve2);
  693.         //printf("nMReserve3   :        %d", pMovieInfo->st_MovieInfo.m_reserve3);
  694.         //printf("nMReserve4 :        %d", pMovieInfo->st_MovieInfo.m_reserve4);
  695.      cnt++;
  696.      pMovieInfo = pMovieInfo->m_pNext;
  697.     }
  698.     printf("n*********---MovieInfo---Over---***********");
  699. }
  700. void PrintXMLWeatherInfo(void)
  701. {
  702.     KB_WeatherInfoNode  *pWeatherInfo = NULL;                        
  703.     int                 cnt = 0;
  704.     
  705.     pWeatherInfo = gXmlWeatherInfo;         
  706.     if (NULL == pWeatherInfo) 
  707.     {
  708.         printf("nPrintXMLWeatherInfo::gXmlWeatherInfo is NULL");
  709.         return;
  710.     }
  711.     printf("n*********---WeatherInfo---Begin---***********");
  712.     while (pWeatherInfo != NULL)
  713.     {        
  714.      printf("nn----------%d-----------", cnt);
  715.      printf("ncity:                %s", pWeatherInfo->st_WeatherInfo.city);
  716.         printf("nToday:");
  717.         printf("ndate        :         %s", pWeatherInfo->st_WeatherInfo.today.date);
  718.         printf("nweather     :         %d", pWeatherInfo->st_WeatherInfo.today.weather);
  719.         printf("ntemperature :         %s", pWeatherInfo->st_WeatherInfo.today.temperature);
  720.         printf("nweatherDes :          %s", pWeatherInfo->st_WeatherInfo.today.weatherDes);
  721.         printf("nTomorrow:");
  722.         printf("ndate        :         %s", pWeatherInfo->st_WeatherInfo.tomorrow.date);
  723.         printf("nweather     :         %d", pWeatherInfo->st_WeatherInfo.tomorrow.weather);
  724.         printf("ntemperature :         %s", pWeatherInfo->st_WeatherInfo.tomorrow.temperature);
  725.         printf("nweatherDes :          %s", pWeatherInfo->st_WeatherInfo.tomorrow.weatherDes);
  726.         printf("nThe D-A-Tomorrow:");
  727.         printf("ndate        :         %s", pWeatherInfo->st_WeatherInfo.afTomorrow.date);
  728.         printf("nweather     :         %d", pWeatherInfo->st_WeatherInfo.afTomorrow.weather);
  729.         printf("ntemperature :         %s", pWeatherInfo->st_WeatherInfo.afTomorrow.temperature);
  730.         printf("nweatherDes :          %s", pWeatherInfo->st_WeatherInfo.afTomorrow.weatherDes);
  731.      cnt++;
  732.      pWeatherInfo = pWeatherInfo->m_pNext;
  733.     }
  734.     printf("n*********---WeatherInfo---Over---***********");
  735. }
  736. void PrintXMLBulletinInfo(void)
  737. {
  738.     KB_BulletinInfoNode *pBulletinInfo = NULL;                        
  739.     int            cnt = 0;
  740.     
  741.     pBulletinInfo = gXmlBulletinInfo;         
  742.     if (NULL == pBulletinInfo) 
  743.     {
  744.         printf("nPrintXMLMovieInfo::gXmlBulletinInfo is NULL");
  745.         return;
  746.     }
  747.     printf("n*********---BulletinInfo---Begin---***********");
  748.     while (pBulletinInfo != NULL)
  749.     {        
  750.      printf("nn----------%d-----------", cnt);
  751.      printf("ntitleLen    :           %d", pBulletinInfo->st_BulletinInfo.titleLen);
  752.         printf("ntitle       :           %s", pBulletinInfo->st_BulletinInfo.title);
  753.         printf("ncontentLen  :           %d", pBulletinInfo->st_BulletinInfo.contentLen);
  754.         printf("ncontent     :           %s", pBulletinInfo->st_BulletinInfo.content);
  755.      cnt++;
  756.      pBulletinInfo = pBulletinInfo->m_pNext;
  757.     }
  758.     printf("n*********---BulletinInfo---OVER---***********");
  759. }
  760. void PrintXMLVoteInfo(void)
  761. {
  762.      kb_vote_node_t *pVoteInfo=NULL;                        
  763.      unsigned short    index=0;
  764. printf("n*********---VoteInfo---Begin---***********");
  765. for(index=0;index<kb_vote_service_last;index++)
  766. {
  767. pVoteInfo=g_kb_vote_service[index];
  768. while(pVoteInfo!=NULL)
  769.      {        
  770.      printf("ntype      :           %d",pVoteInfo->voteService.type);
  771. printf("nname    :           %s",pVoteInfo->voteService.name);
  772. printf("nitem      :           %s",pVoteInfo->voteService.item);
  773. printf("nindex    :           %d",pVoteInfo->voteService.itemIndex);
  774. printf("ncount    :           %d",pVoteInfo->voteService.itemCount);
  775.      pVoteInfo=pVoteInfo->pNext;
  776.      }
  777. }
  778.      printf("n*********---VoteInfo---OVER---***********");
  779. }
  780. void kb_xml_printServiceInfo(void)
  781. {
  782.     kb_xml_serviceInfoNode_t  *pServiceInfo = NULL;                        
  783.     int                 cnt = 0;
  784.     
  785.     pServiceInfo = s_kb_xml_ServiceInfo;         
  786.     if (NULL == pServiceInfo) 
  787.     {
  788.         printf("nkb_xml_printServiceInfo::s_kb_xml_ServiceInfo is NULL");
  789.         return;
  790.     }
  791.     printf("n*********---ServiceInfo---Begin---***********");
  792.     while (pServiceInfo != NULL)
  793.     {        
  794.       printf("nn----------%d-----------", cnt);
  795.       printf("nfre:                %ld", pServiceInfo->st_ServiceInfo.m_freq);
  796.         printf("ndate        :         %ld", pServiceInfo->st_ServiceInfo.m_nPid);
  797.         printf("nweather     :         %s", pServiceInfo->st_ServiceInfo.m_string);
  798.         printf("ntemperature :         %ld", pServiceInfo->st_ServiceInfo.m_transactionsId);
  799.         printf("nweatherDes :          %d", pServiceInfo->st_ServiceInfo.m_type);
  800.       cnt++;
  801.       pServiceInfo = pServiceInfo->m_pNext;
  802.     }
  803.     printf("n*********---WeatherInfo---Over---***********");
  804. }
  805. //
  806. // 取得所有影片中最大影片的大小值
  807. // add by shriek 2008.2.13
  808. unsigned long GetXMLMovieMaxSize(void)
  809. {
  810. KB_MovieInfoNode *pMovieInfo = NULL;   
  811. unsigned long max_size=0;
  812. pMovieInfo = gXmlMovieInfo;         
  813. if (NULL == pMovieInfo) 
  814. {
  815. printf("n GetXMLMovieMaxSize::gXmlMovieInfo is NULL");
  816. return;
  817. }
  818. while (pMovieInfo != NULL)
  819. {        
  820. printf("nSize          :        %d", pMovieInfo->st_MovieInfo.m_nSize);
  821. if(max_size < pMovieInfo->st_MovieInfo.m_nSize)
  822. max_size = pMovieInfo->st_MovieInfo.m_nSize;
  823. pMovieInfo = pMovieInfo->m_pNext;
  824. }
  825. printf("n ==GetXMLMovieMaxSize:  maxsize=%d", max_size);
  826. return max_size;
  827. }