--- /dev/null
+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
+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: ${TARGETS}
+ install -m755 ${TARGETS} ${PREFIX}/bin
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <iconv.h>
+
+#include "aribstr.h"
+
+#define CODE_UNKNOWN 0 // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È(ÈóÂбþ)
+#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 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 WORD convertjis(DWORD);
+
+static const bool abCharSizeTable[] =
+{
+ false, // CODE_UNKNOWN ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È(ÈóÂбþ)
+ 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
+};
+
+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];
+
+ 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 0x20U :
+ case 0xA0U : lpszDst[dwDstLen++] = TEXT(' '); break; // SP
+ 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 :
+ // ±Ñ¿ô»ú¥³¡¼¥É½ÐÎÏ
+ return PutAlphanumericChar(lpszDst, wCode);
+
+ 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);
+#if 1
+ case CODE_ADDITIONAL_SYMBOLS :
+ // Äɲå·¥ó¥Ü¥ë¥³¡¼¥É½ÐÎÏ
+ return PutSymbolsChar(lpszDst, wCode);
+#endif
+ default :
+ return 0UL;
+ }
+}
+
+const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode)
+{
+ // JIS¢ªShift-JIS´Á»ú¥³¡¼¥ÉÊÑ´¹
+ const WORD wShiftJIS = convertjis(wCode);
+
+#ifdef _UNICODE
+ // Shift-JIS ¢ª UNICODE
+ const char szShiftJIS[3] = {(char)(wShiftJIS >> 8), (char)(wShiftJIS & 0x00FFU), '\0'};
+ ::MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, szShiftJIS, 2, lpszDst, 2);
+
+ return 1UL;
+#else
+ // Shift-JIS ¢ª Shift-JIS
+ lpszDst[0] = (wShiftJIS >> 8) & 0xFF;
+ lpszDst[1] = (char)(wShiftJIS & 0x00FFU);
+
+ return 2UL;
+#endif
+}
+
+const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode)
+{
+ // ±Ñ¿ô»úʸ»ú¥³¡¼¥ÉÊÑ´¹
+ static const TCHAR *acAlphanumericTable =
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡")
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡")
+ TEXT("¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿")
+ TEXT("£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©")
+ TEXT("¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï")
+ TEXT("£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡ï¡Ï¡°¡²")
+ TEXT("¡¡£á£â£ã£ä£å£æ£ç£è£é£ì£ë£ì£í£î£ï")
+ TEXT("£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡±¡¡");
+
+#ifdef _UNICODE
+ lpszDst[0] = acAlphanumericTable[wCode];
+
+ return 1UL;
+#else
+ lpszDst[0] = acAlphanumericTable[wCode * 2U + 0U];
+ lpszDst[1] = acAlphanumericTable[wCode * 2U + 1U];
+
+ return 2UL;
+#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 * 2U + 0U];
+ lpszDst[1] = acHiraganaTable[wCode * 2U + 1U];
+
+ return 2UL;
+#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 * 2U + 0U];
+ lpszDst[1] = acKatakanaTable[wCode * 2U + 1U];
+
+ return 2UL;
+#endif
+}
+
+const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode)
+{
+ // JIS¥«¥¿¥«¥Êʸ»ú¥³¡¼¥ÉÊÑ´¹
+ static const TCHAR *acJisKatakanaTable =
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡")
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡")
+ TEXT("¡¡¡£¡Ö¡×¡¢¡¦¥ò¥¡¥£¥¥¥§¥©¥ã¥å¥ç¥Ã")
+ TEXT("¡¼¥¢¥¤¥¦¥¨¥ª¥«¥¥¯¥±¥³¥µ¥·¥¹¥»¥½")
+ TEXT("¥¿¥Á¥Ä¥Æ¥È¥Ê¥Ë¥Ì¥Í¥Î¥Ï¥Ò¥Õ¥Ø¥Û¥Þ")
+ TEXT("¥ß¥à¥á¥â¥ä¥æ¥è¥é¥ê¥ë¥ì¥í¥ï¥ó¡«¡¬")
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡")
+ TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡");
+
+#ifdef _UNICODE
+ lpszDst[0] = acJisKatakanaTable[wCode];
+
+ return 1UL;
+#else
+ lpszDst[0] = acJisKatakanaTable[wCode * 2U + 0U];
+ lpszDst[1] = acJisKatakanaTable[wCode * 2U + 1U];
+
+ return 2UL;
+#endif
+}
+
+const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode)
+{
+ // Äɲå·¥ó¥Ü¥ëʸ»ú¥³¡¼¥ÉÊÑ´¹(¤È¤ê¤¢¤¨¤ºÉ¬Íפ½¤¦¤Ê¤â¤Î¤À¤±)
+ static const TCHAR *aszSymbolsTable1[] =
+ {
+ _T("[HV]"), _T("[SD]"), _T("[£Ð]"), _T("[£×]"), _T("[MV]"), _T("[¼ê]"), _T("[»ú]"), _T("[ÁÐ]"), // 0x7A50 - 0x7A57 90/48 - 90/55
+ _T("[¥Ç]"), _T("[£Ó]"), _T("[Æó]"), _T("[¿]"), _T("[²ò]"), _T("[SS]"), _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("[À¼]"), _T("[¿á]"), _T("[PPV]"), _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("Hz"), _T("ha"), _T("km"), _T("Ê¿Êýkm"), _T("hPa"), _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("XI"), _T("X¶"), _T("±"), _T("²"), _T("³"), _T("´"), // 0x7E29 - 0x7E30 94/09 - 94/16
+ _T("(1)"), _T("(2)"), _T("(3)"), _T("(4)"), _T("(5)"), _T("(6)"), _T("(7)"), _T("(8)"), // 0x7E31 - 0x7E38 94/17 - 94/24
+ _T("(9)"), _T("(10)"), _T("(11)"), _T("(12)"), _T("(21)"), _T("(22)"), _T("(23)"), _T("(24)"), // 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("(25)"), _T("(26)"), _T("(27)"), _T("(28)"), _T("(29)"), _T("(30)"), // 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("(31)") // 0x7E79 - 0x7E7D 94/89 - 94/93
+ };
+
+ // ¥·¥ó¥Ü¥ë¤òÊÑ´¹¤¹¤ë
+ 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{
+ 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[byIndexG];
+}
+
+void LockingShiftGR(const BYTE byIndexG)
+{
+ // LSxR
+ m_pLockingGR = &m_CodeG[byIndexG];
+}
+
+void SingleShiftGL(const BYTE byIndexG)
+{
+ // SSx
+ m_pSingleGL = &m_CodeG[byIndexG];
+}
+
+const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode)
+{
+ // G¤Î¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë
+ 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; // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È
+ }
+}
+
+const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode)
+{
+ // DRCS¤Î¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë
+ 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; // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È
+ }
+}
+
+WORD convertjis(DWORD jiscode) {
+ char code[3];
+ char xcode[4];
+ iconv_t cd;
+
+ size_t inbyte = 2;
+ size_t outbyte = 4;
+
+ const char *fptr;
+ char *tptr;
+
+ WORD rtn;
+
+ code[0] = jiscode >> 8;
+ code[1] = jiscode & 0xFF;
+ code[3] = '\0';
+
+ /*
+ cd = iconv_open("ISO-2022-JP","UTF-8");
+
+ fptr = code;
+ tptr = xcode;
+ iconv(cd, &fptr, &inbyte, &tptr, &outbyte);
+
+ iconv_close(cd);
+ */
+
+ xcode[0] = code[0] | 0x80;
+ xcode[1] = code[1] | 0x80;
+
+ rtn = ((xcode[0] << 8) & 0xFF00) | (xcode[1] & 0xFF);
+
+ return rtn;
+
+}
--- /dev/null
+#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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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);
+
+
+ //save->descriptor_number = descriptor_number;
+ //*new = swap;
+ //*save = swap;
+ if (swap.descriptor_number==1){
+// printf("descriptor_num %d typeB\n",swap.descriptor_number);
+ }
+
+ return 1;
+ } else {
+
+
+ //printf("descriptor_num %d typeC\n",swap.descriptor_number);
+
+
+
+ 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;
+
+
+ if (swap.descriptor_number==1){
+ printf("descriptor_num %d typeD\n",swap.descriptor_number);
+ }
+
+
+ return 0;
+ } else {
+ /* ¥Ö¥ì¡¼¥¯¡£save¤ò°õºþÂоݤˤ¹¤ë¡£save¤ò¥¯¥ê¥¢? */
+ 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;
+
+
+
+
+ if (swap.descriptor_number==1){
+ printf("descriptor_num %d typeE\n",swap.descriptor_number);
+ }
+
+
+ } else {
+ *save = *new;
+ save->descriptor_number = descriptor_number;
+
+ if (swap.descriptor_number==1){
+ printf("descriptor_num %d typeF\n",swap.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 ;
+}
+void conv_title_subtitle(EIT_CONTROL *eitptr)
+{
+ int lp = 0 ;
+ size_t addsize ;
+ char *ptr ;
+ 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 ;
+ }
+ newsubtitle = calloc(1, ((strlen(ptr) + 1) + (strlen(eitptr->subtitle) + 1)));
+ memcpy(newsubtitle, ptr, strlen(ptr));
+ newsubtitle[strlen(ptr)] = ' ';
+ *ptr = NULL ;
+ 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 ;
+ EIT_CONTROL *curtmp ;
+
+ int len = 0;
+ int loop_len = 0;
+ int loop_blen = 0;
+ int loop_elen = 0;
+ int str_alen = 0;
+
+ int ehh, emm, ess;
+
+ /* EIT */
+ len = parseEIThead(ptr, &eith);
+
+ ptr += len;
+ loop_len = eith.section_length - (len - 3 + 4); // 3¤Ï¶¦Ḁ̈إåÀĹ 4¤ÏCRC
+ while(loop_len > 0) {
+ /* Ϣ³¤¹¤ë³ÈÄ¥¥¤¥Ù¥ó¥È¤Ï¡¢´Á»ú¥³¡¼¥É¤¬µã¤Ê̤줷¤Æ
+ ʬ³ä¤µ¤ì¤ë¤è¤¦¤À¡£Ï¢Â³¤«¤É¤¦¤«¤Ï¡¢item_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){
+ curtmp = NULL;
+ cur = calloc(1, sizeof(EIT_CONTROL));
+ }
+ else {
+ curtmp = cur;
+ }
+ 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 ;
+ if ( !curtmp ) 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 (1||checkEEVTDitem(&save_eevtitem, &eevtitem,
+ eevthead.descriptor_number)) {
+#if 0
+ {
+ if (eevtitem.descriptor_number>0){
+ //printf("descriptor_num %d\n",eevtitem.descriptor_number);
+ }
+
+ /* long format */
+ //printf("descriptor_num %d\n",eevtitem.descriptor_number);
+#if 1
+ printf("EEVT,%d,%d,%d,%s,%s\n",
+ eith.service_id,
+ eitb.event_id,
+ eevtitem.descriptor_number, // ÂàÈò¹àÌÜ
+ eevtitem.item_description,
+ eevtitem.item);
+#endif
+
+ }
+#endif
+ cur = searcheit(eittop, eith.service_id, eitb.event_id);
+ if(cur == NULL){
+ curtmp = NULL;
+ cur = calloc(1, sizeof(EIT_CONTROL));
+ }
+ else {
+ curtmp = cur;
+ }
+
+#if 1
+ if ( cur->desc ) {
+ str_alen = strlen( cur->desc );
+ }
+ else {
+ str_alen = 0;
+ }
+ eevtitem.item_description_length = strlen(eevtitem.item_description);
+ eevtitem.item_length = strlen(eevtitem.item);
+ cur->desc = realloc(cur->desc, str_alen + eevtitem.item_description_length + eevtitem.item_length + 1000);
+ if ( !str_alen ) *cur->desc = '\0';
+
+ if ( eevtitem.item_description_length && !strstr(cur->desc, eevtitem.item_description) ) {
+ strcat(cur->desc, eevtitem.item_description);
+ strcat(cur->desc, "\t");
+ }
+
+ if ( eevtitem.item_length && !strstr(cur->desc, eevtitem.item) ) {
+ strcat(cur->desc, eevtitem.item);
+ strcat(cur->desc, "\\n");
+ }
+#endif
+ if ( !curtmp ) enqueue(eittop, cur);
+ }
+ }
+
+ len = parseEEVTDtail(ptr, &eevttail);
+#if 0
+ { /* long format */
+ printf("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
+ printf("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;
+
+}
--- /dev/null
+#ifndef EIT_H
+#define EIT_H 1
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#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];
+ 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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <iconv.h>
+#include <time.h>
+
+#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" },
+ { "¼ñÌ£¡¦¼ÂÍÑ", "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},
+ { "NHK BSh", "3003.ontvjapan.com", 16626, 4, 103},
+ { "BSÆü¥Æ¥ì", "3004.ontvjapan.com", 16592, 4, 141},
+ { "BSÄ«Æü", "3005.ontvjapan.com", 16400, 4, 151},
+ { "BS-i", "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},
+ { "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},
+ { "ÆüËܱDzèÀìÌç£ã£è£È£Ä", "1086.ontvjapan.com", 24608, 6, 239},
+ { "¥Õ¥¸¥Æ¥ì¥Ó£Ã£Ó£È£Ä", "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},
+ { "¥È¥¥¡¼¥ó¡¦¥Ç¥£¥º¥Ë¡¼", "1213.ontvjapan.com", 28736, 7, 334},
+ { "Åì±Ç¥Á¥ã¥ó¥Í¥ë", "1010.ontvjapan.com", 28768, 7, 221},
+ { "±ÒÀ±·à¾ì", "1005.ontvjapan.com", 28768, 7, 222},
+ { "¥Á¥ã¥ó¥Í¥ë£Î£Å£Ã£Ï", "1008.ontvjapan.com", 28768, 7, 223},
+ { "Íβè¡ú¥·¥Í¥Õ¥£¥ë", "1009.ontvjapan.com", 28768, 7, 224},
+ { "¥¹¥¿¡¼¡¦¥¯¥é¥·¥Ã¥¯", "1003.ontvjapan.com", 28768, 7, 238},
+ { "»þÂå·àÀìÌç¥Á¥ã¥ó¥Í¥ë", "1133.ontvjapan.com", 28768, 7, 292},
+ { "¥¹¡¼¥Ñ¡¼¥É¥é¥Þ", "1006.ontvjapan.com", 28768, 7, 310},
+ { "£Á£Ø£Î", "1014.ontvjapan.com", 28768, 7, 311},
+ { "¥Ê¥·¥ç¥¸¥ª¥Á¥ã¥ó¥Í¥ë", "1204.ontvjapan.com", 28768, 7, 343},
+ { "¥ï¥ó¥Æ¥ó¥Ý¡¼¥¿¥ë", "110ch.epgdata.ontvjapan", 28864, 7, 110},
+ { "¥´¥ë¥Õ¥Á¥ã¥ó¥Í¥ë", "1028.ontvjapan.com", 28864, 7, 260},
+ { "¥Æ¥ìÄ«¥Á¥ã¥ó¥Í¥ë", "1092.ontvjapan.com", 28864, 7, 303},
+ { "£Í£Ô£Ö", "1019.ontvjapan.com", 28864, 7, 323},
+ { "¥ß¥å¡¼¥¸¥Ã¥¯¡¦¥¨¥¢", "1024.ontvjapan.com", 28864, 7, 324},
+ { "Ä«Æü¥Ë¥å¡¼¥¹¥¿¡¼", "1067.ontvjapan.com", 28864, 7, 352},
+ { "£Â£Â£Ã¥ï¡¼¥ë¥É", "1070.ontvjapan.com", 28864, 7, 353},
+ { "£Ã£Î£Î£ê", "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},
+ { "ÊõÄÍ¥×¥í¥â¥Á¥ã¥ó¥Í¥ë", "101ch.epgdata.ontvjapan", 28928, 7, 101},
+ { "£Ó£Ë£Ù¡¦£Ó£Ô£Á£Ç£Å", "1207.ontvjapan.com", 28928, 7, 290},
+ { "¥Á¥ã¥ó¥Í¥ë¶ä²Ï", "305ch.epgdata.ontvjapan", 28928, 7, 305},
+ { "£Á£Ô-£Ø", "1201.ontvjapan.com", 28928, 7, 333},
+ { "¥Ò¥¹¥È¥ê¡¼¥Á¥ã¥ó¥Í¥ë", "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},
+ { "¥Õ¥¸¥Æ¥ì¥Ó£Ô£×£Ï", "1072.ontvjapan.com", 28992, 7, 308},
+ { "¥¢¥Ë¥Þ¥Ã¥¯¥¹", "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},
+ { "£Ô£Â£Ó¥Á¥ã¥ó¥Í¥ë", "3201.ontvjapan.com", 29024, 7, 301},
+ { "¥Ç¥£¥º¥Ë¡¼¥Á¥ã¥ó¥Í¥ë", "1090.ontvjapan.com", 29024, 7, 304},
+ { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325},
+ { "¥¥Ã¥º¥¹¥Æ¡¼¥·¥ç¥ó", "1045.ontvjapan.com", 29024, 7, 330},
+ { "£Ô£Â£Ó¥Ë¥å¡¼¥¹¥Ð¡¼¥É", "1076.ontvjapan.com", 29024, 7, 351},
+ { "£Ã£ÓÆüËÜÈÖÁÈ¥¬¥¤¥É", "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 desc[102400] = {0};
+char Category[1024];
+char ServiceName[1024];
+iconv_t cd ;
+
+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;
+ char *outptr ;
+ char *inptr ;
+ size_t ilen;
+ size_t olen;
+ 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 ;
+ }
+ outptr = title ;
+ memset(title, '\0', sizeof(title));
+ ilen = strlen(eitcur->title);
+ olen = sizeof(title);
+ inptr = eitcur->title;
+ iconv(cd, &inptr, &ilen, &outptr, &olen);
+ xmlspecialchars(title);
+
+ memset(subtitle, '\0', sizeof(subtitle));
+ ilen = strlen(eitcur->subtitle);
+ olen = sizeof(subtitle);
+ outptr = subtitle ;
+ inptr = eitcur->subtitle;
+ iconv(cd, &inptr, &ilen, &outptr, &olen);
+ xmlspecialchars(subtitle);
+
+ memset(desc, '\0', sizeof(desc));
+ if ( eitcur->desc ) {
+ ilen = strlen(eitcur->desc);
+ olen = sizeof(desc);
+ outptr = desc ;
+ inptr = eitcur->desc;
+ iconv(cd, &inptr, &ilen, &outptr, &olen);
+ xmlspecialchars(desc);
+ }
+
+ memset(Category, '\0', sizeof(Category));
+ ilen = strlen(ContentCatList[eitcur->content_type].japanese);
+ olen = sizeof(Category);
+ outptr = Category ;
+ inptr = ContentCatList[eitcur->content_type].japanese;
+ iconv(cd, &inptr, &ilen, &outptr, &olen);
+ 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, " <programme start=\"%s +0900\" stop=\"%s +0900\" channel=\"%s\">\n",
+ cstarttime, cendtime, psta->ontv);
+ fprintf(outfile, " <title lang=\"ja_JP\">%s</title>\n", title);
+ fprintf(outfile, " <desc lang=\"ja_JP\">%s</desc>\n", subtitle);
+ fprintf(outfile, " <longdesc lang=\"ja_JP\">%s</longdesc>\n", desc);
+ fprintf(outfile, " <category lang=\"ja_JP\">%s</category>\n", Category);
+ fprintf(outfile, " <category lang=\"en\">%s</category>\n", ContentCatList[eitcur->content_type].english);
+ fprintf(outfile, " </programme>\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;
+ int arg_maxcount = 1 ;
+ char *arg_onTV ;
+ int mode = 1;
+ int staCount ;
+ int eitcnt;
+ char *file;
+ int inclose = 0;
+ int outclose = 0;
+ int flag = 0 ;
+ SVT_CONTROL *svtcur ;
+ SVT_CONTROL *svtsave ;
+ char *outptr ;
+ char *inptr ;
+ size_t ilen;
+ size_t olen;
+ SECcache secs[SECCOUNT];
+ int rtn;
+ int lp ;
+ STATION *pStas ;
+ int act ;
+
+ /* ¶½Ì£¤Î¤¢¤ëpid¤ò»ØÄê */
+ 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 <tsFile> <outfile>\n", argv[0]);
+ fprintf(stdout, "Usage : %s <ontvcode> <tsFile> <outfile>\n", argv[0]);
+ fprintf(stdout, "ontvcode ¥Á¥ã¥ó¥Í¥ë¼±Ê̻ҡ£****.ontvjapan.com ¤Ê¤É\n");
+ fprintf(stdout, "/BS BS¥â¡¼¥É¡£°ì¤Ä¤ÎTS¤«¤éBSÁ´¶É¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ß¤Þ¤¹¡£\n");
+ fprintf(stdout, "/CS CS¥â¡¼¥É¡£°ì¤Ä¤ÎTS¤«¤éÊ£¿ô¶É¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ß¤Þ¤¹¡£\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 ;
+ }
+
+ 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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ fprintf(outfile, "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n");
+ fprintf(outfile, "<tv generator-info-name=\"tsEPG2xml\" generator-info-url=\"http://localhost/\">\n");
+
+ cd = iconv_open("UTF-8", "EUC-JP");
+ for(lp = 0 ; lp < staCount ; lp++){
+ memset(ServiceName, '\0', sizeof(ServiceName));
+ ilen = strlen(pStas[lp].name);
+ olen = sizeof(ServiceName);
+ outptr = ServiceName ;
+ inptr = pStas[lp].name ;
+ iconv(cd, &inptr, &ilen, &outptr, &olen);
+ xmlspecialchars(ServiceName);
+
+ fprintf(outfile, " <channel id=\"%s\">\n", pStas[lp].ontv);
+ fprintf(outfile, " <display-name lang=\"ja_JP\">%s</display-name>\n", ServiceName);
+ fprintf(outfile, " </channel>\n");
+ }
+ for(lp = 0 ; lp < staCount ; lp++){
+ GetEIT(infile, outfile, &pStas[lp], secs, SECCOUNT);
+ }
+ fprintf(outfile, "</tv>\n");
+ if(inclose) {
+ fclose(infile);
+ }
+
+ if(outclose) {
+ fclose(outfile);
+ }
+ iconv_close(cd);
+ if(act){
+ free(pStas);
+ svtcur = svttop ; //ÀèƬ
+ while(svtcur != NULL){
+ svtsave = svtcur->next ;
+ free(svtcur);
+ svtcur = svtsave ;
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+diff -Nur epgdumpr2_orig/ts.c epgdumpr2/ts.c
+--- epgdumpr2_orig/ts.c 2009-03-15 21:35:57.000000000 +0900
++++ epgdumpr2/ts.c 2009-07-19 18:38:17.000000000 +0900
+@@ -202,6 +202,11 @@
+ pk.payloadlen -= 1;
+ }
+ memset(pk.payload, 0xFF, sizeof(pk.payload));
++#if 1 /* 07/07/2009 add: */
++ if( pk.payloadlen > sizeof(pk.payload) ){
++ continue;
++ }
++#endif
+ memcpy(pk.payload, payptr, pk.payloadlen);
+
+ /*
+@@ -307,6 +312,14 @@
+
+ int checkcrc(SECcache *secs) {
+
++#if 1 /* 07/07/2009 add: °Û¾ï¾õÂÖ²óÈò¤Î¤¿¤á */
++ /* ¥»¥¯¥·¥ç¥óºÇÂçŤòĶ¤¨¤ë¤³¤È¤Ê¤É¤¢¤êÆÀ¤Ê¤¤¤Ï¤º¤À¤¬... */
++ if( secs->seclen > MAXSECLEN ){
++ /* ¤è¤¯Ê¬¤«¤é¤ó¤Î¤ÇÇË´þ¤·¤Æ¤ä¤ë */
++ return 0;
++ }
++#endif
++
+ /* ¥»¥¯¥·¥ç¥ó¤Î½ª¤ê¤ËÃÖ¤«¤ì¤ë4¥Ð¥¤¥È¤ÎCRC32¤Ï¡¢
+ CRC·×»»¤Î·ë²Ì0¤Ë¤Ê¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤ë¡£
+ Ãͤ¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢¥¨¥é¡¼¤Ê¤Î¤ÇÂоݳ°¤Ë¤¹¤ë */
--- /dev/null
+begin-base64 644 t1.uuc
+H4sIAFTfZkoAA+2TTU8TQRjHe91+ikm80G63ndltu1AiqSFwUg568dY0223Z
+AG2zu01AwocBnzVESSCgVkBLAwQq1cIJD8YYExOEkphAvBpnaA1WkRPBg88v
+m3nb5+U//+yaxVymNFZMOWYumy6NuqmsNZ4qpl1jOOyOu74rgXLi0aiYmR7X
+WnOMnp2LdVTXfYypGo3TmM5UH2XxmE59hF5N+8spOW7aJsSXL+RKxrB1SZxp
+O9ch6HrJWNksUYZKNjFbX4Ktpgq2lYu4Ttg4Pzvb+hVFuShMUintUaimsBhR
+WUKLJWJ6mP6EyLSHUr8sy7+Va6fpCushrDuhdSfYn2nJJFFUqobiRBYTYySZ
+9BNJkooj4WJ6YrSQzoyaeaLcJKxXnE+JYcwcc0y36zwkROj44GCIONYDs5D9
+5UUg0OuXb1hZwqRIkFA9wh8hi6QzmQQJRvyyJFnZLtLZre+CQiQwKYIlo5B3
+rXzJ7BW7KV7czHOP26qM4kSHKr4ounaoszyXRAQiJxI8c0CjunBAY9yB6JkD
+fmLlXWIMm8aIYRtd9wb6jTTfkaBjGk6ATPKIv99r4X3la+Xb+v7iae0EGrAG
+n1pX5aHeqjfvlb0D73Rle/1gcxlONp/DLDRhCWqwA69hBo62qnwFsAsrUIW5
+cDjcyhY+ie5KHx9bNt25dZ8ruz0w1HaHN4AvML8zB0/gEE557+3t+tPvUIYt
++AzNtuG26ZbsPKHCwnMHZe5Hh0BovHoMR1Df2OfVjqEZ9fY88GrQ6L/br6mw
+Oz3DM7iPfFt+t7oKjXJz8Q2FOhff5CoeQb36cfMInonc6Yet2I23MFebr77g
+itYqx8sHooo36x1Ov+RZXO36XuXD0gKvsdxS+69/XwRBEARBEARBEARBEARB
+EARBEARBEARBEOQ/5wfnyBSoACgAAA==
+====
--- /dev/null
+diff -rcw epgdumpr2.old/eit.c epgdumpr2/eit.c
+*** epgdumpr2.old/eit.c 2009-03-15 19:02:33.000000000 +0900
+--- epgdumpr2/eit.c 2009-03-24 20:45:25.961750270 +0900
+***************
+*** 6,11 ****
+--- 6,14 ----
+
+ char *subtitle_cnv_str[] = {
+ "¡¡Âè",
++ "¡¼Âè",
++ "-Âè",
++ " Âè",
+ "¡¡¡Ö",
+ "¡¡¡ô",
+ "¡Ê",
+***************
+*** 39,45 ****
+ return 14;
+ }
+
+! int parseEITbody(unsigned char *data, EITbody *b) {
+ int boff = 0;
+ int tnum;
+ char buf[4];
+--- 42,49 ----
+ return 14;
+ }
+
+! int parseEITbody(unsigned char *data, EITbody *b)
+! {
+ int boff = 0;
+ int tnum;
+ char buf[4];
+***************
+*** 78,97 ****
+
+ b->yy += 1900;
+
+ sprintf(buf, "%x", b->start_time[2]);
+ b->hh = atoi(buf);
+ sprintf(buf, "%x", b->start_time[3]);
+ b->hm = atoi(buf);
+ sprintf(buf, "%x", b->start_time[4]);
+ b->ss = atoi(buf);
+
+ sprintf(buf, "%x", b->duration[0]);
+ b->dhh = atoi(buf);
+ sprintf(buf, "%x", b->duration[1]);
+ b->dhm = atoi(buf);
+ sprintf(buf, "%x", b->duration[2]);
+ b->dss = atoi(buf);
+!
+ return 12;
+ }
+
+--- 82,110 ----
+
+ 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;
+ }
+
+***************
+*** 269,274 ****
+--- 282,291 ----
+ if(ptr == NULL){
+ continue ;
+ }
++ // ¥¿¥¤¥È¥ë¤¬¤Ê¤¯¤Ê¤é¤Ê¤¤¤è¤¦¤Ë
++ if(ptr == eitptr->title){
++ continue ;
++ }
+ newsubtitle = calloc(1, ((strlen(ptr) + 1) + (strlen(eitptr->subtitle) + 1)));
+ memcpy(newsubtitle, ptr, strlen(ptr));
+ newsubtitle[strlen(ptr)] = ' ';
+diff -rcw epgdumpr2.old/epgdump.c epgdumpr2/epgdump.c
+*** epgdumpr2.old/epgdump.c 2009-03-15 21:29:33.000000000 +0900
+--- epgdumpr2/epgdump.c 2009-03-24 20:55:30.885022486 +0900
+***************
+*** 177,183 ****
+ char *inptr ;
+ size_t ilen;
+ size_t olen;
+! time_t time ;
+ time_t end_time ;
+ struct tm tl ;
+ struct tm *endtl ;
+--- 177,183 ----
+ char *inptr ;
+ size_t ilen;
+ size_t olen;
+! time_t l_time ;
+ time_t end_time ;
+ struct tm tl ;
+ struct tm *endtl ;
+***************
+*** 239,247 ****
+ tl.tm_wday = 0;
+ tl.tm_isdst = 0;
+ tl.tm_yday = 0;
+! time = mktime(&tl);
+! end_time = 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);
+--- 239,253 ----
+ 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);
--- /dev/null
+xmltv-epg
+
+MPEG-TS\82É\8aÜ\82Ü\82ê\82éepg\82ðxml\82Å\8fo\97Í\82·\82é\83v\83\8d\83O\83\89\83\80\82Å\82·\81B
+\81\9fN/E9PqspSk\8e\81\82ªrecfriio Solaris\94Å(http://2sen.dip.jp/cgi-bin/friioup/source/up0737.zip)\82É\8aÜ\82Ü\82ê\82éepgdump\82ð
+Linux\94Å\82ð\89ü\91¢\82µ\82½\82à\82Ì\82ð\83x\81[\83X\82Éxmltv\97p\82Ìxml\83t\83@\83C\83\8b\82ð\8dì\90¬\82µ\82Ü\82·\81B
+
+\82Ü\82½\81A\83^\83C\83g\83\8b\93à\82É\8aÜ\82Ü\82ê\82é
+ "\81@\91æ"\82â\81A"\81@\81u"\81A"\81@\81\94"\81A"\81i"\81A"\81u"\81A\82ð\83T\83u\83^\83C\83g\83\8b\82Æ\82µ\82Ä\88µ\82¤\97l\82É\8fC\90³\82µ\82Ä\82¢\82Ü\82·\81B
+\97á\81F
+
+\83^\83C\83g\83\8b\82ª\81A
+\96¾\93ú\82Ì\82æ\82¢\82¿\81I\81u\82 \82Ì\8e\9e\8cN\82Í\83\8f\83\8b\82©\82Á\82½\81v
+\82Ì\8fê\8d\87
+\96¾\93ú\82Ì\82æ\82¢\82¿\81I\82ª\83^\83C\83g\83\8b\82É\81A\81u\82 \82Ì\8e\9e\8cN\82Í\83\8f\83\8b\82©\82Á\82½\81v\82ª\83T\83u\83^\83C\83g\83\8b\82É\92Ç\89Á\82³\82ê\82Ü\82·\81B
+
+\83T\83u\83^\83C\83g\83\8b\82Æ\82µ\82Ä\88µ\82¤\82à\82Ì\82ð\91\9d\82â\82·\8fê\8d\87\82Í\81Aeit.c\82É\82 \82ésubtitle_cnv_str\82É\92Ç\89Á\82µ\82Ä\82\82¾\82³\82¢\81B
+
+\8eg\97p\95û\96@\82Í\88È\89º\82Ì\92Ê\82è\82Å\82·\81B
+
+Usage : ./epgdump /BS <tsFile> <outfile>
+Usage : ./epgdump <ontvcode> <tsFile> <outfile>
+ontvcode \83`\83\83\83\93\83l\83\8b\8e¯\95Ê\8eq\81B****.ontvjapan.com \82È\82Ç
+/BS BS\83\82\81[\83h\81B\88ê\82Â\82ÌTS\82©\82çBS\91S\8bÇ\82Ì\83f\81[\83^\82ð\93Ç\82Ý\8d\9e\82Ý\82Ü\82·\81B
+/CS CS\83\82\81[\83h\81B\88ê\82Â\82ÌTS\82©\82ç\95¡\90\94\8bÇ\82Ì\83f\81[\83^\82ð\93Ç\82Ý\8d\9e\82Ý\82Ü\82·\81B
+
+make\82·\82é\82Æepgdump\82ª\83r\83\8b\83h\82³\82ê\82Ü\82·\81B
+
+epgdump\83\89\83C\83Z\83\93\83X(Solaris\94Å\82æ\82è\88ø\97p):
+>epgdump\82É\8aÖ\82µ\82Ä\82Í\81ABonTest Ver.1.40\82©\82ç\82»\82Ì\82Ü\82Ü\83\\81[\83X\82ð\8e\9d\82Á\82Ä\82«\82Ä\82¢\82é\95\94\95ª\82à
+>\82 \82é\82½\82ß\81A\82»\82Ì\83\89\83C\83Z\83\93\83X\82É\8f]\82¢\82µ\82Ü\82·\81B
+>BonTest\82ÌReadme.txt\82æ\82è
+>>
+>>\82R\81D\83\89\83C\83Z\83\93\83X\82É\82Â\82¢\82Ä
+>>\81@\81@\81E\96{\83p\83b\83P\81[\83W\82É\8aÜ\82Ü\82ê\82é\91S\82Ä\82Ì\83\\81[\83X\83R\81[\83h\81A\83o\83C\83i\83\8a\82É\82Â\82¢\82Ä\92\98\8dì\8c \82Í\88ê\90Ø\8eå\92£\82µ\82Ü\82¹\82ñ\81B
+>>\81@\81@\81E\83I\83\8a\83W\83i\83\8b\82Ì\82Ü\82Ü\96\94\82Í\89ü\95Ï\82µ\81A\8ae\8e©\82Ì\83\\83t\83g\83E\83F\83A\82É\8e©\97R\82É\93Y\95t\81A\91g\82Ý\8d\9e\82Þ\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+>>\81@\81@\81E\92A\82µGPL\82É\8f]\82¤\82±\82Æ\82ð\97v\8b\81\82µ\82Ü\82·\82Ì\82Å\82±\82ê\82ç\82ð\8ds\82¤\8fê\8d\87\82Í\83\\81[\83X\83R\81[\83h\82Ì\8aJ\8e¦\82ª\95K\90{\82Æ\82È\82è\82Ü\82·\81B
+>>\81@\81@\81E\82±\82Ì\82Æ\82«\96{\83\\83t\83g\83E\83F\83A\82Ì\92\98\8dì\8c \95\\8e¦\82ð\8ds\82¤\82©\82Ç\82¤\82©\82Í\94C\88Ó\82Å\82·\81B
+>>\81@\81@\81E\96{\83\\83t\83g\83E\83F\83A\82ÍFAAD2\82Ì\83\89\83C\83u\83\89\83\8a\94Å\83o\83C\83i\83\8a\82ð\8eg\97p\82µ\82Ä\82¢\82Ü\82·\81B
+>>
+>>\81@\81@\81@"Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+>>
+>>\81@\81@\81E\83r\83\8b\83h\82É\95K\97v\82È\8aÂ\8b«
+>>\81@\81@\81@- Microsoft Visual Studio 2005 \88È\8fã\81@\81¦MFC\82ª\95K\97v
+>>\81@\81@\81@- Microsoft Windows SDK v6.0 \88È\8fã\81@\81@\81¦DirectShow\8aî\92ê\83N\83\89\83X\82Ì\83R\83\93\83p\83C\83\8b\8dÏ\82Ý\83\89\83C\83u\83\89\83\8a\82ª\95K\97v
+>>\81@\81@\81@- Microsoft DirectX 9.0 SDK \88È\8fã
+
+Special Thanks:
+\81ESolaris\94Å\8aJ\94\8eÒ\82Ì\95û
+\81E\8ag\92£\83c\81[\83\8b\92\86\82Ì\90l
+\81E\81\9fN/E9PqspSk\8e\81
+\81EARIB(\8e\91\97¿\82Ì\96³\97¿\83_\83E\83\93\83\8d\81[\83h\82É\91Î\82µ\82Ä)
+
+\93®\8dì\8am\94F\8aÂ\8b«:
+ Debian GNU/Linux sid
+ Linux 2.6.27.19 SMP PREEMPT x86_64
+
+tomy \81\9fCfWlfzSGyg
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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¤ÏCRC
+ 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:\83f\83W\83^\83\8bTV\83T\81[\83r\83X
+0xA5:\83v\83\8d\83\82\81[\83V\83\87\83\93\89f\91\9c\83T\81[\83r\83X
+0x0C:\83f\81[\83^\83T\81[\83r\83X
+ */
+ 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;
+}
--- /dev/null
+#ifndef SDT_H
+#define SDT_H 1
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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 {
+ /* ¤³¤³¤Çseclen¤¬¸Ù¤ë¤è¤¦¤Ë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) {
+ /* ºÇ½é¤ÏbufÃæ¤Ë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 1 /* 07/07/2009 add: */
+ if( pk.payloadlen > sizeof(pk.payload) ){
+ continue;
+ }
+#endif
+ memcpy(pk.payload, payptr, pk.payloadlen);
+
+ /*
+ if(pk.rcount == 62) {
+ printf("62\n");
+ }
+
+ if(pk.rcount == 63) {
+ printf("63\n");
+ }
+ */
+
+ /* ¶½Ì£¤Î¤¢¤ëpid¤«³Îǧ */
+ 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) {
+
+#if 1 /* 07/07/2009 add: °Û¾ï¾õÂÖ²óÈò¤Î¤¿¤á */
+ /* ¥»¥¯¥·¥ç¥óºÇÂçŤòĶ¤¨¤ë¤³¤È¤Ê¤É¤¢¤êÆÀ¤Ê¤¤¤Ï¤º¤À¤¬... */
+ if( secs->seclen > MAXSECLEN ){
+ /* ¤è¤¯Ê¬¤«¤é¤ó¤Î¤ÇÇË´þ¤·¤Æ¤ä¤ë */
+ return 0;
+ }
+#endif
+
+ /* ¥»¥¯¥·¥ç¥ó¤Î½ª¤ê¤ËÃÖ¤«¤ì¤ë4¥Ð¥¤¥È¤ÎCRC32¤Ï¡¢
+ CRC·×»»¤Î·ë²Ì0¤Ë¤Ê¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤ë¡£
+ Ãͤ¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢¥¨¥é¡¼¤Ê¤Î¤ÇÂоݳ°¤Ë¤¹¤ë */
+ if(CalcCrc(0xffffffffU, secs->buf, secs->seclen)) {
+// fprintf(stderr, "tblid:0x%x CRC error\n", secs->buf[0]);
+ return 0;
+ }
+ return 1;
+}
+
--- /dev/null
+#ifndef TS_H
+#define TS_H 1
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#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
--- /dev/null
+#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 ; // ¥µ¥Ö¥¿¥¤¥È¥ë
+ char *desc ; // Description
+};
+#endif
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "aribstr.h"
+#include "util.h"
+
+int strrep(char *buf, char *mae, char *ato)
+{
+ char *mituke;
+ size_t maelen, atolen;
+
+ maelen = strlen(mae);
+ atolen = strlen(ato);
+ if (maelen == 0 || (mituke = strstr(buf, mae)) == NULL) return 0;
+ memmove(mituke + atolen, mituke + maelen, strlen(buf) - (mituke + maelen - buf ) + 1);
+ memcpy(mituke, ato, 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¤ÎºÇÂç32bit */
+ unsigned int tnum;
+
+ memcpy(tbuf, fbyte, sizeof(unsigned char) * 4);
+
+ /* ÀèƬ¥Ð¥¤¥È¤«¤éÉÔÍ×bit¤ò¥«¥Ã¥È */
+ 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;
+}
+
--- /dev/null
+#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
--- /dev/null
+static STATION bsSta[] = {
+ { "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101},
+ { "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102},
+ { "NHK BSh", "3003.ontvjapan.com", 16626, 4, 103},
+ { "BSÆü¥Æ¥ì", "3004.ontvjapan.com", 16592, 4, 141},
+ { "BSÄ«Æü", "3005.ontvjapan.com", 16400, 4, 151},
+ { "BS-i", "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},
+ { "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},
+ { "ÆüËܱDzèÀìÌç£ã£è£È£Ä", "1086.ontvjapan.com", 24608, 6, 239},
+ { "¥Õ¥¸¥Æ¥ì¥Ó£Ã£Ó£È£Ä", "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},
+ { "¥È¥¥¡¼¥ó¡¦¥Ç¥£¥º¥Ë¡¼", "1213.ontvjapan.com", 28736, 7, 334},
+ { "Åì±Ç¥Á¥ã¥ó¥Í¥ë", "1010.ontvjapan.com", 28768, 7, 221},
+ { "±ÒÀ±·à¾ì", "1005.ontvjapan.com", 28768, 7, 222},
+ { "¥Á¥ã¥ó¥Í¥ë£Î£Å£Ã£Ï", "1008.ontvjapan.com", 28768, 7, 223},
+ { "Íβè¡ú¥·¥Í¥Õ¥£¥ë", "1009.ontvjapan.com", 28768, 7, 224},
+ { "¥¹¥¿¡¼¡¦¥¯¥é¥·¥Ã¥¯", "1003.ontvjapan.com", 28768, 7, 238},
+ { "»þÂå·àÀìÌç¥Á¥ã¥ó¥Í¥ë", "1133.ontvjapan.com", 28768, 7, 292},
+ { "¥¹¡¼¥Ñ¡¼¥É¥é¥Þ", "1006.ontvjapan.com", 28768, 7, 310},
+ { "£Á£Ø£Î", "1014.ontvjapan.com", 28768, 7, 311},
+ { "¥Ê¥·¥ç¥¸¥ª¥Á¥ã¥ó¥Í¥ë", "1204.ontvjapan.com", 28768, 7, 343},
+ { "¥ï¥ó¥Æ¥ó¥Ý¡¼¥¿¥ë", "110ch.epgdata.ontvjapan", 28864, 7, 110},
+ { "¥´¥ë¥Õ¥Á¥ã¥ó¥Í¥ë", "1028.ontvjapan.com", 28864, 7, 260},
+ { "¥Æ¥ìÄ«¥Á¥ã¥ó¥Í¥ë", "1092.ontvjapan.com", 28864, 7, 303},
+ { "£Í£Ô£Ö", "1019.ontvjapan.com", 28864, 7, 323},
+ { "¥ß¥å¡¼¥¸¥Ã¥¯¡¦¥¨¥¢", "1024.ontvjapan.com", 28864, 7, 324},
+ { "Ä«Æü¥Ë¥å¡¼¥¹¥¿¡¼", "1067.ontvjapan.com", 28864, 7, 352},
+ { "£Â£Â£Ã¥ï¡¼¥ë¥É", "1070.ontvjapan.com", 28864, 7, 353},
+ { "£Ã£Î£Î£ê", "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},
+ { "ÊõÄÍ¥×¥í¥â¥Á¥ã¥ó¥Í¥ë", "101ch.epgdata.ontvjapan", 28928, 7, 101},
+ { "£Ó£Ë£Ù¡¦£Ó£Ô£Á£Ç£Å", "1207.ontvjapan.com", 28928, 7, 290},
+ { "¥Á¥ã¥ó¥Í¥ë¶ä²Ï", "305ch.epgdata.ontvjapan", 28928, 7, 305},
+ { "£Á£Ô-£Ø", "1201.ontvjapan.com", 28928, 7, 333},
+ { "¥Ò¥¹¥È¥ê¡¼¥Á¥ã¥ó¥Í¥ë", "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, 258},
+ { "¥Õ¥¸¥Æ¥ì¥Ó£·£²£±", "1072.ontvjapan.com", 28992, 7, 302},
+ { "¥¢¥Ë¥Þ¥Ã¥¯¥¹", "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},
+ { "£Ô£Â£Ó¥Á¥ã¥ó¥Í¥ë", "3201.ontvjapan.com", 29024, 7, 301},
+ { "¥Ç¥£¥º¥Ë¡¼¥Á¥ã¥ó¥Í¥ë", "1090.ontvjapan.com", 29024, 7, 304},
+ { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325},
+ { "¥¥Ã¥º¥¹¥Æ¡¼¥·¥ç¥ó", "1045.ontvjapan.com", 29024, 7, 330},
+ { "£Ô£Â£Ó¥Ë¥å¡¼¥¹¥Ð¡¼¥É", "1076.ontvjapan.com", 29024, 7, 351},
+ { "£Ã£ÓÆüËÜÈÖÁÈ¥¬¥¤¥É", "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);