void WriteLog(char *s) { HDD_TAP_PushDir(); TAP_Hdd_ChangeDir(ROOTDIR); LogEntry(LOGFILE, "SDS", TRUE, TIMESTAMP_YMDHMS, s); HDD_TAP_PopDir(); }
char *LogoManager_GetPathToLogoByChannelID(ulong64 ChannelID, tLogoStyle LogoStyle, tLogoSize LogoSize, tLogoAspect LogoAR, char *LogoPath) { TRACEENTER(); char s[20], LP[FBLIB_DIR_SIZE]; if(LogoPath) { LogoManager_Initialize(LogoManager_CB); TAP_SPrint(LogoPath, "%s/", LogoManager_GetDirectory(LogoStyle, LogoAR, LP)); HDD_TAP_PushDir(); HDD_ChangeDir(LOGOROOT); if(TAP_Hdd_Exist(LILNAME)) { TAP_SPrint(s, "%16.16llx", ChannelID); INIOpenFile(LILNAME, NULL); INIGetString(s, &LogoPath[strlen(LogoPath)], "", 40); INICloseFile(); HDD_TAP_PopDir(); switch(LogoSize) { case LGSZ_qtl: strcat(LogoPath, ".qtl"); break; case LGSZ_ibl: strcat(LogoPath, ".ibl"); break; case LGSZ_qsl: strcat(LogoPath, ".qsl"); break; default: break; } TRACEEXIT(); return LogoPath; } HDD_TAP_PopDir(); } TRACEEXIT(); return ""; }
void CreateRootDir(void) { TRACEENTER(); //Check & Create Folders HDD_TAP_PushDir(); HDD_ChangeDir("/ProgramFiles"); if(!TAP_Hdd_Exist("Settings")) TAP_Hdd_Create("Settings", ATTR_FOLDER); HDD_ChangeDir("Settings"); if(!TAP_Hdd_Exist("SDS")) TAP_Hdd_Create("SDS", ATTR_FOLDER); HDD_TAP_PopDir(); TRACEEXIT(); }
void LogoManager_ProcessLILAdd(char *AddFileName) { TRACEENTER(); TYPE_File *f; int fs; char *Text, Line[80]; HDD_TAP_PushDir(); HDD_ChangeDir(LOGOROOT); INIOpenFile(LILNAME, NULL); f = TAP_Hdd_Fopen(AddFileName); if(f) { fs = TAP_Hdd_Flen(f); Text = TAP_MemAlloc(fs+1); if(Text) { TAP_Hdd_Fread(Text, 1, fs, f); Text[fs] = '\0'; while(*Text) { ExtractLine(Text, Line); if(Line[0] == '0' && Line[1] == 'x' && Line[18] == '=') { LowerCase(Line); Line[18] = '\0'; INISetString(&Line[2], &Line[19]); } } TAP_MemFree(Text); } TAP_Hdd_Fclose(f); } INISaveFile(LILNAME, INILOCATION_AtCurrentDir, NULL); INICloseFile(); HDD_TAP_PopDir(); TRACEEXIT(); }
void LogEntryGeneric(char *ProgramName, bool Console, char *Text) { TRACEENTER(); char *s; int l; TYPE_File *File; char TimeResult[40]; char CRLF[] = {'\r', '\n'}; byte Sec; byte *ISOText; #define FILENAME "TAPSystem.log" if(!ProgramName || !Text) { TRACEEXIT(); return; } HDD_TAP_PushDir(); if(!HDD_ChangeDir("/ProgramFiles/Settings")) { HDD_ChangeDir("/ProgramFiles"); if(!TAP_Hdd_Exist("Settings")) TAP_Hdd_Create("Settings", ATTR_FOLDER); HDD_ChangeDir("Settings"); } l = strlen(ProgramName) + strlen(Text) + 4; s = TAP_MemAlloc(l); if(s) { memset(s, 0, l); TAP_SPrint(s, "%s: %s", ProgramName, Text); StrToISOAlloc(s, &ISOText); if(ISOText) { TimeFormat(Now(&Sec), Sec, TIMESTAMP_YMDHMS, TimeResult); strcat(TimeResult, " "); if(!TAP_Hdd_Exist(FILENAME)) TAP_Hdd_Create(FILENAME, ATTR_NORMAL); if((File = TAP_Hdd_Fopen(FILENAME)) != NULL) { TAP_Hdd_Fseek(File, 0, SEEK_END); TAP_Hdd_Fwrite(TimeResult, strlen(TimeResult), 1, File); TAP_Hdd_Fwrite(ISOText, strlen(ISOText), 1, File); TAP_Hdd_Fwrite(CRLF, 2, 1, File); TAP_Hdd_Fclose(File); } if(Console) { TAP_PrintNet("%s%s\n", TimeResult, ISOText); } TAP_MemFree(ISOText); } TAP_MemFree(s); } HDD_TAP_PopDir(); TRACEEXIT(); }
TYPE_File *HDD_FappendOpen(char *FileName) { TRACEENTER(); TYPE_File *file; char buffer[512]; dword pos, blks, i; char *end; char TAPPath[FBLIB_DIR_SIZE], Name[FBLIB_DIR_SIZE]; if(!FileName || !*FileName) { TRACEEXIT(); return NULL; } ConvertPathType(FileName, TAPPath, PF_TAPPathOnly); ConvertPathType(FileName, Name, PF_FileNameOnly); HDD_TAP_PushDir(); if(*TAPPath) HDD_ChangeDir(TAPPath); if(!TAP_Hdd_Exist(Name)) TAP_Hdd_Create(Name, ATTR_NORMAL); if((file = TAP_Hdd_Fopen(Name))) { if(TAP_Hdd_Fseek(file, 0, SEEK_SET) != 0) { TAP_Hdd_Fclose(file); file = NULL; } else { pos = 0; do { memset(buffer, 0, sizeof(buffer)); blks = TAP_Hdd_Fread(&buffer, sizeof(buffer), 1, file); for(i = 0, end = buffer; i < sizeof(buffer); i++) if(buffer[i] == '\0') { end = buffer + i; break; } if(i < sizeof(buffer)) break; else pos += sizeof(buffer); } while(blks == 1); pos += end - buffer; if(TAP_Hdd_Fseek(file, pos, SEEK_SET) != pos) { TAP_Hdd_Fclose(file); file = NULL; } } } HDD_TAP_PopDir(); TRACEEXIT(); return file; }
int LogoManager_UpdateLIL(void) { TRACEENTER(); typedef struct { ulong64 ChannelID; char Name[MAXLOGONAME+1]; }tNewIDs; int nTvSvc, nRadioSvc; int i; TYPE_TapChInfo chInfo; char s[255], LogoName[MAX_SvcName + 1]; SYSTEM_TYPE SystemType; tFlashSatTable SatInfo; word SatPos; ulong64 ChannelID; tNewIDs *NewIDs; int NewIDCount; SystemType = GetSystemType(); HDD_TAP_PushDir(); HDD_ChangeDir(LOGOROOT); TAP_Channel_GetTotalNum(&nTvSvc, &nRadioSvc); NewIDs = TAP_MemAlloc((nTvSvc + nRadioSvc) * sizeof(tNewIDs)); NewIDCount = 0; INIOpenFile(LILNAME, NULL); for(i = 0; i < nTvSvc; i++) { TAP_Channel_GetInfo(SVC_TYPE_Tv, i, &chInfo); FlashSatTablesGetInfo(chInfo.satIdx, &SatInfo); switch(SystemType) { case ST_S: case ST_TMSS: { SatPos = SatInfo.SatPosition; break; } default: SatPos = 0; break; } ChannelID = LogoManager_CalculateChannelID(SatPos, chInfo.orgNetId, chInfo.tsId, chInfo.svcId); TAP_SPrint(s, "%16.16llx", ChannelID); if(!INIKeyExists(s)) { NewIDs[NewIDCount].ChannelID = ChannelID; strcpy(NewIDs[NewIDCount].Name, LogoManager_ChannelNameToLogoName(chInfo.chName, LogoName, sizeof(LogoName))); if(NewIDs[NewIDCount].Name[0]) NewIDCount++; } } for(i = 0; i < nRadioSvc; i++) { TAP_Channel_GetInfo(SVC_TYPE_Radio, i, &chInfo); FlashSatTablesGetInfo(chInfo.satIdx, &SatInfo); switch(SystemType) { case ST_S: case ST_TMSS: { SatPos = SatInfo.SatPosition; break; } default: SatPos = 0; break; } ChannelID = LogoManager_CalculateChannelID(SatPos, chInfo.orgNetId, chInfo.tsId, chInfo.svcId); TAP_SPrint(s, "%16.16llx", ChannelID); if(!INIKeyExists(s)) { NewIDs[NewIDCount].ChannelID = ChannelID; TAP_SPrint(NewIDs[NewIDCount].Name, "r_%s", LogoManager_ChannelNameToLogoName(chInfo.chName, LogoName, sizeof(LogoName))); if(NewIDs[NewIDCount].Name[0]) NewIDCount++; } } INICloseFile(); if(NewIDCount > 0) { TYPE_File *f; word year; byte month, day, weekDay; if(!TAP_Hdd_Exist(LILNAME)) TAP_Hdd_Create(LILNAME, ATTR_NORMAL); f = TAP_Hdd_Fopen(LILNAME); if(!f) { HDD_TAP_PopDir(); if(LogoManager_CB) LogoManager_CB(-1, 3); TRACEEXIT(); return -1; } TAP_Hdd_Fseek(f, 0, SEEK_END); TAP_ExtractMjd(Now(NULL) >> 16, &year, &month, &day, &weekDay); TAP_SPrint(s, "\n\n# Added %4.4d-%2.2d-%2.2d\n", year, month, day); TAP_Hdd_Fwrite(s, 1, strlen(s), f); for(i = 0; i < NewIDCount; i++) { TAP_SPrint(s, "%16.16llx=%s\n", NewIDs[i].ChannelID, NewIDs[i].Name); TAP_Hdd_Fwrite(s, 1, strlen(s), f); } TAP_Hdd_Fclose(f); if(LogoManager_CB) LogoManager_CB(5, NewIDCount); }
void LogoManager_LogoCacheRebuild(void) { TRACEENTER(); char ID[4]; dword Version; TYPE_File *f, *fLogo; int i, j, k, NrFiles; TYPE_FolderEntry FolderEntry; dword LogoIndex; byte *PixelData, *TempBuffer; dword BufferSize, CompressedSize; TYPE_GrData *grData; int LogosConverted; char LogoPath[FBLIB_DIR_SIZE]; if(LogoManager_CB) LogoManager_CB(2, -1); //Step 1: Kill the current cache HDD_TAP_PushDir(); HDD_ChangeDir(LOGOROOT); TAP_Hdd_Delete(LOGOCACHE); //Step 2: iterate through all directories and count the number of logos LogoManager_NrLogos = 0; for(i = LGST_3pgstyle; i < LGST_NRITEMS; i++) { for(j = LGAR_43; j < LGAR_NRITEMS; j++) { if(HDD_ChangeDir(LogoManager_GetDirectory(i, j, LogoPath))) { NrFiles = TAP_Hdd_FindFirst(&FolderEntry, "qtl|qsl|ibl"); for(k = 0; k < NrFiles; k++) { if(FolderEntry.attr == ATTR_NORMAL) { FixInvalidFileName(FolderEntry.name); LogoManager_NrLogos++; } TAP_Hdd_FindNext(&FolderEntry); } } } } if(LogoManager_CB) LogoManager_CB(3, LogoManager_NrLogos); //Step 3: build the basic cache file LogosConverted = 0; if(LogoManager_LogoData) TAP_MemFree(LogoManager_LogoData); LogoManager_LogoData = TAP_MemAlloc(LogoManager_NrLogos * sizeof(tLogoData)); if(LogoManager_LogoData) { memset(LogoManager_LogoData, 0, LogoManager_NrLogos * sizeof(tLogoData)); HDD_ChangeDir(LOGOROOT); if(!TAP_Hdd_Exist(LOGOCACHE)) TAP_Hdd_Create(LOGOCACHE, ATTR_NORMAL); f = TAP_Hdd_Fopen(LOGOCACHE); if(f) { strcpy(ID, LOGOCACHEID); Version = LOGOCACHEVERSION; TAP_Hdd_Fwrite(ID, 4, 1, f); TAP_Hdd_Fwrite(&Version, sizeof(dword), 1, f); TAP_Hdd_Fwrite(&LogoManager_NrLogos, sizeof(dword), 1, f); TAP_Hdd_Fwrite(LogoManager_LogoData, sizeof(tLogoData), LogoManager_NrLogos, f); //Step 4: iterate through all directories again, compress the data and save it to the cache LogoIndex = 0; for(i = LGST_3pgstyle; i < LGST_NRITEMS; i++) { for(j = LGAR_43; j < LGAR_NRITEMS; j++) { if(HDD_ChangeDir(LogoManager_GetDirectory(i, j, LogoPath))) { NrFiles = TAP_Hdd_FindFirst(&FolderEntry, "qtl|qsl|ibl"); for(k = 0; k < NrFiles; k++) { if(LogoManager_CB) LogoManager_CB(2, LogosConverted * 100 / LogoManager_NrLogos); if(FolderEntry.attr == ATTR_NORMAL) { LogoManager_LogoData[LogoIndex].ChannelID = 0; strncpy(LogoManager_LogoData[LogoIndex].LogoName, FolderEntry.name, MAXLOGONAME); LogoManager_LogoData[LogoIndex].LogoName[MAXLOGONAME] = '\0'; LogoManager_LogoData[LogoIndex].LogoName[strlen(LogoManager_LogoData[LogoIndex].LogoName) - 4] = '\0'; LogoManager_LogoData[LogoIndex].Style = i; if(StringEndsWith(FolderEntry.name, ".qtl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_qtl; if(StringEndsWith(FolderEntry.name, ".qsl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_qsl; if(StringEndsWith(FolderEntry.name, ".ibl")) LogoManager_LogoData[LogoIndex].Size = LGSZ_ibl; LogoManager_LogoData[LogoIndex].Aspect = j; LogoManager_LogoData[LogoIndex].grData = NULL; fLogo = TAP_Hdd_Fopen(FolderEntry.name); if(fLogo) { BufferSize = TAP_Hdd_Flen(fLogo) - 8; PixelData = TAP_MemAlloc(BufferSize + 8); TempBuffer = TAP_MemAlloc(sizeof(TYPE_GrData) + BufferSize); if(PixelData && TempBuffer) { TAP_Hdd_Fread(PixelData, BufferSize + 8, 1, fLogo); CompressedSize = CompressTFD(&PixelData[8], BufferSize, &TempBuffer[sizeof(TYPE_GrData)], 0x0001, 0xffff, NULL); TAP_Put16bit(&TempBuffer[sizeof(TYPE_GrData) + 0x0e], 0xffff); grData = (TYPE_GrData*)TempBuffer; grData->version = 1; grData->reserved = 0; grData->dataFormat = OSD_1555; grData->compessMethod = COMPRESS_Tfp; grData->data = NULL; grData->dataSize = BufferSize; grData->width = TAP_Get32bit(&PixelData[0]); grData->height = TAP_Get32bit(&PixelData[4]); LogoManager_LogoData[LogoIndex].CachePosition = TAP_Hdd_Ftell(f); LogoManager_LogoData[LogoIndex].grDataSize = sizeof(TYPE_GrData) + CompressedSize; TAP_Hdd_Fwrite(grData, LogoManager_LogoData[LogoIndex].grDataSize, 1, f); LogoIndex++; } if(PixelData) TAP_MemFree(PixelData); if(TempBuffer) TAP_MemFree(TempBuffer); TAP_Hdd_Fclose(fLogo); } else { if(LogoManager_CB) LogoManager_CB(-1, 2); } LogosConverted++; } TAP_Hdd_FindNext(&FolderEntry); } } } } //Step 5: if the LIL exists, read and update the ChannelID of all Logos //Step 6: rewrite the cache structure to update all pointers TAP_Hdd_Fseek(f, sizeof(ID) + sizeof(dword) + sizeof(dword), SEEK_SET); TAP_Hdd_Fwrite(LogoManager_LogoData, sizeof(tLogoData), LogoManager_NrLogos, f); TAP_Hdd_Fclose(f); } } HDD_TAP_PopDir(); if(LogoManager_CB) LogoManager_CB(4, 0); TRACEEXIT(); }