From 695d6d36ac8bf635d1de640c290d905f65011de1 Mon Sep 17 00:00:00 2001 From: xtne6f Date: Mon, 5 Oct 2020 23:36:06 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B4=E9=96=A2=E9=80=A3=E3=81=AE?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=BF=E3=83=95=E3=82=A7=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp | 53 +++++++++++++++++++-- ini/HttpPublic/legacy/logo.lua | 39 +++++++++++++-- 2 files changed, 82 insertions(+), 10 deletions(-) diff --git a/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp b/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp index cfcdb2edc9..a6115df48e 100644 --- a/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp +++ b/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp @@ -2890,12 +2890,14 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM DWORD readSize; if( ReadVALUE(&ver, cmdParam.data, cmdParam.dataSize, &readSize) ){ vector list; - if( ReadVALUE2(ver, &list, cmdParam.data.get() + readSize, cmdParam.dataSize - readSize, NULL) && list.size() < 32 ){ + if( ReadVALUE2(ver, &list, cmdParam.data.get() + readSize, cmdParam.dataSize - readSize, NULL) ){ + //転送サイズがtotalSizeRemainより大きい場合、結果はトリムされる + size_t totalSizeRemain = 256 * 1024 * 1024; vector result(list.size()); for( size_t i = 0; i < list.size(); i++ ){ - result[i].Name = list[i]; fs_path path; - if( UtilComparePath(list[i].c_str(), L"ChSet5.txt") == 0 ){ + if( UtilComparePath(list[i].c_str(), L"ChSet5.txt") == 0 || + UtilComparePath(list[i].c_str(), LOGO_SAVE_FOLDER L".ini") == 0 ){ path = GetSettingPath().append(list[i]); }else if( UtilComparePath(list[i].c_str(), L"EpgTimerSrv.ini") == 0 || UtilComparePath(list[i].c_str(), L"Common.ini") == 0 || @@ -2904,9 +2906,39 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM UtilComparePath(list[i].c_str(), L"ViewApp.ini") == 0 || UtilComparePath(list[i].c_str(), L"Bitrate.ini") == 0 ){ path = GetCommonIniPath().replace_filename(list[i]); + }else{ + //ロゴフォルダに対する特例 + size_t namePos = array_size(LOGO_SAVE_FOLDER L"\\") - 1; + if( list[i].size() > namePos && UtilComparePath(list[i].substr(0, namePos).c_str(), LOGO_SAVE_FOLDER L"\\") == 0 ){ + path = GetSettingPath().append(LOGO_SAVE_FOLDER); + wstring name = list[i].substr(namePos); + if( name != L"*.*" ){ + CheckFileName(name); + } + path.append(name); + } } if( path.empty() == false ){ - if( UtilPathEndsWith(path.c_str(), L".ini") ){ + if( UtilPathEndsWith(path.c_str(), L"*.*") ){ + //ファイルリストを返す + wstring strData = L"\xFEFF"; + EnumFindFile(path, [&strData](UTIL_FIND_DATA& findData) -> bool { + WCHAR prop[64]; + swprintf_s(prop, L"%d %lld %lld ", + findData.isDir ? 1 : 0, findData.lastWriteTime + I64_UTIL_TIMEZONE, findData.fileSize); + strData += prop; + strData += findData.fileName; + strData += L"\r\n"; + return true; + }); + if( totalSizeRemain < strData.size() ){ + result.resize(i); + break; + } + totalSizeRemain -= strData.size(); + //BOMつきUTF-16 + result[i].Data.assign((const BYTE*)strData.c_str(), (const BYTE*)(strData.c_str() + strData.size())); + }else if( UtilPathEndsWith(path.c_str(), L".ini") ){ //ファイルロックを邪魔しないようAPI経由で読む wstring strData = L"\xFEFF"; int appendModulePathState = UtilComparePath(path.filename().c_str(), L"Common.ini") == 0; @@ -2933,6 +2965,11 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM strData += L"[SET]\r\nModulePath=\"" + GetCommonIniPath().parent_path().native() + L"\"\r\n"; } if( strData.size() > 1 ){ + if( totalSizeRemain < strData.size() ){ + result.resize(i); + break; + } + totalSizeRemain -= strData.size(); //BOMつきUTF-16 result[i].Data.assign((const BYTE*)strData.c_str(), (const BYTE*)(strData.c_str() + strData.size())); } @@ -2940,7 +2977,12 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM std::unique_ptr fp(UtilOpenFile(path, UTIL_SECURE_READ), fclose); if( fp && _fseeki64(fp.get(), 0, SEEK_END) == 0 ){ __int64 fileSize = _ftelli64(fp.get()); - if( 0 < fileSize && fileSize < 16 * 1024 * 1024 ){ + if( 0 < fileSize ){ + if( (__int64)totalSizeRemain < fileSize ){ + result.resize(i); + break; + } + totalSizeRemain -= (size_t)fileSize; result[i].Data.resize((size_t)fileSize); rewind(fp.get()); if( fread(&result[i].Data.front(), 1, (size_t)fileSize, fp.get()) != (size_t)fileSize ){ @@ -2950,6 +2992,7 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM } } } + result[i].Name.swap(list[i]); } resParam.data = NewWriteVALUE2WithVersion(ver, result, resParam.dataSize); resParam.param = CMD_SUCCESS; diff --git a/ini/HttpPublic/legacy/logo.lua b/ini/HttpPublic/legacy/logo.lua index 6952050192..4ab1c100a5 100644 --- a/ini/HttpPublic/legacy/logo.lua +++ b/ini/HttpPublic/legacy/logo.lua @@ -1,7 +1,7 @@ -- 局ロゴを転送するスクリプト --- LogoData.iniとLogoフォルダがあるフォルダの絶対パス --- 未指定のとき局ロゴは公開フォルダ下の"img/logo/ONIDSID{.png|.bmp}"と仮定 +-- EDCBのロゴフォルダにロゴがないときに検索する、LogoData.iniとLogoフォルダがあるフォルダの絶対パス +-- 未指定のときは公開フォルダ下の"img/logo/ONIDSID{.png|.bmp}"が使われる --LOGO_DIR=edcb.GetPrivateProfile('SET','ModulePath','','Common.ini')..'\\..\\TVTest' dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') @@ -9,10 +9,39 @@ dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') onid=GetVarInt(mg.request_info.query_string,'onid',0,65535) or 0 sid=GetVarInt(mg.request_info.query_string,'sid',0,65535) or 0 -if LOGO_DIR then +-- ロゴ識別とServiceIDとの対応を調べる +ddid=tonumber(edcb.GetPrivateProfile('LogoIDMap',('%04X%04X'):format(onid,sid),'','Setting\\LogoData.ini')) +if ddid then + dir=edcb.GetPrivateProfile('SET','DataSavePath','','Common.ini') + if dir=='' then + dir=edcb.GetPrivateProfile('SET','ModulePath','','Common.ini')..'\\Setting' + end + dir=dir..'\\LogoData\\' + ff=edcb.FindFile(dir..('%04X_%03X_*'):format(onid,ddid),6) or {} + -- ファイル名の末尾2桁はロゴタイプ(STD-B21) + for i,v in ipairs({'05%.png','02%.png','04%.png','01%.png','03%.png','00%.png'}) do + for j,w in ipairs(ff) do + if w.name:lower():find(v..'$') then + fname=w.name + break + end + end + if fname then + f=edcb.io.open(dir..fname,'rb') + if f then + logo=f:read('*a') + f:close() + end + break + end + end +end + +if not logo and LOGO_DIR then + fname=nil f=edcb.io.open(LOGO_DIR..'\\LogoData.ini','rb') if f then - -- ダウンロードデータ識別とServiceIDとの対応を調べる + -- ロゴ識別とServiceIDとの対応を調べる ddid=tonumber(f:read('*a'):upper():match(('\n%04X%04X=(%%d+)'):format(onid,sid))) f:close() if ddid then @@ -36,7 +65,7 @@ if LOGO_DIR then end end end -else +elseif not logo then fname=('%04X%04X.png'):format(onid,sid) f=edcb.io.open(DocumentToNativePath('img/logo/'..fname),'rb') if not f then