• C开发机顶盒实战应用代码片段


    /*********头文件区****************************************************/
    #include "dare_program.h"
    //#include "dare_sntp.h"
    //#include "input_event.h"
    #include "ipanel_event.h"
    #include "stb_debug_ctrl.h"

    #ifdef STBSW_DEBUG_dare_program
    #define stb_printf(...) STB_debug_Printf(__VA_ARGS__)
    #else
    #define stb_printf(...) do { } while (0)
    #endif
    /*********宏定义区****************************************************/
    #ifndef PROMGRAM_DEBUG
    //#define PROMGRAM_DEBUG
    #endif
    #define CHANNELCOUNT              150
    #define URLLENGTH                     257
    #define USERTOKENLENGTH        33
    #define EGPGROUPNMBLENGTH   9
    #define AUDIOTRACKLEN       5
    #define ERRLENGTH           129
    #define MAX_NUMBRE_KEY 10
    /*********数据结构区****************************************************/
    struct _ServiceEntry_key
    {
     unsigned char isused;
     unsigned int key;
     char url[256];
     char desc[64];
    };
    typedef struct _channel_data
    {
     unsigned int channelcount; /*count of the chain table*/
      int currentchannel;/*current chain table*/
     unsigned int addchlnum;/*current chain table*/
     ChannelInfoStruct  pchlinfo[CHANNELCOUNT];
     char EPGDomain[URLLENGTH];
     char EPGDomainBackup[URLLENGTH];
     char UpgradeDomain[URLLENGTH];
     char UpgradeDomainBackup[URLLENGTH];
     char ManagementDomain[URLLENGTH];
     char ManagementDomainBackup[URLLENGTH];
     char NTPDomain[URLLENGTH];
     char NTPDomainBackup[URLLENGTH];
     char UserToken[USERTOKENLENGTH];
     char EGPGroupNMB[EGPGROUPNMBLENGTH];
     char BTVEPGURL[URLLENGTH];
     char BTVEPGHotkey[URLLENGTH];

     char VODEPGURL[URLLENGTH];
     char VODEPGHotkey[URLLENGTH];
     char SelfServiceEPGURL[URLLENGTH];
     char SelfServiceEPGHotkey[URLLENGTH];
     char UserSpaceURL[URLLENGTH];
     char UserSpaceHotkey[URLLENGTH];
     char InfoEPGURL[URLLENGTH];
     char InfoEPGHotkey[URLLENGTH];
     char GameEPGURL[URLLENGTH];
     char GameEPGHotkey[URLLENGTH];
     char EmailEPGURL[URLLENGTH];
     char EmailEPGHotkey[URLLENGTH];
     char UMEPGURL[URLLENGTH];
     char UMEPGHotkey[URLLENGTH];
        /*add by liut*/
        char AudioTrack[AUDIOTRACKLEN];
        char LastError[ERRLENGTH];
     char NativeUIFlag;
     char MuteUIFlag;
     char audioVolumeUIFlag;
     //char UserToken
     char audioTrackUIFlag;
     char progressBarUIFlag;
     char channelNoUIFlag;
    }ChanelData;
    /*********静态变量区****************************************************/
    static ChanelData Gchanneldata;

    static struct _ServiceEntry_key ServiceEntry_key[MAX_NUMBRE_KEY];

    /*********外部变量区****************************************************/


    /*********静态函数区****************************************************/


    /*********全局函数区****************************************************/

    /* initial the channel source before using it */
    int dare_program_initial()
    {
     Gchanneldata.currentchannel = 0;
     Gchanneldata.channelcount = 0;
     Gchanneldata.addchlnum = 0;
     Gchanneldata.NativeUIFlag = 1;
     Gchanneldata.MuteUIFlag = 1;
     Gchanneldata.audioVolumeUIFlag = 1;
     Gchanneldata.audioTrackUIFlag = 1;
     Gchanneldata.progressBarUIFlag = 1;
     Gchanneldata.channelNoUIFlag = 1;

     if (Gchanneldata.channelcount == 0)
     {
      //Gchanneldata.pchlinfo = NULL;
      memset(&Gchanneldata.pchlinfo,0x00,sizeof(ChannelInfoStruct));
     }
     else
     {
      /*&Gchanneldata.pchlinfo = malloc(Gchanneldata.channelcount * sizeof(ChannelInfoStruct));
      if (Gchanneldata.pchlinfo==NULL)
      {
       stb_printf("chan_initial error\n");
      }*/
     }
     return 0;
    }
    /*clear all struct*/
    int dare_program_uninit()
    {
        memset(&Gchanneldata,0,sizeof(Gchanneldata));   
        memset(&ServiceEntry_key,0,sizeof(ServiceEntry_key));
    }
    int dare_prgram_destory(void)
    {

     #if 0
     if (Gchanneldata.pchlinfo!=NULL)
     {
      free(Gchanneldata.pchlinfo);
      Gchanneldata.pchlinfo = NULL;
     }
     Gchanneldata.channelcount = 0;
     Gchanneldata.currentchannel = 0;
    #endif
     return 0;
    }

    /*  *add channel information item */
    int dare_program_add(char * buff, int len)
    {
     char *p = NULL;
     unsigned int i;
     char tmp[CHANNELCOUNT];
     char val[URLLENGTH+1];
     
     if(len!= (int)strlen(buff))
      stb_printf("buffer length of channel information item is not accordant!\n");
     
     i = Gchanneldata.addchlnum;
     if(i >= CHANNELCOUNT)
     {
      stb_printf("program list full\n");
      return 0;
     }
     if((p = strstr(buff, "ChannelID"))!=NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlId = atoi(val);
     }
     if((p = strstr(buff, "ChannelName"))!= NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].chlname);
     }
     if((p = strstr(buff, "UserChannelID"))!= NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val); 
      Gchanneldata.pchlinfo[i].userchlId = atoi(val);
      //stb_printf("------%d--i=%d---\n",Gchanneldata.pchlinfo[i].userchlId,i);
     }
     if((p = strstr(buff, "ChannelURL"))!= NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].chlURL);
     }
     if((p = strstr(buff, "TimeShift"))!=NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, &(Gchanneldata.pchlinfo[i].TimeShift));
     }
     if((p = strstr(buff, "ChannelSDP"))!= NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].chlSDP);
     }
     if((p = strstr(buff, "TimeShiftURL"))!= NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].timeshiftURL);
     }
     if((p = strstr(buff, "ChannelLogURL"))!= NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].chlLogo.ChannelLogURL);
     }
     if((p = strstr(buff, "PositionX")) != NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlLogo.positionX = atoi(val);
     }
     if((p = strstr(buff, "PositionY")) != NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlLogo.positionY = atoi(val);
     }
     if((p = strstr(buff, "BeginTime")) != NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlLogo.beginTime = atoi(val);
     }
     if((p = strstr(buff, "Interval")) != NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlLogo.interval = atoi(val);
     }
     if((p = strstr(buff, "Lasting")) != NULL)
     {
      memset(val, 0, sizeof(val));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, val);
      Gchanneldata.pchlinfo[i].chlLogo.Lasting = atoi(val);
            /*edit by liut*/
            if(Gchanneldata.pchlinfo[i].chlLogo.interval>0&&Gchanneldata.pchlinfo[i].chlLogo.Lasting >= Gchanneldata.pchlinfo[i].chlLogo.interval)
            {
                stb_printf("the Lasting=%d is bigger than interval=%d!\n,Gchanneldata.pchlinfo[i].chlLogo.Lasting,Gchanneldata.pchlinfo[i].chlLogo.interval");
                //Gchanneldata.pchlinfo[i].chlLogo.Lasting == Gchanneldata.pchlinfo[i].chlLogo.interval-1;
            }
            /***/
     }
     if((p = strstr(buff, "ChannelType")) != NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, Gchanneldata.pchlinfo[i].chltype);
     }
     if((p = strstr(buff, "ChannelPurchased")) != NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, &(Gchanneldata.pchlinfo[i].ChannelPurchased));
     }
     Gchanneldata.pchlinfo[i].vpid = 0;
     Gchanneldata.pchlinfo[i].vformat = 0;
     Gchanneldata.pchlinfo[i].apid = 0;
     Gchanneldata.pchlinfo[i].aformat = 0;
     Gchanneldata.pchlinfo[i].pcrpid = 0;
     Gchanneldata.addchlnum++;
     #ifdef PROMGRAM_DEBUG
     stb_printf("-------------------------channelcount[%d]-------------------------\n", i);
     stb_printf("ChannelID=%d\n", Gchanneldata.pchlinfo[i].chlId);
     stb_printf("ChannelName=%s\n", Gchanneldata.pchlinfo[i].chlname);
     stb_printf("UserChannelID=%d\n", Gchanneldata.pchlinfo[i].userchlId);
     stb_printf("ChannelURL=%s\n", Gchanneldata.pchlinfo[i].chlURL);
     stb_printf("TimeShift=%c\n", Gchanneldata.pchlinfo[i].TimeShift);
     stb_printf("ChannelSDP=%s\n", Gchanneldata.pchlinfo[i].chlSDP);
     stb_printf("TimeShiftURL=%s\n", Gchanneldata.pchlinfo[i].timeshiftURL);
     stb_printf("ChannelLogURL=%s\n", Gchanneldata.pchlinfo[i].chlLogo.ChannelLogURL);
     stb_printf("PositionX=%d\n", Gchanneldata.pchlinfo[i].chlLogo.positionX);
     stb_printf("PositionY=%d\n", Gchanneldata.pchlinfo[i].chlLogo.positionY);
     stb_printf("BeginTime=%d\n", Gchanneldata.pchlinfo[i].chlLogo.beginTime);
     stb_printf("Interval=%d\n", Gchanneldata.pchlinfo[i].chlLogo.interval);
     stb_printf("Lasting=%d\n", Gchanneldata.pchlinfo[i].chlLogo.Lasting);
     stb_printf("ChannelType=%s\n", Gchanneldata.pchlinfo[i].chltype);
     stb_printf("ChannelPurchased=%c\n", Gchanneldata.pchlinfo[i].ChannelPurchased);
     stb_printf("-------------------------------------------------------------------\n");
     #endif
     return 0;

    int dare_program_set_ChannelCount(char * buff, int len)
    {
     //Gchanneldata.channelcount = 0;
     Gchanneldata.addchlnum = 0;
     Gchanneldata.channelcount = atoi(buff);
     if(Gchanneldata.channelcount>CHANNELCOUNT)
      Gchanneldata.channelcount = CHANNELCOUNT;
     return strlen(buff);
    }
    int dare_program_get_ChannelCount(char * buff, int len)
    {
     
     sprintf(buff, "%u", Gchanneldata.channelcount);
     return strlen(buff);
    }
    int dare_program_set_CurrentChlNum(int val)
    {
     Gchanneldata.currentchannel = val;
     return 1;
    }
    int dare_program_get_CurrentChlNum(char * buff, int len)
    {
     
     sprintf(buff, "%u", Gchanneldata.currentchannel);
     return strlen(buff);
    }
    int dare_program_get_LastError(char * buff, int len)
    {
        return 0;
    }
    int dare_program_set_EPGDomain(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.EPGDomain))
     {
      stb_printf("buffer length of set EPGDomain is not accordant!\n");
     }
     strncpy(Gchanneldata.EPGDomain, buff, sizeof(Gchanneldata.EPGDomain));
     return strlen(Gchanneldata.EPGDomain);
    }
    int dare_program_get_EPGDomain(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.EPGDomain))
     {
      stb_printf("buffer length of get EPGDomain is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.EPGDomain, len);
     return strlen(buff);
    }
    int dare_program_set_EPGDomainBackup(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.EPGDomainBackup))
     {
      stb_printf("buffer length of set EPGDomainBackup is not accordant!\n");
     }
     strncpy(Gchanneldata.EPGDomainBackup, buff,
        sizeof(Gchanneldata.EPGDomainBackup));
     return strlen(Gchanneldata.EPGDomainBackup);
    }
    int dare_program_get_EPGDomainBackup(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.EPGDomainBackup))
     {
      stb_printf("buffer length of get EPGDomainBackup is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.EPGDomainBackup, len);
     return strlen(buff);
    }
    int dare_program_set_UpgradeDomain(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UpgradeDomain))
     {
      stb_printf("buffer length of set UpgradeDomain is not accordant!\n");
     }
     strncpy(Gchanneldata.UpgradeDomain, buff,
        sizeof(Gchanneldata.UpgradeDomain));
     return strlen(Gchanneldata.UpgradeDomain);
    }
    int dare_program_get_UpgradeDomain(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UpgradeDomain))
     {
      stb_printf("Upgrade %s\n",Gchanneldata.UpgradeDomain);
     }
     stb_printf("Upgrade2 %s\n",Gchanneldata.UpgradeDomain);
     strncpy(buff, Gchanneldata.UpgradeDomain, len);
     return strlen(buff);
    }
    int dare_program_set_UpgradeDomainBackup(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UpgradeDomainBackup))
     {
      stb_printf("buffer length of set UpgradeDomainBackup is not accordant!\n");
     }
     strncpy(Gchanneldata.UpgradeDomainBackup, buff,
        sizeof(Gchanneldata.UpgradeDomainBackup));
     return strlen(Gchanneldata.UpgradeDomainBackup);
    }
    int dare_program_get_UpgradeDomainBackup(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UpgradeDomainBackup))
     {
      stb_printf("buffer length of get UpgradeDomainBackup is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UpgradeDomainBackup, len);
     return strlen(buff);
    }

    int dare_program_set_ManagementDomain(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.ManagementDomain))
     {
      stb_printf("buffer length of set ManagementDmomain is not accordant!\n");
     }
     strncpy(Gchanneldata.ManagementDomain, buff,
        sizeof(Gchanneldata.ManagementDomain));
     return strlen(Gchanneldata.ManagementDomain);
    }
    int dare_program_get_ManagementDomain(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.ManagementDomain))
     {
      stb_printf("buffer length of get ManagementDomain is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.ManagementDomain, len);
     return strlen(buff);
    }
    int dare_program_set_ManagementDomainBackup(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.ManagementDomainBackup))
     {
      stb_printf("buffer length of set ManagementDomainBackup is not accordant!\n");
     }
     strncpy(Gchanneldata.ManagementDomainBackup, buff,
        sizeof(Gchanneldata.ManagementDomainBackup));
     return strlen(Gchanneldata.ManagementDomainBackup);
    }
    int dare_program_get_ManagementDomainBackup(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.ManagementDomainBackup))
     {
      stb_printf("buffer length of get ManagementDomainBackup is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.ManagementDomainBackup, len);
     return strlen(buff);
    }
    int dare_program_set_NTPDomain(const char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.NTPDomain))
     {
      stb_printf("buffer length of set NTPDomain is not accordant!\n");
     }
     stb_printf("########NTPDomain%s\n",buff);
     strncpy(Gchanneldata.NTPDomain, buff, sizeof(Gchanneldata.NTPDomain));
     //IS_SNTP_SYNC(Gchanneldata.NTPDomain,"\0",1);
     return strlen(Gchanneldata.NTPDomain);
    }
    int dare_program_get_NTPDomain(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.NTPDomain))
     {
      stb_printf("buffer length of get NTPDomain is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.NTPDomain, len);
     return strlen(buff);
    }
    int dare_program_set_NTPDomainBackup(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.NTPDomainBackup))
     {
      stb_printf("buffer length of set NTPDomainBackup is not accordant!\n");
     }
     strncpy(Gchanneldata.NTPDomainBackup, buff, sizeof(Gchanneldata.NTPDomainBackup));
     return strlen(Gchanneldata.NTPDomainBackup);
    }
    int dare_program_get_NTPDomainBackup(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.NTPDomainBackup))
     {
      stb_printf("buffer length of get NTPDomainBackup is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.NTPDomainBackup, len);
     return strlen(buff);
    }
    int dare_program_set_UserToken(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UserToken))
     {
      stb_printf("buffer length of set UserToken is not accordant!\n");
     }
     memset(Gchanneldata.UserToken, 0, sizeof(Gchanneldata.UserToken));
     strncpy(Gchanneldata.UserToken, buff, sizeof(Gchanneldata.UserToken));
     return strlen(Gchanneldata.UserToken);
    }
    int dare_program_get_UserToken(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UserToken))
     {
      stb_printf("buffer length of get UserToken is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UserToken, len);
     return strlen(buff);
    }
    int dare_program_set_EGPGroupNMB(char * buff, int len)
    {
     if(buff==NULL) return 0;
     if(len > (int)sizeof(Gchanneldata.EGPGroupNMB))
     {
      stb_printf("buffer length of set EGPGroupNMB is not accordant!\n");
     }
     memset(Gchanneldata.EGPGroupNMB, 0, sizeof(Gchanneldata.EGPGroupNMB));
     strncpy(Gchanneldata.EGPGroupNMB, buff, sizeof(Gchanneldata.EGPGroupNMB));
     return strlen(Gchanneldata.EGPGroupNMB);
    }
    int dare_program_get_EGPGroupNMB(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.EGPGroupNMB))
     {
      stb_printf("buffer length of get EGPGroupNMB is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.EGPGroupNMB, len);
     return strlen(buff);
    }
    int dare_program_set_BTVEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.BTVEPGURL))
     {
      stb_printf("buffer length of set BTVEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.BTVEPGURL, 0, sizeof(Gchanneldata.BTVEPGURL));
     strncpy(Gchanneldata.BTVEPGURL, buff, sizeof(Gchanneldata.BTVEPGURL));
     return strlen(Gchanneldata.BTVEPGURL);
    }
    int dare_program_get_BTVEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.BTVEPGURL))
     {
      stb_printf("buffer length of get BTVEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.BTVEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_BTVEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.BTVEPGHotkey))
     {
      stb_printf("buffer length of set BTVEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.BTVEPGHotkey, 0, sizeof(Gchanneldata.BTVEPGHotkey));
     strncpy(Gchanneldata.BTVEPGHotkey, buff, sizeof(Gchanneldata.BTVEPGHotkey));
     return strlen(Gchanneldata.BTVEPGHotkey);
    }
    int dare_program_get_BTVEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.BTVEPGHotkey))
     {
      stb_printf("buffer length of get BTVEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.BTVEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_VODEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.VODEPGURL))
     {
      stb_printf("buffer length of set VODEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.VODEPGURL, 0, sizeof(Gchanneldata.VODEPGURL));
     strncpy(Gchanneldata.VODEPGURL, buff, sizeof(Gchanneldata.VODEPGURL));
     return strlen(Gchanneldata.VODEPGURL);
    }
    int dare_program_get_VODEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.VODEPGURL))
     {
      stb_printf("buffer length of get VODEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.VODEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_VODEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.VODEPGHotkey))
     {
      stb_printf("buffer length of set VODEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.VODEPGHotkey, 0, sizeof(Gchanneldata.VODEPGHotkey));
     strncpy(Gchanneldata.VODEPGHotkey, buff, sizeof(Gchanneldata.VODEPGHotkey));
     return strlen(Gchanneldata.VODEPGHotkey);
    }
    int dare_program_get_VODEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.VODEPGHotkey))
     {
      stb_printf("buffer length of get VODEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.VODEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_SelfServiceEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.SelfServiceEPGURL))
     {
      stb_printf("buffer length of set SelfServiceEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.SelfServiceEPGURL, 0, sizeof(Gchanneldata.SelfServiceEPGURL));
     strncpy(Gchanneldata.SelfServiceEPGURL, buff, sizeof(Gchanneldata.SelfServiceEPGURL));
     return strlen(Gchanneldata.SelfServiceEPGURL);
    }
    int dare_program_get_SelfServiceEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.SelfServiceEPGURL))
     {
      stb_printf("buffer length of get SelfServiceEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.SelfServiceEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_SelfServiceEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.SelfServiceEPGHotkey))
     {
      stb_printf("buffer length of set SelfServiceEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.SelfServiceEPGHotkey, 0, sizeof(Gchanneldata.SelfServiceEPGHotkey));
     strncpy(Gchanneldata.SelfServiceEPGHotkey, buff, sizeof(Gchanneldata.SelfServiceEPGHotkey));
     return strlen(Gchanneldata.SelfServiceEPGHotkey);
    }
    int dare_program_get_SelfServiceEPGHotkey(char * buff, int len)
    {
     if(len != (int)strlen(Gchanneldata.SelfServiceEPGHotkey))
     {
      stb_printf("buffer length of get SelfServiceEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.SelfServiceEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_UserSpaceURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UserSpaceURL))
     {
      stb_printf("buffer length of set UserSpaceURL is not accordant!\n");
     }
     memset(Gchanneldata.UserSpaceURL, 0, sizeof(Gchanneldata.UserSpaceURL));
     strncpy(Gchanneldata.UserSpaceURL, buff, sizeof(Gchanneldata.UserSpaceURL));
     return strlen(Gchanneldata.UserSpaceURL);
    }
    int dare_program_get_UserSpaceURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UserSpaceURL))
     {
      stb_printf("buffer length of get UserSpaceURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UserSpaceURL, len);
     return strlen(buff);
    }
    int dare_program_set_UserSpaceHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UserSpaceHotkey))
     {
      stb_printf("buffer length of set UserSpaceHotkey is not accordant!\n");
     }
     memset(Gchanneldata.UserSpaceHotkey, 0, sizeof(Gchanneldata.UserSpaceHotkey));
     strncpy(Gchanneldata.UserSpaceHotkey, buff, sizeof(Gchanneldata.UserSpaceHotkey));
     return strlen(Gchanneldata.UserSpaceHotkey);
    }
    int dare_program_get_UserSpaceHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UserSpaceHotkey))
     {
      stb_printf("buffer length of get UserSpaceHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UserSpaceHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_InfoEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.InfoEPGURL))
     {
      stb_printf("buffer length of set InfoEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.InfoEPGURL, 0, sizeof(Gchanneldata.InfoEPGURL));
     strncpy(Gchanneldata.InfoEPGURL, buff, sizeof(Gchanneldata.InfoEPGURL));
     return strlen(Gchanneldata.InfoEPGURL);
    }
    int dare_program_get_InfoEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.InfoEPGURL))
     {
      stb_printf("buffer length of get InfoEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.InfoEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_InfoEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.InfoEPGHotkey))
     {
      stb_printf("buffer length of set InfoEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.InfoEPGHotkey, 0, sizeof(Gchanneldata.InfoEPGHotkey));
     strncpy(Gchanneldata.InfoEPGHotkey, buff, sizeof(Gchanneldata.InfoEPGHotkey));
     return strlen(Gchanneldata.InfoEPGHotkey);
    }
    int dare_program_get_InfoEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.InfoEPGHotkey))
     {
      stb_printf("buffer length of get InfoEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.InfoEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_GameEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.GameEPGURL))
     {
      stb_printf("buffer length of set GameEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.GameEPGURL, 0, sizeof(Gchanneldata.GameEPGURL));
     strncpy(Gchanneldata.GameEPGURL, buff, sizeof(Gchanneldata.GameEPGURL));
     return strlen(Gchanneldata.GameEPGURL);
    }
    int dare_program_get_GameEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.GameEPGURL))
     {
      stb_printf("buffer length of get GameEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.GameEPGURL, len);
     return strlen(buff);
    }

    int dare_program_set_GameEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.GameEPGHotkey))
     {
      stb_printf("buffer length of set GameEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.GameEPGHotkey, 0, sizeof(Gchanneldata.GameEPGHotkey));
     strncpy(Gchanneldata.GameEPGHotkey, buff, sizeof(Gchanneldata.GameEPGHotkey));
     return strlen(Gchanneldata.GameEPGHotkey);
    }
    int dare_program_get_GameEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.GameEPGHotkey))
     {
      stb_printf("buffer length of get GameEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.GameEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_EmailEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.EmailEPGURL))
     {
      stb_printf("buffer length of set EmailEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.EmailEPGURL, 0, sizeof(Gchanneldata.EmailEPGURL));
     strncpy(Gchanneldata.EmailEPGURL, buff, sizeof(Gchanneldata.EmailEPGURL));
     return strlen(Gchanneldata.EmailEPGURL);
    }
    int dare_program_get_EmailEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.EmailEPGURL))
     {
      stb_printf("buffer length of get EmailEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.EmailEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_EmailEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.EmailEPGHotkey))
     {
      stb_printf("buffer length of set EmailEPGHotkey is not accordant!\n");
     }
     memset(Gchanneldata.EmailEPGHotkey, 0, sizeof(Gchanneldata.EmailEPGHotkey));
     strncpy(Gchanneldata.EmailEPGHotkey, buff, sizeof(Gchanneldata.EmailEPGHotkey));
     return strlen(Gchanneldata.EmailEPGHotkey);
    }
    int dare_program_get_EmailEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.EmailEPGHotkey))
     {
      stb_printf("buffer length of get EmailEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.EmailEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_UMEPGURL(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UMEPGURL))
     {
      stb_printf("buffer length of set UMEPGURL is not accordant!\n");
     }
     memset(Gchanneldata.UMEPGURL, 0, sizeof(Gchanneldata.UMEPGURL));
     strncpy(Gchanneldata.UMEPGURL, buff, sizeof(Gchanneldata.UMEPGURL));
     return strlen(Gchanneldata.UMEPGURL);
    }
    int dare_program_get_UMEPGURL(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UMEPGURL))
     {
      stb_printf("buffer length of get UMEPGURL is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UMEPGURL, len);
     return strlen(buff);
    }
    int dare_program_set_UMEPGHotkey(char * buff, int len)
    {
     if(len > (int)sizeof(Gchanneldata.UMEPGHotkey))
     {
      stb_printf("buffer length of set UMEPGHotkey is not accordant!\n");
      return -1;
     }
     memset(Gchanneldata.UMEPGHotkey, 0, sizeof(Gchanneldata.UMEPGHotkey));
     strncpy(Gchanneldata.UMEPGHotkey, buff, sizeof(Gchanneldata.UMEPGHotkey));
     return strlen(Gchanneldata.UMEPGHotkey);
    }
    int dare_program_get_UMEPGHotkey(char * buff, int len)
    {
     if(len < (int)strlen(Gchanneldata.UMEPGHotkey))
     {
      stb_printf("buffer length of get UMEPGHotkey is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.UMEPGHotkey, len);
     return strlen(buff);
    }
    int dare_program_set_AudioTrack(char * buff, int len)
    {
        if(len > (int)sizeof(Gchanneldata.AudioTrack))
     {
      stb_printf("buffer length of set AudioTrack is not accordant!\n");
      return -1;
     }
     memset(Gchanneldata.AudioTrack, 0, sizeof(Gchanneldata.AudioTrack));
     strncpy(Gchanneldata.AudioTrack, buff, sizeof(Gchanneldata.AudioTrack));
     return strlen(Gchanneldata.AudioTrack);
    }
    int dare_program_get_AudioTrack(char * buff, int len)
    {
        if(len < (int)strlen(Gchanneldata.AudioTrack))
     {
      stb_printf("buffer length of get AudioTrack is not accordant!\n");
     }
     strncpy(buff, Gchanneldata.AudioTrack, len);
     return strlen(buff);
    }
    int dare_program_set_NativeUIFlag(char * buff)
    {
     Gchanneldata.NativeUIFlag = atoi(buff);

     return 0;
    }
    int dare_program_get_NativeUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.NativeUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.NativeUIFlag;
    }
    int dare_program_set_MuteUIFlag(char * buff)
    {
     Gchanneldata.MuteUIFlag = atoi(buff);
     return 0;
    }
    int dare_program_get_MuteUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.MuteUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.MuteUIFlag;
    }
    int dare_program_set_AudioVolumeUIFlag(char * buff)
    {
     Gchanneldata.audioVolumeUIFlag = atoi(buff);

     return 0;
    }
    int dare_program_get_AudioVolumeUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.audioVolumeUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.audioVolumeUIFlag;
    }
    int dare_program_set_AudioTrackUIFlag(char * buff)
    {
     Gchanneldata.audioTrackUIFlag = atoi(buff);
     return 0;
    }
    int dare_program_get_AudioTrackUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.audioTrackUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.audioTrackUIFlag;
    }
    int dare_program_set_ProgressBarUIFlag(char * buff)
    {
     Gchanneldata.progressBarUIFlag = atoi(buff);
     return 0;
    }
    int dare_program_get_ProgressBarUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.progressBarUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.progressBarUIFlag;
    }
    int dare_program_set_ChannelNoUIFlag(char * buff)
    {
     Gchanneldata.channelNoUIFlag = atoi(buff);
     return 0;
    }
    int dare_program_get_ChannelNoUIFlag(char * buff, int len)
    {
            if(buff != NULL)
            {
                sprintf(buff, "%d",Gchanneldata.channelNoUIFlag);
                len = strlen(buff);
            }
     return Gchanneldata.channelNoUIFlag;
    }
    char * DareMW_program_get_ServiceEntry(unsigned int key)
    {
     int i;
     for(i=0;i<MAX_NUMBRE_KEY;i++)
     {
      stb_printf("serch %d %d %s\n",ServiceEntry_key[i].isused,ServiceEntry_key[i].key,ServiceEntry_key[i].url);
      if ((ServiceEntry_key[i].isused==TRUE) && (ServiceEntry_key[i].key==key))
       return ServiceEntry_key[i].url;
     }
     return NULL;
    }
    int DareMW_program_set_ServiceEntry(char * buff, int len)
    {
     char *p = NULL;
     unsigned int key=0;
     char tmp[32];
     char value[32];
     int i;
     
     
     if(len != (int)strlen(buff))
     {
      stb_printf("set ServiceEntry is--->%s  size[%d]\n", buff, len);
     }

     
     if((p = strstr(buff, "HotKey"))!=NULL)
     {
      sscanf(p, "%[^\"]\"%[^\"]", tmp, value);
      key = atoi(value); 
      stb_printf("key=%d\n",key);
      if(key == 0)
      return 0;  
     }
     if(key==0x110)
     {
            //key = EIS_IRKEY_PORTAL;
     }
     else if(key==0x113)
     { 
      key = EIS_IRKEY_RED;
     }
     else if(key==0x114)
     { 
      key = EIS_IRKEY_GREEN;
     }
     else if(key==0x115)
     {
      key = EIS_IRKEY_YELLOW;
     }
     else if(key==0x116)
     { 
      key = EIS_IRKEY_BLUE;
     }
     else if(key==0x117)
     {
      //key = EIS_IRKEY_GREY;
     }
     else if(key==0x11f)
     {
            key = EIS_IRKEY_DESKTOP;//Desktop
     }
     for(i=0;i<MAX_NUMBRE_KEY;i++)
     {
      /*if ((ServiceEntry_key[i].key>0) && (ServiceEntry_key[i].key==key))
      {
       ServiceEntry_key[i].isused = TRUE;
       break;
      }*/
      
      if ((ServiceEntry_key[i].isused==FALSE) && (ServiceEntry_key[i].key==0))
      {
       ServiceEntry_key[i].key = key;
       ServiceEntry_key[i].isused = TRUE;
       break;
      }
     }
     
     if (i>=MAX_NUMBRE_KEY)
     {
      return 0;
     }

     if((p = strstr(buff, "URL"))!=NULL)
     {
      memset(ServiceEntry_key[i].url,0,sizeof(ServiceEntry_key[i].url));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, ServiceEntry_key[i].url);
     }
     else
     {
         ServiceEntry_key[i].key = 0;
         ServiceEntry_key[i].isused = FALSE;
            return 0;
     }
     if((p = strstr(buff, "Desc"))!=NULL)
     {
      memset(ServiceEntry_key[i].desc,0,sizeof(ServiceEntry_key[i].desc));
      sscanf(p, "%[^\"]\"%[^\"]", tmp, ServiceEntry_key[i].desc);
      stb_printf("%s\n", ServiceEntry_key[i].desc);
      if(key==0)
      {
       if(strcmp(ServiceEntry_key[i].desc,"EPGURL")==0)
       { 
        //key = EIS_IRKEY_PORTAL;
       }
       else if(strcmp(ServiceEntry_key[i].desc,"BTVEPGURL")==0)
       { 
        key = EIS_IRKEY_RED;
       }
       else if(strcmp(ServiceEntry_key[i].desc,"VODEPGURL")==0)
       {
        key = EIS_IRKEY_YELLOW;
       }
       else if(strcmp(ServiceEntry_key[i].desc,"TVODEPGURL")==0)
       { 
        key = EIS_IRKEY_GREEN;
       }
       else if(strcmp(ServiceEntry_key[i].desc,"InfoEPGURL")==0)
       {
        key = EIS_IRKEY_BLUE;
       }
       ServiceEntry_key[i].key = key;
       stb_printf("cur key=%d\n",key);
      }
     }
     stb_printf("key %d url %s\n", key,ServiceEntry_key[i].url);
     return 0;
    }
    #if 0
    int dare_program_get(int id, int channelNum,char * strigmp, char* strrtsp)
    {
     unsigned int i;
     if(strigmp==NULL||strrtsp==NULL)
      return 0;
     for (i=0;i<Gchanneldata.channelcount;i++)
     {
      //stb_printf("%d  =?= %d\n",Gchanneldata.pchlinfo[i].userchlId,channelNum);
      if (Gchanneldata.pchlinfo[i].userchlId==channelNum)
      {
       Gchanneldata.currentchannel = channelNum;
       strncpy(strigmp,Gchanneldata.pchlinfo[i].chlURL,URLLENGTH);
       strncpy(strrtsp,Gchanneldata.pchlinfo[i].timeshiftURL,URLLENGTH);
       return 1;
      }
     }
     stb_printf("dare_program_get error !%d\n",Gchanneldata.channelcount);
     return 0;
    }
    #else
    int dare_program_get(int id, int channelNum,ChannelInfoStruct ** channelinfo)
    {
     unsigned int i;
     if(channelinfo==NULL)
      return 0;
     for (i=0;i<Gchanneldata.channelcount;i++)
     {
      //stb_printf("%d  =?= %d cont %ld\n",Gchanneldata.pchlinfo[i].userchlId,channelNum,Gchanneldata.channelcount);
      if (Gchanneldata.pchlinfo[i].userchlId==channelNum)
      {
       Gchanneldata.currentchannel = channelNum;
       *channelinfo = &Gchanneldata.pchlinfo[i];
       //memcpy(channelinfo, &Gchanneldata.pchlinfo[i],sizeof(ChannelInfoStruct));
       return 1;
      }
     }
     stb_printf("dare_program_get error !%d\n",Gchanneldata.channelcount);
     /*if(Gchanneldata.channelcount>0)
     {
      *channelinfo = &Gchanneldata.pchlinfo[0];
      Gchanneldata.currentchannel = 0;
      return 1;
     }*/
     return 0;
    }

    #endif
    int dare_program_set_ChlPId(int chlnum, unsigned short vpid, unsigned short vformat,unsigned short apid,unsigned short aformat,unsigned short pcrpid)
    {
     unsigned int i;
     
     for (i=0;i<Gchanneldata.channelcount;i++)
     {
      if (Gchanneldata.pchlinfo[i].userchlId==chlnum)
      {
       Gchanneldata.pchlinfo[i].vpid = vpid;
       Gchanneldata.pchlinfo[i].vformat = vformat;
       Gchanneldata.pchlinfo[i].apid = apid;
       Gchanneldata.pchlinfo[i].aformat = aformat;
       Gchanneldata.pchlinfo[i].pcrpid = pcrpid;
       return 0;
      }
     }
     return -1;
    }

  • 相关阅读:
    PAT B1021 个位数统计 (15)
    PAT B1006 换个格式输出整数 (15)
    PAT A1058 A+B in Hogwarts (20)
    PAT A1027 Colors in Mars (20)
    PAT A1019 General Palindromic Number (20 分)
    PAT B1022 D进制的A+B
    J2EE
    MVC
    数据库长连接短连接
    twisted
  • 原文地址:https://www.cnblogs.com/fx2008/p/2163823.html
Copyright © 2020-2023  润新知