Index: /trunk/epgdumpr2/sdt.h =================================================================== --- /trunk/epgdumpr2/sdt.h (リビジョン 136) +++ /trunk/epgdumpr2/sdt.h (リビジョン 136) @@ -0,0 +1,61 @@ +#ifndef SDT_H +#define SDT_H 1 + +#include +#include + +#include "util.h" +#include "ts_ctl.h" + +typedef struct _SDThead { + char table_id; + int section_syntax_indicator; + int reserved_future_use1; + int reserved1; + int section_length; + int transport_stream_id; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; + int original_network_id; + int reserved_future_use2; +} SDThead; + +typedef struct _SDTbody { + int service_id; + int reserved_future_use1; + int EIT_user_defined_flags; + int EIT_schedule_flag; + int EIT_present_following_flag; + int running_status; + int free_CA_mode; + int descriptors_loop_length; +} SDTbody; + +typedef struct _SVCdesc { + int descriptor_tag; + int descriptor_length; + int service_type; + int service_provider_name_length; + char service_provider_name[MAXSECLEN]; + int service_name_length; + char service_name[MAXSECLEN]; +} SVCdesc; + + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseSDThead(unsigned char *data, SDThead *h); + int parseSDTbody(unsigned char *data, SDTbody *b); + int parseSVCdesc(unsigned char *data, SVCdesc *desc); + void dumpSDT(unsigned char *data, SVT_CONTROL *top); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif Index: /trunk/epgdumpr2/epgdump.c =================================================================== --- /trunk/epgdumpr2/epgdump.c (リビジョン 136) +++ /trunk/epgdumpr2/epgdump.c (リビジョン 136) @@ -0,0 +1,382 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "ts.h" +#include "sdt.h" +#include "eit.h" +#include "ts_ctl.h" + +typedef struct _ContentTYPE{ + char *japanese ; + char *english ; +}CONTENT_TYPE; + +#define CAT_COUNT 16 +static CONTENT_TYPE ContentCatList[CAT_COUNT] = { + { "����若��糸���, "news" }, + { "�鴻��若�", "sports" }, + { "���", "information" }, + { "�����, "drama" }, + { "�恰ソ", "music" }, + { "��������, "variety" }, + { "���", "cinema" }, + { "�≪��<��号�", "anime" }, + { "����ャ��潟�����紙�蕕�, "documentary" }, + { "羲��", "stage" }, + { "莇e��糸���, "hobby" }, + { "胼霛�, "etc" }, //胼霛� { "篋��", "etc" }, //篋�� + { "篋��", "etc" }, //篋�� + { "篋��", "etc" }, //篋�� + { "���篁�, "etc" } //���篁�}; +typedef struct _TAG_STATION +{ + char *name; + char *ontv; + int tsId; // OriginalNetworkID + int onId; // TransportStreamID + int svId; // ServiceID +} STATION; + +static STATION bsSta[] = { + { "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101}, + { "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102},//綮�� 2011/3/31 + { "NHK BS��������, "3003.ontvjapan.com", 16626, 4, 103}, + { "BS�ャ���, "3004.ontvjapan.com", 16592, 4, 141}, + { "BS���", "3005.ontvjapan.com", 16400, 4, 151}, + { "BS-TBS", "3006.ontvjapan.com", 16401, 4, 161}, + { "BS�吾����", "3007.ontvjapan.com", 16433, 4, 171}, + { "BS���", "3008.ontvjapan.com", 16593, 4, 181}, + { "WOWOW", "3009.ontvjapan.com", 16432, 4, 191}, + { "WOWOW2", "3010.ontvjapan.com", 16432, 4, 192}, + { "WOWOW3", "3011.ontvjapan.com", 16432, 4, 193}, + { "�鴻��若�����潟���, "3012.ontvjapan.com", 16529, 4, 200}, + { "BS11", "3013.ontvjapan.com", 16528, 4, 211}, + { "TwellV", "3014.ontvjapan.com", 16530, 4, 222}, +}; + +static int bsStaCount = sizeof(bsSta) / sizeof (STATION); + + + +static STATION csSta[] = { + { "�鴻��種�鐔�����", "1002.ontvjapan.com", 24608, 6, 237}, + { "�ユ����絨��鐔��鐚�爾", "1086.ontvjapan.com", 24608, 6, 239},//��������SHD �� { "��������汐鐚ワ叱鐚�, "306ch.epgdata.ontvjapan", 24608, 6, 306}, + { "�激��������潟���, "1059.ontvjapan.com", 24704, 6, 55}, + { "�吟��激���, "1217.ontvjapan.com", 24736, 6, 228}, + { "�鴻�����鰹示鐚わ�鐚��", "800ch.epgdata.ontvjapan", 24736, 6, 800}, + { "�鴻�����鰹�鐚��", "801ch.epgdata.ontvjapan", 24736, 6, 801}, + { "�鴻�����鰹�鐚��", "802ch.epgdata.ontvjapan", 24736, 6, 802}, + { "鐔�������, "100ch.epgdata.ontvjapan", 28736, 7, 100}, + { "�ゃ��帥�������鐚器雫", "194ch.epgdata.ontvjapan", 28736, 7, 194}, + { "鐚��������鐚ワ竺鐚逸汐", "1025.ontvjapan.com", 28736, 7, 256}, + { "鐚�鹿鐚�, "1016.ontvjapan.com", 28736, 7, 312}, + { "�鴻��若��激����鐚器雫", "1018.ontvjapan.com", 28736, 7, 322}, + { "�������若�������", "1046.ontvjapan.com", 28736, 7, 331}, + { "����若��祉��c����", "1213.ontvjapan.com", 28736, 7, 334}, + { "�掩�����潟���, "1010.ontvjapan.com", 28768, 7, 221}, + { "茵�����", "1005.ontvjapan.com", 28768, 7, 222}, + { "����潟���汐鐚ワ治鐚�, "1008.ontvjapan.com", 28768, 7, 223}, + { "羇���������c�", "1009.ontvjapan.com", 28768, 7, 224}, + { "�鴻��若�����激���, "1003.ontvjapan.com", 28768, 7, 238}, + { "��撮�������c����", "1133.ontvjapan.com", 28768, 7, 292}, + { "�鴻���������, "1006.ontvjapan.com", 28768, 7, 310}, + { "鐚¥叱鐚�, "1014.ontvjapan.com", 28768, 7, 311}, + { "����с�����c����", "1204.ontvjapan.com", 28768, 7, 343}, + { "����������帥�", "110ch.epgdata.ontvjapan", 28864, 7, 110}, + { "�眼�����c����", "1028.ontvjapan.com", 28864, 7, 260}, + { "�������c����", "1092.ontvjapan.com", 28864, 7, 303}, + { "鐚�軸鐚�, "1019.ontvjapan.com", 28864, 7, 323}, + { "����若�����祉���, "1024.ontvjapan.com", 28864, 7, 324}, + { "�������若��帥�", "1067.ontvjapan.com", 28864, 7, 352}, + { "鐚�滋鐚c��若���, "1070.ontvjapan.com", 28864, 7, 353}, + { "鐚o汐鐚��", "1069.ontvjapan.com", 28864, 7, 354}, + { "�吾��鴻��祉���, "361ch.epgdata.ontvjapan", 28864, 7, 361}, + { "鐚��������鐚�, "1041.ontvjapan.com", 28896, 7, 251}, + { "鐚��������鐚�, "1042.ontvjapan.com", 28896, 7, 252}, + { "鐚�������式鐔��鐔�示", "1043.ontvjapan.com", 28896, 7, 253}, + { "鐚э次鐚�鴫鐚�, "1026.ontvjapan.com", 28896, 7, 254}, + { "鐔��鐔��鐚<�������", "1040.ontvjapan.com", 28896, 7, 255}, + { "絎������≪��c����", "101ch.epgdata.ontvjapan", 28928, 7, 101}, + { "鐚鰹自鐚鴻�鐚鰹軸鐚¥磁鐚�, "1207.ontvjapan.com", 28928, 7, 290}, + { "����潟����羃�, "305ch.epgdata.ontvjapan", 28928, 7, 305}, + { "鐚¥軸-鐚�, "1201.ontvjapan.com", 28928, 7, 333}, + { "�������若��c����", "1050.ontvjapan.com", 28928, 7, 342}, + { "�鴻�����鰹�鐚��", "803ch.epgdata.ontvjapan", 28928, 7, 803}, + { "�鴻�����鰹�鐚��", "804ch.epgdata.ontvjapan", 28928, 7, 804}, + { "����������刻示鐚�, "1007.ontvjapan.com", 28960, 7, 240}, + { "�眼������������, "1027.ontvjapan.com", 28960, 7, 262}, + { "鐚��鐚����示鐚�, "1074.ontvjapan.com", 28960, 7, 314}, + { "��������鹿鐚�璽", "1073.ontvjapan.com", 28992, 7, 307},//��������39�� { "��������軸鐚件鹿", "1072.ontvjapan.com", 28992, 7, 308},//��������21�� { "�≪�������", "1047.ontvjapan.com", 28992, 7, 332}, + { "����鴻������, "1062.ontvjapan.com", 28992, 7, 340}, + { "�≪������������, "1193.ontvjapan.com", 28992, 7, 341}, + { "鐚�鐚器滋鐚潟�������", "160ch.epgdata.ontvjapan", 29024, 7, 160}, + { "鐚縁雫鐚�, "1120.ontvjapan.com", 29024, 7, 161}, + { "����ゃ�鐚��鐚��鐚器雫", "185ch.epgdata.ontvjapan", 29024, 7, 185}, + { "�������弱���, "1015.ontvjapan.com", 29024, 7, 293}, + { "鐚器滋鐚潟��c����", "3201.ontvjapan.com", 29024, 7, 301}, + { "����冴��若��c����", "1090.ontvjapan.com", 29024, 7, 304}, + { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, + { "����冴�����激���D", "1045.ontvjapan.com", 29024, 7, 335},//HD�� { "鐚器滋鐚潟��ャ��鴻��若�", "1076.ontvjapan.com", 29024, 7, 351}, + { "鐚o竺�ユ���������, "147ch.epgdata.ontvjapan", 29056, 7, 147}, + { "�ャ���磁鐚�, "1068.ontvjapan.com", 29056, 7, 257}, + { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291}, + { "�ャ�������", "300ch.epgdata.ontvjapan", 29056, 7, 300}, + { "�������若����鐚器雫", "1023.ontvjapan.com", 29056, 7, 320}, + { "Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321}, + { "�ャ���汐鐚ワ七鐚鰹�鐚�, "2002.ontvjapan.com", 29056, 7, 350}, +}; + +static int csStaCount = sizeof(csSta) / sizeof (STATION); +SVT_CONTROL *svttop = NULL; +#define SECCOUNT 4 +char title[1024]; +char subtitle[1024]; +char Category[1024]; +char ServiceName[1024]; + +/* prototype */ +extern int strrep(char *buf, char *mae, char *ato); + +void xmlspecialchars(char *str) +{ + strrep(str, "&", "&"); + strrep(str, "'", "'"); + strrep(str, "\"", """); + strrep(str, "<", "<"); + strrep(str, ">", ">"); +} + + + +void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count) +{ + SECcache *bsecs; + + while((bsecs = readTS(infile, secs, count)) != NULL) { + /* SDT */ + if((bsecs->pid & 0xFF) == 0x11) { + dumpSDT(bsecs->buf, svttop); + } + } +} +void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int count) +{ + SECcache *bsecs; + EIT_CONTROL *eitcur ; + EIT_CONTROL *eitnext ; + EIT_CONTROL *eittop = NULL; + time_t l_time ; + time_t end_time ; + struct tm tl ; + struct tm *endtl ; + char cendtime[32]; + char cstarttime[32]; + + eittop = calloc(1, sizeof(EIT_CONTROL)); + eitcur = eittop ; + fseek(infile, 0, SEEK_SET); + while((bsecs = readTS(infile, secs, SECCOUNT)) != NULL) { + /* EIT */ + if((bsecs->pid & 0xFF) == 0x12) { + dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); + }else if((bsecs->pid & 0xFF) == 0x26) { + dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); + }else if((bsecs->pid & 0xFF) == 0x27) { + dumpEIT(bsecs->buf, psta->svId, psta->onId, psta->tsId, eittop); + } + } + eitcur = eittop ; + while(eitcur != NULL){ + if(!eitcur->servid){ + eitcur = eitcur->next ; + continue ; + } + if(eitcur->content_type > CAT_COUNT){ + eitcur->content_type = CAT_COUNT -1 ; + } + memset(title, '\0', sizeof(title)); + strcpy(title, eitcur->title); + xmlspecialchars(title); + + memset(subtitle, '\0', sizeof(subtitle)); + strcpy(subtitle, eitcur->subtitle); + xmlspecialchars(subtitle); + + memset(Category, '\0', sizeof(Category)); + strcpy(Category, ContentCatList[eitcur->content_type].japanese); + xmlspecialchars(Category); + + tl.tm_sec = eitcur->ss ; + tl.tm_min = eitcur->hm ; + tl.tm_hour = eitcur->hh ; + tl.tm_mday = eitcur->dd ; + tl.tm_mon = (eitcur->mm - 1); + tl.tm_year = (eitcur->yy - 1900); + tl.tm_wday = 0; + tl.tm_isdst = 0; + tl.tm_yday = 0; + l_time = mktime(&tl); + if((eitcur->ehh == 0) && (eitcur->emm == 0) && (eitcur->ess == 0)){ + (void)time(&l_time); + end_time = l_time + (60 * 5); // 鐚��緇��荐�� + endtl = localtime(&end_time); + }else{ + end_time = l_time + eitcur->ehh * 3600 + eitcur->emm * 60 + eitcur->ess; + endtl = localtime(&end_time); + } + memset(cendtime, '\0', sizeof(cendtime)); + memset(cstarttime, '\0', sizeof(cstarttime)); + strftime(cendtime, (sizeof(cendtime) - 1), "%Y%m%d%H%M%S", endtl); + strftime(cstarttime, (sizeof(cstarttime) - 1), "%Y%m%d%H%M%S", &tl); +#if 1 + fprintf(outfile, " \n", + cstarttime, cendtime, psta->ontv); + fprintf(outfile, " %s\n", title); + fprintf(outfile, " %s\n", subtitle); + fprintf(outfile, " %s\n", Category); + fprintf(outfile, " %s\n", ContentCatList[eitcur->content_type].english); + fprintf(outfile, " \n"); +#else + fprintf(outfile, "(%x:%x:%x)%s,%s,%s,%s,%s,%s\n", + eitcur->servid, eitcur->table_id, eitcur->event_id, + cstarttime, cendtime, + title, subtitle, + Category, + ContentCatList[eitcur->content_type].english); +#endif +#if 0 + fprintf(outfile, "(%x:%x)%04d/%02d/%02d,%02d:%02d:%02d,%02d:%02d:%02d,%s,%s,%s,%s\n", + eitcur->table_id, eitcur->event_id, + eitcur->yy, eitcur->mm, eitcur->dd, + eitcur->hh, eitcur->hm, eitcur->ss, + eitcur->ehh, eitcur->emm, eitcur->ess, + eitcur->title, eitcur->subtitle, + ContentCatList[eitcur->content_type].japanese, + ContentCatList[eitcur->content_type].english); +#endif + eitnext = eitcur->next ; + free(eitcur->title); + free(eitcur->subtitle); + free(eitcur); + eitcur = eitnext ; + } + free(eittop); + eittop = NULL; +} +int main(int argc, char *argv[]) +{ + + FILE *infile = stdin; + FILE *outfile = stdout; + char *arg_onTV ; + int staCount ; + char *file; + int inclose = 0; + int outclose = 0; + SVT_CONTROL *svtcur ; + SVT_CONTROL *svtsave ; + SECcache secs[SECCOUNT]; + int lp ; + STATION *pStas ; + int act ; + + /* ��������id���絎�*/ + memset(secs, 0, sizeof(SECcache) * SECCOUNT); + secs[0].pid = 0x11; + secs[1].pid = 0x12; + secs[2].pid = 0x26; + secs[3].pid = 0x27; + + if(argc == 4){ + arg_onTV = argv[1]; + file = argv[2]; + if(strcmp(file, "-")) { + infile = fopen(file, "r"); + inclose = 1; + } + if(strcmp(argv[3], "-")) { + outfile = fopen(argv[3], "w+"); + outclose = 1; + } + }else{ + fprintf(stdout, "Usage : %s {/BS|/CS} \n", argv[0]); + fprintf(stdout, "Usage : %s \n", argv[0]); + fprintf(stdout, "\n"); + fprintf(stdout, " ontvcode Channel identifier (ex. ****.ontvjapan.com)\n"); + fprintf(stdout, " /BS BS mode\n"); + fprintf(stdout, " This mode reads the data of all BS TV stations\n"); + fprintf(stdout, " from one TS data.\n"); + fprintf(stdout, " /CS CS mode\n"); + fprintf(stdout, " This mode reads the data of two or more CS TV stations\n"); + fprintf(stdout, " from one TS data.\n"); + return 0; + } + + if(strcmp(arg_onTV, "/BS") == 0){ + pStas = bsSta; + staCount = bsStaCount; + act = 0 ; + }else if(strcmp(arg_onTV, "/CS") == 0){ + pStas = csSta; + staCount = csStaCount; + act = 0 ; + }else{ + act = 1 ; + svttop = calloc(1, sizeof(SVT_CONTROL)); + GetSDT(infile, svttop, secs, SECCOUNT); + svtcur = svttop->next ; //��� + if(svtcur == NULL){ + free(svttop); + return 1; + } + + pStas = calloc(1, sizeof(STATION)); + pStas->tsId = svtcur->transport_stream_id ; + pStas->onId = svtcur->original_network_id ; + pStas->svId = svtcur->event_id ; + pStas->ontv = arg_onTV ; + pStas->name = svtcur->servicename ; + staCount = 1; + } + + fprintf(outfile, "\n"); + fprintf(outfile, "\n\n"); + fprintf(outfile, "\n"); + + for(lp = 0 ; lp < staCount ; lp++){ + memset(ServiceName, '\0', sizeof(ServiceName)); + strcpy(ServiceName, pStas[lp].name); + xmlspecialchars(ServiceName); + + fprintf(outfile, " \n", pStas[lp].ontv); + fprintf(outfile, " %s\n", ServiceName); + fprintf(outfile, " \n"); + } + for(lp = 0 ; lp < staCount ; lp++){ + GetEIT(infile, outfile, &pStas[lp], secs, SECCOUNT); + } + fprintf(outfile, "\n"); + if(inclose) { + fclose(infile); + } + + if(outclose) { + fclose(outfile); + } + if(act){ + free(pStas); + svtcur = svttop ; //��� + while(svtcur != NULL){ + svtsave = svtcur->next ; + free(svtcur); + svtcur = svtsave ; + } + } + + return 0; +} Index: /trunk/epgdumpr2/aribstr.c =================================================================== --- /trunk/epgdumpr2/aribstr.c (リビジョン 136) +++ /trunk/epgdumpr2/aribstr.c (リビジョン 136) @@ -0,0 +1,673 @@ +#include +#include +#include +#include +#include + +#include "aribstr.h" + +#define CODE_UNKNOWN 0 // 筝���������c�������(���綽� +#define CODE_KANJI 1 // Kanji +#define CODE_ALPHANUMERIC 2 // Alphanumeric +#define CODE_HIRAGANA 3 // Hiragana +#define CODE_KATAKANA 4 // Katakana +#define CODE_MOSAIC_A 5 // Mosaic A +#define CODE_MOSAIC_B 6 // Mosaic B +#define CODE_MOSAIC_C 7 // Mosaic C +#define CODE_MOSAIC_D 8 // Mosaic D +#define CODE_PROP_ALPHANUMERIC 9 // Proportional Alphanumeric +#define CODE_PROP_HIRAGANA 10 // Proportional Hiragana +#define CODE_PROP_KATAKANA 11 // Proportional Katakana +#define CODE_JIS_X0201_KATAKANA 12 // JIS X 0201 Katakana +#define CODE_JIS_KANJI_PLANE_1 13 // JIS compatible Kanji Plane 1 +#define CODE_JIS_KANJI_PLANE_2 14 // JIS compatible Kanji Plane 2 +#define CODE_ADDITIONAL_SYMBOLS 15 // Additional symbols + + +#define TCHAR char +#define BYTE char +#define WORD int +#define DWORD int +#define bool int +#define true 1 +#define false 0 +#define TEXT(a) a +#define _T(a) a +#define CODE_SET int + +static int m_CodeG[4]; +static int *m_pLockingGL; +static int *m_pLockingGR; +static int *m_pSingleGL; + +static BYTE m_byEscSeqCount; +static BYTE m_byEscSeqIndex; +static bool m_bIsEscSeqDrcs; + + +static const DWORD AribToStringInternal(TCHAR *lpszDst, const BYTE *pSrcData, const DWORD dwSrcLen); +static const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet); + +static const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode); +static const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode); +//static const DWORD PutAlphanumericHankakuChar(TCHAR *lpszDst, const WORD wCode); +static const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode); +static const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode); +static const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode); +static const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode); + +static void ProcessEscapeSeq(const BYTE byCode); + +static void LockingShiftGL(const BYTE byIndexG); +static void LockingShiftGR(const BYTE byIndexG); +static void SingleShiftGL(const BYTE byIndexG); + +static const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode); +static const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode); + +static const bool abCharSizeTable[] = +{ + false, // CODE_UNKNOWN 筝���������c�������(���綽� + true, // CODE_KANJI Kanji + false, // CODE_ALPHANUMERIC Alphanumeric + false, // CODE_HIRAGANA Hiragana + false, // CODE_KATAKANA Katakana + false, // CODE_MOSAIC_A Mosaic A + false, // CODE_MOSAIC_B Mosaic B + false, // CODE_MOSAIC_C Mosaic C + false, // CODE_MOSAIC_D Mosaic D + false, // CODE_PROP_ALPHANUMERIC Proportional Alphanumeric + false, // CODE_PROP_HIRAGANA Proportional Hiragana + false, // CODE_PROP_KATAKANA Proportional Katakana + false, // CODE_JIS_X0201_KATAKANA JIS X 0201 Katakana + true, // CODE_JIS_KANJI_PLANE_1 JIS compatible Kanji Plane 1 + true, // CODE_JIS_KANJI_PLANE_2 JIS compatible Kanji Plane 2 + true // CODE_ADDITIONAL_SYMBOLS Additional symbols +}; + +typedef enum{ + STR_SMALL = 0, //SSZ + STR_MEDIUM, //MSZ + STR_NORMAL, //NSZ + STR_MICRO, //SZX 0x60 + STR_HIGH_W, //SZX 0x41 + STR_WIDTH_W, //SZX 0x44 + STR_W, //SZX 0x45 + STR_SPECIAL_1, //SZX 0x6B + STR_SPECIAL_2, //SZX 0x64 +} STRING_SIZE; + +STRING_SIZE m_emStrSize; + +bool IsSmallCharMode(void) +{ + bool bRet = false; + switch(m_emStrSize){ + case STR_SMALL: + bRet = true; + break; + case STR_MEDIUM: + bRet = true; + break; + case STR_NORMAL: + bRet = false; + break; + case STR_MICRO: + bRet = true; + break; + case STR_HIGH_W: + bRet = false; + break; + case STR_WIDTH_W: + bRet = false; + break; + case STR_W: + bRet = false; + break; + case STR_SPECIAL_1: + bRet = false; + break; + case STR_SPECIAL_2: + bRet = false; + break; + default: + break; + } + return bRet; +} + +int AribToString( + char *lpszDst, + const char *pSrcData, + const int dwSrcLen) { + + return AribToStringInternal(lpszDst, pSrcData, dwSrcLen); +} + + +const DWORD AribToStringInternal(TCHAR *lpszDst, + const BYTE *pSrcData, const DWORD dwSrcLen) +{ + if(!pSrcData || !dwSrcLen || !lpszDst)return 0UL; + + DWORD dwSrcPos = 0UL; + DWORD dwDstLen = 0UL; + int dwSrcData; + + // �倶����荐�� + m_byEscSeqCount = 0U; + m_pSingleGL = NULL; + + m_CodeG[0] = CODE_KANJI; + m_CodeG[1] = CODE_ALPHANUMERIC; + m_CodeG[2] = CODE_HIRAGANA; + m_CodeG[3] = CODE_KATAKANA; + + m_pLockingGL = &m_CodeG[0]; + m_pLockingGR = &m_CodeG[2]; + + m_emStrSize = STR_NORMAL; + + while(dwSrcPos < dwSrcLen){ + dwSrcData = pSrcData[dwSrcPos] & 0xFF; + + if(!m_byEscSeqCount){ + + // GL/GR��� + if((dwSrcData >= 0x21U) && (dwSrcData <= 0x7EU)){ + // GL��� + const CODE_SET CurCodeSet = (m_pSingleGL)? *m_pSingleGL : *m_pLockingGL; + m_pSingleGL = NULL; + + if(abCharSizeTable[CurCodeSet]){ + // 2�������若� + if((dwSrcLen - dwSrcPos) < 2UL)break; + + dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], ((WORD)pSrcData[dwSrcPos + 0] << 8) | (WORD)pSrcData[dwSrcPos + 1], CurCodeSet); + dwSrcPos++; + } + else{ + // 1�������若� + dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], (WORD)dwSrcData, CurCodeSet); + } + } + else if((dwSrcData >= 0xA1U) && (dwSrcData <= 0xFEU)){ + // GR��� + const CODE_SET CurCodeSet = *m_pLockingGR; + + if(abCharSizeTable[CurCodeSet]){ + // 2�������若� + if((dwSrcLen - dwSrcPos) < 2UL)break; + + dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], ((WORD)(pSrcData[dwSrcPos + 0] & 0x7FU) << 8) | (WORD)(pSrcData[dwSrcPos + 1] & 0x7FU), CurCodeSet); + dwSrcPos++; + } + else{ + // 1�������若� + dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], (WORD)(dwSrcData & 0x7FU), CurCodeSet); + } + } + else{ + // �九勝�潟��� switch(dwSrcData){ + case 0x0FU : LockingShiftGL(0U); break; // LS0 + case 0x0EU : LockingShiftGL(1U); break; // LS1 + case 0x19U : SingleShiftGL(2U); break; // SS2 + case 0x1DU : SingleShiftGL(3U); break; // SS3 + case 0x1BU : m_byEscSeqCount = 1U; break; // ESC + case 0x89U : m_emStrSize = STR_MEDIUM; break; // MSZ + case 0x8AU : m_emStrSize = STR_NORMAL; break; // NSZ + case 0x20U : + case 0xA0U : + //SP 腥榊� + //腥榊����絖���ゃ���襲�帥��� if( IsSmallCharMode() == false ){ + strcpy(&lpszDst[dwDstLen], "��); + dwDstLen += 3U; + } else { + lpszDst[dwDstLen++] = TEXT(' '); + } + break; + default : break; // ���綽� } + } + } + else{ + // ����宴�����若��潟���� + ProcessEscapeSeq(dwSrcData); + } + + dwSrcPos++; + } + + // 腟����� + lpszDst[dwDstLen] = TEXT('\0'); + + return dwDstLen; +} + +const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet) +{ + switch(CodeSet){ + case CODE_KANJI : + case CODE_JIS_KANJI_PLANE_1 : + case CODE_JIS_KANJI_PLANE_2 : + // 羲√��潟������ return PutKanjiChar(lpszDst, wCode); + + case CODE_ALPHANUMERIC : + case CODE_PROP_ALPHANUMERIC : + // �掩�絖���若��阪� + if( IsSmallCharMode() == false ){ + //����������潟����� + return PutAlphanumericChar(lpszDst, wCode); + } else { + //����������上��� lpszDst[0] = wCode; + return 1UL; + } + + case CODE_HIRAGANA : + case CODE_PROP_HIRAGANA : + // �蚊�����潟������ return PutHiraganaChar(lpszDst, wCode); + + case CODE_PROP_KATAKANA : + case CODE_KATAKANA : + // �������潟������ return PutKatakanaChar(lpszDst, wCode); + + case CODE_JIS_X0201_KATAKANA : + // JIS�������潟������ return PutJisKatakanaChar(lpszDst, wCode); + + case CODE_ADDITIONAL_SYMBOLS : + // 菴遵��激�����潟������ return PutSymbolsChar(lpszDst, wCode); + + default : + return 0UL; + } +} + +const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode) +{ + char code[9]; + char xcode[5]; + iconv_t cd; + + size_t inbyte = 8; + size_t outbyte = sizeof(xcode); + + memset(xcode, '\0', sizeof(xcode)); + + const char *fptr; + char *tptr; + + code[0] = 0x1BU; + code[1] = 0x24U; + code[2] = 0x40U; + code[3] = wCode >> 8; + code[4] = wCode & 0xFF; + code[5] = 0x1BU; + code[6] = 0x28U; + code[7] = 0x4AU; + code[8] = '\0'; + + cd = iconv_open("UTF-8","ISO-2022-JP"); + + fptr = code; + tptr = xcode; + iconv(cd, (char **)&fptr, &inbyte, &tptr, &outbyte); + + iconv_close(cd); + + strncpy(lpszDst, xcode, strlen(xcode)); + + return strlen(lpszDst); +} + +const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode) +{ + // �掩�絖��茹��絖���若�紊�� static const TCHAR *acAlphanumericTable = + TEXT("������������������������") + TEXT("������������������������") + TEXT("������鐚��鐚��鐚��鐚��鐚��鐚��") + TEXT("鐚��鐚��鐚��鐚��鐚��鐚��鐚��鐚��") + TEXT("鐚�次鐚�治鐚わ璽鐚�磁鐚�而鐚�自鐚�辞鐚�鹿") + TEXT("鐚逸識鐚駕竺鐚器宍鐚駈七鐚醐執鐚削嫉鐃ワ悉鐚常漆") + TEXT("���鐔��鐔��鐔��鐔��鐔��鐔��鐔��") + TEXT("鐔��鐔��鐔��鐔��鐔��鐔��鐔��鐃c�"); + +#ifdef _UNICODE + lpszDst[0] = acAlphanumericTableZenkaku[wCode]; + + return 1UL; +#else + lpszDst[0] = acAlphanumericTable[wCode * 3U + 0U]; + lpszDst[1] = acAlphanumericTable[wCode * 3U + 1U]; + lpszDst[2] = acAlphanumericTable[wCode * 3U + 2U]; + + return 3UL; +#endif +} + +const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode) +{ + // �蚊��������潟������ static const TCHAR *acHiraganaTable = + TEXT("������������������������") + TEXT("������������������������") + TEXT("������������������������") + TEXT("������������������������") + TEXT("����≪��ゃ����������������") + TEXT("�違��蚊��眼��吟��吾��冴��若��障�") + TEXT("������������������������") + TEXT("����������������������祉�"); + +#ifdef _UNICODE + lpszDst[0] = acHiraganaTable[wCode]; + + return 1UL; +#else + lpszDst[0] = acHiraganaTable[wCode * 3U + 0U]; + lpszDst[1] = acHiraganaTable[wCode * 3U + 1U]; + lpszDst[2] = acHiraganaTable[wCode * 3U + 2U]; + + return 3UL; +#endif +} + +const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode) +{ + // �������掩�絖��絖���若�紊�� static const TCHAR *acKatakanaTable = + TEXT("������������������������") + TEXT("������������������������") + TEXT("����≪��ゃ����������������") + TEXT("�違��蚊��眼��吟��吾��冴��若��障�") + TEXT("������������������������") + TEXT("������������������������") + TEXT("����≪��ゃ����������������") + TEXT("�違��蚊��眼��吟��障��������祉�"); + +#ifdef _UNICODE + lpszDst[0] = acKatakanaTable[wCode]; + + return 1UL; +#else + lpszDst[0] = acKatakanaTable[wCode * 3U + 0U]; + lpszDst[1] = acKatakanaTable[wCode * 3U + 1U]; + lpszDst[2] = acKatakanaTable[wCode * 3U + 2U]; + + return 3UL; +#endif +} + +const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode) +{ + // JIS����������潟������ static const TCHAR *acJisKatakanaTable = + TEXT("������������������������") + TEXT("������������������������") + TEXT("����������蚊��c��с��c��с�") + TEXT("�若��ゃ�����������潟��激��祉�") + TEXT("�帥����������������������) + TEXT("����<��ゃ����������������") + TEXT("������������������������") + TEXT("������������������������"); + +#ifdef _UNICODE + lpszDst[0] = acJisKatakanaTable[wCode]; + + return 1UL; +#else + lpszDst[0] = acJisKatakanaTable[wCode * 3U + 0U]; + lpszDst[1] = acJisKatakanaTable[wCode * 3U + 1U]; + lpszDst[2] = acJisKatakanaTable[wCode * 3U + 2U]; + + return 3UL; +#endif +} + +const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode) +{ + // 菴遵��激��������潟���������������荀�����������) + static const TCHAR *aszSymbolsTable1[] = + { + _T("��V��), _T("��D��), _T("��式��), _T("��七��), _T("��V��), _T("�����), _T("�����), _T("����"), // 0x7A50 - 0x7A57 90/48 - 90/55 + _T("�����), _T("��竺��), _T("�����), _T("�����), _T("��В��), _T("��S��), _T("��滋��), _T("��汐��), // 0x7A58 - 0x7A5F 90/56 - 90/63 + _T("��), _T("��, _T("��ぉ��), _T("��困��), _T("�����), _T("�����), _T("�����), _T("��拘藹√����"), // 0x7A60 - 0x7A67 90/64 - 90/71 + _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("��鴬��), // 0x7A68 - 0x7A6F 90/72 - 90/79 + _T("��0��), _T("�����), _T("��PV��), _T("鐚��鐚�), _T("�祉�") // 0x7A70 - 0x7A74 90/80 - 90/84 + }; + + static const TCHAR *aszSymbolsTable2[] = + { + _T("��), _T("��), _T("��), _T("��), _T("��, _T("��), _T("綛�), _T("��), // 0x7C21 - 0x7C28 92/01 - 92/08 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("鐚�"), // 0x7C29 - 0x7C30 92/09 - 92/16 + _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), // 0x7C31 - 0x7C38 92/17 - 92/24 + _T("鐚�"), _T("羂�, _T("��), _T("��), _T("��), _T("��), _T("[��"), _T("鐚�"), // 0x7C39 - 0x7C40 92/25 - 92/32 + _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), _T("鐚�"), // 0x7C41 - 0x7C48 92/33 - 92/40 + _T("鐚�"), _T("(腓�"), _T("(莢�"), _T("(��"), _T("(��"), _T("(篁�"), _T("(��), _T("��), // 0x7C49 - 0x7C50 92/41 - 92/48 + _T("��), _T("��), _T("��), _T("��), _T("^2"), _T("^3"), _T("(CD)"), _T("(vn)"), // 0x7C51 - 0x7C58 92/49 - 92/56 + _T("(ob)"), _T("(cb)"), _T("(ce"), _T("mb)"), _T("(hp)"), _T("(br)"), _T("(p)"), _T("(s)"), // 0x7C59 - 0x7C60 92/57 - 92/64 + _T("(ms)"), _T("(t)"), _T("(bs)"), _T("(b)"), _T("(tb)"), _T("(tp)"), _T("(ds)"), _T("(ag)"), // 0x7C61 - 0x7C68 92/65 - 92/72 + _T("(eg)"), _T("(vo)"), _T("(fl)"), _T("(ke"), _T("y)"), _T("(sa"), _T("x)"), _T("(sy"), // 0x7C69 - 0x7C70 92/73 - 92/80 + _T("n)"), _T("(or"), _T("g)"), _T("(pe"), _T("r)"), _T("(R)"), _T("(C)"), _T("(膊�), // 0x7C71 - 0x7C78 92/81 - 92/88 + _T("DJ"), _T("[羲�"), _T("Fax") // 0x7C79 - 0x7C7B 92/89 - 92/91 + }; + + static const TCHAR *aszSymbolsTable3[] = + { + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7D21 - 0x7D28 93/01 - 93/08 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7D29 - 0x7D30 93/09 - 93/16 + _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), _T("�����), // 0x7D31 - 0x7D38 93/17 - 93/24 + _T("�����), _T("��竺��), _T("鐚紙�鐚�), _T("鐚紙�鐚�), _T("鐚私�鐚�), _T("鐚私�鐚�), _T("鐚私�鐚�), _T("鐚脂�鐚�), // 0x7D39 - 0x7D40 93/25 - 93/32 + _T("鐚糸窪鐚�), _T("鐚私賢鐚�), _T("鐚糸勜悉"), _T("鐚紙�鐚�), _T("鐚肢軌鐚�), _T("鐚紙�鐚�), _T("��), _T("��, // 0x7D41 - 0x7D48 93/33 - 93/40 + _T("��), _T("ha"), _T("��), _T("��), _T("��), _T("��), _T("��), _T("1/2"), // 0x7D49 - 0x7D50 93/41 - 93/48 + _T("0/3"), _T("1/3"), _T("2/3"), _T("1/4"), _T("3/4"), _T("1/5"), _T("2/5"), _T("3/5"), // 0x7D51 - 0x7D58 93/49 - 93/56 + _T("4/5"), _T("1/6"), _T("5/6"), _T("1/7"), _T("1/8"), _T("1/9"), _T("1/10"), _T("��), // 0x7D59 - 0x7D60 93/57 - 93/64 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7D61 - 0x7D68 93/65 - 93/72 + _T("��), _T("��), _T("��), _T("��), _T("皃�), _T("��), _T("��), _T("(����"), // 0x7D69 - 0x7D70 93/73 - 93/80 + _T("��), _T("(��"), _T("(��"), _T("(紊ч�)"), _T("��), _T("(�潔�)"), _T("��), _T("��), // 0x7D71 - 0x7D78 93/81 - 93/88 + _T("��), _T("��), _T("��) // 0x7D79 - 0x7D7B 93/89 - 93/91 + }; + + static const TCHAR *aszSymbolsTable4[] = + { + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E21 - 0x7E28 94/01 - 94/08 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E29 - 0x7E30 94/09 - 94/16 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E31 - 0x7E38 94/17 - 94/24 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E39 - 0x7E40 94/25 - 94/32 + _T("(A)"), _T("(B)"), _T("(C)"), _T("(D)"), _T("(E)"), _T("(F)"), _T("(G)"), _T("(H)"), // 0x7E41 - 0x7E48 94/33 - 94/40 + _T("(I)"), _T("(J)"), _T("(K)"), _T("(L)"), _T("(M)"), _T("(N)"), _T("(O)"), _T("(P)"), // 0x7E49 - 0x7E50 94/41 - 94/48 + _T("(Q)"), _T("(R)"), _T("(S)"), _T("(T)"), _T("(U)"), _T("(V)"), _T("(W)"), _T("(X)"), // 0x7E51 - 0x7E58 94/49 - 94/56 + _T("(Y)"), _T("(Z)"), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E59 - 0x7E60 94/57 - 94/64 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E61 - 0x7E68 94/65 - 94/72 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E69 - 0x7E70 94/73 - 94/80 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7E71 - 0x7E78 94/81 - 94/88 + _T("��), _T("��), _T("��), _T("��), _T("��) // 0x7E79 - 0x7E7D 94/89 - 94/93 + }; + + static const TCHAR *aszSymbolsTable5[] = + { + _T("��), _T("篋�), _T("篁�), _T("篁�), _T("箴�), _T("篆�), _T("��), _T("��), // 0x7521 - 0x7528 85/01 - 85/08 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("荅�), _T("��), _T("��), // 0x7529 - 0x7530 85/09 - 85/16 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7531 - 0x7538 85/17 - 85/24 + _T("��), _T("鍜�), _T("紜�), _T("紮�), _T("紲�), _T("紿�), _T("絲�), _T("鍜�), // 0x7539 - 0x7540 85/25 - 85/32 + _T("��), _T("綺�), _T("綣�), _T("綵�), _T("緇�), _T("��), _T("��), _T("��), // 0x7541 - 0x7548 85/33 - 85/40 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("罅�), _T("��), _T("罎�), // 0x7549 - 0x7550 85/41 - 85/48 + _T("罎�), _T("罘�), _T("罟�), _T("罠�), _T("��), _T("��), _T("��), _T("罸�), // 0x7551 - 0x7558 85/49 - 85/56 + _T("羈�), _T("羇�), _T("鍠�), _T("羔�), _T("羞�), _T("羞�), _T("鍠�), _T("羹�), // 0x7559 - 0x7560 85/57 - 85/64 + _T("羶�), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7561 - 0x7568 85/65 - 85/72 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("鍠�), _T("��), _T("��), // 0x7569 - 0x7570 85/73 - 85/80 + _T("��), _T("��), _T("��), _T("禹�), _T("��), _T("��), _T("��), _T("��), // 0x7571 - 0x7578 85/81 - 85/88 + _T("脾�), _T("脾�), _T("腑�), _T("胼�), _T("��), _T("��) // 0x7579 - 0x757E 85/89 - 85/94 + }; + + static const TCHAR *aszSymbolsTable6[] = + { + _T("��), _T("腱�), _T("腮�), _T("膈�), _T("膂�), _T("��), _T("膓�), _T("臂�), // 0x7621 - 0x7628 86/01 - 86/08 + _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7629 - 0x7630 86/09 - 86/16 + _T("��), _T("��), _T("��), _T("��), _T("茖�), _T("茹�), _T("茫�), _T("莊�), // 0x7631 - 0x7638 86/17 - 86/24 + _T("莨�), _T("菴�), _T("��), _T("��), _T("��), _T("��), _T("��), _T("��), // 0x7639 - 0x7640 86/25 - 86/32 + _T("��), _T("��), _T("��), _T("��), _T("蕕�), _T("薀�), _T("蕭�), _T("薇�), // 0x7641 - 0x7648 86/33 - 86/40 + _T("薹�), _T("藝�), _T("藝�) // 0x7649 - 0x764B 86/41 - 86/43 + }; + + // �激������������ if((wCode >= 0x7A50U) && (wCode <= 0x7A74U)){ + strcpy(lpszDst, aszSymbolsTable1[wCode - 0x7A50U]); + } + else if((wCode >= 0x7C21U) && (wCode <= 0x7C7BU)){ + strcpy(lpszDst, aszSymbolsTable2[wCode - 0x7C21U]); + } + else if((wCode >= 0x7D21U) && (wCode <= 0x7D7BU)){ + strcpy(lpszDst, aszSymbolsTable3[wCode - 0x7D21U]); + } + else if((wCode >= 0x7E21U) && (wCode <= 0x7E7DU)){ + strcpy(lpszDst, aszSymbolsTable4[wCode - 0x7E21U]); + } + else if((wCode >= 0x7521U) && (wCode <= 0x757EU)){ + strcpy(lpszDst, aszSymbolsTable5[wCode - 0x7521U]); + } + else if((wCode >= 0x7621U) && (wCode <= 0x764BU)){ + strcpy(lpszDst, aszSymbolsTable6[wCode - 0x7621U]); + } + else{ + strcpy(lpszDst, TEXT("��)); + } + + return strlen(lpszDst); +} + +void ProcessEscapeSeq(const BYTE byCode) +{ + // ����宴�����若��潟���� + switch(m_byEscSeqCount){ + // 1������ + case 1U : + switch(byCode){ + // Invocation of code elements + case 0x6EU : LockingShiftGL(2U); m_byEscSeqCount = 0U; return; // LS2 + case 0x6FU : LockingShiftGL(3U); m_byEscSeqCount = 0U; return; // LS3 + case 0x7EU : LockingShiftGR(1U); m_byEscSeqCount = 0U; return; // LS1R + case 0x7DU : LockingShiftGR(2U); m_byEscSeqCount = 0U; return; // LS2R + case 0x7CU : LockingShiftGR(3U); m_byEscSeqCount = 0U; return; // LS3R + + // Designation of graphic sets + case 0x24U : + case 0x28U : m_byEscSeqIndex = 0U; break; + case 0x29U : m_byEscSeqIndex = 1U; break; + case 0x2AU : m_byEscSeqIndex = 2U; break; + case 0x2BU : m_byEscSeqIndex = 3U; break; + default : m_byEscSeqCount = 0U; return; // ����� } + break; + + // 2������ + case 2U : + if(DesignationGSET(m_byEscSeqIndex, byCode)){ + m_byEscSeqCount = 0U; + return; + } + + switch(byCode){ + case 0x20 : m_bIsEscSeqDrcs = true; break; + case 0x28 : m_bIsEscSeqDrcs = true; m_byEscSeqIndex = 0U; break; + case 0x29 : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 1U; break; + case 0x2A : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 2U; break; + case 0x2B : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 3U; break; + default : m_byEscSeqCount = 0U; return; // ����� } + break; + + // 3������ + case 3U : + if(!m_bIsEscSeqDrcs){ + if(DesignationGSET(m_byEscSeqIndex, byCode)){ + m_byEscSeqCount = 0U; + return; + } + } + else{ + if(DesignationDRCS(m_byEscSeqIndex, byCode)){ + m_byEscSeqCount = 0U; + return; + } + } + + if(byCode == 0x20U){ + m_bIsEscSeqDrcs = true; + } + else{ + // ����� m_byEscSeqCount = 0U; + return; + } + break; + + // 4������ + case 4U : + DesignationDRCS(m_byEscSeqIndex, byCode); + m_byEscSeqCount = 0U; + return; + } + + m_byEscSeqCount++; +} + +void LockingShiftGL(const BYTE byIndexG) +{ + // LSx + m_pLockingGL = &m_CodeG[(int)byIndexG]; +} + +void LockingShiftGR(const BYTE byIndexG) +{ + // LSxR + m_pLockingGR = &m_CodeG[(int)byIndexG]; +} + +void SingleShiftGL(const BYTE byIndexG) +{ + // SSx + m_pSingleGL = &m_CodeG[(int)byIndexG]; +} + +const bool DesignationGSET(const BYTE byIndexG_arg, const BYTE byCode) +{ + int byIndexG = (int)byIndexG_arg; + + // G�������c���������������� + switch(byCode){ + case 0x42U : m_CodeG[byIndexG] = CODE_KANJI; return true; // Kanji + case 0x4AU : m_CodeG[byIndexG] = CODE_ALPHANUMERIC; return true; // Alphanumeric + case 0x30U : m_CodeG[byIndexG] = CODE_HIRAGANA; return true; // Hiragana + case 0x31U : m_CodeG[byIndexG] = CODE_KATAKANA; return true; // Katakana + case 0x32U : m_CodeG[byIndexG] = CODE_MOSAIC_A; return true; // Mosaic A + case 0x33U : m_CodeG[byIndexG] = CODE_MOSAIC_B; return true; // Mosaic B + case 0x34U : m_CodeG[byIndexG] = CODE_MOSAIC_C; return true; // Mosaic C + case 0x35U : m_CodeG[byIndexG] = CODE_MOSAIC_D; return true; // Mosaic D + case 0x36U : m_CodeG[byIndexG] = CODE_PROP_ALPHANUMERIC; return true; // Proportional Alphanumeric + case 0x37U : m_CodeG[byIndexG] = CODE_PROP_HIRAGANA; return true; // Proportional Hiragana + case 0x38U : m_CodeG[byIndexG] = CODE_PROP_KATAKANA; return true; // Proportional Katakana + case 0x49U : m_CodeG[byIndexG] = CODE_JIS_X0201_KATAKANA; return true; // JIS X 0201 Katakana + case 0x39U : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_1; return true; // JIS compatible Kanji Plane 1 + case 0x3AU : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_2; return true; // JIS compatible Kanji Plane 2 + case 0x3BU : m_CodeG[byIndexG] = CODE_ADDITIONAL_SYMBOLS; return true; // Additional symbols + default : return false; // 筝���������c������� + } +} + +const bool DesignationDRCS(const BYTE byIndexG_arg, const BYTE byCode) +{ + int byIndexG = (int)byIndexG_arg; + + // DRCS�������c���������������� + switch(byCode){ + case 0x40U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-0 + case 0x41U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-1 + case 0x42U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-2 + case 0x43U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-3 + case 0x44U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-4 + case 0x45U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-5 + case 0x46U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-6 + case 0x47U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-7 + case 0x48U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-8 + case 0x49U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-9 + case 0x4AU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-10 + case 0x4BU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-11 + case 0x4CU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-12 + case 0x4DU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-13 + case 0x4EU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-14 + case 0x4FU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-15 + case 0x70U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // Macro + default : return false; // 筝���������c������� +} +} Index: /trunk/epgdumpr2/aribstr.h =================================================================== --- /trunk/epgdumpr2/aribstr.h (リビジョン 136) +++ /trunk/epgdumpr2/aribstr.h (リビジョン 136) @@ -0,0 +1,14 @@ +#ifndef ARIBSTR_H +#define ARIBSTR_H 1 + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int AribToString(char *lpszDst, const char *pSrcData, const int dwSrcLen); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif Index: /trunk/epgdumpr2/util.c =================================================================== --- /trunk/epgdumpr2/util.c (リビジョン 136) +++ /trunk/epgdumpr2/util.c (リビジョン 136) @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "aribstr.h" +#include "util.h" + +int strrep(char *buf, char *mae, char *ato) +{ + char *mitsuke, *findpos; + size_t maelen, atolen; + int shift; + + findpos = buf; + maelen = strlen(mae); + atolen = strlen(ato); + shift = (int)(strlen(ato)-strlen(mae)); + + if (maelen == 0 || strstr(findpos, mae) == NULL) return 0; + while ((mitsuke = strstr(findpos, mae)) != NULL) { + if (shift > 0) { + memmove(mitsuke + shift, mitsuke, strlen(mitsuke) + 1); + } else if (shift < 0) { + memmove(mitsuke, mitsuke - shift, strlen(mitsuke) + shift + 1); + } + memmove(mitsuke, ato, atolen); + findpos = mitsuke + atolen; + } + return 1; +} + +int getBit(unsigned char *byte, int *pbit, int gbit) { + int pbyte = *pbit / 8; + unsigned char *fbyte = byte + pbyte; + + int cutbit = *pbit - (pbyte * 8); + int lcutbit = 32 - (cutbit + gbit); + + unsigned char tbuf[4]; /* int���紊�2bit */ + unsigned int tnum; + + memcpy(tbuf, fbyte, sizeof(unsigned char) * 4); + + /* ������������荀�it������ */ + tbuf[0] = tbuf[0] << cutbit; + tbuf[0] = tbuf[0] >> cutbit; + + /* int�������障� */ + tnum = tbuf[0] << 24 | tbuf[1] << 16 | tbuf[2] << 8 | tbuf[3]; + + /* 緇�����荀���ゃ������� */ + tnum = tnum >> lcutbit; + + *pbit += gbit; + + return tnum; + +} + +void getStr(char *tostr, unsigned char *byte, int *pbit, int len) { + char str[MAXSECLEN]; + int pbyte = *pbit / 8; + unsigned char *fbyte = byte + pbyte; + + memset(str, 0, sizeof(char) * MAXSECLEN); + memcpy(str, fbyte, len); + + *pbit += (len * 8); + + AribToString(tostr, str, len); + + return; + +} + +int parseOTHERdesc(unsigned char *data) { + int boff = 0; + int descriptor_tag; + int descriptor_length; + + descriptor_tag = getBit(data, &boff, 8); + descriptor_length = getBit(data, &boff, 8); + + /* printf("other desc_tag:0x%x\n", descriptor_tag); */ + + return descriptor_length + 2; +} Index: /trunk/epgdumpr2/tags =================================================================== --- /trunk/epgdumpr2/tags (リビジョン 136) +++ /trunk/epgdumpr2/tags (リビジョン 136) @@ -0,0 +1,113 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.7 // +AribToString aribstr.c /^int AribToString($/;" f +AribToStringInternal aribstr.c /^const DWORD AribToStringInternal(TCHAR *lpszDst, $/;" f +BYTE aribstr.c 28;" d file: +CAT_COUNT epgdump.c 18;" d file: +CODE_ADDITIONAL_SYMBOLS aribstr.c 24;" d file: +CODE_ALPHANUMERIC aribstr.c 11;" d file: +CODE_HIRAGANA aribstr.c 12;" d file: +CODE_JIS_KANJI_PLANE_1 aribstr.c 22;" d file: +CODE_JIS_KANJI_PLANE_2 aribstr.c 23;" d file: +CODE_JIS_X0201_KATAKANA aribstr.c 21;" d file: +CODE_KANJI aribstr.c 10;" d file: +CODE_KATAKANA aribstr.c 13;" d file: +CODE_MOSAIC_A aribstr.c 14;" d file: +CODE_MOSAIC_B aribstr.c 15;" d file: +CODE_MOSAIC_C aribstr.c 16;" d file: +CODE_MOSAIC_D aribstr.c 17;" d file: +CODE_PROP_ALPHANUMERIC aribstr.c 18;" d file: +CODE_PROP_HIRAGANA aribstr.c 19;" d file: +CODE_PROP_KATAKANA aribstr.c 20;" d file: +CODE_SET aribstr.c 36;" d file: +CODE_UNKNOWN aribstr.c 9;" d file: +CONTENT_TYPE epgdump.c /^}CONTENT_TYPE;$/;" t typeref:struct:_ContentTYPE file: +CalcCrc ts.c /^unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len) {$/;" f +Category epgdump.c /^char Category[1024];$/;" v +ContentCatList epgdump.c /^static CONTENT_TYPE ContentCatList[CAT_COUNT] = {$/;" v file: +DWORD aribstr.c 30;" d file: +DesignationDRCS aribstr.c /^const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode)$/;" f +DesignationGSET aribstr.c /^const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode)$/;" f +GetEIT epgdump.c /^void GetEIT(FILE *infile, FILE *outfile, SVT_CONTROL *svtcur, SECcache *secs, int count)$/;" f +GetSDT epgdump.c /^void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count)$/;" f +LockingShiftGL aribstr.c /^void LockingShiftGL(const BYTE byIndexG)$/;" f +LockingShiftGR aribstr.c /^void LockingShiftGR(const BYTE byIndexG)$/;" f +ProcessCharCode aribstr.c /^const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet)$/;" f +ProcessEscapeSeq aribstr.c /^void ProcessEscapeSeq(const BYTE byCode)$/;" f +PutAlphanumericChar aribstr.c /^const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutHiraganaChar aribstr.c /^const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutJisKatakanaChar aribstr.c /^const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutKanjiChar aribstr.c /^const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutKatakanaChar aribstr.c /^const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutSymbolsChar aribstr.c /^const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode)$/;" f +SECCOUNT epgdump.c 140;" d file: +STATION epgdump.c /^} STATION;$/;" t typeref:struct:_TAG_STATION file: +ServiceName epgdump.c /^char ServiceName[1024];$/;" v +SingleShiftGL aribstr.c /^void SingleShiftGL(const BYTE byIndexG)$/;" f +TCHAR aribstr.c 27;" d file: +TEXT aribstr.c 34;" d file: +WORD aribstr.c 29;" d file: +_ContentTYPE epgdump.c /^typedef struct _ContentTYPE{$/;" s file: +_T aribstr.c 35;" d file: +_TAG_STATION epgdump.c /^typedef struct _TAG_STATION$/;" s file: +abCharSizeTable aribstr.c /^static const bool abCharSizeTable[] =$/;" v file: +bool aribstr.c 31;" d file: +bsSta epgdump.c /^static STATION bsSta[] = {$/;" v file: +bsSta xmldata.c /^static STATION bsSta[] = {$/;" v file: +bsStaCount epgdump.c /^static int bsStaCount = sizeof(bsSta) \/ sizeof (STATION);$/;" v file: +bsStaCount xmldata.c /^static int bsStaCount = sizeof(bsSta) \/ sizeof (STATION);$/;" v file: +cd epgdump.c /^iconv_t cd ;$/;" v +checkEEVTDitem eit.c /^int checkEEVTDitem(EEVTDitem *save, EEVTDitem *new, int descriptor_number) {$/;" f +checkcrc ts.c /^int checkcrc(SECcache *secs) {$/;" f +convertjis aribstr.c /^WORD convertjis(DWORD jiscode) {$/;" f +csSta epgdump.c /^static STATION csSta[] = {$/;" v file: +csSta xmldata.c /^static STATION csSta[] = {$/;" v file: +csStaCount epgdump.c /^static int csStaCount = sizeof(csSta) \/ sizeof (STATION);$/;" v file: +csStaCount xmldata.c /^static int csStaCount = sizeof(csSta) \/ sizeof (STATION);$/;" v file: +dumpEIT eit.c /^void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int transport_stream_id, EIT_CONTROL *eittop)$/;" f +dumpSDT sdt.c /^void dumpSDT(unsigned char *ptr, SVT_CONTROL *top)$/;" f +english epgdump.c /^ char *english ;$/;" m struct:_ContentTYPE file: +enqueue eit.c /^void enqueue(EIT_CONTROL *top, EIT_CONTROL *eitptr)$/;" f +enqueue_sdt sdt.c /^void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr)$/;" f +false aribstr.c 33;" d file: +getBit util.c /^int getBit(unsigned char *byte, int *pbit, int gbit) {$/;" f +getStr util.c /^void getStr(char *tostr, unsigned char *byte, int *pbit, int len) {$/;" f +japanese epgdump.c /^ char *japanese ;$/;" m struct:_ContentTYPE file: +m_CodeG aribstr.c /^static int m_CodeG[4];$/;" v file: +m_bIsEscSeqDrcs aribstr.c /^static bool m_bIsEscSeqDrcs;$/;" v file: +m_byEscSeqCount aribstr.c /^static BYTE m_byEscSeqCount;$/;" v file: +m_byEscSeqIndex aribstr.c /^static BYTE m_byEscSeqIndex;$/;" v file: +m_pLockingGL aribstr.c /^static int *m_pLockingGL;$/;" v file: +m_pLockingGR aribstr.c /^static int *m_pLockingGR;$/;" v file: +m_pSingleGL aribstr.c /^static int *m_pSingleGL;$/;" v file: +main epgdump.c /^int main(int argc, char *argv[])$/;" f +name epgdump.c /^ char *name;$/;" m struct:_TAG_STATION file: +onId epgdump.c /^ int onId; \/\/ TransportStreamID$/;" m struct:_TAG_STATION file: +ontv epgdump.c /^ char *ontv;$/;" m struct:_TAG_STATION file: +parseContentDesc eit.c /^int parseContentDesc(unsigned char *data, ContentDesc *desc) {$/;" f +parseEEVTDhead eit.c /^int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) {$/;" f +parseEEVTDitem eit.c /^int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) {$/;" f +parseEEVTDtail eit.c /^int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) {$/;" f +parseEITbody eit.c /^int parseEITbody(unsigned char *data, EITbody *b) {$/;" f +parseEIThead eit.c /^int parseEIThead(unsigned char *data, EIThead *h) {$/;" f +parseOTHERdesc util.c /^int parseOTHERdesc(unsigned char *data) {$/;" f +parseSDTbody sdt.c /^int parseSDTbody(unsigned char *data, SDTbody *b) {$/;" f +parseSDThead sdt.c /^int parseSDThead(unsigned char *data, SDThead *h) {$/;" f +parseSEVTdesc eit.c /^int parseSEVTdesc(unsigned char *data, SEVTdesc *desc) {$/;" f +parseSVCdesc sdt.c /^int parseSVCdesc(unsigned char *data, SVCdesc *desc) {$/;" f +parseSeriesDesc eit.c /^int parseSeriesDesc(unsigned char *data, SeriesDesc *desc) {$/;" f +readTS ts.c /^SECcache *readTS(FILE *in, SECcache secs[], int size) {$/;" f +searcheit eit.c /^EIT_CONTROL *searcheit(EIT_CONTROL *top, int servid, int eventid)$/;" f +serachid sdt.c /^int serachid(SVT_CONTROL *top, int service_id)$/;" f +subtitle epgdump.c /^char subtitle[1024];$/;" v +svId epgdump.c /^ int svId; \/\/ ServiceID$/;" m struct:_TAG_STATION file: +svttop epgdump.c /^SVT_CONTROL *svttop = NULL;$/;" v +timecmp eit.c /^void timecmp(int *thh, int *tmm, int *tss,$/;" f +title epgdump.c /^char title[1024];$/;" v +true aribstr.c 32;" d file: +tsId epgdump.c /^ int tsId; \/\/ OriginalNetworkID$/;" m struct:_TAG_STATION file: +xmlspecialchars epgdump.c /^void xmlspecialchars(char *str)$/;" f Index: /trunk/epgdumpr2/eit.c =================================================================== --- /trunk/epgdumpr2/eit.c (リビジョン 136) +++ /trunk/epgdumpr2/eit.c (リビジョン 136) @@ -0,0 +1,608 @@ +#include +#include +#include + +#include "eit.h" + +char *subtitle_cnv_str[] = { + NULL +}; +static void timecmp(int *,int *,int *, + int, int, int); + +int parseEIThead(unsigned char *data, EIThead *h) { + int boff = 0; + + memset(h, 0, sizeof(EIThead)); + + h->table_id = getBit(data, &boff, 8); + h->section_syntax_indicator = getBit(data, &boff, 1); + h->reserved_future_use = getBit(data, &boff, 1); + h->reserved1 = getBit(data, &boff, 2); + h->section_length =getBit(data, &boff,12); + h->service_id = getBit(data, &boff, 16); + h->reserved2 = getBit(data, &boff, 2); + h->version_number = getBit(data, &boff, 5); + h->current_next_indicator = getBit(data, &boff, 1); + h->section_number = getBit(data, &boff, 8); + h->last_section_number = getBit(data, &boff, 8); + h->transport_stream_id = getBit(data, &boff, 16); + h->original_network_id = getBit(data, &boff, 16); + h->segment_last_section_number = getBit(data, &boff, 8); + h->last_table_id = getBit(data, &boff, 8); + + return 14; +} + +int parseEITbody(unsigned char *data, EITbody *b) +{ + int boff = 0; + int tnum; + char buf[4]; + + memset(b, 0, sizeof(EITbody)); + + b->event_id = getBit(data, &boff, 16); + + memcpy(b->start_time, data + boff / 8, 5); + /* b->start_time = getBit(data, &boff, 40); */ + boff += 40; + memcpy(b->duration, data + boff / 8, 3); + /* b->duration = getBit(data, &boff, 24); */ + boff += 24; + b->running_status = getBit(data, &boff, 3); + b->free_CA_mode = getBit(data, &boff, 1); + b->descriptors_loop_length = getBit(data, &boff, 12); + + /* �ヤ�紊��*/ + tnum = (b->start_time[0] & 0xFF) << 8 | (b->start_time[1] & 0xFF); + + b->yy = (tnum - 15078.2) / 365.25; + b->mm = ((tnum - 14956.1) - (int)(b->yy * 365.25)) / 30.6001; + b->dd = (tnum - 14956) - (int)(b->yy * 365.25) - (int)(b->mm * 30.6001); + + if(b->dd == 0) { + printf("aa"); + } + + if(b->mm == 14 || b->mm == 15) { + b->yy += 1; + b->mm = b->mm - 1 - (1 * 12); + } else { + b->mm = b->mm - 1; + } + + b->yy += 1900; + + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->start_time[2]); + b->hh = atoi(buf); + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->start_time[3]); + b->hm = atoi(buf); + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->start_time[4]); + b->ss = atoi(buf); + + if((b->duration[0] == 0xFF) && (b->duration[1] == 0xFF) && (b->duration[2] == 0xFF)){ + b->dhh = b->dhm = b->dss = 0; + }else{ + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->duration[0]); + b->dhh = atoi(buf); + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->duration[1]); + b->dhm = atoi(buf); + memset(buf, '\0', sizeof(buf)); + sprintf(buf, "%x", b->duration[2]); + b->dss = atoi(buf); + } + return 12; +} + +int parseSEVTdesc(unsigned char *data, SEVTdesc *desc) { + int boff = 0; + + memset(desc, 0, sizeof(SEVTdesc)); + + desc->descriptor_tag = getBit(data, &boff, 8); + if((desc->descriptor_tag & 0xFF) != 0x4D) { + return -1; + } + desc->descriptor_length = getBit(data, &boff, 8); + memcpy(desc->ISO_639_language_code, data + boff / 8, 3); + /* desc->ISO_639_language_code = getBit(data, &boff, 24); */ + boff += 24; + desc->event_name_length = getBit(data, &boff, 8); + getStr(desc->event_name, data, &boff, desc->event_name_length); + desc->text_length = getBit(data, &boff, 8); + getStr(desc->text, data, &boff, desc->text_length); + + return desc->descriptor_length + 2; +} + +int parseContentDesc(unsigned char *data, ContentDesc *desc) { + int boff = 0; + + memset(desc, 0, sizeof(ContentDesc)); + + desc->descriptor_tag = getBit(data, &boff, 8); + if((desc->descriptor_tag & 0xFF) != 0x54) { + return -1; + } + desc->descriptor_length = getBit(data, &boff, 8); + memcpy(desc->content, data+(boff/8), desc->descriptor_length); + //getStr(desc->content, data, &boff, desc->descriptor_length); + return desc->descriptor_length + 2; +} + +int parseSeriesDesc(unsigned char *data, SeriesDesc *desc) { + int boff = 0; + + memset(desc, 0, sizeof(SeriesDesc)); + + desc->descriptor_tag = getBit(data, &boff, 8); + if((desc->descriptor_tag & 0xFF) != 0xD5) { + return -1; + } + desc->descriptor_length = getBit(data, &boff, 8); + desc->series_id = getBit(data, &boff, 16); + desc->repeat_label = getBit(data, &boff, 4); + desc->program_pattern = getBit(data, &boff, 3); + desc->expire_date_valid_flag = getBit(data, &boff, 1); + + desc->expire_date = getBit(data, &boff, 16); + //memcpy(desc->expire_date, data + boff / 8, 2); + //boff += 16; + + desc->episode_number = getBit(data, &boff, 12); + desc->last_episode_number = getBit(data, &boff, 12); + + getStr(desc->series_name_char, data, &boff, desc->descriptor_length - 8); + return desc->descriptor_length + 2; +} + +int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) { + int boff = 0; + + memset(desc, 0, sizeof(EEVTDhead)); + + desc->descriptor_tag = getBit(data, &boff, 8); + if((desc->descriptor_tag & 0xFF) != 0x4E) { + return -1; + } + desc->descriptor_length = getBit(data, &boff, 8); + desc->descriptor_number = getBit(data, &boff, 4); + desc->last_descriptor_number = getBit(data, &boff, 4); + memcpy(desc->ISO_639_language_code, data + boff / 8, 3); + /* desc->ISO_639_language_code = getBit(data, &boff, 24); */ + boff += 24; + + desc->length_of_items = getBit(data, &boff, 8); + + return 7; +} + +int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) { + int boff = 0; + + memset(desc, 0, sizeof(EEVTDitem)); + + desc->item_description_length = getBit(data, &boff, 8); + getStr(desc->item_description, data, &boff, desc->item_description_length); + + desc->item_length = getBit(data, &boff, 8); + memcpy(desc->item, data + (boff / 8), desc->item_length); + /* getStr(desc->item, data, &boff, desc->item_length); */ + + return desc->item_description_length + desc->item_length + 2; +} + +int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) { + int boff = 0; + + memset(desc, 0, sizeof(EEVTDtail)); + + desc->text_length = getBit(data, &boff, 8); + getStr(desc->text, data, &boff, desc->text_length); + + return desc->text_length + 1; +} + +int checkEEVTDitem(EEVTDitem *save, EEVTDitem *new, int descriptor_number) { + + EEVTDitem swap; + int boff = 0; + + if(new == NULL) { + if(save->item_length != 0) { + swap = *save; + getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length); + return 1; + } else { + return 0; + } + } + + if(new->item_description_length == 0) { + /* 膓�� 篆�� */ + memcpy(save->item + save->item_length, new->item, new->item_length); + save->item_length += new->item_length; + return 0; + } else { + /* ����若���ave����桁�莟<������ave������? */ + if(save->item_length != 0) { + /* ���羝�������*/ + swap = *save; + getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length); + swap = *new; + *new = *save; + *save = swap; + save->descriptor_number = descriptor_number; + } else { + *save = *new; + save->descriptor_number = descriptor_number; + return 0; + } + } + + return 1; +} +EIT_CONTROL *searcheit(EIT_CONTROL *top, int servid, int eventid) +{ + EIT_CONTROL *cur ; + cur = top ; + + while(cur != NULL){ + if((cur->event_id == eventid) && (cur->servid == servid)){ + return cur ; + } + + cur = cur->next ; + } + return NULL ; +} +char *strstr_eucjp(const char *str, const char *search) +{ + char *pos ; + pos = (char *)str ; + + while (*pos != '\0') { + if (*pos == *search) { + if (strncmp(pos, search, strlen(search)) == 0) { + return pos ; + } + } + if ((unsigned char)*pos == 0x8Fu) { + pos += 3 ; + } else if ((unsigned char)*pos >= 0x80u) { + pos += 2 ; + } else { + pos += 1 ; + } + } + + return NULL ; +} +void conv_title_subtitle(EIT_CONTROL *eitptr) +{ + int lp = 0 ; +// size_t addsize ; + char *ptr ; + char *ptr2 ; + char *newsubtitle ; + + for(lp = 0 ; subtitle_cnv_str[lp] != NULL ; lp++){ + ptr = strstr(eitptr->title, subtitle_cnv_str[lp]); + if(ptr == NULL){ + continue ; + } + // �帥������������������� if(ptr == eitptr->title){ + continue ; + } + ptr2 = ptr ; + for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ ); + for( ; (unsigned char)*ptr2 == 0xA1u && (unsigned char)*(ptr2+1) == 0xA1u ; ptr2 += 2); + for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ ); + newsubtitle = calloc(1, ((strlen(ptr2) + 2) + (strlen(eitptr->subtitle) + 1))); + memcpy(newsubtitle, ptr2, strlen(ptr2)); +// *(newsubtitle+strlen(ptr)) = ' '; + strcat(newsubtitle, "��); + *ptr = '\0'; + strcat(newsubtitle, eitptr->subtitle); + free(eitptr->subtitle); + eitptr->subtitle = newsubtitle ; + return ; + } +} +void enqueue(EIT_CONTROL *top, EIT_CONTROL *eitptr) +{ + EIT_CONTROL *cur ; + cur = top ; + int rc ; + + if(top->next == NULL){ + top->next = eitptr ; + eitptr->prev = top ; + return ; + } + cur = top->next ; + while(cur != NULL){ + rc = memcmp(&cur->yy, &eitptr->yy, (sizeof(int) * 3)); + if(rc == 0){ + rc = memcmp(&cur->hh, &eitptr->hh, (sizeof(int) * 3)); + if(rc == 0){ + free(eitptr->title); + free(eitptr->subtitle); + free(eitptr); + return ; + } + if(rc > 0){ + if(cur->prev != 0){ + cur->prev->next = eitptr ; + eitptr->prev = cur->prev ; + } + cur->prev = eitptr ; + eitptr->next = cur ; + conv_title_subtitle(eitptr); + return ; + } + } + if(rc > 0){ + if(cur->prev != 0){ + cur->prev->next = eitptr ; + eitptr->prev = cur->prev ; + } + cur->prev = eitptr ; + eitptr->next = cur ; + conv_title_subtitle(eitptr); + return ; + } + if(cur->next == NULL){ + cur->next = eitptr ; + eitptr->prev = cur ; + conv_title_subtitle(eitptr); + return ; + } + cur = cur->next ; + } + return ; + +} + +void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int transport_stream_id, EIT_CONTROL *eittop) +{ + + EIThead eith; + EITbody eitb; + SEVTdesc sevtd; + + EEVTDhead eevthead; + EEVTDitem eevtitem; + EEVTDtail eevttail; + + EEVTDitem save_eevtitem; + + EIT_CONTROL *cur ; + + int len = 0; + int loop_len = 0; + int loop_blen = 0; + int loop_elen = 0; + + int ehh, emm, ess; + + /* EIT */ + len = parseEIThead(ptr, &eith); + + ptr += len; + loop_len = eith.section_length - (len - 3 + 4); // 3�����������4��RC + while(loop_len > 0) { + /* �g�����≦宍�ゃ��潟����羲√��潟����羈c��ャ���� + ���������������膓����������tem_description_length�� 荐������������������ゆ��с���������*/ + memset(&save_eevtitem, 0, sizeof(EEVTDitem)); + + len = parseEITbody(ptr, &eitb); + ptr += len; + loop_len -= len; + + /* printf("evtid:%d\n", eitb.event_id); */ + + loop_blen = eitb.descriptors_loop_length; + loop_len -= loop_blen; + while(loop_blen > 0) { + + len = parseSEVTdesc(ptr, &sevtd); + if(len > 0) { + + /* + if(eith.service_id == 19304 && + eitb.event_id == 46564) { + printf("aa"); + } + */ + + ehh = eitb.hh; + emm = eitb.hm; + ess = eitb.ss; + if(eith.service_id != serv_id){ + ptr += len; + loop_blen -= len; + continue ; + } + + timecmp(&ehh, &emm, &ess, + eitb.dhh, eitb.dhm, eitb.dss); + cur = searcheit(eittop, eith.service_id, eitb.event_id); + if(cur == NULL){ + cur = calloc(1, sizeof(EIT_CONTROL)); + cur->event_id = eitb.event_id ; + cur->servid = eith.service_id ; + cur->title = calloc(1, (strlen(sevtd.event_name) + 1)); + + memcpy(cur->title, sevtd.event_name, strlen(sevtd.event_name)); + cur->subtitle = calloc(1, (strlen(sevtd.text) + 1)); + memcpy(cur->subtitle, sevtd.text, strlen(sevtd.text)); + cur->yy = eitb.yy; + cur->mm = eitb.mm; + cur->dd = eitb.dd; + cur->hh = eitb.hh; + cur->hm = eitb.hm; + cur->ss = eitb.ss; + cur->ehh = eitb.dhh; + cur->emm = eitb.dhm; + cur->ess = eitb.dss ; + cur->table_id = eith.table_id ; + enqueue(eittop, cur); + } + } else { + len = parseEEVTDhead(ptr, &eevthead); + + /* + if(eith.service_id == 19304 && + eitb.event_id == 46564) { + printf("aa"); + } + */ + + + if(len > 0) { + ptr += len; + loop_blen -= len; + + loop_elen = eevthead.length_of_items; + loop_len -= loop_elen; + while(loop_elen > 0) { + len = parseEEVTDitem(ptr, &eevtitem); + + ptr += len; + loop_elen -= len; + loop_blen -= len; + + if(checkEEVTDitem(&save_eevtitem, &eevtitem, + eevthead.descriptor_number)) { +#if 0 + if(mode == 1) { /* long format */ + fprintf(out, "EEVT,%d,%d,%d,%s,%s\n", + eith.service_id, + eitb.event_id, + eevtitem.descriptor_number, /* ������ */ + eevtitem.item_description, + eevtitem.item); + } +#endif + } + } + + len = parseEEVTDtail(ptr, &eevttail); +#if 0 + if(mode == 1) { /* long format */ + fprintf(out, "EEVTt,%d,%d,%d,%s\n", + eith.service_id, + eitb.event_id, + eevthead.descriptor_number, + eevttail.text); + } +#endif + } else { + ContentDesc contentDesc; + len = parseContentDesc(ptr, &contentDesc); + if (len > 0) { +// int header_printed = 0; + for (int i = 0; i < contentDesc.descriptor_length - 1; i+=2) { + /* + if (0xff == (unsigned char)contentDesc.content[i]) + continue; + */ +#if 0 + if (!header_printed) { + fprintf(out, "Content,%d,%d", + eith.service_id, + eitb.event_id); + header_printed = 1; + } +#endif +#if 0 + fprintf(out, ",%02x%02x", (unsigned char)contentDesc.content[i], (unsigned char)contentDesc.content[i+1]); +#endif + } + if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){ + cur = searcheit(eittop, eith.service_id, eitb.event_id); + if(cur != NULL){ + cur->content_type = (unsigned char)(contentDesc.content[0] >> 4); +#if 0 + fprintf(stdout, "%s:", cur->title); + fprintf(stdout, ",%02x%02x", (unsigned char)contentDesc.content[0], (unsigned char)contentDesc.content[1]); + fprintf(stdout, ",%02x%02x\n", (unsigned char)contentDesc.content[2], (unsigned char)contentDesc.content[3]); +#endif + + } +#if 0 + if (header_printed) { + fprintf(out, "\n"); + } +#endif + } + } else { + SeriesDesc seriesDesc; + len = parseSeriesDesc(ptr, &seriesDesc); + if (len > 0) { +#if 0 + fprintf(out, "Series,%d,%d,series=%d,repeat=%01x,pattern=%d,expire_valid=%d,expire=%04x,epinum=%d,lastepinum=%d,%s\n", + eith.service_id, + eitb.event_id, + seriesDesc.series_id, + seriesDesc.repeat_label, + seriesDesc.program_pattern, + seriesDesc.expire_date_valid_flag, + seriesDesc.expire_date, + seriesDesc.episode_number, + seriesDesc.last_episode_number, + seriesDesc.series_name_char); +#endif + } else { + len = parseOTHERdesc(ptr); + } + } + } + } + ptr += len; + loop_blen -= len; + } + /* �������������с���*/ + + if(checkEEVTDitem(&save_eevtitem, NULL, 0)) { +#if 0 + if(mode == 1) { /* long format */ + fprintf(out, "EEVT,%d,%d,%d,%s,%s\n", + eith.service_id, + eitb.event_id, + save_eevtitem.descriptor_number, + save_eevtitem.item_description, + save_eevtitem.item); + } +#endif + } + } + + return; +} + +void timecmp(int *thh, int *tmm, int *tss, + int dhh, int dmm, int dss) { + + int ama; + + *tss += dss; + ama = *tss % 60; + *tmm += (*tss / 60); + *tss = ama; + + *tmm += dmm; + ama = *tmm % 60; + *thh += (*tmm / 60); + *tmm = ama; + + *thh += dhh; + +} Index: /trunk/epgdumpr2/util.h =================================================================== --- /trunk/epgdumpr2/util.h (リビジョン 136) +++ /trunk/epgdumpr2/util.h (リビジョン 136) @@ -0,0 +1,18 @@ +#ifndef UTIL_H +#define UTILH 1 + +#define MAXSECLEN 4096 + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int getBit(unsigned char *byte, int *pbit, int gbit); + void getStr(char *tostr, unsigned char *byte, int *pbit, int len); + int parseOTHERdesc(unsigned char *data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif Index: /trunk/epgdumpr2/ts.c =================================================================== --- /trunk/epgdumpr2/ts.c (リビジョン 136) +++ /trunk/epgdumpr2/ts.c (リビジョン 136) @@ -0,0 +1,325 @@ +#include +#include +#include + +#include "ts.h" + +static unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len); +static int checkcrc(SECcache *secs); + +SECcache *readTS(FILE *in, SECcache secs[], int size) { + static int rcount = 0; + static int ridx = -1; + + TSpacket pk; + + unsigned char buf[1024]; + + int boff; + int len; + unsigned char *payptr; + + int inchar; + int i; + + /* sync�������ц��翠��違� */ + if(rcount == 0) { + while((inchar = fgetc(in)) != EOF) { + if((inchar & 0xFF) == 0x47) { + //fseek(in, -1, SEEK_CUR); + ungetc(inchar, in); + break; + } + } + if(inchar == EOF) { + return NULL; + } + } + +retry: + + /* �祉��鴻�罧��������? */ + if(ridx >= 0 && secs[ridx].cont) { + /* ������������ */ + if((secs[ridx].cur.payload[secs[ridx].curlen] & 0xFF) == 0xFF) { + secs[ridx].cont = 0; + secs[ridx].seclen = 0; + secs[ridx].setlen = 0; + secs[ridx].curlen = 0; + } else { + len = secs[ridx].cur.payloadlen - secs[ridx].curlen; + /* ���荐��羝�������� */ + if(len == 0) { + secs[ridx].cont = 0; + secs[ridx].seclen = 0; + secs[ridx].setlen = 0; + secs[ridx].curlen = 0; + } else { + /* �����eclen��隈������TS�������������違���@@ + if(secs[ridx].pid == 0x12) { + int check = secs[ridx].cur.payload[secs[ridx].curlen] & 0xFF; + if(!(check == 0x4E || + check == 0x4F || + (check >= 0x50 && check <= 0x6F))) { + secs[ridx].curlen -= 3; + } + } + */ + + boff = 12; + secs[ridx].seclen = getBit(&secs[ridx].cur.payload[secs[ridx].curlen], &boff, 12) + 3; // ����� + /* + if(secs[ridx].seclen == 2334) { + printf("aa"); + } + */ + + /* TS����翠�-荐��羝������翠� */ + if(secs[ridx].seclen > len) { + memcpy(secs[ridx].buf, &secs[ridx].cur.payload[secs[ridx].curlen], len); + secs[ridx].setlen = len; + secs[ridx].curlen = 0; + secs[ridx].cont = 1; + /* 罨<�����若�茯��莨若� */ + } else { + memcpy(secs[ridx].buf, + &secs[ridx].cur.payload[secs[ridx].curlen], secs[ridx].seclen); + secs[ridx].setlen = secs[ridx].seclen; + secs[ridx].curlen += secs[ridx].seclen; + secs[ridx].cont = 1; + + /* CRC����с���*/ + if(checkcrc(&(secs[ridx]))) { + return &(secs[ridx]); /* �祉� */ + } + goto retry; /* ���筝�� */ + } + } + } + } + + int roffset = 0; + while(1) { + if(fread(buf+roffset, 188-roffset, 1, in) != 1) { + /* 罧������� */ + return NULL; + } + roffset = 0; + rcount++; + + if((buf[0] & 0xFF) != 0x47) { + /* �����uf筝��0x47������������ */ + for(i = 1; i < 188; i++) { + if((buf[i] & 0xFF) == 0x47) { + break; + } + } + + if(i < 188) { + /* ����������粋昭�帥����������seek */ + //fseek(in, (188 - i) * -1, SEEK_CUR); + roffset = i; + memmove(buf, buf + i, 188 - i); + continue; + } + + while((inchar = fgetc(in)) != EOF) { + if((inchar & 0xFF) == 0x47) { + //fseek(in, -1, SEEK_CUR); + ungetc(inchar, in); + break; + } + } + if(inchar == EOF) { + return NULL; + } + continue; + } + + /* + if(rcount == 406502) { + printf("aa"); + } + */ + + + pk.rcount = rcount; + + boff = 0; + pk.sync = getBit(buf, &boff, 8); + pk.transport_error_indicator = getBit(buf, &boff, 1); + pk.payload_unit_start_indicator = getBit(buf, &boff, 1); + pk.transport_priority = getBit(buf, &boff, 1); + pk.pid = getBit(buf, &boff, 13); + pk.transport_scrambling_control = getBit(buf, &boff, 2); + pk.adaptation_field_control = getBit(buf, &boff, 2); + pk.continuity_counter = getBit(buf, &boff, 4); + + /* + adaptation_field_control 2 bslbf + continuity_counter 4 uimsbf + if(adaptation_field_control = = '10' || adaptation_field_control = = '11'){ + adaptation_field() + } + ... + adaptation_field() { + adaptation_field_length 8 uimsbf + if (adaptation_field_length > 0) { + discontinuity_indicator.... + + 00 Reserved for future use by ISO/IEC + 01 No adaptation_field, payload only + 10 Adaptation_field only, no payload + 11 Adaptation_field followed by payload + + */ + + pk.payloadlen = 184; + + if(pk.adaptation_field_control == 2) { + continue; + } + + if(pk.adaptation_field_control == 3) { + len = getBit(buf, &boff, 8); + payptr = buf + (boff / 8) + len; + pk.payloadlen -= (len + 1); + } else { + payptr = buf + (boff / 8); + } + if(pk.payloadlen < 0){ + continue ; + } + + /* + if the Transport Stream packet carries the first byte of a PSI section, the payload_unit_start_indicator value + shall be '1', indicating that the first byte of the payload of this Transport Stream packet carries the pointer_field. + */ + if(pk.payload_unit_start_indicator == 1) { + /* pointer_field��������*/ + payptr += 1; + pk.payloadlen -= 1; + } + memset(pk.payload, 0xFF, sizeof(pk.payload)); + if(pk.payloadlen > sizeof(pk.payload)) + continue; + memcpy(pk.payload, payptr, pk.payloadlen); + + + /* + if(pk.rcount == 62) { + printf("62\n"); + } + + if(pk.rcount == 63) { + printf("63\n"); + } + */ + + /* ��������id��∈茯�*/ + for(int i = 0;i < size; i++) { + if(secs[i].pid == pk.pid) { + secs[i].cur = pk; + /* ��賢���筝������� */ + if(!secs[i].cont) { + /* ��� �祉��激��渇�����鴻� */ + boff = 12; + secs[i].seclen = getBit(secs[i].cur.payload, &boff, 12) + 3; // ����� + /* + if(secs[i].seclen == 2334) { + printf("aa"); + } + */ + + if(secs[i].seclen > secs[i].cur.payloadlen) { + memcpy(secs[i].buf, secs[i].cur.payload, secs[i].cur.payloadlen); + secs[i].setlen = secs[i].cur.payloadlen; + secs[i].cont = 1; + continue; + } + memcpy(secs[i].buf, secs[i].cur.payload, secs[i].seclen); + secs[i].setlen = secs[i].seclen; + secs[i].curlen = secs[i].seclen; + secs[i].cont = 1; + ridx = i; + /* CRC����с���*/ + if(checkcrc(&(secs[ridx]))) { + return &(secs[i]); /* �����������*/ + } + goto retry; /* 罧�������*/ + } + /* �祉��激��渇�-荐��羝����*/ + len = secs[i].seclen - secs[i].setlen; + if(len > secs[i].cur.payloadlen) { + /* ���荵∫� */ + memcpy(&secs[i].buf[secs[i].setlen], + secs[i].cur.payload, secs[i].cur.payloadlen); + secs[i].setlen += secs[i].cur.payloadlen; + continue; + } + /* �祉��激��渇�������荐�� */ + memcpy(&secs[i].buf[secs[i].setlen], secs[i].cur.payload, len); + secs[i].setlen = secs[i].seclen; + secs[i].curlen += len; + secs[i].cont = 1; + ridx = i; + /* CRC����с���*/ + if(checkcrc(&(secs[ridx]))) { + return &(secs[i]); + } + goto retry; /* 罧�������*/ + } + } + } + + //return NULL; +} + +/* BonTest/TsStream.cpp��������� */ +unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len) { + unsigned int c = crc; + int n; + + static const unsigned int CrcTable[256] = { + 0x00000000UL, 0x04C11DB7UL, 0x09823B6EUL, 0x0D4326D9UL, 0x130476DCUL, 0x17C56B6BUL, 0x1A864DB2UL, 0x1E475005UL, 0x2608EDB8UL, 0x22C9F00FUL, 0x2F8AD6D6UL, 0x2B4BCB61UL, 0x350C9B64UL, 0x31CD86D3UL, 0x3C8EA00AUL, 0x384FBDBDUL, + 0x4C11DB70UL, 0x48D0C6C7UL, 0x4593E01EUL, 0x4152FDA9UL, 0x5F15ADACUL, 0x5BD4B01BUL, 0x569796C2UL, 0x52568B75UL, 0x6A1936C8UL, 0x6ED82B7FUL, 0x639B0DA6UL, 0x675A1011UL, 0x791D4014UL, 0x7DDC5DA3UL, 0x709F7B7AUL, 0x745E66CDUL, + 0x9823B6E0UL, 0x9CE2AB57UL, 0x91A18D8EUL, 0x95609039UL, 0x8B27C03CUL, 0x8FE6DD8BUL, 0x82A5FB52UL, 0x8664E6E5UL, 0xBE2B5B58UL, 0xBAEA46EFUL, 0xB7A96036UL, 0xB3687D81UL, 0xAD2F2D84UL, 0xA9EE3033UL, 0xA4AD16EAUL, 0xA06C0B5DUL, + 0xD4326D90UL, 0xD0F37027UL, 0xDDB056FEUL, 0xD9714B49UL, 0xC7361B4CUL, 0xC3F706FBUL, 0xCEB42022UL, 0xCA753D95UL, 0xF23A8028UL, 0xF6FB9D9FUL, 0xFBB8BB46UL, 0xFF79A6F1UL, 0xE13EF6F4UL, 0xE5FFEB43UL, 0xE8BCCD9AUL, 0xEC7DD02DUL, + 0x34867077UL, 0x30476DC0UL, 0x3D044B19UL, 0x39C556AEUL, 0x278206ABUL, 0x23431B1CUL, 0x2E003DC5UL, 0x2AC12072UL, 0x128E9DCFUL, 0x164F8078UL, 0x1B0CA6A1UL, 0x1FCDBB16UL, 0x018AEB13UL, 0x054BF6A4UL, 0x0808D07DUL, 0x0CC9CDCAUL, + 0x7897AB07UL, 0x7C56B6B0UL, 0x71159069UL, 0x75D48DDEUL, 0x6B93DDDBUL, 0x6F52C06CUL, 0x6211E6B5UL, 0x66D0FB02UL, 0x5E9F46BFUL, 0x5A5E5B08UL, 0x571D7DD1UL, 0x53DC6066UL, 0x4D9B3063UL, 0x495A2DD4UL, 0x44190B0DUL, 0x40D816BAUL, + 0xACA5C697UL, 0xA864DB20UL, 0xA527FDF9UL, 0xA1E6E04EUL, 0xBFA1B04BUL, 0xBB60ADFCUL, 0xB6238B25UL, 0xB2E29692UL, 0x8AAD2B2FUL, 0x8E6C3698UL, 0x832F1041UL, 0x87EE0DF6UL, 0x99A95DF3UL, 0x9D684044UL, 0x902B669DUL, 0x94EA7B2AUL, + 0xE0B41DE7UL, 0xE4750050UL, 0xE9362689UL, 0xEDF73B3EUL, 0xF3B06B3BUL, 0xF771768CUL, 0xFA325055UL, 0xFEF34DE2UL, 0xC6BCF05FUL, 0xC27DEDE8UL, 0xCF3ECB31UL, 0xCBFFD686UL, 0xD5B88683UL, 0xD1799B34UL, 0xDC3ABDEDUL, 0xD8FBA05AUL, + 0x690CE0EEUL, 0x6DCDFD59UL, 0x608EDB80UL, 0x644FC637UL, 0x7A089632UL, 0x7EC98B85UL, 0x738AAD5CUL, 0x774BB0EBUL, 0x4F040D56UL, 0x4BC510E1UL, 0x46863638UL, 0x42472B8FUL, 0x5C007B8AUL, 0x58C1663DUL, 0x558240E4UL, 0x51435D53UL, + 0x251D3B9EUL, 0x21DC2629UL, 0x2C9F00F0UL, 0x285E1D47UL, 0x36194D42UL, 0x32D850F5UL, 0x3F9B762CUL, 0x3B5A6B9BUL, 0x0315D626UL, 0x07D4CB91UL, 0x0A97ED48UL, 0x0E56F0FFUL, 0x1011A0FAUL, 0x14D0BD4DUL, 0x19939B94UL, 0x1D528623UL, + 0xF12F560EUL, 0xF5EE4BB9UL, 0xF8AD6D60UL, 0xFC6C70D7UL, 0xE22B20D2UL, 0xE6EA3D65UL, 0xEBA91BBCUL, 0xEF68060BUL, 0xD727BBB6UL, 0xD3E6A601UL, 0xDEA580D8UL, 0xDA649D6FUL, 0xC423CD6AUL, 0xC0E2D0DDUL, 0xCDA1F604UL, 0xC960EBB3UL, + 0xBD3E8D7EUL, 0xB9FF90C9UL, 0xB4BCB610UL, 0xB07DABA7UL, 0xAE3AFBA2UL, 0xAAFBE615UL, 0xA7B8C0CCUL, 0xA379DD7BUL, 0x9B3660C6UL, 0x9FF77D71UL, 0x92B45BA8UL, 0x9675461FUL, 0x8832161AUL, 0x8CF30BADUL, 0x81B02D74UL, 0x857130C3UL, + 0x5D8A9099UL, 0x594B8D2EUL, 0x5408ABF7UL, 0x50C9B640UL, 0x4E8EE645UL, 0x4A4FFBF2UL, 0x470CDD2BUL, 0x43CDC09CUL, 0x7B827D21UL, 0x7F436096UL, 0x7200464FUL, 0x76C15BF8UL, 0x68860BFDUL, 0x6C47164AUL, 0x61043093UL, 0x65C52D24UL, + 0x119B4BE9UL, 0x155A565EUL, 0x18197087UL, 0x1CD86D30UL, 0x029F3D35UL, 0x065E2082UL, 0x0B1D065BUL, 0x0FDC1BECUL, 0x3793A651UL, 0x3352BBE6UL, 0x3E119D3FUL, 0x3AD08088UL, 0x2497D08DUL, 0x2056CD3AUL, 0x2D15EBE3UL, 0x29D4F654UL, + 0xC5A92679UL, 0xC1683BCEUL, 0xCC2B1D17UL, 0xC8EA00A0UL, 0xD6AD50A5UL, 0xD26C4D12UL, 0xDF2F6BCBUL, 0xDBEE767CUL, 0xE3A1CBC1UL, 0xE760D676UL, 0xEA23F0AFUL, 0xEEE2ED18UL, 0xF0A5BD1DUL, 0xF464A0AAUL, 0xF9278673UL, 0xFDE69BC4UL, + 0x89B8FD09UL, 0x8D79E0BEUL, 0x803AC667UL, 0x84FBDBD0UL, 0x9ABC8BD5UL, 0x9E7D9662UL, 0x933EB0BBUL, 0x97FFAD0CUL, 0xAFB010B1UL, 0xAB710D06UL, 0xA6322BDFUL, 0xA2F33668UL, 0xBCB4666DUL, 0xB8757BDAUL, 0xB5365D03UL, 0xB1F740B4UL + }; + + for (n = 0; n < len; n++) { + c = (c << 8) ^ CrcTable[((((c >> 24) & 0xFF) ^ buf[n]) & 0XFF)]; + } + + return c; +} + + +int checkcrc(SECcache *secs) { + + /* regard a section with more than MAXSECLEN data as an error. */ + if(secs->seclen > MAXSECLEN) { + return 0; + } + + /* �祉��激��潟�腟����舟�����������CRC32��� + CRC荐����������������荐�������� + �ゃ��榊�����翫��������若����絲乗院紊����� */ + if(CalcCrc(0xffffffffU, secs->buf, secs->seclen)) { +// fprintf(stderr, "tblid:0x%x CRC error\n", secs->buf[0]); + return 0; + } + return 1; +} Index: /trunk/epgdumpr2/eit.h =================================================================== --- /trunk/epgdumpr2/eit.h (リビジョン 136) +++ /trunk/epgdumpr2/eit.h (リビジョン 136) @@ -0,0 +1,120 @@ +#ifndef EIT_H +#define EIT_H 1 + +#include +#include + +#include "util.h" +#include "ts_ctl.h" + +typedef struct _EIThead { + char table_id; + int section_syntax_indicator; + int reserved_future_use; + int reserved1; + int section_length; + int service_id; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; + int transport_stream_id; + int original_network_id; + int segment_last_section_number; + int last_table_id; +} EIThead; + +typedef struct _EITbody { + int event_id; + char start_time[5]; + unsigned char duration[3]; + int running_status; + int free_CA_mode; + int descriptors_loop_length; + /* 篁ヤ���В������絖�� */ + int yy; + int mm; + int dd; + int hh; + int hm; + int ss; + int dhh; + int dhm; + int dss; +} EITbody; + +typedef struct _SEVTdesc { + int descriptor_tag; + int descriptor_length; + char ISO_639_language_code[3]; + int event_name_length; + char event_name[MAXSECLEN]; + int text_length; + char text[MAXSECLEN]; +} SEVTdesc; + +typedef struct _ContentDesc { + int descriptor_tag; + int descriptor_length; + char content[MAXSECLEN]; +} ContentDesc; + +typedef struct _SeriesDesc { + int descriptor_tag; + int descriptor_length; + int series_id; + int repeat_label; + int program_pattern; + int expire_date_valid_flag; + int expire_date; + int episode_number; + int last_episode_number; + char series_name_char[MAXSECLEN]; +} SeriesDesc; + +typedef struct _EEVTDhead { + int descriptor_tag; + int descriptor_length; + int descriptor_number; + int last_descriptor_number; + char ISO_639_language_code[3]; + int length_of_items; +} EEVTDhead; + +typedef struct _EEVTDitem { + int item_description_length; + char item_description[MAXSECLEN]; + int item_length; + char item[MAXSECLEN]; + /* �����*/ + int descriptor_number; +} EEVTDitem; + +typedef struct _EEVTDtail { + int text_length; + char text[MAXSECLEN]; +} EEVTDtail; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseEIThead(unsigned char *data, EIThead *h); + int parseEITbody(unsigned char *data, EITbody *b); + int parseSEVTdesc(unsigned char *data, SEVTdesc *desc) ; + + int parseContentDesc(unsigned char *data, ContentDesc *desc); + int parseSeriesDesc(unsigned char *data, SeriesDesc *desc); + + int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) ; + int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) ; + int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) ; + + void dumpEIT(unsigned char *data, int serv_id, int original_network_id, int transport_stream_id, EIT_CONTROL *eittop); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif Index: /trunk/epgdumpr2/xmldata.c =================================================================== --- /trunk/epgdumpr2/xmldata.c (リビジョン 136) +++ /trunk/epgdumpr2/xmldata.c (リビジョン 136) @@ -0,0 +1,90 @@ +static STATION bsSta[] = { + { "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101}, + { "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102},//綮�� 2011/3/31 + { "NHK BS��������, "3003.ontvjapan.com", 16626, 4, 103}, + { "BS�ャ���, "3004.ontvjapan.com", 16592, 4, 141}, + { "BS���", "3005.ontvjapan.com", 16400, 4, 151}, + { "BS-TBS", "3006.ontvjapan.com", 16401, 4, 161}, + { "BS�吾����", "3007.ontvjapan.com", 16433, 4, 171}, + { "BS���", "3008.ontvjapan.com", 16593, 4, 181}, + { "WOWOW", "3009.ontvjapan.com", 16432, 4, 191}, + { "WOWOW2", "3010.ontvjapan.com", 16432, 4, 192}, + { "WOWOW3", "3011.ontvjapan.com", 16432, 4, 193}, + { "�鴻��若�����潟���, "3012.ontvjapan.com", 16529, 4, 200}, + { "BS11", "3013.ontvjapan.com", 16528, 4, 211}, + { "TwellV", "3014.ontvjapan.com", 16530, 4, 222}, +}; + +static int bsStaCount = sizeof(bsSta) / sizeof (STATION); + + + +static STATION csSta[] = { + { "�鴻��種�鐔�����", "1002.ontvjapan.com", 24608, 6, 237}, + { "�ユ����絨��鐔��鐚�爾", "1086.ontvjapan.com", 24608, 6, 239}, + { "��������汐鐚ワ叱鐚�, "306ch.epgdata.ontvjapan", 24608, 6, 306},//��������SHD �� { "�激��������潟���, "1059.ontvjapan.com", 24704, 6, 55}, + { "�吟��激���, "1217.ontvjapan.com", 24736, 6, 228}, + { "�鴻�����鰹示鐚わ�鐚��", "800ch.epgdata.ontvjapan", 24736, 6, 800}, + { "�鴻�����鰹�鐚��", "801ch.epgdata.ontvjapan", 24736, 6, 801}, + { "�鴻�����鰹�鐚��", "802ch.epgdata.ontvjapan", 24736, 6, 802}, + { "鐔�������, "100ch.epgdata.ontvjapan", 28736, 7, 100}, + { "�ゃ��帥�������鐚器雫", "194ch.epgdata.ontvjapan", 28736, 7, 194}, + { "鐚��������鐚ワ竺鐚逸汐", "1025.ontvjapan.com", 28736, 7, 256}, + { "鐚�鹿鐚�, "1016.ontvjapan.com", 28736, 7, 312}, + { "�鴻��若��激����鐚器雫", "1018.ontvjapan.com", 28736, 7, 322}, + { "�������若�������", "1046.ontvjapan.com", 28736, 7, 331}, + { "����若��祉��c����", "1213.ontvjapan.com", 28736, 7, 334}, + { "�掩�����潟���, "1010.ontvjapan.com", 28768, 7, 221}, + { "茵�����", "1005.ontvjapan.com", 28768, 7, 222}, + { "����潟���汐鐚ワ治鐚�, "1008.ontvjapan.com", 28768, 7, 223}, + { "羇���������c�", "1009.ontvjapan.com", 28768, 7, 224}, + { "�鴻��若�����激���, "1003.ontvjapan.com", 28768, 7, 238}, + { "��撮�������c����", "1133.ontvjapan.com", 28768, 7, 292}, + { "�鴻���������, "1006.ontvjapan.com", 28768, 7, 310}, + { "鐚¥叱鐚�, "1014.ontvjapan.com", 28768, 7, 311}, + { "����с�����c����", "1204.ontvjapan.com", 28768, 7, 343}, + { "����������帥�", "110ch.epgdata.ontvjapan", 28864, 7, 110}, + { "�眼�����c����", "1028.ontvjapan.com", 28864, 7, 260}, + { "�������c����", "1092.ontvjapan.com", 28864, 7, 303}, + { "鐚�軸鐚�, "1019.ontvjapan.com", 28864, 7, 323}, + { "����若�����祉���, "1024.ontvjapan.com", 28864, 7, 324}, + { "�������若��帥�", "1067.ontvjapan.com", 28864, 7, 352}, + { "鐚�滋鐚c��若���, "1070.ontvjapan.com", 28864, 7, 353}, + { "鐚o汐鐚��", "1069.ontvjapan.com", 28864, 7, 354}, + { "�吾��鴻��祉���, "361ch.epgdata.ontvjapan", 28864, 7, 361}, + { "鐚��������鐚�, "1041.ontvjapan.com", 28896, 7, 251}, + { "鐚��������鐚�, "1042.ontvjapan.com", 28896, 7, 252}, + { "鐚�������式鐔��鐔�示", "1043.ontvjapan.com", 28896, 7, 253}, + { "鐚э次鐚�鴫鐚�, "1026.ontvjapan.com", 28896, 7, 254}, + { "鐔��鐔��鐚<�������", "1040.ontvjapan.com", 28896, 7, 255}, + { "絎������≪��c����", "101ch.epgdata.ontvjapan", 28928, 7, 101}, + { "鐚鰹自鐚鴻�鐚鰹軸鐚¥磁鐚�, "1207.ontvjapan.com", 28928, 7, 290}, + { "����潟����羃�, "305ch.epgdata.ontvjapan", 28928, 7, 305}, + { "鐚¥軸-鐚�, "1201.ontvjapan.com", 28928, 7, 333}, + { "�������若��c����", "1050.ontvjapan.com", 28928, 7, 342}, + { "�鴻�����鰹�鐚��", "803ch.epgdata.ontvjapan", 28928, 7, 803}, + { "�鴻�����鰹�鐚��", "804ch.epgdata.ontvjapan", 28928, 7, 804}, + { "����������刻示鐚�, "1007.ontvjapan.com", 28960, 7, 240}, + { "�眼������������, "1027.ontvjapan.com", 28960, 7, 262}, + { "鐚��鐚����示鐚�, "1074.ontvjapan.com", 28960, 7, 314}, + { "��������鹿鐚�璽", "1073.ontvjapan.com", 28992, 7, 307},//��������39�� { "��������軸鐚件鹿", "1072.ontvjapan.com", 28992, 7, 308},//��������21�� { "�≪�������", "1047.ontvjapan.com", 28992, 7, 332}, + { "����鴻������, "1062.ontvjapan.com", 28992, 7, 340}, + { "�≪������������, "1193.ontvjapan.com", 28992, 7, 341}, + { "鐚�鐚器滋鐚潟�������", "160ch.epgdata.ontvjapan", 29024, 7, 160}, + { "鐚縁雫鐚�, "1120.ontvjapan.com", 29024, 7, 161}, + { "����ゃ�鐚��鐚��鐚器雫", "185ch.epgdata.ontvjapan", 29024, 7, 185}, + { "�������弱���, "1015.ontvjapan.com", 29024, 7, 293}, + { "鐚器滋鐚潟��c����", "3201.ontvjapan.com", 29024, 7, 301}, + { "����冴��若��c����", "1090.ontvjapan.com", 29024, 7, 304}, + { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, + { "����冴�����激���D", "1045.ontvjapan.com", 29024, 7, 335},//HD�� { "鐚器滋鐚潟��ャ��鴻��若�", "1076.ontvjapan.com", 29024, 7, 351}, + { "鐚o竺�ユ���������, "147ch.epgdata.ontvjapan", 29056, 7, 147}, + { "�ャ���磁鐚�, "1068.ontvjapan.com", 29056, 7, 257}, + { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291}, + { "�ャ�������", "300ch.epgdata.ontvjapan", 29056, 7, 300}, + { "�������若����鐚器雫", "1023.ontvjapan.com", 29056, 7, 320}, + { "Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321}, + { "�ャ���汐鐚ワ七鐚鰹�鐚�, "2002.ontvjapan.com", 29056, 7, 350}, +}; + +static int csStaCount = sizeof(csSta) / sizeof (STATION); Index: /trunk/epgdumpr2/sdt.c =================================================================== --- /trunk/epgdumpr2/sdt.c (リビジョン 136) +++ /trunk/epgdumpr2/sdt.c (リビジョン 136) @@ -0,0 +1,165 @@ +#include +#include +#include + +#include "sdt.h" +#include "ts_ctl.h" + +int parseSDThead(unsigned char *data, SDThead *h) { + int boff = 0; + + memset(h, 0, sizeof(SDThead)); + + boff = 0; + h->table_id = getBit(data, &boff, 8); + h->section_syntax_indicator = getBit(data, &boff, 1); + h->reserved_future_use1 = getBit(data, &boff, 1); + h->reserved1 = getBit(data, &boff, 2); + h->section_length = getBit(data, &boff, 12); + h->transport_stream_id = getBit(data, &boff, 16); + h->reserved2 = getBit(data, &boff, 2); + h->version_number = getBit(data, &boff, 5); + h->current_next_indicator = getBit(data, &boff, 1); + h->section_number = getBit(data, &boff, 8); + h->last_section_number = getBit(data, &boff, 8); + h->original_network_id = getBit(data, &boff, 16); + h->reserved_future_use2 = getBit(data, &boff, 8); + + return 11; +} + +int parseSDTbody(unsigned char *data, SDTbody *b) { + int boff = 0; + + memset(b, 0, sizeof(SDTbody)); + + b->service_id = getBit(data, &boff, 16); + b->reserved_future_use1 = getBit(data, &boff, 3); + b->EIT_user_defined_flags = getBit(data, &boff, 3); + b->EIT_schedule_flag = getBit(data, &boff, 1); + b->EIT_present_following_flag = getBit(data, &boff, 1); + b->running_status = getBit(data, &boff, 3); + b->free_CA_mode = getBit(data, &boff, 1); + b->descriptors_loop_length = getBit(data, &boff, 12); + + return 5; +} + +int parseSVCdesc(unsigned char *data, SVCdesc *desc) { + int boff = 0; + + memset(desc, 0, sizeof(SVCdesc)); + + desc->descriptor_tag = getBit(data, &boff, 8); + desc->descriptor_length = getBit(data, &boff, 8); + desc->service_type = getBit(data, &boff, 8); + desc->service_provider_name_length = getBit(data, &boff, 8); + getStr(desc->service_provider_name, data, &boff, desc->service_provider_name_length); + desc->service_name_length = getBit(data, &boff, 8); + getStr(desc->service_name, data, &boff, desc->service_name_length); + + return desc->descriptor_length + 2; +} +int serachid(SVT_CONTROL *top, int service_id) +{ + SVT_CONTROL *cur = top ; + while(cur != NULL){ + if(cur->event_id == service_id){ + return 1 ; + } + cur = cur->next ; + } + return 0 ; +} + +void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr) +{ + SVT_CONTROL *cur ; + + if(top->next == NULL){ + top->next = sdtptr ; + top->prev = top ; + return ; + } + cur = top->next ; + while(cur != NULL){ + if(sdtptr->event_id < cur->event_id){ + if(cur->prev != NULL){ + cur->prev->next = sdtptr ; + sdtptr->prev = cur->prev ; + } + cur->prev = sdtptr ; + sdtptr->next = cur ; + return ; + } + if(cur->next == NULL){ + cur->next = sdtptr ; + sdtptr->prev = cur ; + return ; + } + cur = cur->next ; + } + return ; + +} + +void dumpSDT(unsigned char *ptr, SVT_CONTROL *top) +{ + + SDThead sdth; + SDTbody sdtb; + SVCdesc desc; + SVT_CONTROL *svtptr ; + int rc ; + + int len = 0; + int loop_len = 0; + + /* SDT */ + len = parseSDThead(ptr, &sdth); + ptr += len; + loop_len = sdth.section_length - (len - 3 + 4); // 3�����������4��RC + while(loop_len > 0) { + len = parseSDTbody(ptr, &sdtb); + ptr += len; + loop_len -= len; + parseSVCdesc(ptr, &desc); + + rc = serachid(top, sdtb.service_id); + if(rc == 0){ + svtptr = calloc(1, sizeof(SVT_CONTROL)); + svtptr->event_id = sdtb.service_id; + svtptr->original_network_id = sdth.original_network_id; + svtptr->transport_stream_id = sdth.transport_stream_id; + svtptr->event_id = sdtb.service_id; + memcpy(svtptr->servicename, desc.service_name, strlen(desc.service_name)); + enqueue_sdt(top, svtptr); +#if 0 + printf("SDT=%s,%d,%x,%x,%x,%x,%x,%x,%x\n", + desc.service_name, sdtb.service_id, sdtb.reserved_future_use1, + sdtb.EIT_user_defined_flags, sdtb.EIT_schedule_flag, sdtb.EIT_present_following_flag, + sdtb.running_status, sdtb.free_CA_mode, sdtb.descriptors_loop_length); +/* +#else +0x01:����帥�TV�泣���� +0xA5:����≪��激��恰���泣���� +0x0C:����帥��若��� */ + printf("SDT=(%x:%x)%s,%d,%d,%d,%d,%d(%d,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", + sdth.table_id, desc.service_type, + desc.service_name, sdtb.service_id, + desc.descriptor_tag, desc.descriptor_length, desc.service_type, + desc.service_provider_name_length, desc.service_name_length, + sdth.table_id, sdth.section_syntax_indicator, sdth.reserved_future_use1, + sdth.reserved1, sdth.section_length, sdth.transport_stream_id, + sdth.reserved2, sdth.version_number, sdth.current_next_indicator, + sdth.section_number, sdth.last_section_number, sdth.original_network_id, + sdth.reserved_future_use2); +#endif + } + + ptr += sdtb.descriptors_loop_length; + loop_len -= sdtb.descriptors_loop_length; + } + + return; +} Index: /trunk/epgdumpr2/readme.txt =================================================================== --- /trunk/epgdumpr2/readme.txt (リビジョン 136) +++ /trunk/epgdumpr2/readme.txt (リビジョン 136) @@ -0,0 +1,55 @@ +xmltv-epg + +MPEG-TS�����epg�xml�����v������� +�N/E9PqspSk��recfriio Solaris�(http://2sen.dip.jp/cgi-bin/friioup/source/up0737.zip)�����epgdump� +Linux�������������xmltv��xml����������� + +������������� + "��"��"��"�"��"�"�"�"�"����������������������B +�� + +������ +������������������� +�������������������������������������������� + +��������������������Aeit.c���subtitle_cnv_str���������� + +������������� + +Usage : ./epgdump /BS +Usage : ./epgdump +ontvcode �����ッ���****.ontvjapan.com �� +/BS BS�������TS��BS�������������� +/CS CS�������TS����������������� + +make���epgdump��������� + +epgdump�����(Solaris�����): +>epgdump������BonTest Ver.1.40�������������������� +>������������������B +>BonTest�Readme.txt�� +>> +>>����������� +>>��������������������������������������������� +>>������������������ゥ��������ゥ����������������� +>>�����GPL������v���������������\�������ヲ��������� +>>�������������������ヲ������������� +>>�����������FAAD2�������������������� +>> +>>���"Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +>> +>>������������ +>>���- Microsoft Visual Studio 2005 ��@�MFC��� +>>���- Microsoft Windows SDK v6.0 ��@��DirectShow��������������������� +>>���- Microsoft DirectX 9.0 SDK �� +Special Thanks: +�Solaris���メ�� +��������� +��N/E9PqspSk� +�ARIB(���������������) + +������: + Debian GNU/Linux sid + Linux 2.6.27.19 SMP PREEMPT x86_64 + +tomy �CfWlfzSGyg Index: /trunk/epgdumpr2/ts.h =================================================================== --- /trunk/epgdumpr2/ts.h (リビジョン 136) +++ /trunk/epgdumpr2/ts.h (リビジョン 136) @@ -0,0 +1,46 @@ +#ifndef TS_H +#define TS_H 1 + +#include +#include + +#include "util.h" + +#define TSPAYLOADMAX 184 + +typedef struct _TSpacket { + char sync; + int transport_error_indicator; + int payload_unit_start_indicator; + int transport_priority; + int pid; + int transport_scrambling_control; + int adaptation_field_control; + int continuity_counter; + int adaptation_field; + unsigned char payload[TSPAYLOADMAX]; + int payloadlen; + int rcount; +} TSpacket; + +typedef struct _SECcache { + int pid; + unsigned char buf[MAXSECLEN]; + int seclen; + int setlen; + TSpacket cur; + int curlen; + int cont; +} SECcache; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + SECcache *readTS(FILE *in, SECcache secs[], int secscount); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif Index: /trunk/epgdumpr2/Makefile =================================================================== --- /trunk/epgdumpr2/Makefile (リビジョン 136) +++ /trunk/epgdumpr2/Makefile (リビジョン 136) @@ -0,0 +1,27 @@ +PREFIX = /usr/local +TARGETS = epgdump +OBJ_TARGETS = epgdump.o aribstr.o eit.o ts.o util.o sdt.o +HEDDERDEPEND = eit.h sdt.h aribstr.h ts.h util.h + +LANG=C +CC = gcc +CFLAGS = -std=c99 -O2 -Wall -g -Werror -Wno-return-type +#LDFLAGS = -pthread +LIBS = + +.c.o: + ${CC} ${CFLAGS} -c $< + +all: ${TARGETS} + + +${TARGETS}: ${OBJ_TARGETS} + ${CC} ${CFLAGS} ${OBJ_TARGETS} -o $@ ${LDFLAGS} ${LIBS} + +${OBJ_TARGETS}: ${HEDDERDEPEND} + +clean: + rm -f core ${TARGETS} *.o + +install: + install -m 755 ${TARGETS} ${PREFIX}/bin Index: /trunk/epgdumpr2/ts_ctl.h =================================================================== --- /trunk/epgdumpr2/ts_ctl.h (リビジョン 136) +++ /trunk/epgdumpr2/ts_ctl.h (リビジョン 136) @@ -0,0 +1,38 @@ +#ifndef __TS_CONTROL_H__ +#define __TS_CONTROL_H__ + +#include "util.h" + +typedef struct _SVT_CONTROL SVT_CONTROL; +struct _SVT_CONTROL{ + SVT_CONTROL *next ; + SVT_CONTROL *prev ; + int event_id ; // �ゃ��潟�ID + int original_network_id ; // OriginalNetworkID + int transport_stream_id ; // TransporrtStreamID + char servicename[MAXSECLEN] ; // �泣������}; + +typedef struct _EIT_CONTROL EIT_CONTROL; +struct _EIT_CONTROL{ + EIT_CONTROL *next ; + EIT_CONTROL *prev ; + int table_id ; + int servid ; + int event_id ; // �ゃ��潟�ID + int content_type ; // �潟��������ゃ� + int yy; + int mm; + int dd; + int hh; + int hm; + int ss; + int dhh; + int dhm; + int dss; + int ehh; + int emm; + int ess; + char *title ; // �帥���� + char *subtitle ; // �泣��帥���� +}; +#endif